Skip to content

Commit da5703e

Browse files
committed
zebra: show nexthop count in nexthop-group command
Show the nexthops count in an NHG Signed-off-by: Krishnasamy <krishnasamyr@nvidia.com>
1 parent b905359 commit da5703e

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

lib/nexthop_group.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ uint16_t nexthop_group_nexthop_num(const struct nexthop_group *nhg)
8181
return num;
8282
}
8383

84-
static uint16_t nexthop_group_nexthop_num_no_recurse(const struct nexthop_group *nhg)
84+
uint16_t nexthop_group_nexthop_num_no_recurse(const struct nexthop_group *nhg)
8585
{
8686
struct nexthop *nhop;
8787
uint16_t num = 0;

lib/nexthop_group.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ extern uint16_t nexthop_group_nexthop_num(const struct nexthop_group *nhg);
153153
extern uint16_t nexthop_group_active_nexthop_num(const struct nexthop_group *nhg);
154154

155155
extern bool nexthop_group_has_label(const struct nexthop_group *nhg);
156+
extern uint16_t nexthop_group_nexthop_num_no_recurse(const struct nexthop_group *nhg);
156157

157158
#ifdef __cplusplus
158159
}

zebra/zebra_vty.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,13 +1071,16 @@ static void show_nexthop_group_out(struct vty *vty, struct nhg_hash_entry *nhe,
10711071
json_object *json = NULL;
10721072
json_object *json_backup_nexthop_array = NULL;
10731073
json_object *json_backup_nexthops = NULL;
1074+
uint16_t nexthop_count = 0;
10741075

10751076

10761077
uptime2str(nhe->uptime, up_str, sizeof(up_str));
10771078

10781079
if (json_nhe_hdr)
10791080
json = json_object_new_object();
10801081

1082+
nexthop_count = nexthop_group_nexthop_num_no_recurse(&nhe->nhg);
1083+
10811084
if (json) {
10821085
json_object_string_add(json, "type",
10831086
zebra_route_string(nhe->type));
@@ -1092,6 +1095,7 @@ static void show_nexthop_group_out(struct vty *vty, struct nhg_hash_entry *nhe,
10921095
json_object_string_add(json, "vrf",
10931096
vrf_id_to_name(nhe->vrf_id));
10941097
json_object_string_add(json, "afi", zebra_nhg_afi2str(nhe));
1098+
json_object_int_add(json, "nexthopCount", nexthop_count);
10951099

10961100
} else {
10971101
vty_out(vty, "ID: %u (%s)\n", nhe->id,
@@ -1107,6 +1111,7 @@ static void show_nexthop_group_out(struct vty *vty, struct nhg_hash_entry *nhe,
11071111
vty_out(vty, " Uptime: %s\n", up_str);
11081112
vty_out(vty, " VRF: %s(%s)\n", vrf_id_to_name(nhe->vrf_id),
11091113
zebra_nhg_afi2str(nhe));
1114+
vty_out(vty, " Nexthop Count: %u\n", nexthop_count);
11101115
}
11111116

11121117
if (CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_VALID)) {

0 commit comments

Comments
 (0)