summaryrefslogtreecommitdiffstats
path: root/nest/rt-table.c
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>1999-02-13 20:15:28 +0100
committerMartin Mares <mj@ucw.cz>1999-02-13 20:15:28 +0100
commit1a54b1c6ac5177a1ef21f799f6cf28f355c5bbe9 (patch)
treec83a07d8cc3f7317452c5719233e2bccfc599c1c /nest/rt-table.c
parentab749558a2a4356c38ed760649ef7d62daa48223 (diff)
downloadbird-1a54b1c6ac5177a1ef21f799f6cf28f355c5bbe9.tar
bird-1a54b1c6ac5177a1ef21f799f6cf28f355c5bbe9.zip
Implemented real cleanup and pruning of routing table on protocol shutdown.
Diffstat (limited to 'nest/rt-table.c')
-rw-r--r--nest/rt-table.c32
1 files changed, 32 insertions, 0 deletions
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 <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);
+}