]> git.proxmox.com Git - mirror_frr.git/commitdiff
Zebra: On a link down, schedule static routes only.
authorvivek <vivek@cumulusnetworks.com>
Wed, 21 Oct 2015 05:37:32 +0000 (22:37 -0700)
committervivek <vivek@cumulusnetworks.com>
Wed, 21 Oct 2015 05:37:32 +0000 (22:37 -0700)
Ticket: CM-7420
Reviewed By: Vivek, Donald
Testing Done: UT, verification of the fix + ospf and bgp smoke

On a link delete/down event, schedule only the prefixes which have a
static RIB too.

Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
zebra/connected.c
zebra/interface.c
zebra/rib.h
zebra/zebra_rib.c
zebra/zebra_routemap.c

index b891f9e56c310f3d93279396d192b59608f8c6bc..2ec6911d77ec474dbeb49b2007428aaf9f209ac6 100644 (file)
@@ -31,6 +31,7 @@
 #include "log.h"
 #include "memory.h"
 
+#include "zebra/debug.h"
 #include "zebra/zserv.h"
 #include "zebra/redistribute.h"
 #include "zebra/interface.h"
@@ -213,6 +214,9 @@ connected_up_ipv4 (struct interface *ifp, struct connected *ifc)
   rib_add_ipv4 (ZEBRA_ROUTE_CONNECT, 0, 0, &p, NULL, NULL, ifp->ifindex,
        RT_TABLE_MAIN, ifp->metric, 0, SAFI_MULTICAST);
 
+  if (IS_ZEBRA_DEBUG_RIB)
+    zlog_debug ("%s: calling rib_update", __func__);
+
   rib_update ();
 }
 
@@ -327,7 +331,10 @@ connected_down_ipv4 (struct interface *ifp, struct connected *ifc)
 
   rib_delete_ipv4 (ZEBRA_ROUTE_CONNECT, 0, 0, &p, NULL, ifp->ifindex, 0, SAFI_MULTICAST);
 
-  rib_update ();
+  if (IS_ZEBRA_DEBUG_RIB)
+    zlog_debug ("%s: calling rib_update_static", __func__);
+
+  rib_update_static ();
 }
 
 void
@@ -387,7 +394,10 @@ connected_delete_ipv4 (struct interface *ifp, int flags, struct in_addr *addr,
 
   connected_withdraw (ifc);
 
-  rib_update();
+  if (IS_ZEBRA_DEBUG_RIB)
+    zlog_debug ("%s: calling rib_update_static", __func__);
+
+  rib_update_static();
 }
 
 #ifdef HAVE_IPV6
@@ -413,6 +423,9 @@ connected_up_ipv6 (struct interface *ifp, struct connected *ifc)
   rib_add_ipv6 (ZEBRA_ROUTE_CONNECT, 0, 0, &p, NULL, ifp->ifindex, RT_TABLE_MAIN,
                 ifp->metric, 0, SAFI_UNICAST);
 
+  if (IS_ZEBRA_DEBUG_RIB)
+    zlog_debug ("%s: calling rib_update", __func__);
+
   rib_update ();
 }
 
@@ -498,7 +511,10 @@ connected_down_ipv6 (struct interface *ifp, struct connected *ifc)
 
   rib_delete_ipv6 (ZEBRA_ROUTE_CONNECT, 0, 0, &p, NULL, ifp->ifindex, 0, SAFI_UNICAST);
 
-  rib_update ();
+  if (IS_ZEBRA_DEBUG_RIB)
+    zlog_debug ("%s: calling rib_update_static", __func__);
+
+  rib_update_static ();
 }
 
 void
@@ -519,6 +535,9 @@ connected_delete_ipv6 (struct interface *ifp, struct in6_addr *address,
 
   connected_withdraw (ifc);
 
-  rib_update();
+  if (IS_ZEBRA_DEBUG_RIB)
+    zlog_debug ("%s: calling rib_update_static", __func__);
+
+  rib_update_static();
 }
 #endif /* HAVE_IPV6 */
index 9dc13f7b194a961e6ecf4f81070e63d8171dc7c1..9d4a2f89d264da524bb3da08a40b546174c4aebb 100644 (file)
@@ -636,6 +636,10 @@ if_up (struct interface *ifp)
        }
     }
 
+  if (IS_ZEBRA_DEBUG_RIB)
+    zlog_debug ("%s: calling rib_update on interface %s up", __func__,
+                ifp->name);
+
   /* Examine all static routes. */
   rib_update ();
 }
