Commit 91e69d82 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Don't consider infinite metric xroutes if not blackhole routes.

parent 03475d29
...@@ -73,12 +73,14 @@ find_best_xroute(unsigned char *prefix, unsigned short plen) ...@@ -73,12 +73,14 @@ find_best_xroute(unsigned char *prefix, unsigned short plen)
int i; int i;
for(i = 0; i < numxroutes; i++) { for(i = 0; i < numxroutes; i++) {
if(xroutes[i].plen == plen && if(xroutes[i].metric >= INFINITY && xroutes[i].cost < INFINITY)
memcmp(xroutes[i].prefix, prefix, 16) == 0) { continue;
if((!xroute || xroutes[i].metric < xroute->metric) && if(xroutes[i].plen != plen ||
find_installed_route(xroutes[i].gateway) != NULL) memcmp(xroutes[i].prefix, prefix, 16) != 0)
xroute = &xroutes[i]; continue;
} if((!xroute || xroutes[i].metric < xroute->metric) &&
find_installed_route(xroutes[i].gateway) != NULL)
xroute = &xroutes[i];
} }
return xroute; return xroute;
} }
...@@ -93,6 +95,9 @@ install_xroute(struct xroute *xroute) ...@@ -93,6 +95,9 @@ install_xroute(struct xroute *xroute)
if(xroute->installed) if(xroute->installed)
return; return;
if(xroute->metric >= INFINITY && xroute->cost < INFINITY)
return;
if(xroute->plen >= 8 && if(xroute->plen >= 8 &&
(xroute->prefix[0] == 0 || xroute->prefix[0] == 0xFF)) { (xroute->prefix[0] == 0 || xroute->prefix[0] == 0xFF)) {
fprintf(stderr, "Attempted to install martian xroute.\n"); fprintf(stderr, "Attempted to install martian xroute.\n");
......
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