diff options
author | Martin Mares <mj@ucw.cz> | 1999-02-13 21:46:03 +0100 |
---|---|---|
committer | Martin Mares <mj@ucw.cz> | 1999-02-13 21:46:03 +0100 |
commit | 013a9b91fe495371cbf9a5690613de45b634e3af (patch) | |
tree | 29ed464a9658596b389e66c0a206b00e3c94200e /sysdep/unix | |
parent | 0a2e9d9f5685fb4ca63e02fd3645194bb6de79d7 (diff) | |
download | bird-013a9b91fe495371cbf9a5690613de45b634e3af.tar bird-013a9b91fe495371cbf9a5690613de45b634e3af.zip |
When shutting down, remove all routes (except for RTS_INHERIT and RTS_DEVICE
routes) from kernel routing tables unless the "persist" switch is set.
Diffstat (limited to 'sysdep/unix')
-rw-r--r-- | sysdep/unix/Modules | 1 | ||||
-rw-r--r-- | sysdep/unix/krt-set.Y | 29 | ||||
-rw-r--r-- | sysdep/unix/krt-set.c | 26 | ||||
-rw-r--r-- | sysdep/unix/krt-set.h | 1 | ||||
-rw-r--r-- | sysdep/unix/krt.h | 1 | ||||
-rw-r--r-- | sysdep/unix/sync-rt.c | 1 |
6 files changed, 59 insertions, 0 deletions
diff --git a/sysdep/unix/Modules b/sysdep/unix/Modules index f6db6d3..2969ee4 100644 --- a/sysdep/unix/Modules +++ b/sysdep/unix/Modules @@ -9,5 +9,6 @@ krt.Y krt.h krt-set.c krt-set.h +krt-set.Y krt-iface.h krt-iface.Y diff --git a/sysdep/unix/krt-set.Y b/sysdep/unix/krt-set.Y new file mode 100644 index 0000000..551ee16 --- /dev/null +++ b/sysdep/unix/krt-set.Y @@ -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 diff --git a/sysdep/unix/krt-set.c b/sysdep/unix/krt-set.c index 2f0abe6..e77015b 100644 --- a/sysdep/unix/krt-set.c +++ b/sysdep/unix/krt-set.c @@ -133,3 +133,29 @@ void 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; +} diff --git a/sysdep/unix/krt-set.h b/sysdep/unix/krt-set.h index 53b1146..ec96e65 100644 --- a/sysdep/unix/krt-set.h +++ b/sysdep/unix/krt-set.h @@ -10,6 +10,7 @@ #define _BIRD_KRT_SET_H_ struct krt_set_params { + int persist; }; struct krt_set_status { diff --git a/sysdep/unix/krt.h b/sysdep/unix/krt.h index 5631bc5..9b630b2 100644 --- a/sysdep/unix/krt.h +++ b/sysdep/unix/krt.h @@ -52,6 +52,7 @@ void krt_scan_ifaces_done(struct krt_proto *); void krt_set_preconfig(struct krt_config *); void krt_set_start(struct krt_proto *); +void krt_set_shutdown(struct krt_proto *); /* sync-if.c */ diff --git a/sysdep/unix/sync-rt.c b/sysdep/unix/sync-rt.c index 094da1c..99ef92a 100644 --- a/sysdep/unix/sync-rt.c +++ b/sysdep/unix/sync-rt.c @@ -43,6 +43,7 @@ krt_shutdown(struct proto *p) krt_scan_shutdown(k); krt_if_shutdown(k); + krt_set_shutdown(k); return PS_DOWN; } |