]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Nest: Improve reconfiguration of dynamic BGP
authorOndrej Zajicek <santiago@crfreenet.org>
Thu, 26 Feb 2026 14:29:40 +0000 (15:29 +0100)
committerOndrej Zajicek <santiago@crfreenet.org>
Thu, 26 Feb 2026 16:10:03 +0000 (17:10 +0100)
During reconfiguration, first add all existing dynamic protocols to the
new BGP config to ensure that there is already full set of protocols
when reconfiguration hooks for individual protocols are called.

Also, bgp_spawn() should not be called when parent BGP is not yet
configured, otherwise we would end with an old proto_config linked
from the new configuration.

nest/proto.c
proto/bgp/bgp.c

index 1aeea96c599708a5cb638e2738c3d2f48e4a247b..1b4a98571e3ed640f55bee9adfa64cce926589c1 100644 (file)
@@ -1338,13 +1338,10 @@ protos_commit(struct config *new, struct config *old, int force_reconfig, int ty
   DBG("protos_commit:\n");
   if (old)
   {
+    /* First, add dynamic protocols to the new config */
     WALK_LIST(oc, old->protos)
     {
-      p = oc->proto;
-      sym = cf_find_symbol(new, oc->name);
-
-      /* Handle dynamic protocols */
-      if (!sym && oc->parent && !new->shutdown)
+      if (oc->parent && !cf_find_symbol(new, oc->name) && !new->shutdown)
       {
        struct symbol *parsym = cf_find_symbol(new, oc->parent->name);
        if (parsym && parsym->class == SYM_PROTO)
@@ -1359,6 +1356,12 @@ protos_commit(struct config *new, struct config *old, int force_reconfig, int ty
          cfg_mem = NULL;
        }
       }
+    }
+
+    WALK_LIST(oc, old->protos)
+    {
+      p = oc->proto;
+      sym = cf_find_symbol(new, oc->name);
 
       if (sym && sym->class == SYM_PROTO && !new->shutdown)
       {
index 5aa465c15a0fba65f16aa2fe4f139b026056b0c8..5431d08b3fdb6146424d590a1539791367885169 100644 (file)
@@ -1086,6 +1086,10 @@ bgp_spawn(struct bgp_proto *pp, ip_addr remote_ip, ip_addr local_ip, struct ifac
 
   bsprintf(fmt, "%s%%0%dd", pp->cf->dynamic_name, pp->cf->dynamic_name_digits);
 
+  /* The parent protocol must not be not-yet-reconfigured, otherwise we would
+     mix-up different generations of configuration */
+  ASSERT(pp->p.cf->global == config);
+
   /* This is hack, we would like to share config, but we need to copy it now */
   new_config = config;
   cfg_mem = config->mem;