Commit 46a60aa2 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Allow routes with infinite refmetric.

parent 1d1df7f8
...@@ -220,11 +220,10 @@ find_best_route(struct destination *dest) ...@@ -220,11 +220,10 @@ find_best_route(struct destination *dest)
continue; continue;
if(routes[i].time < now.tv_sec - 180) if(routes[i].time < now.tv_sec - 180)
continue; continue;
if(routes[i].metric >= INFINITY)
continue;
if(!route_feasible(&routes[i])) if(!route_feasible(&routes[i]))
continue; continue;
if(route && route->metric + 512 >= routes[i].metric) { if(route && route->metric < INFINITY &&
route->metric + 512 >= routes[i].metric) {
if(route->origtime <= now.tv_sec - 30 && if(route->origtime <= now.tv_sec - 30 &&
routes[i].origtime >= now.tv_sec - 30) routes[i].origtime >= now.tv_sec - 30)
continue; continue;
...@@ -304,14 +303,11 @@ update_route(const unsigned char *d, int seqno, int refmetric, ...@@ -304,14 +303,11 @@ update_route(const unsigned char *d, int seqno, int refmetric,
int oldseqno; int oldseqno;
int oldmetric; int oldmetric;
if(refmetric >= INFINITY) {
flush_route(route);
return NULL;
}
oldseqno = route->seqno; oldseqno = route->seqno;
oldmetric = route->metric; oldmetric = route->metric;
route->time = now.tv_sec; route->time = now.tv_sec;
if(route->refmetric >= INFINITY && refmetric < INFINITY)
route->origtime = now.tv_sec;
route->seqno = seqno; route->seqno = seqno;
route->refmetric = refmetric; route->refmetric = refmetric;
change_route_metric(route, metric); change_route_metric(route, metric);
...@@ -366,7 +362,7 @@ consider_route(struct route *route) ...@@ -366,7 +362,7 @@ consider_route(struct route *route)
if(route->installed) if(route->installed)
return; return;
if(route->metric >= INFINITY || !route_feasible(route)) if(!route_feasible(route))
return; return;
installed = find_installed_route(route->dest); installed = find_installed_route(route->dest);
...@@ -399,7 +395,7 @@ change_route_metric(struct route *route, int newmetric) ...@@ -399,7 +395,7 @@ change_route_metric(struct route *route, int newmetric)
{ {
int rc; int rc;
if(route->installed) { if(route->installed) {
rc = kernel_route(newmetric >= INFINITY ? ROUTE_FLUSH : ROUTE_MODIFY, rc = kernel_route(ROUTE_MODIFY,
route->dest->address, 128, route->dest->address, 128,
route->nexthop->address, route->nexthop->address,
route->nexthop->network->ifindex, route->nexthop->network->ifindex,
...@@ -409,8 +405,6 @@ change_route_metric(struct route *route, int newmetric) ...@@ -409,8 +405,6 @@ change_route_metric(struct route *route, int newmetric)
perror("kernel_route(MODIFY)"); perror("kernel_route(MODIFY)");
return; return;
} }
if(newmetric >= INFINITY)
route->installed = 0;
} }
route->metric = newmetric; route->metric = newmetric;
} }
...@@ -421,7 +415,8 @@ send_triggered_update(struct route *route, int oldmetric) ...@@ -421,7 +415,8 @@ send_triggered_update(struct route *route, int oldmetric)
if(!route->installed) if(!route->installed)
return; return;
if(route->metric - oldmetric >= 256 || oldmetric - route->metric >= 256) if((route->metric >= INFINITY && oldmetric < INFINITY) ||
(route->metric - oldmetric >= 256 || oldmetric - route->metric >= 256))
send_update(route->dest, NULL); send_update(route->dest, NULL);
if(route->metric - oldmetric >= 384) { if(route->metric - oldmetric >= 384) {
......
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