Commit 3f392904 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Fix and simplify route timeout and gc.

parent 849a1f89
......@@ -724,20 +724,15 @@ expire_routes(void)
while(i < numroutes) {
struct route *route = &routes[i];
if(route->blackhole_time > 0 &&
route->blackhole_time < now.tv_sec - 65) {
if(route->time < now.tv_sec - route_gc_delay) {
flush_route(route);
continue;
}
if(route->time < now.tv_sec - 120)
update_route(route->dest->address, ((route->seqno + 1) & 0xFF),
INFINITY, route->nexthop, NULL, 0);
else
update_route_metric(route);
update_route_metric(route);
if(route->installed && route->refmetric < INFINITY) {
if(route->time <= now.tv_sec - 70)
if(route->time < now.tv_sec - MAX(5, route_timeout_delay - 25))
send_unicast_request(route->nexthop, route->dest);
}
i++;
......
......@@ -38,6 +38,8 @@ THE SOFTWARE.
struct route routes[MAXROUTES];
int numroutes = 0;
int kernel_metric = 0;
int route_timeout_delay = 50;
int route_gc_delay = 95;
struct route *
find_route(const unsigned char *dest, struct neighbour *nexthop)
......@@ -254,18 +256,33 @@ void
update_route_metric(struct route *route)
{
int oldmetric;
int newmetric;
oldmetric = route->metric;
change_route_metric(route,
MIN(route->refmetric + neighbour_cost(route->nexthop),
INFINITY));
if(route->time < now.tv_sec - route_timeout_delay) {
if(oldmetric < INFINITY) {
route->refmetric = INFINITY;
route->seqno = (route->dest->seqno + 1) & 0xFF;
}
newmetric = INFINITY;
} else {
newmetric = MIN(route->refmetric + neighbour_cost(route->nexthop),
INFINITY);
}
change_route_metric(route, newmetric);
if(route->installed) {
struct route *better_route;
better_route = find_best_route(route->dest);
if(better_route && better_route->metric <= route->metric - 96)
consider_route(better_route);
else
send_triggered_update(route, oldmetric);
if(newmetric > oldmetric) {
struct route *better_route;
better_route = find_best_route(route->dest);
if(better_route && better_route->metric <= route->metric - 96)
consider_route(better_route);
else
send_triggered_update(route, oldmetric);
} else {
send_triggered_update(route, oldmetric);
}
} else {
consider_route(route);
}
......@@ -306,13 +323,8 @@ update_route(const unsigned char *d, int seqno, int refmetric,
oldseqno = route->seqno;
oldmetric = route->metric;
route->time = now.tv_sec;
if(refmetric < INFINITY) {
route->blackhole_time = 0;
if(route->refmetric >= INFINITY)
route->origtime = now.tv_sec;
} else if(route->blackhole_time <= 0) {
route->blackhole_time = now.tv_sec;
}
if(route->refmetric >= INFINITY)
route->origtime = now.tv_sec;
route->seqno = seqno;
route->refmetric = refmetric;
change_route_metric(route, metric);
......@@ -347,7 +359,6 @@ update_route(const unsigned char *d, int seqno, int refmetric,
route->nexthop = nexthop;
route->time = now.tv_sec;
route->origtime = now.tv_sec;
route->blackhole_time = 0;
route->installed = 0;
numroutes++;
for(i = 0; i < numpxroutes; i++)
......
......@@ -30,13 +30,14 @@ struct route {
struct neighbour *nexthop;
int time;
int origtime;
int blackhole_time;
int installed;
};
extern struct route routes[MAXROUTES];
extern int numroutes;
extern int kernel_metric;
extern int route_timeout_delay;
extern int route_gc_delay;
struct route *find_route(const unsigned char *dest, struct neighbour *nexthop);
struct route *find_installed_route(struct destination *dest);
......
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