From 8527bb6bf3f645f059223013a21f9f5beb5bf0a0 Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Tue, 5 Mar 2024 14:48:37 +0100 Subject: [PATCH] Simplified table deletion (one less step) --- nest/route.h | 3 --- nest/rt-table.c | 49 +++++++++++++++++++------------------------------ 2 files changed, 19 insertions(+), 33 deletions(-) diff --git a/nest/route.h b/nest/route.h index 7850a54c..f398cb33 100644 --- a/nest/route.h +++ b/nest/route.h @@ -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; diff --git a/nest/rt-table.c b/nest/rt-table.c index ef849e62..46b8ae6d 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -2378,26 +2378,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) { @@ -2688,7 +2668,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); @@ -3799,15 +3778,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); @@ -3815,12 +3799,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)