Permalink
Browse files

sharpd: Do addition/subtraction for me

Write a bit of code to track the start/stop times and do subtraction!
In the future we expect this code to slice and dice as well.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
  • Loading branch information...
donaldsharp committed Jan 10, 2019
1 parent dbc1bf4 commit 25c84d86d722a689ad592f6e10b0134be8a5bb39
Showing with 13 additions and 2 deletions.
  1. +13 −2 sharpd/sharp_zebra.c
@@ -129,6 +129,8 @@ static int interface_state_down(int command, struct zclient *zclient,
return 0;
}

static struct timeval t_start;
static struct timeval t_end;
extern uint32_t total_routes;
extern uint32_t installed_routes;
extern uint32_t removed_routes;
@@ -152,6 +154,7 @@ void sharp_install_routes_helper(struct prefix *p, uint8_t instance,
} else
temp = ntohl(p->u.val32[3]);

monotime(&t_start);
for (i = 0; i < routes; i++) {
route_add(p, (uint8_t)instance, nhg);
if (v4)
@@ -175,6 +178,7 @@ void sharp_remove_routes_helper(struct prefix *p, uint8_t instance,
} else
temp = ntohl(p->u.val32[3]);

monotime(&t_start);
for (i = 0; i < routes; i++) {
route_delete(p, (uint8_t)instance);
if (v4)
@@ -207,6 +211,7 @@ static void handle_repeated(bool installed)
static int route_notify_owner(int command, struct zclient *zclient,
zebra_size_t length, vrf_id_t vrf_id)
{
struct timeval r;
struct prefix p;
enum zapi_route_notify_owner note;
uint32_t table;
@@ -218,7 +223,10 @@ static int route_notify_owner(int command, struct zclient *zclient,
case ZAPI_ROUTE_INSTALLED:
installed_routes++;
if (total_routes == installed_routes) {
zlog_debug("Installed All Items");
monotime(&t_end);
timersub(&t_end, &t_start, &r);
zlog_debug("Installed All Items %ld.%ld", r.tv_sec,
r.tv_usec);
handle_repeated(true);
}
break;
@@ -231,7 +239,10 @@ static int route_notify_owner(int command, struct zclient *zclient,
case ZAPI_ROUTE_REMOVED:
removed_routes++;
if (total_routes == removed_routes) {
zlog_debug("Removed all Items");
monotime(&t_end);
timersub(&t_end, &t_start, &r);
zlog_debug("Removed all Items %ld.%ld", r.tv_sec,
r.tv_usec);
handle_repeated(false);
}
break;

0 comments on commit 25c84d8

Please sign in to comment.