From: Philippe Guibert Date: Wed, 4 Nov 2020 09:52:11 +0000 (+0000) Subject: bgpd: upon bgp deletion, do not systematically ask to remove main bgp X-Git-Tag: base_8.0~355^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=999e803f314ac0be715aa7c15ad4a372e2253302;p=matthieu%2Ffrr.git bgpd: upon bgp deletion, do not systematically ask to remove main bgp Dependencies between bgp instances is necessary only when it comes to configure some specific services like ipv4-vpn, ipv6-vpn or l2vpn-evpn. The list of config possibilities is listed, and an error is returned if one of the above services is configured on the bgp vrf instance. There may be some missingn services not covered. For clarification, here are services configured on bgp vrf instances, while trying to delete main bgp instance: - if evpn main instance is the main bgp instance, and if evpn rt5 service is configured (with advertise command) - if a vni is configured in the vrf instance - if l3vpn import/export commands are solicitated for importing/exporting entries from a vpnv4/6 network located on main bgp instance. (in l3vpn, the main bgp instance is the location where vpnv4/6 sits). Signed-off-by: Philippe Guibert --- diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 1a7a3543f9..b2ab23fee1 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -1448,8 +1448,26 @@ DEFUN_YANG(no_router_bgp, struct bgp *tmp_bgp; for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) { - if (tmp_bgp->inst_type - == BGP_INSTANCE_TYPE_VRF) { + if (tmp_bgp->inst_type != BGP_INSTANCE_TYPE_VRF) + continue; + if (CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], + BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT) || + CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], + BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT) || + CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], + BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) || + CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], + BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) || + CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], + BGP_CONFIG_VRF_TO_VRF_EXPORT) || + CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], + BGP_CONFIG_VRF_TO_VRF_EXPORT) || + (bgp == bgp_get_evpn() && + (CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], + BGP_L2VPN_EVPN_ADVERTISE_IPV4_UNICAST) || + CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], + BGP_L2VPN_EVPN_ADVERTISE_IPV6_UNICAST))) || + (tmp_bgp->vnihash && hashcount(tmp_bgp->vnihash))) { vty_out(vty, "%% Cannot delete default BGP instance. Dependent VRF instances exist\n"); return CMD_WARNING_CONFIG_FAILED;