mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-09 05:33:42 +00:00
zebra: Add show command to dump nexthop-group information for Zebra
Just a simple addition of a command to dump the nexthop group information. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
69171da262
commit
21be136402
@ -52,6 +52,7 @@
|
|||||||
#include "zebra/ipforward.h"
|
#include "zebra/ipforward.h"
|
||||||
#include "zebra/zebra_vxlan_private.h"
|
#include "zebra/zebra_vxlan_private.h"
|
||||||
#include "zebra/zebra_pbr.h"
|
#include "zebra/zebra_pbr.h"
|
||||||
|
#include "zebra/zebra_nhg.h"
|
||||||
|
|
||||||
extern int allow_delete;
|
extern int allow_delete;
|
||||||
|
|
||||||
@ -1101,6 +1102,78 @@ DEFUN (ip_nht_default_route,
|
|||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void show_nexthop_group_cmd_helper(struct vty *vty,
|
||||||
|
struct zebra_vrf *zvrf, afi_t afi)
|
||||||
|
{
|
||||||
|
struct list *list = hash_to_list(zrouter.nhgs);
|
||||||
|
struct nhg_hash_entry *nhe;
|
||||||
|
struct listnode *node;
|
||||||
|
|
||||||
|
for (ALL_LIST_ELEMENTS_RO(list, node, nhe)) {
|
||||||
|
struct nexthop *nhop;
|
||||||
|
|
||||||
|
if (nhe->afi != afi)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (nhe->vrf_id != zvrf->vrf->vrf_id)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
vty_out(vty, "Group: %u RefCnt: %u afi: %d\n", nhe->dplane_ref,
|
||||||
|
nhe->refcnt, nhe->afi);
|
||||||
|
|
||||||
|
for (ALL_NEXTHOPS(nhe->nhg, nhop)) {
|
||||||
|
vty_out(vty, " ");
|
||||||
|
nexthop_group_write_nexthop(vty, nhop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
list_delete(&list);
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFPY (show_nexthop_group,
|
||||||
|
show_nexthop_group_cmd,
|
||||||
|
"show nexthop-group <ipv4$v4|ipv6$v6> [vrf <NAME$vrf_name|all$vrf_all>]",
|
||||||
|
SHOW_STR
|
||||||
|
IP_STR
|
||||||
|
IP6_STR
|
||||||
|
"Show Nexthop Groups\n"
|
||||||
|
VRF_FULL_CMD_HELP_STR)
|
||||||
|
{
|
||||||
|
afi_t afi = v4 ? AFI_IP : AFI_IP6;
|
||||||
|
struct zebra_vrf *zvrf;
|
||||||
|
|
||||||
|
if (vrf_all) {
|
||||||
|
struct vrf *vrf;
|
||||||
|
|
||||||
|
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
|
||||||
|
struct zebra_vrf *zvrf;
|
||||||
|
|
||||||
|
zvrf = vrf->info;
|
||||||
|
if (!zvrf)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
vty_out(vty, "VRF: %s\n", vrf->name);
|
||||||
|
show_nexthop_group_cmd_helper(vty, zvrf, afi);
|
||||||
|
}
|
||||||
|
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vrf_name)
|
||||||
|
zvrf = zebra_vrf_lookup_by_name(vrf_name);
|
||||||
|
else
|
||||||
|
zvrf = zebra_vrf_lookup_by_name(VRF_DEFAULT_NAME);
|
||||||
|
|
||||||
|
if (!zvrf) {
|
||||||
|
vty_out(vty, "VRF %s specified does not exist", vrf_name);
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
show_nexthop_group_cmd_helper(vty, zvrf, afi);
|
||||||
|
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
DEFUN (no_ip_nht_default_route,
|
DEFUN (no_ip_nht_default_route,
|
||||||
no_ip_nht_default_route_cmd,
|
no_ip_nht_default_route_cmd,
|
||||||
"no ip nht resolve-via-default",
|
"no ip nht resolve-via-default",
|
||||||
@ -3033,6 +3106,8 @@ void zebra_vty_init(void)
|
|||||||
install_element(CONFIG_NODE, &zebra_packet_process_cmd);
|
install_element(CONFIG_NODE, &zebra_packet_process_cmd);
|
||||||
install_element(CONFIG_NODE, &no_zebra_packet_process_cmd);
|
install_element(CONFIG_NODE, &no_zebra_packet_process_cmd);
|
||||||
|
|
||||||
|
install_element(VIEW_NODE, &show_nexthop_group_cmd);
|
||||||
|
|
||||||
install_element(VIEW_NODE, &show_vrf_cmd);
|
install_element(VIEW_NODE, &show_vrf_cmd);
|
||||||
install_element(VIEW_NODE, &show_vrf_vni_cmd);
|
install_element(VIEW_NODE, &show_vrf_vni_cmd);
|
||||||
install_element(VIEW_NODE, &show_route_cmd);
|
install_element(VIEW_NODE, &show_route_cmd);
|
||||||
|
Loading…
Reference in New Issue
Block a user