Commit dc905c81 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Retract xroutes by setting their cost to infinity.

This makes sure we advertise xroutes after they are retracted.  They
will be flushed by the normal GC mechanism.
parent de5d2177
......@@ -321,10 +321,8 @@ update_route(const unsigned char *d, int seqno, int refmetric,
route->refmetric = refmetric;
change_route_metric(route, metric);
if(seqno_compare(oldseqno, seqno) <= 0) {
if(seqno_compare(oldseqno, seqno) < 0) {
/* Flush retracted xroutes */
flush_xroutes(dest, pxroutes, numpxroutes);
}
if(seqno_compare(oldseqno, seqno) < 0)
retract_xroutes(dest, pxroutes, numpxroutes);
for(i = 0; i < numpxroutes; i++)
update_xroute(pxroutes[i].prefix,
pxroutes[i].plen,
......
......@@ -209,24 +209,21 @@ flush_xroute(struct xroute *xroute)
}
void
flush_xroutes(struct destination *gateway,
const struct xroute *except, int numexcept)
retract_xroutes(struct destination *gateway,
const struct xroute *except, int numexcept)
{
int i, j;
i = 0;
while(i < numxroutes) {
if(xroutes[i].gateway == gateway) {
for(i = 0; i < numxroutes; i++) {
if(xroutes[i].cost < INFINITY && xroutes[i].gateway == gateway) {
for(j = 0; j < numexcept; j++) {
if(memcmp(xroutes[i].prefix, except[j].prefix, 16) == 0 &&
xroutes[i].plen == except[j].plen)
goto skip;
}
flush_xroute(&xroutes[i]);
continue;
update_xroute_metric(&xroutes[i], INFINITY);
}
skip:
i++;
skip: ;
}
}
......
......@@ -44,8 +44,8 @@ void install_xroute(struct xroute *xroute);
void uninstall_xroute(struct xroute *xroute);
void consider_xroute(struct xroute *xroute);
void flush_xroute(struct xroute *xroute);
void flush_xroutes(struct destination *gateway,
const struct xroute *except, int numexcept);
void retract_xroutes(struct destination *gateway,
const struct xroute *except, int numexcept);
struct xroute * update_xroute(const unsigned char *prefix, unsigned short plen,
struct destination *gateway, int cost);
void update_xroute_metric(struct xroute *xroute, int cost);
......
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