From 23693958aa95edf5baaeaa5baa55725dc4895681 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 7 May 2000 11:28:59 +0000 Subject: [PATCH] Implemented `show route <...> stats'. --- TODO | 5 +++-- doc/reply_codes | 1 + nest/config.Y | 8 ++++++-- nest/route.h | 2 ++ nest/rt-table.c | 8 +++++++- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/TODO b/TODO index c8162b4d..5a9e4c7e 100644 --- a/TODO +++ b/TODO @@ -9,11 +9,12 @@ Core - Makefile: install target? -- forgetting device routes??? -- filter-defined internal attributes - netlink: realms - filters: deletion of mandatory attributes? +- filters: user defined attributes? + +- cli: show tables? Documentation ~~~~~~~~~~~~~ diff --git a/doc/reply_codes b/doc/reply_codes index def809e9..1a547913 100644 --- a/doc/reply_codes +++ b/doc/reply_codes @@ -22,6 +22,7 @@ Reply codes of BIRD command-line interface 0011 Enabled 0012 Restarted 0013 Status report +0014 Route count 1000 BIRD version 1001 Interface list diff --git a/nest/config.Y b/nest/config.Y index 5ac9c213..65142f76 100644 --- a/nest/config.Y +++ b/nest/config.Y @@ -22,7 +22,7 @@ CF_DECLS CF_KEYWORDS(ROUTER, ID, PROTOCOL, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT) CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, TABLE, STATES, ROUTES, FILTERS) CF_KEYWORDS(PASSWORD, FROM, PASSIVE, TO, ID, EVENTS, PACKETS, PROTOCOLS, INTERFACES) -CF_KEYWORDS(PRIMARY) +CF_KEYWORDS(PRIMARY, STATS) CF_ENUM(T_ENUM_RTS, RTS_, DUMMY, STATIC, INHERIT, DEVICE, STATIC_DEVICE, REDIRECT, RIP, OSPF, OSPF_EXT, OSPF_IA, OSPF_BOUNDARY, BGP, PIPE) @@ -240,7 +240,7 @@ CF_CLI(SHOW INTERFACES,,, [[Show network interfaces]]) CF_CLI(SHOW INTERFACES SUMMARY,,, [[Show summary of network interfaces]]) { if_show_summary(); } ; -CF_CLI(SHOW ROUTE, r_args, [] [table ] [filter ] [all] [primary] [(import|protocol)

], [[Show routing table]]) +CF_CLI(SHOW ROUTE, r_args, [] [table ] [filter ] [all] [primary] [(import|protocol)

] [stats], [[Show routing table]]) { rt_show($3); } ; r_args: @@ -290,6 +290,10 @@ r_args: $$->import_protocol = c->proto; $$->running_on_config = c->proto->cf->global; } + | r_args STATS { + $$ = $1; + $$->stats = 1; + } ; import_or_proto: diff --git a/nest/route.h b/nest/route.h index 1e6fd64b..c36cde6d 100644 --- a/nest/route.h +++ b/nest/route.h @@ -209,6 +209,8 @@ struct rt_show_data { struct proto *import_protocol; int import_mode, primary_only; struct config *running_on_config; + int net_counter, rt_counter, show_counter; + int stats; }; void rt_show(struct rt_show_data *); diff --git a/nest/rt-table.c b/nest/rt-table.c index 1261aae1..38253038 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -720,11 +720,13 @@ rt_show_net(struct cli *c, net *n, struct rt_show_data *d) int ok; bsprintf(ia, "%I/%d", n->n.prefix, n->n.pxlen); + d->net_counter++; for(e=n->routes; e; e=e->next) { struct ea_list *tmpa, *old_tmpa; struct proto *p0 = e->attrs->proto; struct proto *p1 = d->import_protocol; + d->rt_counter++; ee = e; rte_update_lock(); /* We use the update buffer for filtering */ old_tmpa = tmpa = p0->make_tmp_attrs ? p0->make_tmp_attrs(e, rte_update_pool) : NULL; @@ -743,6 +745,7 @@ rt_show_net(struct cli *c, net *n, struct rt_show_data *d) } if (ok) { + d->show_counter++; rt_show_rte(c, ia, e, d, tmpa); ia[0] = 0; } @@ -789,7 +792,10 @@ rt_show_cont(struct cli *c) rt_show_net(c, n, d); } FIB_ITERATE_END(f); - cli_printf(c, 0, ""); + if (d->stats) + cli_printf(c, 14, "%d of %d routes for %d networks", d->show_counter, d->rt_counter, d->net_counter); + else + cli_printf(c, 0, ""); done: c->cont = c->cleanup = NULL; }