]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra,doc: add type specifier to show nexthop-group
authorStephen Worley <sworley@cumulusnetworks.com>
Fri, 23 Oct 2020 18:28:50 +0000 (14:28 -0400)
committerStephen Worley <sworley@nvidia.com>
Mon, 26 Oct 2020 19:55:02 +0000 (15:55 -0400)
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>
doc/user/zebra.rst
zebra/zebra_vty.c

index 98655e6cbaf3e883883531275b4abfadac3557be..624e3cfe1a3ac4c1cf64253683160cbd4023cf94 100644 (file)
@@ -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
index 1a6e6032b681690ceb98490c4aabd57818ee19ff..c635b84b173244ec4f5e8adf315659d6120c86f1 100644 (file)
@@ -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;
 }