From 013a9b91fe495371cbf9a5690613de45b634e3af Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sat, 13 Feb 1999 20:46:03 +0000 Subject: When shutting down, remove all routes (except for RTS_INHERIT and RTS_DEVICE routes) from kernel routing tables unless the "persist" switch is set. --- sysdep/unix/krt-set.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'sysdep/unix/krt-set.c') diff --git a/sysdep/unix/krt-set.c b/sysdep/unix/krt-set.c index 2f0abe66..e77015b3 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; +} -- cgit v1.2.3