From b84c7253263c70f2b4445c36418a037140155375 Mon Sep 17 00:00:00 2001 From: vivek Date: Tue, 20 Oct 2015 22:37:32 -0700 Subject: [PATCH] Zebra: On a link down, schedule static routes only. 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 Reviewed-by: Vivek Venkatraman Reviewed-by: Donald Sharp --- zebra/connected.c | 27 +++++++++++++++++++++++---- zebra/interface.c | 10 +++++++++- zebra/rib.h | 1 + zebra/zebra_rib.c | 29 +++++++++++++++++++++++++++++ zebra/zebra_routemap.c | 19 +++++++++++++++++++ 5 files changed, 81 insertions(+), 5 deletions(-) diff --git a/zebra/connected.c b/zebra/connected.c index b891f9e56c..2ec6911d77 100644 --- a/zebra/connected.c +++ b/zebra/connected.c @@ -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 */ diff --git a/zebra/interface.c b/zebra/interface.c index 9dc13f7b19..9d4a2f89d2 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -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); diff --git a/zebra/rib.h b/zebra/rib.h index 7d9e2f7770..fa37f7d8c3 100644 --- a/zebra/rib.h +++ b/zebra/rib.h @@ -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); diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 518cdeb81f..a69dead1a6 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -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) diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c index 17e7faaa08..1c7b63e757 100644 --- a/zebra/zebra_routemap.c +++ b/zebra/zebra_routemap.c @@ -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); -- 2.39.5