]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Update EVPN type-1 routes when VNI RT changes 8290/head
authorAmeya Dharkar <adharkar@vmware.com>
Fri, 19 Mar 2021 01:34:45 +0000 (18:34 -0700)
committerAmeya Dharkar <adharkar@vmware.com>
Tue, 23 Mar 2021 15:40:29 +0000 (08:40 -0700)
1. When VNI export RT changes, for each local es_evi, update local
EAD/ES and EAD/EVI routes and advertise.

2. When VNI import RT changes, uninstall all type-1 routes imported in
the VNI and import routes carrying the updated RT.

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
bgpd/bgp_evpn.c
bgpd/bgp_evpn_mh.c
bgpd/bgp_evpn_mh.h

index ec712640818ccf11b1a4ec0d02d2ee79775ac13c..cebc1c4d22ac94dceb2958ed78a059e0b097a391 100644 (file)
@@ -2235,6 +2235,8 @@ int update_routes_for_vni(struct bgp *bgp, struct bgpevpn *vpn)
        int ret;
        struct prefix_evpn p;
 
+       update_type1_routes_for_evi(bgp, vpn);
+
        /* Update and advertise the type-3 route (only one) followed by the
         * locally learnt type-2 routes (MACIP) - for this VNI.
         *
@@ -3136,7 +3138,7 @@ static int uninstall_routes_for_vni(struct bgp *bgp, struct bgpevpn *vpn)
                return ret;
 
        ret = install_uninstall_routes_for_vni(bgp, vpn, BGP_EVPN_AD_ROUTE,
-                                              1);
+                                              0);
        if (ret)
                return ret;
 
index 123c46f12f8bb60546a35388a2380f3c4b5060fc..826de21b9db966b90342e37c8497f9b09697bf8d 100644 (file)
@@ -970,6 +970,48 @@ static int bgp_evpn_type1_route_update(struct bgp *bgp,
        return 0;
 }
 
+/*
+ * This function is called when the export RT for a VNI changes.
+ * Update all type-1 local routes for this VNI from VNI/ES tables and the global
+ * table and advertise these routes to peers.
+ */
+
+void update_type1_routes_for_evi(struct bgp *bgp, struct bgpevpn *vpn)
+{
+       struct prefix_evpn p;
+       struct bgp_evpn_es *es;
+       struct bgp_evpn_es_evi *es_evi;
+       struct bgp_evpn_es_evi *es_evi_next;
+
+       RB_FOREACH_SAFE(es_evi, bgp_es_evi_rb_head,
+                       &vpn->es_evi_rb_tree, es_evi_next) {
+               es = es_evi->es;
+
+               /* Update EAD-ES */
+               if (CHECK_FLAG(es->flags, BGP_EVPNES_OPER_UP)) {
+                       build_evpn_type1_prefix(&p, BGP_EVPN_AD_ES_ETH_TAG,
+                                               &es->esi, es->originator_ip);
+                       if (bgp_evpn_type1_route_update(bgp, es, NULL, &p))
+                               flog_err(EC_BGP_EVPN_ROUTE_CREATE,
+                                       "%u: EAD-ES route update failure for ESI %s VNI %u",
+                                       bgp->vrf_id, es->esi_str,
+                                       es_evi->vpn->vni);
+               }
+
+               /* Update EAD-EVI */
+               if (CHECK_FLAG(es->flags, BGP_EVPNES_ADV_EVI)) {
+                       build_evpn_type1_prefix(&p, BGP_EVPN_AD_EVI_ETH_TAG,
+                                               &es->esi, es->originator_ip);
+                       if (bgp_evpn_type1_route_update(bgp, es, es_evi->vpn,
+                                                       &p))
+                               flog_err(EC_BGP_EVPN_ROUTE_DELETE,
+                                       "%u: EAD-EVI route update failure for ESI %s VNI %u",
+                                       bgp->vrf_id, es->esi_str,
+                                       es_evi->vpn->vni);
+               }
+       }
+}
+
 /* Delete local Type-1 route */
 static int bgp_evpn_type1_es_route_delete(struct bgp *bgp,
                struct bgp_evpn_es *es, struct prefix_evpn *p)
index 1053e3f022916f5f478bf6d348d3f0e67edae13f..8c66e391b689aeef5a087fc323db7f3c53867e6c 100644 (file)
@@ -335,6 +335,7 @@ extern int bgp_evpn_es_route_install_uninstall(struct bgp *bgp,
                struct bgp_evpn_es *es, afi_t afi, safi_t safi,
                struct prefix_evpn *evp, struct bgp_path_info *pi,
                int install);
+extern void update_type1_routes_for_evi(struct bgp *bgp, struct bgpevpn *vpn);
 int bgp_evpn_type1_route_process(struct peer *peer, afi_t afi, safi_t safi,
                struct attr *attr, uint8_t *pfx, int psize,
                uint32_t addpath_id);