]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: handle different sequence of bgp vrf create/delete
authorMitesh Kanjariya <mitesh@marvel-07.cumulusnetworks.com>
Fri, 10 Nov 2017 09:49:48 +0000 (01:49 -0800)
committerMitesh Kanjariya <mitesh@marvel-07.cumulusnetworks.com>
Thu, 14 Dec 2017 18:57:07 +0000 (10:57 -0800)
BGP VRF can be created/deleted either via config or via l3vni add/del.
We need to handle various sequences.

1. If user config is presented, an l3vni del should not delete the vrf instance
2. do not write bgp config in show running for auto created vrf
2. If l3vni present, disallow the cli for deleting bgp vrf instance
3. If l3vni is added and vrf config is present set the flags properly
4. if bgp vrf is configured unset the AUTO flag

Ticket: CM-18630
Review: CCR-6906
Testing: Manual

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
bgpd/bgp_evpn.c
bgpd/bgp_vty.c
bgpd/bgpd.c

index 0d0480781824969dbbd1e64de42e3c4fef5a809d..090663beb7d334c3b7dd3ad22310339d4a41bd0c 100644 (file)
@@ -3669,7 +3669,7 @@ int bgp_evpn_local_l3vni_add(vni_t l3vni,
        as = bgp_def->as;
 
        /* if the BGP vrf instance doesnt exist - create one */
-       bgp_vrf = bgp_lookup_by_vrf_id(vrf_id);
+       bgp_vrf = bgp_lookup_by_name(vrf_id_to_name(vrf_id));
        if (!bgp_vrf) {
 
                int ret = 0;
index 49a0f38db86dc668759ca15f0e1804cefdb45bbb..6c8a4f3d80c6a429f90f29d166d14575ee930a71 100644 (file)
@@ -873,6 +873,8 @@ DEFUN_NOSH (router_bgp,
                 */
        }
 
+       /* unset the auto created flag as the user config is now present */
+       UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO);
        VTY_PUSH_CONTEXT(BGP_NODE, bgp);
 
        return CMD_SUCCESS;
@@ -909,6 +911,12 @@ DEFUN (no_router_bgp,
                                "%% Multiple BGP processes are configured\n");
                        return CMD_WARNING_CONFIG_FAILED;
                }
+
+               if (bgp->l3vni) {
+                       vty_out(vty, "%% Please unconfigure l3vni %u",
+                               bgp->l3vni);
+                       return CMD_WARNING_CONFIG_FAILED;
+               }
        } else {
                as = strtoul(argv[idx_asn]->arg, NULL, 10);
 
@@ -921,6 +929,12 @@ DEFUN (no_router_bgp,
                        vty_out(vty, "%% Can't find BGP instance\n");
                        return CMD_WARNING_CONFIG_FAILED;
                }
+
+               if (bgp->l3vni) {
+                       vty_out(vty, "%% Please unconfigure l3vni %u",
+                               bgp->l3vni);
+                       return CMD_WARNING_CONFIG_FAILED;
+               }
        }
 
        bgp_delete(bgp);
index 67bb76f774ad6d8d7d6c6908cefb3500fd0dffb8..c7161c58625c49995dbab7334674bbccf105c2fb 100644 (file)
@@ -7080,6 +7080,11 @@ int bgp_config_write(struct vty *vty)
 
        /* BGP configuration. */
        for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) {
+
+               /* skip all auto created vrf as they dont have user config */
+               if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO))
+                       continue;
+
                /* Router bgp ASN */
                vty_out(vty, "router bgp %u", bgp->as);