Skip to content

Commit

Permalink
zebra: add client counter for nhg operations
Browse files Browse the repository at this point in the history
Add three counters that account for the nhg operations
that are using the zebra API with the NHG_ADD and NHG_DEL
commands.

> # show zebra client
> [..]
> Type        Add         Update      Del
> ==================================================
> IPv4        100         0           0
> IPv6        0           0           0
> Redist:v4   0           0           0
> Redist:v6   0           0           0
> L3NHG       1           1           1
> VRF         3           0           0
> [..]

Signed-off-by: Philippe Guibert <[email protected]>
  • Loading branch information
pguibert6WIND committed Nov 27, 2023
1 parent 3778824 commit 58809bc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
10 changes: 9 additions & 1 deletion zebra/zapi_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1973,6 +1973,8 @@ static void zread_nhg_del(ZAPI_HANDLER_ARGS)
zsend_nhg_notify(api_nhg.proto, client->instance,
client->session_id, api_nhg.id,
ZAPI_NHG_REMOVE_FAIL);
/* Stats */
client->l3nhg_del_cnt++;
}

static void zread_nhg_add(ZAPI_HANDLER_ARGS)
Expand All @@ -1981,7 +1983,7 @@ static void zread_nhg_add(ZAPI_HANDLER_ARGS)
struct zapi_nhg api_nhg = {};
struct nexthop_group *nhg = NULL;
struct nhg_backup_info *bnhg = NULL;
struct nhg_hash_entry *nhe;
struct nhg_hash_entry *nhe, *nhe_tmp;

s = msg;
if (zapi_nhg_decode(s, hdr->command, &api_nhg) < 0) {
Expand Down Expand Up @@ -2039,6 +2041,12 @@ static void zread_nhg_add(ZAPI_HANDLER_ARGS)
nexthop_group_delete(&nhg);
zebra_nhg_backup_free(&bnhg);

/* Stats */
nhe_tmp = zebra_nhg_lookup_id(api_nhg.id);
if (nhe_tmp)
client->l3nhg_upd8_cnt++;
else
client->l3nhg_add_cnt++;
}

static void zread_route_add(ZAPI_HANDLER_ARGS)
Expand Down
2 changes: 2 additions & 0 deletions zebra/zserv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,8 @@ static void zebra_show_client_detail(struct vty *vty, struct zserv *client)
0, client->redist_v4_del_cnt);
vty_out(vty, "Redist:v6 %-12u%-12u%-12u\n", client->redist_v6_add_cnt,
0, client->redist_v6_del_cnt);
vty_out(vty, "L3NHG %-12u%-12u%-12u\n", client->l3nhg_add_cnt,
client->l3nhg_upd8_cnt, client->l3nhg_del_cnt);
vty_out(vty, "VRF %-12u%-12u%-12u\n", client->vrfadd_cnt, 0,
client->vrfdel_cnt);
vty_out(vty, "Connected %-12u%-12u%-12u\n", client->ifadd_cnt, 0,
Expand Down
3 changes: 3 additions & 0 deletions zebra/zserv.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ struct zserv {
uint32_t local_es_evi_add_cnt;
uint32_t local_es_evi_del_cnt;
uint32_t error_cnt;
uint32_t l3nhg_add_cnt;
uint32_t l3nhg_upd8_cnt;
uint32_t l3nhg_del_cnt;

time_t nh_reg_time;
time_t nh_dereg_time;
Expand Down

0 comments on commit 58809bc

Please sign in to comment.