]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Handle change to router id for EVPN
authorvivek <vivek@cumulusnetworks.com>
Mon, 15 May 2017 22:02:33 +0000 (15:02 -0700)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 12 Jul 2017 19:07:28 +0000 (15:07 -0400)
When the BGP router-id changes, EVPN routes need to be processed due
to potential change to their RD.

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

index c787e21e83adcb9dd6b7a3e21e15e58e4a4a17a8..77dc2f2bc7739a847ba8623c842717f8e148b7dc 100644 (file)
@@ -1761,6 +1761,61 @@ delete_withdraw_vni_routes (struct bgp *bgp, struct bgpevpn *vpn)
   return 0;
 }
 
+/*
+ * Handle router-id change. Update and advertise local routes corresponding
+ * to this VNI from peers. Note that this is invoked after updating the
+ * router-id. The routes in the per-VNI table are used to create routes in
+ * the global table and schedule them.
+ */
+static void
+update_router_id_vni (struct hash_backet *backet, struct bgp *bgp)
+{
+  struct bgpevpn *vpn;
+
+  vpn = (struct bgpevpn *) backet->data;
+
+  if (!vpn)
+    {
+      zlog_warn ("%s: VNI hash entry for VNI not found",
+                 __FUNCTION__);
+      return;
+    }
+
+  /* Skip VNIs with configured RD. */
+  if (is_rd_configured (vpn))
+    return;
+
+  bgp_evpn_derive_auto_rd (bgp, vpn);
+  update_advertise_vni_routes (bgp, vpn);
+}
+
+/*
+ * Handle router-id change. Delete and withdraw local routes corresponding
+ * to this VNI from peers. Note that this is invoked prior to updating
+ * the router-id and is done only on the global route table, the routes
+ * are needed in the per-VNI table to re-advertise with new router id.
+ */
+static void
+withdraw_router_id_vni (struct hash_backet *backet, struct bgp *bgp)
+{
+  struct bgpevpn *vpn;
+
+  vpn = (struct bgpevpn *) backet->data;
+
+  if (!vpn)
+    {
+      zlog_warn ("%s: VNI hash entry for VNI not found",
+                 __FUNCTION__);
+      return;
+    }
+
+  /* Skip VNIs with configured RD. */
+  if (is_rd_configured (vpn))
+    return;
+
+  delete_withdraw_vni_routes (bgp, vpn);
+}
+
 /*
  * Process received EVPN type-2 route (advertise or withdraw).
  */
@@ -2106,6 +2161,26 @@ free_vni_entry (struct hash_backet *backet, struct bgp *bgp)
  * Public functions.
  */
 
+/*
+ * Handle change to BGP router id. This is invoked twice by the change
+ * handler, first before the router id has been changed and then after
+ * the router id has been changed. The first invocation will result in
+ * local routes for all VNIs being deleted and withdrawn and the next
+ * will result in the routes being re-advertised.
+ */
+void
+bgp_evpn_handle_router_id_update (struct bgp *bgp, int withdraw)
+{
+  if (withdraw)
+    hash_iterate (bgp->vnihash,
+                  (void (*) (struct hash_backet *, void *))
+                  withdraw_router_id_vni, bgp);
+  else
+    hash_iterate (bgp->vnihash,
+                  (void (*) (struct hash_backet *, void *))
+                  update_router_id_vni, bgp);
+}
+
 /*
  * Handle change to export RT - update and advertise local routes.
  */
index 1a71ec284a90154054dfdf1d69527f090859b1cb..610710d8451be69a04362fd3b840e62095a53761 100644 (file)
@@ -25,6 +25,8 @@
 
 #define EVPN_ROUTE_STRLEN 200 /* Must be >> MAC + IPv6 strings. */
 
+extern void
+bgp_evpn_handle_router_id_update (struct bgp *bgp, int withdraw);
 extern char *
 bgp_evpn_label2str (mpls_label_t *label, char *buf, int len);
 extern char *
index 723742eb3ddafc1ee55c2565de22b86a0e8c3be2..3a4a3e676003d957da1c51ec342c1f2fee5cba63 100644 (file)
@@ -227,6 +227,10 @@ bgp_router_id_set (struct bgp *bgp, const struct in_addr *id)
   if (IPV4_ADDR_SAME (&bgp->router_id, id))
     return 0;
 
+  /* EVPN uses router id in RD, withdraw them */
+  if (bgp->advertise_all_vni)
+    bgp_evpn_handle_router_id_update (bgp, TRUE);
+
   IPV4_ADDR_COPY (&bgp->router_id, id);
 
   /* Set all peer's local identifier with this value. */
@@ -242,6 +246,10 @@ bgp_router_id_set (struct bgp *bgp, const struct in_addr *id)
        }
     }
 
+  /* EVPN uses router id in RD, update them */
+  if (bgp->advertise_all_vni)
+    bgp_evpn_handle_router_id_update (bgp, FALSE);
+
   return 0;
 }