]> git.proxmox.com Git - mirror_frr.git/commitdiff
zebra: Add a dump table information command to zebra
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 4 Jan 2019 14:41:09 +0000 (09:41 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 4 Jan 2019 14:48:40 +0000 (09:48 -0500)
Allow zebra to dump the table information it has from a router perspective.

This table looks like this:
donna.cumulusnetworks.com# show zebra router table summary
VRF             NS ID    VRF ID     AFI            SAFI    Table      Count
---------------------------------------------------------------------------
default             0         0    IPv4         unicast       49          1
default             0         0    IPv4         unicast      254          7
default             0         0    IPv4       multicast      254          9
default             0         0    IPv6         unicast      254          1
default             0         0    IPv6       multicast      254          1
BLUE                0        31    IPv4         unicast     1005          0
BLUE                0        31    IPv4       multicast     1005          0
BLUE                0        31    IPv6         unicast     1005          0
BLUE                0        31    IPv6       multicast     1005          0

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
zebra/zebra_router.c
zebra/zebra_router.h
zebra/zebra_vty.c

index 7f911164cd18a4df789c870cb8276b56b3485516..0c4d16906edc53e31e43c0fdb0576d72fe10799a 100644 (file)
@@ -126,6 +126,25 @@ unsigned long zebra_router_score_proto(uint8_t proto, unsigned short instance)
        return cnt;
 }
 
+void zebra_router_show_table_summary(struct vty *vty)
+{
+       struct zebra_router_table *zrt;
+
+       vty_out(vty,
+               "VRF             NS ID    VRF ID     AFI            SAFI    Table      Count\n");
+       vty_out(vty,
+               "---------------------------------------------------------------------------\n");
+       RB_FOREACH (zrt, zebra_router_table_head, &zrouter.tables) {
+               rib_table_info_t *info = route_table_get_info(zrt->table);
+
+               vty_out(vty, "%-16s%5d %9d %7s %15s %8d %10lu\n", info->zvrf->vrf->name,
+                       zrt->ns_id, info->zvrf->vrf->vrf_id,
+                       afi2str(zrt->afi), safi2str(zrt->safi),
+                       zrt->tableid,
+                       zrt->table->count);
+       }
+}
+
 void zebra_router_sweep_route(void)
 {
        struct zebra_router_table *zrt;
index d6b8b66087ad001c1c61f13f0ad731f959d60f80..1e0788d1ba9ce1d68e06d42fb2289bca868b6a1e 100644 (file)
@@ -81,4 +81,6 @@ extern int zebra_router_config_write(struct vty *vty);
 extern unsigned long zebra_router_score_proto(uint8_t proto,
                                              unsigned short instance);
 extern void zebra_router_sweep_route(void);
+
+extern void zebra_router_show_table_summary(struct vty *vty);
 #endif
index 8b06d2ae115a9683f0714e91503efc3ffdc225f9..b18f0e943cf8a1d3f57efc7fac438bde05dc5ad6 100644 (file)
@@ -2857,6 +2857,20 @@ DEFUN (no_zebra_dplane_queue_limit,
        return CMD_SUCCESS;
 }
 
+DEFUN (zebra_show_routing_tables_summary,
+       zebra_show_routing_tables_summary_cmd,
+       "show zebra router table summary",
+       SHOW_STR
+       ZEBRA_STR
+       "The Zebra Router Information\n"
+       "Table Information about this Zebra Router\n"
+       "Summary Information\n")
+{
+       zebra_router_show_table_summary(vty);
+
+       return CMD_SUCCESS;
+}
+
 /* Table configuration write function. */
 static int config_write_table(struct vty *vty)
 {
@@ -3000,4 +3014,6 @@ void zebra_vty_init(void)
        install_element(VIEW_NODE, &show_dataplane_providers_cmd);
        install_element(CONFIG_NODE, &zebra_dplane_queue_limit_cmd);
        install_element(CONFIG_NODE, &no_zebra_dplane_queue_limit_cmd);
+
+       install_element(VIEW_NODE, &zebra_show_routing_tables_summary_cmd);
 }