From d41b425ab3384f80b338a8ec3b407a277a8646e0 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Thu, 23 Nov 2023 17:18:23 +0100 Subject: [PATCH] zebra: add client counter for nhg operations 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 > NHG 1 1 1 > VRF 3 0 0 > [..] Signed-off-by: Philippe Guibert --- zebra/zapi_msg.c | 10 +++++++++- zebra/zserv.c | 2 ++ zebra/zserv.h | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index 98268dafa6..f7293d8f0f 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -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->nhg_del_cnt++; } static void zread_nhg_add(ZAPI_HANDLER_ARGS) @@ -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) { @@ -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->nhg_upd8_cnt++; + else + client->nhg_add_cnt++; } static void zread_route_add(ZAPI_HANDLER_ARGS) diff --git a/zebra/zserv.c b/zebra/zserv.c index 2db228b158..1d3989dc73 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -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, "NHG %-12u%-12u%-12u\n", client->nhg_add_cnt, + client->nhg_upd8_cnt, client->nhg_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, diff --git a/zebra/zserv.h b/zebra/zserv.h index 90aa4d53f4..631145e4fb 100644 --- a/zebra/zserv.h +++ b/zebra/zserv.h @@ -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 nhg_add_cnt; + uint32_t nhg_upd8_cnt; + uint32_t nhg_del_cnt; time_t nh_reg_time; time_t nh_dereg_time; -- 2.39.5