Commit 599cbf5d authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Flush xroutes at exit.

This avoids the send_self_retract hack.
parent bda34388
...@@ -681,8 +681,8 @@ main(int argc, char **argv) ...@@ -681,8 +681,8 @@ main(int argc, char **argv)
} }
debugf("Exiting...\n"); debugf("Exiting...\n");
/* Uninstall and retract all routes. */
while(numroutes > 0) { while(numroutes > 0) {
/* Uninstall and retract all routes. */
if(routes[0].installed) { if(routes[0].installed) {
uninstall_route(&routes[0]); uninstall_route(&routes[0]);
send_update(NULL, 1, routes[0].src->prefix, routes[0].src->plen); send_update(NULL, 1, routes[0].src->prefix, routes[0].src->plen);
...@@ -690,16 +690,21 @@ main(int argc, char **argv) ...@@ -690,16 +690,21 @@ main(int argc, char **argv)
/* We need to flush the route so network_up won't reinstall it */ /* We need to flush the route so network_up won't reinstall it */
flush_route(&routes[0]); flush_route(&routes[0]);
} }
while(numxroutes > 0) {
xroutes[0].metric = INFINITY;
send_update(NULL, 1, xroutes[0].prefix, xroutes[0].plen);
flush_xroute(&xroutes[0]);
}
flushupdates();
for(i = 0; i < numnets; i++) { for(i = 0; i < numnets; i++) {
if(!nets[i].up) if(!nets[i].up)
continue; continue;
/* Retract exported routes. */
send_self_retract(&nets[i]);
/* Make sure that we expire quickly from our neighbours' /* Make sure that we expire quickly from our neighbours'
association caches. Since we sleep on average 10ms per association caches. Since we sleep on average 10ms per
network, set the hello interval to numnets cs. */ network, set the hello interval to numnets centiseconds. */
send_hello_noupdate(&nets[i], numnets); send_hello_noupdate(&nets[i], numnets);
flushupdates();
flushbuf(&nets[i]); flushbuf(&nets[i]);
usleep(5000 + random() % 10000); usleep(5000 + random() % 10000);
} }
...@@ -707,9 +712,7 @@ main(int argc, char **argv) ...@@ -707,9 +712,7 @@ main(int argc, char **argv)
if(!nets[i].up) if(!nets[i].up)
continue; continue;
/* Make sure they got it. */ /* Make sure they got it. */
send_self_retract(&nets[i]);
send_hello_noupdate(&nets[i], 1); send_hello_noupdate(&nets[i], 1);
flushupdates();
flushbuf(&nets[i]); flushbuf(&nets[i]);
usleep(5000 + random() % 10000); usleep(5000 + random() % 10000);
network_up(&nets[i], 0); network_up(&nets[i], 0);
......
...@@ -38,6 +38,7 @@ extern struct xroute xroutes[MAXXROUTES]; ...@@ -38,6 +38,7 @@ extern struct xroute xroutes[MAXXROUTES];
extern int numxroutes; extern int numxroutes;
struct xroute *find_xroute(const unsigned char *prefix, unsigned char plen); struct xroute *find_xroute(const unsigned char *prefix, unsigned char plen);
void flush_xroute(struct xroute *xroute);
int add_xroute(int kind, unsigned char prefix[16], unsigned char plen, int add_xroute(int kind, unsigned char prefix[16], unsigned char plen,
unsigned short metric, unsigned int ifindex, int proto); unsigned short metric, unsigned int ifindex, int proto);
int check_xroutes(int send_updates); int check_xroutes(int send_updates);
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