]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Simplified table deletion (one less step)
authorMaria Matejka <mq@ucw.cz>
Tue, 5 Mar 2024 13:48:37 +0000 (14:48 +0100)
committerMaria Matejka <mq@ucw.cz>
Sat, 6 Apr 2024 16:28:43 +0000 (18:28 +0200)
nest/route.h
nest/rt-table.c

index 7850a54cf408d85e7dd5f7c984f88747b27518fd..f398cb3307762087d214d877e6ddd4ff31c50c40 100644 (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;
index ef849e625cc1996bc283e60d4c9922f12daf35d4..46b8ae6dd3e27d2066a9f3163a54d4d573c73c39 100644 (file)
@@ -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)