summaryrefslogtreecommitdiffstats
path: root/nest/proto.c
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>1999-05-17 22:14:52 +0200
committerMartin Mares <mj@ucw.cz>1999-05-17 22:14:52 +0200
commit0e02abfd5770062768eeb4c75061b7d2f656489d (patch)
treec9ee70e3b8d7eff81ced44994b58e878d9edafdc /nest/proto.c
parent4107df1d1b7454a16e6f45ea55aae13b01c9f566 (diff)
downloadbird-0e02abfd5770062768eeb4c75061b7d2f656489d.tar
bird-0e02abfd5770062768eeb4c75061b7d2f656489d.zip
From now we support multiple tables. The master_table variable is
definitely gone. Both rte_update() and rte_discard() have an additional argument telling which table should they modify. Also, rte_update() no longer walks the whole protocol list -- each table has a list of all protocols connected to this table and having the rt_notify hook set. Each protocol can also freely decide (by calling proto_add_announce_hook) to connect to any other table, but it will be probably used only by the table-to-table protocol. The default debugging dumps now include all routing tables and also all their connections.
Diffstat (limited to 'nest/proto.c')
-rw-r--r--nest/proto.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/nest/proto.c b/nest/proto.c
index ad4aa11..3199fee 100644
--- a/nest/proto.c
+++ b/nest/proto.c
@@ -86,7 +86,7 @@ proto_new(struct proto_config *c, unsigned size)
p->preference = c->preference;
p->disabled = c->disabled;
p->proto = pr;
- p->table = &master_table;
+ p->table = (c->table ? : c->global->master_rtc)->table;
p->in_filter = c->in_filter;
p->out_filter = c->out_filter;
return p;
@@ -101,6 +101,33 @@ proto_init_instance(struct proto *p)
p->attn->data = p;
}
+struct announce_hook *
+proto_add_announce_hook(struct proto *p, struct rtable *t)
+{
+ struct announce_hook *h;
+
+ if (!p->rt_notify)
+ return NULL;
+ DBG("Connecting protocol %s to table %s\n", p->name, t->name);
+ h = mb_alloc(p->pool, sizeof(struct announce_hook));
+ h->table = t;
+ h->proto = p;
+ h->next = p->ahooks;
+ p->ahooks = h;
+ add_tail(&t->hooks, &h->n);
+ return h;
+}
+
+static void
+proto_flush_hooks(struct proto *p)
+{
+ struct announce_hook *h;
+
+ for(h=p->ahooks; h; h=h->next)
+ rem_node(&h->n);
+ p->ahooks = NULL;
+}
+
void *
proto_config_new(struct protocol *pr, unsigned size)
{
@@ -296,6 +323,7 @@ proto_feed(void *P)
struct proto *p = P;
DBG("Feeding protocol %s\n", p->name);
+ proto_add_announce_hook(p, p->table);
if_feed_baby(p);
rt_feed_baby(p);
p->core_state = FS_HAPPY;
@@ -365,11 +393,12 @@ proto_flush_all(void *unused)
{
struct proto *p;
- rt_prune(&master_table);
+ rt_prune_all();
neigh_prune();
while ((p = HEAD(flush_proto_list))->n.next)
{
DBG("Flushing protocol %s\n", p->name);
+ proto_flush_hooks(p);
rfree(p->pool);
p->pool = NULL;
p->core_state = FS_HUNGRY;