From 50fe90edf3deab409ea7887c131bfe6ce89fa556 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 16 Jan 2000 16:44:50 +0000 Subject: First attempt on dynamic reconfiguration. There are still lots of bugs and problems to solve, but the hardest part works. --- nest/rt-table.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 59 insertions(+), 8 deletions(-) (limited to 'nest/rt-table.c') diff --git a/nest/rt-table.c b/nest/rt-table.c index 401c5f8..b0d1e29 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -1,7 +1,7 @@ /* * BIRD -- Routing Table * - * (c) 1998--1999 Martin Mares + * (c) 1998--2000 Martin Mares * * 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"); } /* -- cgit v1.2.3