]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: register to vrf_update_name() hook
authorPhilippe Guibert <philippe.guibert@6wind.com>
Wed, 19 Jun 2019 09:15:43 +0000 (11:15 +0200)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Tue, 27 Aug 2019 13:08:50 +0000 (15:08 +0200)
that hook is called back when default vrf name changes.
note that the hook is bgp_vrf_enable, and that the function is slightly
modified in order to be able to move bgp vrf instance from vrf to
default instance. for this, rfapi contexts are allocated.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
bgpd/bgp_main.c

index abd8586f4c71d73ed392e32a3ba9c1ea17e10cfc..ef73b47ffb9407336403e32722bead0765e9e935 100644 (file)
@@ -269,12 +269,20 @@ static int bgp_vrf_enable(struct vrf *vrf)
                zlog_debug("VRF enable add %s id %u", vrf->name, vrf->vrf_id);
 
        bgp = bgp_lookup_by_name(vrf->name);
-       if (bgp) {
+       if (bgp && bgp->vrf_id != vrf->vrf_id) {
                if (bgp->name && strmatch(vrf->name, VRF_DEFAULT_NAME)) {
                        XFREE(MTYPE_BGP, bgp->name);
                        bgp->name = NULL;
                        XFREE(MTYPE_BGP, bgp->name_pretty);
                        bgp->name_pretty = XSTRDUP(MTYPE_BGP, "VRF default");
+                       bgp->inst_type = BGP_INSTANCE_TYPE_DEFAULT;
+#if ENABLE_BGP_VNC
+                       if (!bgp->rfapi) {
+                               bgp->rfapi = bgp_rfapi_new(bgp);
+                               assert(bgp->rfapi);
+                               assert(bgp->rfapi_cfg);
+                       }
+#endif /* ENABLE_BGP_VNC */
                }
                old_vrf_id = bgp->vrf_id;
                /* We have instance configured, link to VRF and make it "up". */
@@ -343,7 +351,7 @@ static int bgp_vrf_disable(struct vrf *vrf)
 static void bgp_vrf_init(void)
 {
        vrf_init(bgp_vrf_new, bgp_vrf_enable, bgp_vrf_disable,
-                bgp_vrf_delete, NULL);
+                bgp_vrf_delete, bgp_vrf_enable);
 }
 
 static void bgp_vrf_terminate(void)