diff options
Diffstat (limited to 'sharpd/sharp_zebra.c')
| -rw-r--r-- | sharpd/sharp_zebra.c | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c index 4a88b6c8ee..72e1eb2b21 100644 --- a/sharpd/sharp_zebra.c +++ b/sharpd/sharp_zebra.c @@ -133,6 +133,53 @@ extern uint32_t total_routes; extern uint32_t installed_routes; extern uint32_t removed_routes; +void sharp_install_routes_helper(struct prefix *p, uint8_t instance, + struct nexthop_group *nhg, + uint32_t routes) +{ + uint32_t temp, i; + + zlog_debug("Inserting %u routes", routes); + + temp = ntohl(p->u.prefix4.s_addr); + for (i = 0; i < routes; i++) { + route_add(p, (uint8_t)instance, nhg); + p->u.prefix4.s_addr = htonl(++temp); + } +} + +void sharp_remove_routes_helper(struct prefix *p, uint8_t instance, + uint32_t routes) +{ + uint32_t temp, i; + + zlog_debug("Removing %u routes", routes); + + temp = ntohl(p->u.prefix4.s_addr); + for (i = 0; i < routes; i++) { + route_delete(p, (uint8_t)instance); + p->u.prefix4.s_addr = htonl(++temp); + } +} + +static int handle_repeated(bool installed) +{ + repeat--; + + if (repeat <= 0) + return; + + if (installed) { + removed_routes = 0; + sharp_remove_routes_helper(&prefix, inst, total_routes); + } + + if (!installed) { + installed_routes = 0; + sharp_remove_routes + } +} + static int route_notify_owner(int command, struct zclient *zclient, zebra_size_t length, vrf_id_t vrf_id) { @@ -146,8 +193,10 @@ static int route_notify_owner(int command, struct zclient *zclient, switch (note) { case ZAPI_ROUTE_INSTALLED: installed_routes++; - if (total_routes == installed_routes) + if (total_routes == installed_routes) { zlog_debug("Installed All Items"); + handle_repeated(true); + } break; case ZAPI_ROUTE_FAIL_INSTALL: zlog_debug("Failed install of route"); @@ -157,8 +206,10 @@ static int route_notify_owner(int command, struct zclient *zclient, break; case ZAPI_ROUTE_REMOVED: removed_routes++; - if (total_routes == removed_routes) + if (total_routes == removed_routes) { zlog_debug("Removed all Items"); + handle_repeated(false); + } break; case ZAPI_ROUTE_REMOVE_FAIL: zlog_debug("Route removal Failure"); |
