Commit 7f168798 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Fix computation of metrics of unusable xroutes.

parent a05a0ff6
...@@ -299,7 +299,9 @@ update_xroute(const unsigned char *prefix, unsigned short plen, ...@@ -299,7 +299,9 @@ update_xroute(const unsigned char *prefix, unsigned short plen,
xroute->nexthop = nexthop; xroute->nexthop = nexthop;
xroute->cost = cost; xroute->cost = cost;
xroute->metric = xroute->metric =
gwroute ? MIN(gwroute->metric + cost, INFINITY) : INFINITY; gwroute && gwroute->nexthop == xroute->nexthop ?
MIN(gwroute->metric + cost, INFINITY) :
INFINITY;
xroute->time = now.tv_sec; xroute->time = now.tv_sec;
xroute->installed = 0; xroute->installed = 0;
numxroutes++; numxroutes++;
...@@ -319,8 +321,9 @@ update_xroute_metric(struct xroute *xroute, int cost) ...@@ -319,8 +321,9 @@ update_xroute_metric(struct xroute *xroute, int cost)
gwroute = find_installed_route(xroute->gateway); gwroute = find_installed_route(xroute->gateway);
oldmetric = xroute->metric; oldmetric = xroute->metric;
newmetric = gwroute ? MIN(gwroute->metric + cost, INFINITY) : INFINITY; newmetric = gwroute && gwroute->nexthop == xroute->nexthop ?
MIN(gwroute->metric + cost, INFINITY) :
INFINITY;
if(xroute->cost != cost || oldmetric != newmetric) { if(xroute->cost != cost || oldmetric != newmetric) {
xroute->cost = cost; xroute->cost = cost;
if(xroute->installed) { if(xroute->installed) {
......
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