mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 08:50:26 +00:00
Merge pull request #7381 from sworleys/NHG-Show-Proto-Filter
zebra: add type specifier to show nexthop-group
This commit is contained in:
commit
aa9d75efaf
@ -1033,14 +1033,15 @@ zebra Terminal Mode Commands
|
||||
total number of route nodes in the table. Which will be higher than
|
||||
the actual number of routes that are held.
|
||||
|
||||
.. index:: show nexthop-group rib [ID] [vrf NAME] [singleton [ip|ip6]]
|
||||
.. clicmd:: show nexthop-group rib [ID] [vrf NAME]
|
||||
.. index:: show nexthop-group rib [ID] [vrf NAME] [singleton [ip|ip6]] [type]
|
||||
.. clicmd:: show nexthop-group rib [ID] [vrf NAME] [singleton [ip|ip6]] [type]
|
||||
|
||||
Display nexthop groups created by zebra. The [vrf NAME] option
|
||||
is only meaningful if you have started zebra with the --vrfwnetns
|
||||
option as that nexthop groups are per namespace in linux.
|
||||
If you specify singleton you would like to see the singleton
|
||||
nexthop groups that do have an afi.
|
||||
nexthop groups that do have an afi. [type] allows you to filter those
|
||||
only coming from a specific NHG type (protocol).
|
||||
|
||||
|
||||
Router-id
|
||||
|
@ -1405,6 +1405,7 @@ struct nhe_show_context {
|
||||
struct vty *vty;
|
||||
vrf_id_t vrf_id;
|
||||
afi_t afi;
|
||||
int type;
|
||||
};
|
||||
|
||||
static int nhe_show_walker(struct hash_bucket *bucket, void *arg)
|
||||
@ -1420,6 +1421,9 @@ static int nhe_show_walker(struct hash_bucket *bucket, void *arg)
|
||||
if (ctx->vrf_id && nhe->vrf_id != ctx->vrf_id)
|
||||
goto done;
|
||||
|
||||
if (ctx->type && nhe->type != ctx->type)
|
||||
goto done;
|
||||
|
||||
show_nexthop_group_out(ctx->vty, nhe);
|
||||
|
||||
done:
|
||||
@ -1427,14 +1431,15 @@ done:
|
||||
}
|
||||
|
||||
static void show_nexthop_group_cmd_helper(struct vty *vty,
|
||||
struct zebra_vrf *zvrf,
|
||||
afi_t afi)
|
||||
struct zebra_vrf *zvrf, afi_t afi,
|
||||
int type)
|
||||
{
|
||||
struct nhe_show_context ctx;
|
||||
|
||||
ctx.vty = vty;
|
||||
ctx.afi = afi;
|
||||
ctx.vrf_id = zvrf->vrf->vrf_id;
|
||||
ctx.type = type;
|
||||
|
||||
hash_walk(zrouter.nhgs_id, nhe_show_walker, &ctx);
|
||||
}
|
||||
@ -1493,7 +1498,7 @@ DEFPY (show_interface_nexthop_group,
|
||||
|
||||
DEFPY (show_nexthop_group,
|
||||
show_nexthop_group_cmd,
|
||||
"show nexthop-group rib <(0-4294967295)$id|[singleton <ip$v4|ipv6$v6>] [vrf <NAME$vrf_name|all$vrf_all>]>",
|
||||
"show nexthop-group rib <(0-4294967295)$id|[singleton <ip$v4|ipv6$v6>] [<kernel|zebra|bgp|sharp>$type_str] [vrf <NAME$vrf_name|all$vrf_all>]>",
|
||||
SHOW_STR
|
||||
"Show Nexthop Groups\n"
|
||||
"RIB information\n"
|
||||
@ -1501,11 +1506,16 @@ DEFPY (show_nexthop_group,
|
||||
"Show Singleton Nexthop-Groups\n"
|
||||
IP_STR
|
||||
IP6_STR
|
||||
"Kernel (not installed via the zebra RIB)\n"
|
||||
"Zebra (implicitly created by zebra)\n"
|
||||
"Border Gateway Protocol (BGP)\n"
|
||||
"Super Happy Advanced Routing Protocol (SHARP)\n"
|
||||
VRF_FULL_CMD_HELP_STR)
|
||||
{
|
||||
|
||||
struct zebra_vrf *zvrf = NULL;
|
||||
afi_t afi = AFI_UNSPEC;
|
||||
int type = 0;
|
||||
|
||||
if (id)
|
||||
return show_nexthop_group_id_cmd_helper(vty, id);
|
||||
@ -1515,6 +1525,14 @@ DEFPY (show_nexthop_group,
|
||||
else if (v6)
|
||||
afi = AFI_IP6;
|
||||
|
||||
if (type_str) {
|
||||
type = proto_redistnum((afi ? afi : AFI_IP), type_str);
|
||||
if (type < 0) {
|
||||
/* assume zebra */
|
||||
type = ZEBRA_ROUTE_NHG;
|
||||
}
|
||||
}
|
||||
|
||||
if (!vrf_is_backend_netns() && (vrf_name || vrf_all)) {
|
||||
vty_out(vty,
|
||||
"VRF subcommand does not make any sense in l3mdev based vrf's\n");
|
||||
@ -1532,7 +1550,7 @@ DEFPY (show_nexthop_group,
|
||||
continue;
|
||||
|
||||
vty_out(vty, "VRF: %s\n", vrf->name);
|
||||
show_nexthop_group_cmd_helper(vty, zvrf, afi);
|
||||
show_nexthop_group_cmd_helper(vty, zvrf, afi, type);
|
||||
}
|
||||
|
||||
return CMD_SUCCESS;
|
||||
@ -1549,7 +1567,7 @@ DEFPY (show_nexthop_group,
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
show_nexthop_group_cmd_helper(vty, zvrf, afi);
|
||||
show_nexthop_group_cmd_helper(vty, zvrf, afi, type);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user