0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-10-18 09:58:43 +00:00

Simplified table deletion (one less step)

This commit is contained in:
Maria Matejka 2024-03-05 14:48:37 +01:00 committed by Katerina Kubecova
parent 7c4db11b9f
commit feb16991ee
2 changed files with 19 additions and 33 deletions

View File

@ -175,9 +175,6 @@ LOBJ_UNLOCK_CLEANUP(rtable, rtable);
#define RT_PUB(tab) SKIP_BACK(rtable, priv, tab)
/* Flags for birdloop_flag() */
#define RTF_DELETE 8
extern struct rt_cork {
_Atomic uint active;
event_list queue;

View File

@ -2375,26 +2375,6 @@ rt_schedule_prune(struct rtable_private *tab)
ev_send_loop(tab->loop, tab->prune_event);
}
static void
rt_flag_handler(struct birdloop_flag_handler *fh, u32 flags)
{
RT_LOCKED(RT_PUB(SKIP_BACK(struct rtable_private, fh, fh)), tab)
{
ASSERT_DIE(birdloop_inside(tab->loop));
rt_lock_table(tab);
if (flags & RTF_DELETE)
{
if (tab->hostcache)
rt_stop_export_locked(tab, tab->hostcache->req.hook);
rt_unlock_table(tab);
}
rt_unlock_table(tab);
}
}
static void
rt_prune_timer(timer *t)
{
@ -2685,7 +2665,6 @@ rt_setup(pool *pp, struct rtable_config *cf)
hmap_init(&t->id_map, p, 1024);
hmap_set(&t->id_map, 0);
t->fh = (struct birdloop_flag_handler) { .hook = rt_flag_handler, };
t->nhu_event = ev_new_init(p, rt_next_hop_update, t);
t->nhu_uncork_event = ev_new_init(p, rt_nhu_uncork, t);
t->prune_timer = tm_new_init(p, rt_prune_timer, t, 0, 0);
@ -3796,15 +3775,20 @@ rt_commit(struct config *new, struct config *old)
if (old)
{
WALK_LIST(o, old->tables)
{
_Bool ok;
RT_LOCKED(o->table, tab)
{
if (tab->deleted)
continue;
r = tab->deleted ? NULL : rt_find_table_config(new, o->name);
ok = r && !new->shutdown && rt_reconfigure(tab, r, o);
}
r = rt_find_table_config(new, o->name);
if (r && !new->shutdown && rt_reconfigure(tab, r, o))
continue;
if (ok)
continue;
birdloop_enter(o->table->loop);
RT_LOCKED(o->table, tab)
{
DBG("\t%s: deleted\n", o->name);
tab->deleted = old;
config_add_obstacle(old);
@ -3812,12 +3796,17 @@ rt_commit(struct config *new, struct config *old)
rt_check_cork_low(tab);
if (tab->hcu_event && (ev_get_list(tab->hcu_event) == &rt_cork.queue))
ev_postpone(tab->hcu_event);
if (tab->hcu_event)
{
if (ev_get_list(tab->hcu_event) == &rt_cork.queue)
ev_postpone(tab->hcu_event);
/* Force one more loop run */
birdloop_flag(tab->loop, RTF_DELETE);
rt_stop_export_locked(tab, tab->hostcache->req.hook);
}
rt_unlock_table(tab);
}
birdloop_leave(o->table->loop);
}
}
WALK_LIST(r, new->tables)