]> git.proxmox.com Git - mirror_frr.git/commitdiff
Quagga: Support VRF unregister for clients
authorvivek <vivek@cumulusnetworks.com>
Fri, 12 Feb 2016 19:37:33 +0000 (11:37 -0800)
committervivek <vivek@cumulusnetworks.com>
Fri, 12 Feb 2016 19:37:33 +0000 (11:37 -0800)
Clients (BGP, OSPF etc.) register with Zebra for information about
a VRF such as Router ID, interfaces and redistribution. Add API to
support unregister also which is required for the non-default VRF.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Ticket: CM-9128
Reviewed By: CCR-4098
Testing Done: Manual testing

bgpd/bgp_zebra.c
isisd/isis_zebra.c
lib/zclient.c
lib/zclient.h
ospf6d/ospf6_zebra.c
ospfd/ospf_zebra.c
ripd/rip_zebra.c
ripngd/ripng_zebra.c

index 4b80bbeafcdbdb1a4515b68772b36e9ac7caf2cb..9ffe44f267e6be5c949ffba3f8d209e1110a3f27 100644 (file)
@@ -239,9 +239,9 @@ bgp_vrf_add (int command, struct zclient *zclient, zebra_size_t length,
       bgp->vrf_id = vrf_id;
 
       if (BGP_DEBUG (zebra, ZEBRA) && vrf)
-        zlog_debug("zclient_send_requests %u", vrf_id);
+        zlog_debug("zclient_send_reg_requests %u", vrf_id);
 
-      zclient_send_requests (zclient, vrf_id);
+      zclient_send_reg_requests (zclient, vrf_id);
 
       bgp_instance_up (bgp);
       //Pending: See if the following can be moved inside bgp_instance_up ()
@@ -264,7 +264,7 @@ bgp_vrf_update (struct bgp *bgp)
         bgp->vrf_id = vrf->vrf_id;
     }
 
-  zclient_send_requests (zclient, bgp->vrf_id);
+  zclient_send_reg_requests (zclient, bgp->vrf_id);
   bgp_nht_register_all (bgp->vrf_id);
 }
 
index 86e6692e1522ea8ec4b32e946e01c84ca54dd9c1..e02de129ac84c30389aec03b641abcb96092be8c 100644 (file)
@@ -603,7 +603,7 @@ isis_redistribute_default_set (int routetype, int metric_type,
 static void
 isis_zebra_connected (struct zclient *zclient)
 {
-  zclient_send_requests (zclient, VRF_DEFAULT);
+  zclient_send_reg_requests (zclient, VRF_DEFAULT);
 }
 
 void
index 21d92530670eed4af53b6d75fc3909bc5c94c173..82f0c26e592eac6524fe7be757bfaabb134b5c79 100644 (file)
@@ -371,9 +371,9 @@ zebra_hello_send (struct zclient *zclient)
   return 0;
 }
 
-/* Send requests to zebra daemon for the information in a VRF. */
+/* Send register requests to zebra daemon for the information in a VRF. */
 void
-zclient_send_requests (struct zclient *zclient, vrf_id_t vrf_id)
+zclient_send_reg_requests (struct zclient *zclient, vrf_id_t vrf_id)
 {
   int i;
   afi_t afi;
@@ -387,7 +387,7 @@ zclient_send_requests (struct zclient *zclient, vrf_id_t vrf_id)
     return;
 
   if (zclient_debug)
-    zlog_debug ("%s: send messages for VRF %u", __func__, vrf_id);
+    zlog_debug ("%s: send register messages for VRF %u", __func__, vrf_id);
 
   /* We need router-id information. */
   zebra_message_send (zclient, ZEBRA_ROUTER_ID_ADD, vrf_id);
@@ -426,6 +426,61 @@ zclient_send_requests (struct zclient *zclient, vrf_id_t vrf_id)
     zebra_message_send (zclient, ZEBRA_REDISTRIBUTE_DEFAULT_ADD, vrf_id);
 }
 
