From 5e54c6026912d5e0060349943ac87d067d6ae36c Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 8 Mar 2018 10:25:12 -0500 Subject: [PATCH] *: Add code to notify on route removal status If a interested party removes one of it's routes let it know that it has happened as asked for. Add a ZAPI_ROUTE_REMOVED to the send of the route_notify_owner Add a ZAPI_ROUTE_REMOVE_FAIL to the send of the route_notify_owner Add code in sharpd to notice this and to allow it to keep track of routes removed for that invocation and give timing results. Signed-off-by: Donald Sharp --- lib/zclient.h | 2 ++ sharpd/sharp_zebra.c | 26 ++++++++++++++++++++++---- zebra/zebra_rib.c | 4 ++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/lib/zclient.h b/lib/zclient.h index e0b39c88e8..1848440db2 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -346,6 +346,8 @@ enum zapi_route_notify_owner { ZAPI_ROUTE_FAIL_INSTALL, ZAPI_ROUTE_BETTER_ADMIN_WON, ZAPI_ROUTE_INSTALLED, + ZAPI_ROUTE_REMOVED, + ZAPI_ROUTE_REMOVE_FAIL, }; /* Zebra MAC types */ diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c index c1c827c366..8915397c7e 100644 --- a/sharpd/sharp_zebra.c +++ b/sharpd/sharp_zebra.c @@ -130,6 +130,7 @@ static int interface_state_down(int command, struct zclient *zclient, extern uint32_t total_routes; extern uint32_t installed_routes; +extern uint32_t removed_routes; static int route_notify_owner(int command, struct zclient *zclient, zebra_size_t length, vrf_id_t vrf_id) @@ -141,10 +142,27 @@ static int route_notify_owner(int command, struct zclient *zclient, if (!zapi_route_notify_decode(zclient->ibuf, &p, &table, ¬e)) return -1; - installed_routes++; - - if (total_routes == installed_routes) - zlog_debug("Installed All Items"); + switch (note) { + case ZAPI_ROUTE_INSTALLED: + installed_routes++; + if (total_routes == installed_routes) + zlog_debug("Installed All Items"); + break; + case ZAPI_ROUTE_FAIL_INSTALL: + zlog_debug("Failed install of route"); + break; + case ZAPI_ROUTE_BETTER_ADMIN_WON: + zlog_debug("Better Admin Distance won over us"); + break; + case ZAPI_ROUTE_REMOVED: + removed_routes++; + if (total_routes == removed_routes) + zlog_debug("Removed all Items"); + break; + case ZAPI_ROUTE_REMOVE_FAIL: + zlog_debug("Route removal Failure"); + break; + } return 0; } diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 8946c9c6b5..c5906f5829 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -1058,6 +1058,8 @@ void kernel_route_rib_pass_fail(struct route_node *rn, struct prefix *p, dest->selected_fib = NULL; for (ALL_NEXTHOPS(re->nexthop, nexthop)) UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB); + + zsend_route_notify_owner(re, p, ZAPI_ROUTE_REMOVED); break; case SOUTHBOUND_DELETE_FAILURE: /* @@ -1067,6 +1069,8 @@ void kernel_route_rib_pass_fail(struct route_node *rn, struct prefix *p, dest->selected_fib = NULL; zlog_warn("%u:%s: Route Deletion failure", re->vrf_id, prefix2str(p, buf, sizeof(buf))); + + zsend_route_notify_owner(re, p, ZAPI_ROUTE_REMOVE_FAIL); break; } } -- 2.39.5