mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-02-06 11:09:13 +00:00
Don't send broadcast payloads on interfaces with no neighbours
This commit is contained in:
parent
09540c568b
commit
a71c3f3c1f
@ -200,7 +200,8 @@ int overlay_payload_enqueue(struct overlay_frame *p)
|
|||||||
// make sure there is an interface up that allows broadcasts
|
// make sure there is an interface up that allows broadcasts
|
||||||
for(i=0;i<OVERLAY_MAX_INTERFACES;i++){
|
for(i=0;i<OVERLAY_MAX_INTERFACES;i++){
|
||||||
if (overlay_interfaces[i].state==INTERFACE_STATE_UP
|
if (overlay_interfaces[i].state==INTERFACE_STATE_UP
|
||||||
&& overlay_interfaces[i].send_broadcasts){
|
&& overlay_interfaces[i].send_broadcasts
|
||||||
|
&& link_state_interface_has_neighbour(&overlay_interfaces[i])){
|
||||||
p->broadcast_sent_via[i]=0;
|
p->broadcast_sent_via[i]=0;
|
||||||
drop=0;
|
drop=0;
|
||||||
}else
|
}else
|
||||||
@ -297,7 +298,8 @@ overlay_calc_queue_time(overlay_txqueue *queue, struct overlay_frame *frame){
|
|||||||
int i;
|
int i;
|
||||||
for(i=0;i<OVERLAY_MAX_INTERFACES;i++)
|
for(i=0;i<OVERLAY_MAX_INTERFACES;i++)
|
||||||
{
|
{
|
||||||
if (overlay_interfaces[i].state!=INTERFACE_STATE_UP)
|
if (overlay_interfaces[i].state!=INTERFACE_STATE_UP ||
|
||||||
|
!link_state_interface_has_neighbour(&overlay_interfaces[i]))
|
||||||
continue;
|
continue;
|
||||||
time_ms_t next_packet = limit_next_allowed(&overlay_interfaces[i].transfer_limit);
|
time_ms_t next_packet = limit_next_allowed(&overlay_interfaces[i].transfer_limit);
|
||||||
if (next_allowed_packet==0||next_packet < next_allowed_packet)
|
if (next_allowed_packet==0||next_packet < next_allowed_packet)
|
||||||
@ -398,7 +400,9 @@ overlay_stuff_packet(struct outgoing_packet *packet, overlay_txqueue *queue, tim
|
|||||||
int i, keep=0;
|
int i, keep=0;
|
||||||
for(i=0;i<OVERLAY_MAX_INTERFACES;i++)
|
for(i=0;i<OVERLAY_MAX_INTERFACES;i++)
|
||||||
{
|
{
|
||||||
if (overlay_interfaces[i].state!=INTERFACE_STATE_UP || frame->broadcast_sent_via[i])
|
if (overlay_interfaces[i].state!=INTERFACE_STATE_UP ||
|
||||||
|
frame->broadcast_sent_via[i] ||
|
||||||
|
!link_state_interface_has_neighbour(&overlay_interfaces[i]))
|
||||||
continue;
|
continue;
|
||||||
keep=1;
|
keep=1;
|
||||||
time_ms_t next_allowed = limit_next_allowed(&overlay_interfaces[i].transfer_limit);
|
time_ms_t next_allowed = limit_next_allowed(&overlay_interfaces[i].transfer_limit);
|
||||||
@ -490,18 +494,20 @@ overlay_stuff_packet(struct outgoing_packet *packet, overlay_txqueue *queue, tim
|
|||||||
// check if there is still a broadcast to be sent
|
// check if there is still a broadcast to be sent
|
||||||
for(i=0;i<OVERLAY_MAX_INTERFACES;i++)
|
for(i=0;i<OVERLAY_MAX_INTERFACES;i++)
|
||||||
{
|
{
|
||||||
if (overlay_interfaces[i].state==INTERFACE_STATE_UP)
|
if (overlay_interfaces[i].state==INTERFACE_STATE_UP &&
|
||||||
|
link_state_interface_has_neighbour(&overlay_interfaces[i])){
|
||||||
if (!frame->broadcast_sent_via[i]){
|
if (!frame->broadcast_sent_via[i]){
|
||||||
keep_payload=1;
|
keep_payload=1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!keep_payload){
|
if (!keep_payload){
|
||||||
frame = overlay_queue_remove(queue, frame);
|
frame = overlay_queue_remove(queue, frame);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
skip:
|
skip:
|
||||||
// if we can't send the payload now, check when we should try next
|
// if we can't send the payload now, check when we should try next
|
||||||
@ -547,7 +553,6 @@ overlay_fill_send_packet(struct outgoing_packet *packet, time_ms_t now) {
|
|||||||
static void overlay_send_packet(struct sched_ent *alarm){
|
static void overlay_send_packet(struct sched_ent *alarm){
|
||||||
struct outgoing_packet packet;
|
struct outgoing_packet packet;
|
||||||
bzero(&packet, sizeof(struct outgoing_packet));
|
bzero(&packet, sizeof(struct outgoing_packet));
|
||||||
|
|
||||||
overlay_fill_send_packet(&packet, gettime_ms());
|
overlay_fill_send_packet(&packet, gettime_ms());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
14
route_link.c
14
route_link.c
@ -67,7 +67,7 @@ struct neighbour_link{
|
|||||||
|
|
||||||
char unicast;
|
char unicast;
|
||||||
int ack_sequence;
|
int ack_sequence;
|
||||||
uint32_t ack_mask;
|
uint64_t ack_mask;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct neighbour{
|
struct neighbour{
|
||||||
@ -655,6 +655,18 @@ struct neighbour_link * get_neighbour_link(struct neighbour *neighbour, struct o
|
|||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int link_state_interface_has_neighbour(struct overlay_interface *interface)
|
||||||
|
{
|
||||||
|
struct neighbour *neighbour = neighbours;
|
||||||
|
while(neighbour){
|
||||||
|
if (neighbour->best_link && neighbour->best_link->interface == interface)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
neighbour = neighbour->_next;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// track stats for receiving packets from this neighbour
|
// track stats for receiving packets from this neighbour
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
1
serval.h
1
serval.h
@ -835,6 +835,7 @@ void link_explained(struct subscriber *subscriber);
|
|||||||
void link_interface_down(struct overlay_interface *interface);
|
void link_interface_down(struct overlay_interface *interface);
|
||||||
int link_state_announce_links();
|
int link_state_announce_links();
|
||||||
int link_state_legacy_ack(struct overlay_frame *frame, time_ms_t now);
|
int link_state_legacy_ack(struct overlay_frame *frame, time_ms_t now);
|
||||||
|
int link_state_interface_has_neighbour(struct overlay_interface *interface);
|
||||||
|
|
||||||
int generate_nonce(unsigned char *nonce,int bytes);
|
int generate_nonce(unsigned char *nonce,int bytes);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user