summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Worley <sworley@cumulusnetworks.com>2020-10-23 20:28:50 +0200
committerStephen Worley <sworley@nvidia.com>2020-10-26 20:55:02 +0100
commita8ad9a89eae36974349c056e0a29a2b341e61e8b (patch)
tree1a1d20e141234c5f73c6889a0f2b15ae43abf202
parentMerge pull request #7384 from opensourcerouting/nb-dyn-modules (diff)
downloadfrr-a8ad9a89eae36974349c056e0a29a2b341e61e8b.tar.xz
frr-a8ad9a89eae36974349c056e0a29a2b341e61e8b.zip
zebra,doc: add type specifier to show nexthop-group
Add a type specifier to the `show nexthop-group` command so we can easily filter by type when using proto created nexthop groups. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
-rw-r--r--doc/user/zebra.rst7
-rw-r--r--zebra/zebra_vty.c28
2 files changed, 27 insertions, 8 deletions
diff --git a/doc/user/zebra.rst b/doc/user/zebra.rst
index 98655e6cb..624e3cfe1 100644
--- a/doc/user/zebra.rst
+++ b/doc/user/zebra.rst
@@ -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
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index 1a6e6032b..c635b84b1 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -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;
}