From 1a54b1c6ac5177a1ef21f799f6cf28f355c5bbe9 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sat, 13 Feb 1999 19:15:28 +0000 Subject: Implemented real cleanup and pruning of routing table on protocol shutdown. --- nest/rt-table.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'nest/rt-table.c') diff --git a/nest/rt-table.c b/nest/rt-table.c index 0ccb8da..cc735e3 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -8,6 +8,8 @@ #include +#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); +} -- cgit v1.2.3