Commit 0144848a authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Rewrite send_triggered_update.

parent d97aecee
...@@ -539,41 +539,43 @@ consider_route(struct route *route) ...@@ -539,41 +539,43 @@ consider_route(struct route *route)
void void
send_triggered_update(struct route *route, struct source *oldsrc, int oldmetric) send_triggered_update(struct route *route, struct source *oldsrc, int oldmetric)
{ {
int urgent = 0, newmetric; int urgent = 0, newmetric, diff;
if(!route->installed) if(!route->installed)
return; return;
newmetric = route->metric; newmetric = route->metric;
diff =
newmetric >= oldmetric ? newmetric - oldmetric : oldmetric - newmetric;
if(route->src != oldsrc || (oldmetric < INFINITY && newmetric >= INFINITY)) if(route->src != oldsrc || (oldmetric < INFINITY && newmetric >= INFINITY))
/* Switching sources can cause transient routing loops. /* Switching sources can cause transient routing loops.
Retractions are always urgent. */ Retractions are always urgent. */
urgent = 2; urgent = 2;
else if(newmetric >= 8 * 256 && oldmetric >= 8 * 256) else if(newmetric >= 6 * 256 && oldmetric >= 6 * 256)
/* Don't be noisy about far-away nodes */ /* Don't be noisy about far-away nodes */
urgent = -1; urgent = -1;
else if(newmetric >= oldmetric + 512 || oldmetric >= newmetric + 512) else if(diff >= 512)
urgent = 1; urgent = 1;
/* Make sure that requests are satisfied speedily */ /* Make sure that requests are satisfied speedily */
if(urgent < 1) {
if(unsatisfied_request(route->src->prefix, route->src->plen, if(unsatisfied_request(route->src->prefix, route->src->plen,
route->seqno, hash_id(route->src->id))) route->seqno, hash_id(route->src->id)))
urgent = MAX(urgent, 1); urgent = 1;
}
if(urgent < 0) if(urgent < 0 || (!urgent && diff < 256))
/* Never mind. */
return; return;
if(urgent ||
(newmetric >= oldmetric + 256 || oldmetric >= newmetric + 256)) {
if(urgent >= 2) if(urgent >= 2)
send_update_resend(NULL, route->src->prefix, route->src->plen); send_update_resend(NULL, route->src->prefix, route->src->plen);
else else
send_update(NULL, urgent, route->src->prefix, route->src->plen); send_update(NULL, urgent, route->src->prefix, route->src->plen);
}
if(oldmetric < INFINITY) { if(oldmetric < INFINITY) {
if(newmetric >= INFINITY || newmetric >= oldmetric + 384) { if(newmetric >= oldmetric + 384) {
send_request_resend(NULL, route->src->prefix, route->src->plen, send_request_resend(NULL, route->src->prefix, route->src->plen,
route->src->metric >= INFINITY ? route->src->metric >= INFINITY ?
route->src->seqno : route->src->seqno :
......
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