mirror of
https://github.com/FRRouting/frr.git
synced 2025-04-30 13:37:17 +02:00
zebra: Add show cmd to display all routes which use a NHG
Adding a new entry to the existing show command "show nexthop-group rib <ID> routes" which will walk all the re's which uses that particular NHG and displays the route node, protocol and the installed status. Examples: r1# sh nexthop-group rib 39 routes Routes using nexthop group 39: Route Entry Status Protocol ------------------------------ ----------- -------- fc00::/64 installed connected fc00::1/128 installed local 4:5::6:12/128 installed static r1# sh nexthop-group rib 15 routes Routes using nexthop group 15: Route Entry Status Protocol ------------------------------ ----------- -------- 192.168.4.0/26 installed connected 192.168.4.1/32 installed local 1.1.1.4/32 installed static Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
This commit is contained in:
parent
8dee7cf3e5
commit
4e0ba30515
|
@ -1567,7 +1567,7 @@ 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.
|
||||
|
||||
.. clicmd:: show nexthop-group rib [ID] [vrf NAME] [singleton [ip|ip6]] [type] [json]
|
||||
.. clicmd:: show nexthop-group rib [ID [routes]] [vrf NAME] [singleton [ip|ip6]] [type] [json]
|
||||
|
||||
Display nexthop groups created by zebra. The [vrf NAME] option
|
||||
is only meaningful if you have started zebra with the --vrfwnetns
|
||||
|
@ -1578,7 +1578,9 @@ zebra Terminal Mode Commands
|
|||
that has `Initial Delay`, means that this nexthop group entry
|
||||
was not installed because no-one was using it at that point and
|
||||
Zebra can delay installing this route until it is used by something
|
||||
else.
|
||||
else. [routes] option after the NHG ID will show all the routes using
|
||||
a particular NHG.
|
||||
|
||||
|
||||
.. clicmd:: show <ip|ipv6> zebra route dump [<vrf> VRFNAME]
|
||||
|
||||
|
|
|
@ -1435,11 +1435,12 @@ 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>] [<kernel|zebra|bgp|sharp>$type_str] [vrf <NAME$vrf_name|all$vrf_all>]> [json]",
|
||||
"show nexthop-group rib <(0-4294967295)$id [routes$routes]|[singleton <ip$v4|ipv6$v6>] [<kernel|zebra|bgp|sharp>$type_str] [vrf <NAME$vrf_name|all$vrf_all>]> [json]",
|
||||
SHOW_STR
|
||||
"Show Nexthop Groups\n"
|
||||
"RIB information\n"
|
||||
"Nexthop Group ID\n"
|
||||
"Show routes using this nexthop group\n"
|
||||
"Show Singleton Nexthop-Groups\n"
|
||||
IP_STR
|
||||
IP6_STR
|
||||
|
@ -1450,19 +1451,74 @@ DEFPY(show_nexthop_group,
|
|||
VRF_FULL_CMD_HELP_STR
|
||||
JSON_STR)
|
||||
{
|
||||
|
||||
struct zebra_vrf *zvrf = NULL;
|
||||
afi_t afi = AFI_UNSPEC;
|
||||
int type = 0;
|
||||
bool uj = use_json(argc, argv);
|
||||
json_object *json = NULL;
|
||||
json_object *json_vrf = NULL;
|
||||
struct route_entry *re = NULL;
|
||||
|
||||
if (uj)
|
||||
json = json_object_new_object();
|
||||
|
||||
if (id)
|
||||
return show_nexthop_group_id_cmd_helper(vty, id, json);
|
||||
if (id) {
|
||||
struct nhg_hash_entry *nhe = zebra_nhg_lookup_id(id);
|
||||
|
||||
if (!nhe) {
|
||||
vty_out(vty, "%% Can't find nexthop group %lu\n", id);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
if (routes) {
|
||||
if (uj) {
|
||||
json_object *json_routes = json_object_new_array();
|
||||
|
||||
frr_each (nhe_re_tree, &nhe->re_head, re) {
|
||||
json_object *json_route = json_object_new_object();
|
||||
char buf[PREFIX_STRLEN];
|
||||
const char *proto_name;
|
||||
|
||||
prefix2str(&re->rn->p, buf, sizeof(buf));
|
||||
proto_name = zebra_route_string(re->type);
|
||||
|
||||
json_object_string_add(json_route, "prefix", buf);
|
||||
json_object_boolean_add(json_route, "installed",
|
||||
CHECK_FLAG(re->flags,
|
||||
ZEBRA_FLAG_SELECTED));
|
||||
json_object_string_add(json_route, "protocol", proto_name);
|
||||
json_object_array_add(json_routes, json_route);
|
||||
}
|
||||
json_object_object_add(json, "routes", json_routes);
|
||||
vty_json(vty, json);
|
||||
} else {
|
||||
vty_out(vty, "Routes using nexthop group %lu:\n", id);
|
||||
|
||||
vty_out(vty,
|
||||
"Route Entry Status Protocol\n");
|
||||
vty_out(vty,
|
||||
"------------------------------ ----------- --------\n");
|
||||
|
||||
frr_each (nhe_re_tree, &nhe->re_head, re) {
|
||||
char buf[PREFIX_STRLEN];
|
||||
const char *proto_name;
|
||||
|
||||
prefix2str(&re->rn->p, buf, sizeof(buf));
|
||||
proto_name = zebra_route_string(re->type);
|
||||
|
||||
vty_out(vty, "%-30s %-11s %s\n", buf,
|
||||
CHECK_FLAG(re->flags, ZEBRA_FLAG_SELECTED)
|
||||
? "installed"
|
||||
: "not installed",
|
||||
proto_name);
|
||||
}
|
||||
}
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
show_nexthop_group_id_cmd_helper(vty, id, uj ? json : NULL);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
if (v4)
|
||||
afi = AFI_IP;
|
||||
|
|
Loading…
Reference in a new issue