When shutting down, remove all routes (except for RTS_INHERIT and RTS_DEVICE

routes) from kernel routing tables unless the "persist" switch is set.
This commit is contained in:
Martin Mares 1999-02-13 20:46:03 +00:00
parent 0a2e9d9f56
commit 013a9b91fe
6 changed files with 59 additions and 0 deletions

View file

@ -9,5 +9,6 @@ krt.Y
krt.h krt.h
krt-set.c krt-set.c
krt-set.h krt-set.h
krt-set.Y
krt-iface.h krt-iface.h
krt-iface.Y krt-iface.Y

29
sysdep/unix/krt-set.Y Normal file
View file

@ -0,0 +1,29 @@
/*
* BIRD -- UNIX Kernel Syncer Configuration
*
* (c) 1998--1999 Martin Mares <mj@ucw.cz>
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
CF_HDR
#include "lib/krt-scan.h"
CF_DECLS
CF_KEYWORDS(PERSIST)
CF_GRAMMAR
CF_ADDTO(kern_proto, kern_proto krt_set_item ';')
krt_set_item:
PERSIST bool {
((struct krt_config *) this_proto)->setopt.persist = $2;
}
;
CF_CODE
CF_END

View file

@ -133,3 +133,29 @@ void
krt_set_preconfig(struct krt_config *c) krt_set_preconfig(struct krt_config *c)
{ {
} }
void
krt_set_shutdown(struct krt_proto *x)
{
struct rtable *t = &master_table;
if (((struct krt_config *) x->p.cf)->setopt.persist)
return;
DBG("Flushing kernel routes...\n");
while (t && t->tos)
t = t->sibling;
if (!t)
return;
FIB_WALK(&t->fib, f)
{
net *n = (net *) f;
rte *e = n->routes;
if (e)
{
rta *a = e->attrs;
if (a->source != RTS_DEVICE && a->source != RTS_INHERIT)
krt_remove_route(e);
}
}
FIB_WALK_END;
}

View file

@ -10,6 +10,7 @@
#define _BIRD_KRT_SET_H_ #define _BIRD_KRT_SET_H_
struct krt_set_params { struct krt_set_params {
int persist;
}; };
struct krt_set_status { struct krt_set_status {

View file

@ -52,6 +52,7 @@ void krt_scan_ifaces_done(struct krt_proto *);
void krt_set_preconfig(struct krt_config *); void krt_set_preconfig(struct krt_config *);
void krt_set_start(struct krt_proto *); void krt_set_start(struct krt_proto *);
void krt_set_shutdown(struct krt_proto *);
/* sync-if.c */ /* sync-if.c */

View file

@ -43,6 +43,7 @@ krt_shutdown(struct proto *p)
krt_scan_shutdown(k); krt_scan_shutdown(k);
krt_if_shutdown(k); krt_if_shutdown(k);
krt_set_shutdown(k);
return PS_DOWN; return PS_DOWN;
} }