@@ -670,7 +674,11 @@ if_down (struct interface *ifp)
     }
 
   /* Examine all static routes which direct to the interface. */
-  rib_update ();
+  if (IS_ZEBRA_DEBUG_RIB)
+    zlog_debug ("%s: calling rib_update_static on interface %s down", __func__,
+                ifp->name);
+
+  rib_update_static ();
 
   if_nbr_ipv6ll_to_ipv4ll_neigh_del_all (ifp);
 
index 7d9e2f7770eb593d79661cd79f84cc04148fbee8..fa37f7d8c3497a3a1e0e4445881eb178d5203bf7 100644 (file)
@@ -414,6 +414,7 @@ extern struct rib *rib_match_ipv4 (struct in_addr);
 extern struct rib *rib_lookup_ipv4 (struct prefix_ipv4 *);
 
 extern void rib_update (void);
+extern void rib_update_static (void);
 extern void rib_weed_tables (void);
 extern void rib_sweep_route (void);
 extern void rib_close (void);
index 518cdeb81f5df756acfb313f50e591737b56b64a..a69dead1a6cef7fe7938ab9602faf2fa87e13d83 100644 (file)
@@ -3890,6 +3890,35 @@ static_delete_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
 }
 #endif /* HAVE_IPV6 */
 
+/* RIB update function. */
+void
+rib_update_static (void)
+{
+  struct route_node *rn;
+  struct route_table *table;
+  struct rib *rib, *next;
+
+  table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
+  if (table)
+    for (rn = route_top (table); rn; rn = route_next (rn))
+      RNODE_FOREACH_RIB_SAFE (rn, rib, next)
+        if (rib->type == ZEBRA_ROUTE_STATIC)
+          {
+            rib_queue_add (&zebrad, rn);
+            break;
+          }
+
+  table = vrf_table (AFI_IP6, SAFI_UNICAST, 0);
+  if (table)
+    for (rn = route_top (table); rn; rn = route_next (rn))
+      RNODE_FOREACH_RIB_SAFE (rn, rib, next)
+        if (rib->type == ZEBRA_ROUTE_STATIC)
+          {
+            rib_queue_add (&zebrad, rn);
+            break;
+          }
+}
+
 /* RIB update function. */
 void
 rib_update (void)
index 17e7faaa08be54ed1318add34f0982b09758bbe4..1c7b63e7579697a07de4bab0e70f31f5b3557c1f 100644 (file)
@@ -763,6 +763,10 @@ DEFUN (ip_protocol,
       XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]);
     }
   proto_rm[AFI_IP][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[1]);
+
+  if (IS_ZEBRA_DEBUG_RIB)
+    zlog_debug ("%s: calling rib_update", __func__);
+
   rib_update();
   return CMD_SUCCESS;
 }
@@ -796,6 +800,10 @@ DEFUN (no_ip_protocol,
     {
       XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]);
       proto_rm[AFI_IP][i] = NULL;
+
+      if (IS_ZEBRA_DEBUG_RIB)
+        zlog_debug ("%s: calling rib_update", __func__);
+
       rib_update();
     }
   return CMD_SUCCESS;
@@ -867,6 +875,10 @@ DEFUN (ipv6_protocol,
       XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP6][i]);
     }
   proto_rm[AFI_IP6][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[1]);
+
+  if (IS_ZEBRA_DEBUG_RIB)
+    zlog_debug ("%s: calling rib_update", __func__);
+
   rib_update();
   return CMD_SUCCESS;
 }
@@ -900,6 +912,10 @@ DEFUN (no_ipv6_protocol,
     {
       XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP6][i]);
       proto_rm[AFI_IP6][i] = NULL;
+
+      if (IS_ZEBRA_DEBUG_RIB)
+        zlog_debug ("%s: calling rib_update", __func__);
+
       rib_update();
     }
   return CMD_SUCCESS;
@@ -1571,6 +1587,9 @@ zebra_route_map_update_timer (struct thread *thread)
   if (IS_ZEBRA_DEBUG_EVENT)
     zlog_debug("Event driven route-map update triggered");
 
+  if (IS_ZEBRA_DEBUG_RIB)
+    zlog_debug ("%s: calling rib_update", __func__);
+
   rib_update();
   zebra_evaluate_rnh(0, AF_INET, 1, RNH_NEXTHOP_TYPE, NULL);
   zebra_evaluate_rnh(0, AF_INET6, 1, RNH_NEXTHOP_TYPE, NULL);