]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: update auto route target for l3vni appropriately
authorPhilippe Guibert <philippe.guibert@6wind.com>
Tue, 17 Aug 2021 12:42:30 +0000 (14:42 +0200)
committermergify-bot <noreply@mergify.io>
Thu, 2 Sep 2021 19:34:56 +0000 (19:34 +0000)
The BGP configuration for BGP EVPN RT5 setup consists in mainly
2 bgp instances (eventually one is enough) and L3VNI config.

When L3VNI is configured before BGP instances, and BGP route
targets are auto derived as per rfc8365, then, the obtained
route targets are wrong. For instance, the following can be
obtained:

=> show bgp vrf cust1 vni
BGP VRF: cust1
  Local-Ip: 10.209.36.1
  L3-VNI: 1000
  Rmac: da:85:42:ba:2a:e9
  VNI Filter: none
  L2-VNI List:

  Export-RTs:
    RT:12757:1000
  Import-RTs:
    RT:12757:1000
  RD: 65000:1000

whereas the derived route targets should be the below
ones:

=> show bgp vrf cust1 vni
BGP VRF: cust1
  Local-Ip: 10.209.36.1
  L3-VNI: 1000
  Rmac: 72:f3:af:a0:98:80
  VNI Filter: none
  L2-VNI List:

  Export-RTs:
    RT:12757:268436456
  Import-RTs:
    RT:12757:268436456
  RD: 65000:1000

There is an update handler that updates appropriately L2VNIs.
But this is not the case for L3VNIs. Add the missing code.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
bgpd/bgp_evpn.c

index cbd29c146a38b9aad03366f9af3682e1f53648ad..5a4b46f3708dd7f62ddc5b5a5deda75415069a58 100644 (file)
@@ -4334,6 +4334,54 @@ static void update_autort_vni(struct hash_bucket *bucket, struct bgp *bgp)
        }
 }
 
+/*
+ * Handle autort change for L3VNI.
+ */
+static void update_autort_l3vni(struct bgp *bgp)
+{
+       if ((CHECK_FLAG(bgp->vrf_flags, BGP_VRF_IMPORT_RT_CFGD))
+           && (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_EXPORT_RT_CFGD)))
+               return;
+
+       if (!CHECK_FLAG(bgp->vrf_flags, BGP_VRF_IMPORT_RT_CFGD)) {
+               if (is_l3vni_live(bgp))
+                       uninstall_routes_for_vrf(bgp);
+
+               /* Cleanup the RT to VRF mapping */
+               bgp_evpn_unmap_vrf_from_its_rts(bgp);
+
+               /* Remove auto generated RT */
+               evpn_auto_rt_import_delete_for_vrf(bgp);
+
+               list_delete_all_node(bgp->vrf_import_rtl);
+
+               /* Map auto derive or configured RTs */
+               evpn_auto_rt_import_add_for_vrf(bgp);
+       }
+
+       if (!CHECK_FLAG(bgp->vrf_flags, BGP_VRF_EXPORT_RT_CFGD)) {
+               list_delete_all_node(bgp->vrf_export_rtl);
+
+               evpn_auto_rt_export_delete_for_vrf(bgp);
+
+               evpn_auto_rt_export_add_for_vrf(bgp);
+
+               if (is_l3vni_live(bgp))
+                       bgp_evpn_map_vrf_to_its_rts(bgp);
+       }
+
+       if (!is_l3vni_live(bgp))
+               return;
+
+       /* advertise type-5 routes if needed */
+       update_advertise_vrf_routes(bgp);
+
+       /* install all remote routes belonging to this l3vni
+        * into corresponding vrf
+        */
+       install_routes_for_vrf(bgp);
+}
+
 /*
  * Public functions.
  */
@@ -4706,6 +4754,8 @@ void bgp_evpn_handle_autort_change(struct bgp *bgp)
                     (void (*)(struct hash_bucket *,
                               void*))update_autort_vni,
                     bgp);
+       if (bgp->l3vni)
+               update_autort_l3vni(bgp);
 }
 
 /*