]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: Ensure correct checks for EVPN route import
authorvivek <vivek@cumulusnetworks.com>
Mon, 19 Aug 2019 06:07:59 +0000 (23:07 -0700)
committervivek <vivek@cumulusnetworks.com>
Mon, 19 Aug 2019 06:07:59 +0000 (23:07 -0700)
In a situation where a VRF has configured route targets for importing
EVPN routes, this configuration may exist prior to the VRF being
ready to have EVPN routes installed into it - e.g., still missing
the L3VNI configuration or associated interface information. Ensure
that this is taken into account during EVPN route import and unimport.
Without this fix, EVPN routes would end up being prematurely imported
into the VRF routing table and consequently installed as inactive
(because the nexthop information would be incorrect when BGP informs
zebra).

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
bgpd/bgp_evpn.c
bgpd/bgp_evpn_private.h

index 3bc3d74de6f2beba78e54e28dc844ad99f025fbc..4d02e39ae22173ce70ef00b64a3cdb8d6ee8efee 100644 (file)
@@ -4459,7 +4459,8 @@ void bgp_evpn_configure_import_rt_for_vrf(struct bgp *bgp_vrf,
                                          struct ecommunity *ecomadd)
 {
        /* uninstall routes from vrf */
-       uninstall_routes_for_vrf(bgp_vrf);
+       if (is_l3vni_live(bgp_vrf))
+               uninstall_routes_for_vrf(bgp_vrf);
 
        /* Cleanup the RT to VRF mapping */
        bgp_evpn_unmap_vrf_from_its_rts(bgp_vrf);
@@ -4471,11 +4472,11 @@ void bgp_evpn_configure_import_rt_for_vrf(struct bgp *bgp_vrf,
        listnode_add_sort(bgp_vrf->vrf_import_rtl, ecomadd);
        SET_FLAG(bgp_vrf->vrf_flags, BGP_VRF_IMPORT_RT_CFGD);
 
-       /* map VRF to its RTs */
-       bgp_evpn_map_vrf_to_its_rts(bgp_vrf);
-
-       /* install routes matching the new VRF */
-       install_routes_for_vrf(bgp_vrf);
+       /* map VRF to its RTs and install routes matching the new RTs */
+       if (is_l3vni_live(bgp_vrf)) {
+               bgp_evpn_map_vrf_to_its_rts(bgp_vrf);
+               install_routes_for_vrf(bgp_vrf);
+       }
 }
 
 void bgp_evpn_unconfigure_import_rt_for_vrf(struct bgp *bgp_vrf,
@@ -4485,7 +4486,8 @@ void bgp_evpn_unconfigure_import_rt_for_vrf(struct bgp *bgp_vrf,
        struct ecommunity *ecom = NULL;
 
        /* uninstall routes from vrf */
-       uninstall_routes_for_vrf(bgp_vrf);
+       if (is_l3vni_live(bgp_vrf))
+               uninstall_routes_for_vrf(bgp_vrf);
 
        /* Cleanup the RT to VRF mapping */
        bgp_evpn_unmap_vrf_from_its_rts(bgp_vrf);
@@ -4509,11 +4511,11 @@ void bgp_evpn_unconfigure_import_rt_for_vrf(struct bgp *bgp_vrf,
                evpn_auto_rt_import_add_for_vrf(bgp_vrf);
        }
 
-       /* map VRFs to its RTs */
-       bgp_evpn_map_vrf_to_its_rts(bgp_vrf);
-
-       /* install routes matching this new RT */
-       install_routes_for_vrf(bgp_vrf);
+       /* map VRFs to its RTs and install routes matching this new RT */
+       if (is_l3vni_live(bgp_vrf)) {
+               bgp_evpn_map_vrf_to_its_rts(bgp_vrf);
+               install_routes_for_vrf(bgp_vrf);
+       }
 }
 
 void bgp_evpn_configure_export_rt_for_vrf(struct bgp *bgp_vrf,
index a5a091242f1636ca61b95d1ca4be5b1ccc68ac1a..f6bde2e9fa3c837c9b195f68ac272b45475cc566 100644 (file)
@@ -275,6 +275,11 @@ static inline int is_vni_live(struct bgpevpn *vpn)
        return (CHECK_FLAG(vpn->flags, VNI_FLAG_LIVE));
 }
 
+static inline int is_l3vni_live(struct bgp *bgp_vrf)
+{
+       return (bgp_vrf->l3vni && bgp_vrf->l3vni_svi_ifindex);
+}
+
 static inline int is_rd_configured(struct bgpevpn *vpn)
 {
        return (CHECK_FLAG(vpn->flags, VNI_FLAG_RD_CFGD));