Don't send broadcast payloads on interfaces with no neighbours

This commit is contained in:
Jeremy Lakeman 2013-05-22 11:57:38 +09:30
parent 09540c568b
commit a71c3f3c1f
3 changed files with 26 additions and 8 deletions

View File

@ -200,7 +200,8 @@ int overlay_payload_enqueue(struct overlay_frame *p)
// make sure there is an interface up that allows broadcasts
for(i=0;i<OVERLAY_MAX_INTERFACES;i++){
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;
drop=0;
}else
@ -297,7 +298,8 @@ overlay_calc_queue_time(overlay_txqueue *queue, struct overlay_frame *frame){
int 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;
time_ms_t next_packet = limit_next_allowed(&overlay_interfaces[i].transfer_limit);
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;
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;
keep=1;
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
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]){
keep_payload=1;
break;
}
}
}
}
if (!keep_payload){
frame = overlay_queue_remove(queue, frame);
continue;
}
}
skip:
// 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){
struct outgoing_packet packet;
bzero(&packet, sizeof(struct outgoing_packet));
overlay_fill_send_packet(&packet, gettime_ms());
}

View File

@ -67,7 +67,7 @@ struct neighbour_link{
char unicast;
int ack_sequence;
uint32_t ack_mask;
uint64_t ack_mask;
};
struct neighbour{
@ -655,6 +655,18 @@ struct neighbour_link * get_neighbour_link(struct neighbour *neighbour, struct o
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
int link_received_packet(struct subscriber *subscriber, struct overlay_interface *interface, int sender_interface, int sender_seq, int unicast)
{

View File

@ -835,6 +835,7 @@ void link_explained(struct subscriber *subscriber);
void link_interface_down(struct overlay_interface *interface);
int link_state_announce_links();
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);