Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table summary #4950

Merged
merged 2 commits into from
Sep 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions doc/user/zebra.rst
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,14 @@ commands in relationship to VRF. Here is an extract of some of those commands:
This command will dump the routing tables within the vrf scope. If `vrf all`
is executed, all routing tables will be dumped.

.. index:: show <ip|ipv6> route summary [vrf VRF] [table TABLENO] [prefix]
.. clicmd:: show <ip|ipv6> route summary [vrf VRF] [table TABLENO] [prefix]

This command will dump a summary output of the specified VRF and TABLENO
combination. If neither VRF or TABLENO is specified FRR defaults to
the default vrf and default table. If prefix is specified dump the
number of prefix routes.

By using the :option:`-n` option, the *Linux network namespace* will be mapped
over the *Zebra* VRF. One nice feature that is possible by handling *Linux
network namespace* is the ability to name default VRF. At startup, *Zebra*
Expand Down
32 changes: 18 additions & 14 deletions zebra/zebra_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -1384,35 +1384,37 @@ DEFPY (show_route_detail,

DEFPY (show_route_summary,
show_route_summary_cmd,
"show\
<\
ip$ipv4 route [vrf <NAME$vrf_name|all$vrf_all>]\
summary [prefix$prefix]\
|ipv6$ipv6 route [vrf <NAME$vrf_name|all$vrf_all>]\
summary [prefix$prefix]\
>",
"show <ip$ipv4|ipv6$ipv6> route [vrf <NAME$vrf_name|all$vrf_all>] \
summary [table (1-4294967295)$table_id] [prefix$prefix]",
SHOW_STR
IP_STR
"IP routing table\n"
VRF_FULL_CMD_HELP_STR
"Summary of all routes\n"
"Prefix routes\n"
IP6_STR
"IP routing table\n"
VRF_FULL_CMD_HELP_STR
"Summary of all routes\n"
"Table to display summary for\n"
"The table number\n"
"Prefix routes\n")
{
afi_t afi = ipv4 ? AFI_IP : AFI_IP6;
struct route_table *table;

if (table_id == 0)
table_id = RT_TABLE_MAIN;

if (vrf_all) {
struct vrf *vrf;
struct zebra_vrf *zvrf;

RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
if ((zvrf = vrf->info) == NULL
|| (table = zvrf->table[afi][SAFI_UNICAST]) == NULL)
if ((zvrf = vrf->info) == NULL)
continue;

table = zebra_vrf_table_with_table_id(afi,
SAFI_UNICAST,
zvrf->vrf->vrf_id,
table_id);
if (!table)
continue;

if (prefix)
Expand All @@ -1426,7 +1428,9 @@ DEFPY (show_route_summary,
if (vrf_name)
VRF_GET_ID(vrf_id, vrf_name, false);

table = zebra_vrf_table(afi, SAFI_UNICAST, vrf_id);
table = zebra_vrf_table_with_table_id(afi,
SAFI_UNICAST,
vrf_id, table_id);
if (!table)
return CMD_SUCCESS;

Expand Down