]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: add client counter for nhg operations
authorPhilippe Guibert <philippe.guibert@6wind.com>
Thu, 23 Nov 2023 16:18:23 +0000 (17:18 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Thu, 30 Nov 2023 13:25:00 +0000 (14:25 +0100)
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 <philippe.guibert@6wind.com>
zebra/zapi_msg.c
zebra/zserv.c
zebra/zserv.h

index 98268dafa6e85f6895f0f8a75e35987616c6efaa..f7293d8f0f75b1a9e5b60f7a0ddaf34555b7a5b8 100644 (file)
@@ -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)
index 2db228b158d104e438a9864b0b016be9c87ce9bd..1d3989dc733de3e8544aed1db7f7f7a96cd9c393 100644 (file)
@@ -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,
index 90aa4d53f46d647e02c7c530b9d1b00fb96bc3cc..631145e4fba3f3c380e055813c2ba71cdbee0412 100644 (file)
@@ -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;