From: Mitesh Kanjariya Date: Fri, 10 Nov 2017 09:49:48 +0000 (-0800) Subject: bgpd: handle different sequence of bgp vrf create/delete X-Git-Tag: frr-4.0-dev~58^2~29 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=0b5131c951538ae8acbfa1c62e92632d89ebbd25;p=matthieu%2Ffrr.git bgpd: handle different sequence of bgp vrf create/delete 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 --- diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index 0d04807818..090663beb7 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -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; diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 49a0f38db8..6c8a4f3d80 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -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); diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 67bb76f774..c7161c5862 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -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);