From: Mark Stapp Date: Mon, 24 Mar 2025 20:53:32 +0000 (-0400) Subject: bgpd: fix handling of configured RTs for l2vni, l3vni X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=2496bfecfef4d4a5f24d0f81bf5898f0cae12ebb;p=matthieu%2Ffrr.git bgpd: fix handling of configured RTs for l2vni, l3vni Test for existing explicit config as part of validation of route-target configuration: allow explicit config of generic/ default AS+VNI, for example, instead of rejecting it. Signed-off-by: Mark Stapp --- diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index 438dd0b3c2..571cca22fd 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -6617,18 +6617,17 @@ static int add_rt(struct bgp *bgp, struct ecommunity *ecom, bool is_import, { /* Do nothing if we already have this route-target */ if (is_import) { - if (!bgp_evpn_vrf_rt_matches_existing(bgp->vrf_import_rtl, - ecom)) - bgp_evpn_configure_import_rt_for_vrf(bgp, ecom, - is_wildcard); - else + if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_IMPORT_RT_CFGD) && + bgp_evpn_vrf_rt_matches_existing(bgp->vrf_import_rtl, ecom)) return -1; + + bgp_evpn_configure_import_rt_for_vrf(bgp, ecom, is_wildcard); } else { - if (!bgp_evpn_vrf_rt_matches_existing(bgp->vrf_export_rtl, - ecom)) - bgp_evpn_configure_export_rt_for_vrf(bgp, ecom); - else + if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_EXPORT_RT_CFGD) && + bgp_evpn_vrf_rt_matches_existing(bgp->vrf_export_rtl, ecom)) return -1; + + bgp_evpn_configure_export_rt_for_vrf(bgp, ecom); } return 0; @@ -7078,10 +7077,11 @@ DEFUN (bgp_evpn_vni_rt, ecommunity_str(ecomadd); /* Do nothing if we already have this import route-target */ - if (!bgp_evpn_rt_matches_existing(vpn->import_rtl, ecomadd)) - evpn_configure_import_rt(bgp, vpn, ecomadd); - else + if (CHECK_FLAG(vpn->flags, VNI_FLAG_IMPRT_CFGD) && + bgp_evpn_rt_matches_existing(vpn->import_rtl, ecomadd)) ecommunity_free(&ecomadd); + else + evpn_configure_import_rt(bgp, vpn, ecomadd); } /* Add/update the export route-target */ @@ -7096,10 +7096,11 @@ DEFUN (bgp_evpn_vni_rt, ecommunity_str(ecomadd); /* Do nothing if we already have this export route-target */ - if (!bgp_evpn_rt_matches_existing(vpn->export_rtl, ecomadd)) - evpn_configure_export_rt(bgp, vpn, ecomadd); - else + if (CHECK_FLAG(vpn->flags, VNI_FLAG_EXPRT_CFGD) && + bgp_evpn_rt_matches_existing(vpn->export_rtl, ecomadd)) ecommunity_free(&ecomadd); + else + evpn_configure_export_rt(bgp, vpn, ecomadd); } return CMD_SUCCESS;