summaryrefslogtreecommitdiff
path: root/nest/rt-table.c
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>2000-01-16 16:44:50 +0000
committerMartin Mares <mj@ucw.cz>2000-01-16 16:44:50 +0000
commit50fe90edf3deab409ea7887c131bfe6ce89fa556 (patch)
treed9aad4ed34285a59cfcc0286a22ca5ccdb63a82f /nest/rt-table.c
parent394aec8fdd112a81da1e2f6f0e09ee74256dc24e (diff)
First attempt on dynamic reconfiguration. There are still lots of bugs
and problems to solve, but the hardest part works.
Diffstat (limited to 'nest/rt-table.c')
-rw-r--r--nest/rt-table.c67
1 files changed, 59 insertions, 8 deletions
diff --git a/nest/rt-table.c b/nest/rt-table.c
index 401c5f85..b0d1e291 100644
--- a/nest/rt-table.c
+++ b/nest/rt-table.c
@@ -1,7 +1,7 @@
/*
* BIRD -- Routing Table
*
- * (c) 1998--1999 Martin Mares <mj@ucw.cz>
+ * (c) 1998--2000 Martin Mares <mj@ucw.cz>
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
@@ -480,17 +480,68 @@ rt_preconfig(struct config *c)
}
void
-rt_commit(struct config *c)
+rt_lock_table(rtable *r)
{
- struct rtable_config *r;
+ r->use_count++;
+}
+
+void
+rt_unlock_table(rtable *r)
+{
+ if (!--r->use_count && r->deleted)
+ {
+ struct config *conf = r->deleted;
+ DBG("Deleting routing table %s\n", r->name);
+ rem_node(&r->n);
+ fib_free(&r->fib);
+ mb_free(r);
+ config_del_obstacle(conf);
+ }
+}
+
+void
+rt_commit(struct config *new, struct config *old)
+{
+ struct rtable_config *o, *r;
- WALK_LIST(r, c->tables)
+ DBG("rt_commit:\n");
+ if (old)
{
- rtable *t = mb_alloc(rt_table_pool, sizeof(struct rtable));
- rt_setup(rt_table_pool, t, r->name);
- add_tail(&routing_tables, &t->n);
- r->table = t;
+ WALK_LIST(o, old->tables)
+ {
+ rtable *ot = o->table;
+ if (!ot->deleted)
+ {
+ struct symbol *sym = cf_find_symbol(o->name);
+ if (sym && sym->class == SYM_TABLE)
+ {
+ DBG("\t%s: same\n", o->name);
+ r = sym->def;
+ r->table = ot;
+ ot->name = r->name;
+ }
+ else
+ {
+ DBG("\t%s: deleted", o->name);
+ ot->deleted = old;
+ config_add_obstacle(old);
+ rt_lock_table(ot);
+ rt_unlock_table(ot);
+ }
+ }
+ }
}
+
+ WALK_LIST(r, new->tables)
+ if (!r->table)
+ {
+ rtable *t = mb_alloc(rt_table_pool, sizeof(struct rtable));
+ DBG("\t%s: created\n", r->name);
+ rt_setup(rt_table_pool, t, r->name);
+ add_tail(&routing_tables, &t->n);
+ r->table = t;
+ }
+ DBG("\tdone\n");
}
/*