summaryrefslogtreecommitdiff
path: root/sysdep/unix/krt-set.c
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>1999-02-13 20:46:03 +0000
committerMartin Mares <mj@ucw.cz>1999-02-13 20:46:03 +0000
commit013a9b91fe495371cbf9a5690613de45b634e3af (patch)
tree29ed464a9658596b389e66c0a206b00e3c94200e /sysdep/unix/krt-set.c
parent0a2e9d9f5685fb4ca63e02fd3645194bb6de79d7 (diff)
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/krt-set.c')
-rw-r--r--sysdep/unix/krt-set.c26
1 files changed, 26 insertions, 0 deletions
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;
+}