Commit 51e4a64e authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Simplify jitter computation.

Remove tracking of time, only timeouts remain.
parent 889a9d83
......@@ -636,8 +636,7 @@ send_hello_noupdate(struct network *net, unsigned interval)
flushbuf(net);
net->hello_seqno = seqno_plus(net->hello_seqno, 1);
delay_jitter(&net->hello_time, &net->hello_timeout,
net->hello_interval);
delay_jitter(&net->hello_timeout, net->hello_interval);
if(!net->up)
return;
......@@ -1006,10 +1005,6 @@ send_update(struct network *net, int urgent,
}
} else {
send_self_update(net, 0);
/* Don't send full route dumps more than ten times per second */
if(net->update_time.tv_sec > 0 &&
timeval_minus_msec(&now, &net->update_time) < 100)
return;
if(!selfonly && !network_idle(net)) {
debugf("Sending update to %s for any.\n", net->ifname);
for(i = 0; i < numroutes; i++)
......@@ -1017,8 +1012,7 @@ send_update(struct network *net, int urgent,
buffer_update(net,
routes[i].src->prefix, routes[i].src->plen);
}
delay_jitter(&net->update_time, &net->update_timeout,
update_interval);
delay_jitter(&net->update_timeout, update_interval);
}
schedule_update_flush(net, urgent);
}
......@@ -1097,8 +1091,7 @@ send_self_update(struct network *net, int force_seqno)
for(i = 0; i < numxroutes; i++)
send_update(net, 0, xroutes[i].prefix, xroutes[i].plen);
}
delay_jitter(&net->self_update_time, &net->self_update_timeout,
net->self_update_interval);
delay_jitter(&net->self_update_timeout, net->self_update_interval);
}
void
......
......@@ -137,9 +137,8 @@ update_jitter(struct network *net, int urgent)
}
void
delay_jitter(struct timeval *time, struct timeval *timeout, int msecs)
delay_jitter(struct timeval *timeout, int msecs)
{
*time = now;
timeval_plus_msec(timeout, &now, roughly(msecs));
}
......@@ -280,12 +279,9 @@ network_up(struct network *net, int up)
memcpy(net->ll, ll, rc * 16);
}
}
delay_jitter(&net->hello_time, &net->hello_timeout,
net->hello_interval);
delay_jitter(&net->self_update_time, &net->self_update_timeout,
net->self_update_interval);
delay_jitter(&net->update_time, &net->update_timeout,
update_interval);
delay_jitter(&net->hello_timeout, net->hello_interval);
delay_jitter(&net->self_update_timeout, net->self_update_interval);
delay_jitter(&net->update_timeout, update_interval);
send_hello(net);
send_request(net, NULL, 0);
} else {
......
......@@ -33,11 +33,8 @@ struct network {
char wired;
unsigned int ifindex;
unsigned short cost;
struct timeval hello_time;
struct timeval hello_timeout;
struct timeval self_update_time;
struct timeval self_update_timeout;
struct timeval update_time;
struct timeval update_timeout;
char ifname[IF_NAMESIZE];
unsigned char *ipv4;
......@@ -75,7 +72,7 @@ int network_idle(struct network *net);
int update_hello_interval(struct network *net);
unsigned jitter(struct network *net, int urgent);
unsigned update_jitter(struct network *net, int urgent);
void delay_jitter(struct timeval *time, struct timeval *timeout, int msecs);
void delay_jitter(struct timeval *timeout, int msecs);
int network_up(struct network *net, int up);
int network_ll_address(struct network *net, const unsigned char *address);
void check_networks(void);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment