diff options
author | Martin Mares <mj@ucw.cz> | 1999-02-13 19:15:28 +0000 |
---|---|---|
committer | Martin Mares <mj@ucw.cz> | 1999-02-13 19:15:28 +0000 |
commit | 1a54b1c6ac5177a1ef21f799f6cf28f355c5bbe9 (patch) | |
tree | c83a07d8cc3f7317452c5719233e2bccfc599c1c /nest/rt-table.c | |
parent | ab749558a2a4356c38ed760649ef7d62daa48223 (diff) |
Implemented real cleanup and pruning of routing table on protocol shutdown.
Diffstat (limited to 'nest/rt-table.c')
-rw-r--r-- | nest/rt-table.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/nest/rt-table.c b/nest/rt-table.c index 0ccb8da6..cc735e32 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -8,6 +8,8 @@ #include <string.h> +#define LOCAL_DEBUG + #include "nest/bird.h" #include "nest/route.h" #include "nest/protocol.h" @@ -282,3 +284,33 @@ rt_init(void) rt_setup(&master_table, "master"); rte_slab = sl_new(&root_pool, sizeof(rte)); } + +void +rt_prune(rtable *tab) +{ + struct fib_iterator fit; + int cnt = 0; + + DBG("Pruning route table %s\n", tab->name); + while (tab) + { + FIB_ITERATE_INIT(&fit, &tab->fib); + again: + FIB_ITERATE_START(&tab->fib, &fit, f) + { + net *n = (net *) f; + rte *e; + for (e=n->routes; e; e=e->next) + if (e->attrs->proto->core_state != FS_HAPPY) + { + FIB_ITERATE_PUT(&fit, f); + rte_discard(e); + cnt++; + goto again; + } + } + FIB_ITERATE_END(f); + tab = tab->sibling; + } + DBG("Pruned %d routes\n", cnt); +} |