mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-30 16:13:51 +00:00
Add small delays to route announcements to reduce packet spam
This commit is contained in:
parent
9b8b57a30d
commit
9f9893095b
@ -260,11 +260,11 @@ int parseEnvelopeHeader(struct decode_context *context, struct overlay_interface
|
|||||||
|
|
||||||
context->packet_version = ob_get(buffer);
|
context->packet_version = ob_get(buffer);
|
||||||
if (context->packet_version < 0 || context->packet_version > SUPPORTED_PACKET_VERSION)
|
if (context->packet_version < 0 || context->packet_version > SUPPORTED_PACKET_VERSION)
|
||||||
RETURN(WHY("Packet version not recognised."));
|
RETURN(WHYF("Packet version %d not recognised.", context->packet_version));
|
||||||
|
|
||||||
context->encapsulation = ob_get(buffer);
|
context->encapsulation = ob_get(buffer);
|
||||||
if (context->encapsulation !=ENCAP_OVERLAY && context->encapsulation !=ENCAP_SINGLE)
|
if (context->encapsulation !=ENCAP_OVERLAY && context->encapsulation !=ENCAP_SINGLE)
|
||||||
RETURN(WHY("Invalid packet encapsulation"));
|
RETURN(WHYF("Invalid packet encapsulation, %d", context->encapsulation));
|
||||||
|
|
||||||
if (overlay_address_parse(context, buffer, &context->sender))
|
if (overlay_address_parse(context, buffer, &context->sender))
|
||||||
RETURN(WHY("Unable to parse sender"));
|
RETURN(WHY("Unable to parse sender"));
|
||||||
|
33
route_link.c
33
route_link.c
@ -375,7 +375,7 @@ next:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
monitor_announce_link(best_hop_count, transmitter, subscriber);
|
monitor_announce_link(best_hop_count, transmitter, subscriber);
|
||||||
state->next_update = now;
|
state->next_update = now+5;
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN(0);
|
RETURN(0);
|
||||||
@ -470,13 +470,13 @@ static int append_link(struct subscriber *subscriber, void *context)
|
|||||||
if (subscriber->reachable==REACHABLE_SELF){
|
if (subscriber->reachable==REACHABLE_SELF){
|
||||||
// Other entries in our keyring are always one hop away from us.
|
// Other entries in our keyring are always one hop away from us.
|
||||||
if (append_link_state(payload, 0, my_subscriber, subscriber, -1, 1, -1, 0, 0)){
|
if (append_link_state(payload, 0, my_subscriber, subscriber, -1, 1, -1, 0, 0)){
|
||||||
link_send_alarm.alarm = now;
|
link_send_alarm.alarm = now+5;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
struct link *link = state->link;
|
struct link *link = state->link;
|
||||||
if (append_link_state(payload, 0, state->transmitter, subscriber, -1, link?link->link_version:-1, -1, 0, link?link->drop_rate:32)){
|
if (append_link_state(payload, 0, state->transmitter, subscriber, -1, link?link->link_version:-1, -1, 0, link?link->drop_rate:32)){
|
||||||
link_send_alarm.alarm = now;
|
link_send_alarm.alarm = now+5;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -573,7 +573,7 @@ static int neighbour_find_best_link(struct neighbour *n)
|
|||||||
|
|
||||||
if (n->best_link != best_link){
|
if (n->best_link != best_link){
|
||||||
n->best_link = best_link;
|
n->best_link = best_link;
|
||||||
n->next_neighbour_update = gettime_ms()+10;
|
n->next_neighbour_update = gettime_ms()+5;
|
||||||
if (config.debug.linkstate && config.debug.verbose)
|
if (config.debug.linkstate && config.debug.verbose)
|
||||||
DEBUGF("LINK STATE; best link from neighbour %s is now on interface %s",
|
DEBUGF("LINK STATE; best link from neighbour %s is now on interface %s",
|
||||||
alloca_tohex_sid(n->subscriber->sid),
|
alloca_tohex_sid(n->subscriber->sid),
|
||||||
@ -656,7 +656,7 @@ static int link_send_neighbours()
|
|||||||
while (n){
|
while (n){
|
||||||
neighbour_find_best_link(n);
|
neighbour_find_best_link(n);
|
||||||
|
|
||||||
if (n->next_neighbour_update <= now){
|
if (n->next_neighbour_update - INCLUDE_ANYWAY <= now){
|
||||||
send_neighbour_link(n);
|
send_neighbour_link(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -819,8 +819,11 @@ int link_received_duplicate(struct subscriber *subscriber, struct overlay_interf
|
|||||||
int link_received_packet(struct subscriber *subscriber, struct overlay_interface *interface, int sender_interface, int sender_seq, int unicast)
|
int link_received_packet(struct subscriber *subscriber, struct overlay_interface *interface, int sender_interface, int sender_seq, int unicast)
|
||||||
{
|
{
|
||||||
// TODO better handling of unicast routes
|
// TODO better handling of unicast routes
|
||||||
if (unicast)
|
if (unicast){
|
||||||
|
if (config.debug.verbose && config.debug.linkstate)
|
||||||
|
DEBUG("LINK STATE; Ignoring unicast packet");
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct neighbour *neighbour = get_neighbour(subscriber, 1);
|
struct neighbour *neighbour = get_neighbour(subscriber, 1);
|
||||||
struct neighbour_link *link=get_neighbour_link(neighbour, interface, sender_interface, unicast);
|
struct neighbour_link *link=get_neighbour_link(neighbour, interface, sender_interface, unicast);
|
||||||
@ -1027,7 +1030,7 @@ int link_receive(overlay_mdp_frame *mdp)
|
|||||||
// send another ack asap
|
// send another ack asap
|
||||||
if (config.debug.linkstate && config.debug.verbose)
|
if (config.debug.linkstate && config.debug.verbose)
|
||||||
DEBUGF("LINK STATE; neighbour %s missed ack %d, queue another", alloca_tohex_sid(sender->sid), neighbour->last_update_seq);
|
DEBUGF("LINK STATE; neighbour %s missed ack %d, queue another", alloca_tohex_sid(sender->sid), neighbour->last_update_seq);
|
||||||
neighbour->next_neighbour_update=now;
|
neighbour->next_neighbour_update=now+5;
|
||||||
update_alarm(neighbour->next_neighbour_update);
|
update_alarm(neighbour->next_neighbour_update);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1051,11 +1054,11 @@ int link_receive(overlay_mdp_frame *mdp)
|
|||||||
if (changed){
|
if (changed){
|
||||||
route_version++;
|
route_version++;
|
||||||
neighbour->path_version ++;
|
neighbour->path_version ++;
|
||||||
if (link_send_alarm.alarm>now || link_send_alarm.alarm==0){
|
if (link_send_alarm.alarm>now+5 || link_send_alarm.alarm==0){
|
||||||
unschedule(&link_send_alarm);
|
unschedule(&link_send_alarm);
|
||||||
link_send_alarm.alarm=now;
|
link_send_alarm.alarm=now+5;
|
||||||
// read all incoming packets first
|
// read all incoming packets first
|
||||||
link_send_alarm.deadline=now+10;
|
link_send_alarm.deadline=now+15;
|
||||||
schedule(&link_send_alarm);
|
schedule(&link_send_alarm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1068,8 +1071,8 @@ void link_explained(struct subscriber *subscriber)
|
|||||||
{
|
{
|
||||||
time_ms_t now = gettime_ms();
|
time_ms_t now = gettime_ms();
|
||||||
struct link_state *state = get_link_state(subscriber);
|
struct link_state *state = get_link_state(subscriber);
|
||||||
state->next_update = now;
|
state->next_update = now+5;
|
||||||
update_alarm(now);
|
update_alarm(now+5);
|
||||||
}
|
}
|
||||||
|
|
||||||
void link_interface_down(struct overlay_interface *interface)
|
void link_interface_down(struct overlay_interface *interface)
|
||||||
@ -1123,11 +1126,11 @@ int link_state_legacy_ack(struct overlay_frame *frame, time_ms_t now)
|
|||||||
if (changed){
|
if (changed){
|
||||||
route_version++;
|
route_version++;
|
||||||
neighbour->path_version ++;
|
neighbour->path_version ++;
|
||||||
if (link_send_alarm.alarm>now || link_send_alarm.alarm==0){
|
if (link_send_alarm.alarm>now+5 || link_send_alarm.alarm==0){
|
||||||
unschedule(&link_send_alarm);
|
unschedule(&link_send_alarm);
|
||||||
link_send_alarm.alarm=now;
|
link_send_alarm.alarm=now+5;
|
||||||
// read all incoming packets first
|
// read all incoming packets first
|
||||||
link_send_alarm.deadline=now+10;
|
link_send_alarm.deadline=now+15;
|
||||||
schedule(&link_send_alarm);
|
schedule(&link_send_alarm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3
serval.h
3
serval.h
@ -779,8 +779,7 @@ int fd_func_exit(struct __sourceloc __whence, struct call_stats *this_call);
|
|||||||
void dump_stack();
|
void dump_stack();
|
||||||
|
|
||||||
#define IN() static struct profile_total _aggregate_stats={NULL,0,__FUNCTION__,0,0,0}; \
|
#define IN() static struct profile_total _aggregate_stats={NULL,0,__FUNCTION__,0,0,0}; \
|
||||||
struct call_stats _this_call; \
|
struct call_stats _this_call={.totals=&_aggregate_stats}; \
|
||||||
_this_call.totals=&_aggregate_stats; \
|
|
||||||
fd_func_enter(__HERE__, &_this_call);
|
fd_func_enter(__HERE__, &_this_call);
|
||||||
|
|
||||||
#define OUT() fd_func_exit(__HERE__, &_this_call)
|
#define OUT() fd_func_exit(__HERE__, &_this_call)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user