Commit e2b970d9 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Tweak routes when installing/uninstalling xroutes.

This prevents a stale route from remaining installed when we get a new xroute.
parent 3f5a024b
...@@ -182,11 +182,18 @@ check_xroutes(int send_updates) ...@@ -182,11 +182,18 @@ check_xroutes(int send_updates)
} }
if(!export) { if(!export) {
unsigned char prefix[16], plen;
struct route *route;
memcpy(prefix, xroutes[i].prefix, 16);
plen = xroutes[i].plen;
flush_xroute(&xroutes[i]);
route = find_best_route(prefix, plen, 1, NULL);
if(route)
install_route(route);
/* send_update_resend only records the prefix, so the update /* send_update_resend only records the prefix, so the update
will only be sent after we perform all of the changes. */ will only be sent after we perform all of the changes. */
if(send_updates) if(send_updates)
send_update_resend(NULL, xroutes[i].prefix, xroutes[i].plen); send_update_resend(NULL, prefix, plen);
flush_xroute(&xroutes[i]);
change = 1; change = 1;
} else { } else {
i++; i++;
...@@ -207,11 +214,16 @@ check_xroutes(int send_updates) ...@@ -207,11 +214,16 @@ check_xroutes(int send_updates)
routes[i].prefix, routes[i].plen, routes[i].prefix, routes[i].plen,
metric, routes[i].ifindex, routes[i].proto); metric, routes[i].ifindex, routes[i].proto);
if(rc) { if(rc) {
struct route *route;
route = find_installed_route(routes[i].prefix, routes[i].plen);
if(route)
uninstall_route(route);
change = 1; change = 1;
if(send_updates) if(send_updates)
send_update(NULL, 0, routes[i].prefix, routes[i].plen); send_update(NULL, 0, routes[i].prefix, routes[i].plen);
} }
} }
} }
return change; return change;
} }
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