]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: fix handling of configured RTs for l2vni, l3vni
authorMark Stapp <mjs@cisco.com>
Mon, 24 Mar 2025 20:53:32 +0000 (16:53 -0400)
committerMark Stapp <mjs@cisco.com>
Mon, 24 Mar 2025 20:53:32 +0000 (16:53 -0400)
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 <mjs@cisco.com>
bgpd/bgp_evpn_vty.c

index 438dd0b3c2c62e82b3ab9ad5885697350f4e759d..571cca22fddff48820af2dac28dbe7fb9e085635 100644 (file)
@@ -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;