+/* Send unregister requests to zebra daemon for the information in a VRF. */
+void
+zclient_send_dereg_requests (struct zclient *zclient, vrf_id_t vrf_id)
+{
+  int i;
+  afi_t afi;
+
+  /* zclient is disabled. */
+  if (! zclient->enable)
+    return;
+
+  /* If not connected to the zebra yet. */
+  if (zclient->sock < 0)
+    return;
+
+  if (zclient_debug)
+    zlog_debug ("%s: send deregister messages for VRF %u", __func__, vrf_id);
+
+  /* We need router-id information. */
+  zebra_message_send (zclient, ZEBRA_ROUTER_ID_DELETE, vrf_id);
+
+  /* We need interface information. */
+  zebra_message_send (zclient, ZEBRA_INTERFACE_DELETE, vrf_id);
+
+  /* Set unwanted redistribute route. */
+  for (afi = AFI_IP; afi < AFI_MAX; afi++)
+    vrf_bitmap_set (zclient->redist[afi][zclient->redist_default], vrf_id);
+
+  /* Flush all redistribute request. */
+  if (vrf_id == VRF_DEFAULT)
+    for (afi = AFI_IP; afi < AFI_MAX; afi++)
+      for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
+        if (zclient->mi_redist[afi][i].enabled)
+          {
+            struct listnode *node;
+            u_short *id;
+
+            for (ALL_LIST_ELEMENTS_RO(zclient->mi_redist[afi][i].instances, node, id))
+              if (!(i == zclient->redist_default && *id == zclient->instance))
+                zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, afi, i,
+                                         *id, VRF_DEFAULT);
+          }
+
+  /* Flush all redistribute request. */
+  for (afi = AFI_IP; afi < AFI_MAX; afi++)
+    for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
+      if (i != zclient->redist_default &&
+          vrf_bitmap_check (zclient->redist[afi][i], vrf_id))
+        zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, afi, i, 0, vrf_id);
+
+  /* If default information is needed. */
+  if (vrf_bitmap_check (zclient->default_information, VRF_DEFAULT))
+    zebra_message_send (zclient, ZEBRA_REDISTRIBUTE_DEFAULT_DELETE, vrf_id);
+}
+
 /* Make connection to zebra daemon. */
 int
 zclient_start (struct zclient *zclient)
index 22cd0410e077c77e5606af4c59849231d72637da..e58870828b81d5a56803d887a01a2cbe74c6424b 100644 (file)
@@ -173,7 +173,8 @@ extern int redist_check_instance (struct redist_proto *, u_short);
 extern void redist_add_instance (struct redist_proto *, u_short);
 extern void redist_del_instance (struct redist_proto *, u_short);
 
-extern void zclient_send_requests (struct zclient *, vrf_id_t);
+extern void zclient_send_reg_requests (struct zclient *, vrf_id_t);
+extern void zclient_send_dereg_requests (struct zclient *, vrf_id_t);
 
 /* Send redistribute command to zebra daemon. Do not update zclient state. */
 extern int zebra_redistribute_send (int command, struct zclient *, afi_t, int type, u_short instance, vrf_id_t vrf_id);
index 3fbc4d9c8d65680c96121c90adc0aa283eab81dd..a40b3d5f0f632f22246037407fb4156997e606b5 100644 (file)
@@ -651,7 +651,7 @@ DEFUN (no_redistribute_ospf6,
 static void
 ospf6_zebra_connected (struct zclient *zclient)
 {
-  zclient_send_requests (zclient, VRF_DEFAULT);
+  zclient_send_reg_requests (zclient, VRF_DEFAULT);
 }
 
 void
index b5980072a0d2e8ba46de4a707a9104382afd4423..543740c67e10f2d90aa3cb39804068146ae79921 100644 (file)
@@ -1557,7 +1557,7 @@ ospf_distance_apply (struct prefix_ipv4 *p, struct ospf_route *or)
 static void
 ospf_zebra_connected (struct zclient *zclient)
 {
-  zclient_send_requests (zclient, VRF_DEFAULT);
+  zclient_send_reg_requests (zclient, VRF_DEFAULT);
 }
 
 void
index a5f7bda6dfd3b72f45676c28588e1b7a137ea2eb..e4b9ae330cf0a2d710bc9490cfdb0b1e1762c7ac 100644 (file)
@@ -679,7 +679,7 @@ static struct cmd_node zebra_node =
 static void
 rip_zebra_connected (struct zclient *zclient)
 {
-  zclient_send_requests (zclient, VRF_DEFAULT);
+  zclient_send_reg_requests (zclient, VRF_DEFAULT);
 }
 
 void
index d894bfcd60c9fa85036580048dd0a67cde8c7540..e404e0f37cc34b56343b899c5f647dfcc833c477 100644 (file)
@@ -500,7 +500,7 @@ static struct cmd_node zebra_node =
 static void
 ripng_zebra_connected (struct zclient *zclient)
 {
-  zclient_send_requests (zclient, VRF_DEFAULT);
+  zclient_send_reg_requests (zclient, VRF_DEFAULT);
 }
 
 /* Initialize zebra structure and it's commands. */