From cced3a2d2911bbf9d2adf3b2b47519b9cdc2c0d3 Mon Sep 17 00:00:00 2001 From: Stephen Worley Date: Thu, 21 Mar 2019 10:52:11 -0400 Subject: [PATCH] zebra: Make show nexthop-group list all nexthop hash entries Add an option to not specify the afi in the show nexthop-group command so that it shows all nexthops, including groups. This is how iproute2 does it. If the afi is given, it will only show single nexthops since groups are AF_UNSPEC. Signed-off-by: Stephen Worley --- zebra/zebra_vty.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 7022b9d57d..7cf82118df 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -1112,7 +1112,7 @@ static void show_nexthop_group_cmd_helper(struct vty *vty, for (ALL_LIST_ELEMENTS_RO(list, node, nhe)) { struct nexthop *nhop; - if (nhe->afi != afi) + if (afi && nhe->afi != afi) continue; if (nhe->vrf_id != zvrf->vrf->vrf_id) @@ -1126,6 +1126,18 @@ static void show_nexthop_group_cmd_helper(struct vty *vty, if (nhe->ifp) vty_out(vty, "\tInterface Index: %d\n", nhe->ifp->ifindex); + + if (nhe->nhg_depends) { + struct listnode *dp_node = NULL; + struct nhg_depend *n_dp = NULL; + vty_out(vty, "\tDepends:"); + for (ALL_LIST_ELEMENTS_RO(nhe->nhg_depends, dp_node, + n_dp)) { + vty_out(vty, " (%u)", n_dp->nhe->id); + } + vty_out(vty, "\n"); + } + for (ALL_NEXTHOPS(nhe->nhg, nhop)) { vty_out(vty, "\t"); nexthop_group_write_nexthop(vty, nhop); @@ -1137,14 +1149,20 @@ static void show_nexthop_group_cmd_helper(struct vty *vty, DEFPY (show_nexthop_group, show_nexthop_group_cmd, - "show nexthop-group [vrf ]", + "show nexthop-group [] [vrf ]", SHOW_STR IP_STR IP6_STR "Show Nexthop Groups\n" VRF_FULL_CMD_HELP_STR) { - afi_t afi = v4 ? AFI_IP : AFI_IP6; + + afi_t afi = 0; + if (v4) + afi = AFI_IP; + else if (v6) + afi = AFI_IP6; + struct zebra_vrf *zvrf; if (vrf_all) { -- 2.39.5