aboutsummaryrefslogtreecommitdiffstats
path: root/proto
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2020-05-14 03:48:17 +0200
committerOndrej Zajicek (work) <santiago@crfreenet.org>2020-06-28 15:38:47 +0200
commitc26c6bc2d78a2fe76f27dcc9fbb5afc95c3a7626 (patch)
treeb9058f04982a155d2a214e488e143bf1fac36597 /proto
parenta948cf9a5c338518773e6c98e895c829c469f56b (diff)
downloadbird-c26c6bc2d78a2fe76f27dcc9fbb5afc95c3a7626.tar.gz
Show info from multiple protocols when protocol is not specified
Most commands like 'show ospf neighbors' fail when protocol is not specified and there are multiple instances of given protocol type. This is annoying in BIRD 2, as many protocols have IPv4 and IPv6 instances. The patch changes that by showing output from all protocol instances of appropriate type. Note that the patch also removes terminating cli_msg() call from these commands and moves it to the common iterating code.
Diffstat (limited to 'proto')
-rw-r--r--proto/babel/babel.c12
-rw-r--r--proto/babel/config.Y8
-rw-r--r--proto/bfd/bfd.c3
-rw-r--r--proto/bfd/config.Y2
-rw-r--r--proto/ospf/config.Y6
-rw-r--r--proto/ospf/ospf.c6
-rw-r--r--proto/rip/config.Y4
-rw-r--r--proto/rip/rip.c6
-rw-r--r--proto/static/config.Y2
-rw-r--r--proto/static/static.c1
10 files changed, 11 insertions, 39 deletions
diff --git a/proto/babel/babel.c b/proto/babel/babel.c
index ba98598b..618abaa8 100644
--- a/proto/babel/babel.c
+++ b/proto/babel/babel.c
@@ -1891,7 +1891,6 @@ babel_show_interfaces(struct proto *P, const char *iff)
if (p->p.proto_state != PS_UP)
{
cli_msg(-1023, "%s: is not up", p->p.name);
- cli_msg(0, "");
return;
}
@@ -1915,8 +1914,6 @@ babel_show_interfaces(struct proto *P, const char *iff)
ifa->cf->rxcost, nbrs, MAX(timer, 0),
ifa->next_hop_ip4, ifa->next_hop_ip6);
}
-
- cli_msg(0, "");
}
void
@@ -1930,7 +1927,6 @@ babel_show_neighbors(struct proto *P, const char *iff)
if (p->p.proto_state != PS_UP)
{
cli_msg(-1024, "%s: is not up", p->p.name);
- cli_msg(0, "");
return;
}
@@ -1955,8 +1951,6 @@ babel_show_neighbors(struct proto *P, const char *iff)
n->addr, ifa->iface->name, n->cost, rts, hellos, MAX(timer, 0));
}
}
-
- cli_msg(0, "");
}
static void
@@ -1998,7 +1992,6 @@ babel_show_entries(struct proto *P)
if (p->p.proto_state != PS_UP)
{
cli_msg(-1025, "%s: is not up", p->p.name);
- cli_msg(0, "");
return;
}
@@ -2008,8 +2001,6 @@ babel_show_entries(struct proto *P)
babel_show_entries_(p, &p->ip4_rtable);
babel_show_entries_(p, &p->ip6_rtable);
-
- cli_msg(0, "");
}
static void
@@ -2041,7 +2032,6 @@ babel_show_routes(struct proto *P)
if (p->p.proto_state != PS_UP)
{
cli_msg(-1025, "%s: is not up", p->p.name);
- cli_msg(0, "");
return;
}
@@ -2051,8 +2041,6 @@ babel_show_routes(struct proto *P)
babel_show_routes_(p, &p->ip4_rtable);
babel_show_routes_(p, &p->ip6_rtable);
-
- cli_msg(0, "");
}
diff --git a/proto/babel/config.Y b/proto/babel/config.Y
index b6bc70fa..2f3b637b 100644
--- a/proto/babel/config.Y
+++ b/proto/babel/config.Y
@@ -130,16 +130,16 @@ dynamic_attr: BABEL_METRIC { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_BAB
CF_CLI_HELP(SHOW BABEL, ..., [[Show information about Babel protocol]]);
CF_CLI(SHOW BABEL INTERFACES, optproto opttext, [<name>] [\"<interface>\"], [[Show information about Babel interfaces]])
-{ babel_show_interfaces(proto_get_named($4, &proto_babel), $5); };
+{ PROTO_WALK_CMD($4, &proto_babel, p) babel_show_interfaces(p, $5); };
CF_CLI(SHOW BABEL NEIGHBORS, optproto opttext, [<name>] [\"<interface>\"], [[Show information about Babel neighbors]])
-{ babel_show_neighbors(proto_get_named($4, &proto_babel), $5); };
+{ PROTO_WALK_CMD($4, &proto_babel, p) babel_show_neighbors(p, $5); };
CF_CLI(SHOW BABEL ENTRIES, optproto opttext, [<name>], [[Show information about Babel prefix entries]])
-{ babel_show_entries(proto_get_named($4, &proto_babel)); };
+{ PROTO_WALK_CMD($4, &proto_babel, p) babel_show_entries(p); };
CF_CLI(SHOW BABEL ROUTES, optproto opttext, [<name>], [[Show information about Babel route entries]])
-{ babel_show_routes(proto_get_named($4, &proto_babel)); };
+{ PROTO_WALK_CMD($4, &proto_babel, p) babel_show_routes(p); };
CF_CODE
diff --git a/proto/bfd/bfd.c b/proto/bfd/bfd.c
index b4c53754..e303d7a0 100644
--- a/proto/bfd/bfd.c
+++ b/proto/bfd/bfd.c
@@ -1104,7 +1104,6 @@ bfd_show_sessions(struct proto *P)
if (p->p.proto_state != PS_UP)
{
cli_msg(-1020, "%s: is not up", p->p.name);
- cli_msg(0, "");
return;
}
@@ -1129,8 +1128,6 @@ bfd_show_sessions(struct proto *P)
s->addr, ifname, bfd_state_names[state], tbuf, tx_int, timeout);
}
HASH_WALK_END;
-
- cli_msg(0, "");
}
diff --git a/proto/bfd/config.Y b/proto/bfd/config.Y
index 84d12306..df1cba42 100644
--- a/proto/bfd/config.Y
+++ b/proto/bfd/config.Y
@@ -182,7 +182,7 @@ bfd_neighbor: ipa bfd_neigh_iface bfd_neigh_local bfd_neigh_multihop
CF_CLI_HELP(SHOW BFD, ..., [[Show information about BFD protocol]]);
CF_CLI(SHOW BFD SESSIONS, optproto, [<name>], [[Show information about BFD sessions]])
-{ bfd_show_sessions(proto_get_named($4, &proto_bfd)); };
+{ PROTO_WALK_CMD($4, &proto_bfd, p) bfd_show_sessions(p); };
CF_CODE
diff --git a/proto/ospf/config.Y b/proto/ospf/config.Y
index ce9245a1..fd2cfe8a 100644
--- a/proto/ospf/config.Y
+++ b/proto/ospf/config.Y
@@ -513,13 +513,13 @@ dynamic_attr: OSPF_ROUTER_ID { $$ = f_new_dynamic_attr(EAF_TYPE_ROUTER_ID, T_QUA
CF_CLI_HELP(SHOW OSPF, ..., [[Show information about OSPF protocol]]);
CF_CLI(SHOW OSPF, optproto, [<name>], [[Show information about OSPF protocol]])
-{ ospf_sh(proto_get_named($3, &proto_ospf)); };
+{ PROTO_WALK_CMD($3, &proto_ospf, p) ospf_sh(p); };
CF_CLI(SHOW OSPF NEIGHBORS, optproto opttext, [<name>] [\"<interface>\"], [[Show information about OSPF neighbors]])
-{ ospf_sh_neigh(proto_get_named($4, &proto_ospf), $5); };
+{ PROTO_WALK_CMD($4, &proto_ospf, p) ospf_sh_neigh(p, $5); };
CF_CLI(SHOW OSPF INTERFACE, optproto opttext, [<name>] [\"<interface>\"], [[Show information about interface]])
-{ ospf_sh_iface(proto_get_named($4, &proto_ospf), $5); };
+{ PROTO_WALK_CMD($4, &proto_ospf, p) ospf_sh_iface(p, $5); };
CF_CLI_HELP(SHOW OSPF TOPOLOGY, [all] [<name>], [[Show information about OSPF network topology]])
diff --git a/proto/ospf/ospf.c b/proto/ospf/ospf.c
index c8ed0e06..ba8c2e2b 100644
--- a/proto/ospf/ospf.c
+++ b/proto/ospf/ospf.c
@@ -800,7 +800,6 @@ ospf_sh_neigh(struct proto *P, const char *iff)
if (p->p.proto_state != PS_UP)
{
cli_msg(-1013, "%s: is not up", p->p.name);
- cli_msg(0, "");
return;
}
@@ -811,7 +810,6 @@ ospf_sh_neigh(struct proto *P, const char *iff)
if ((iff == NULL) || patmatch(iff, ifa->ifname))
WALK_LIST(n, ifa->neigh_list)
ospf_sh_neigh_info(n);
- cli_msg(0, "");
}
void
@@ -826,7 +824,6 @@ ospf_sh(struct proto *P)
if (p->p.proto_state != PS_UP)
{
cli_msg(-1014, "%s: is not up", p->p.name);
- cli_msg(0, "");
return;
}
@@ -896,7 +893,6 @@ ospf_sh(struct proto *P)
FIB_WALK_END;
}
- cli_msg(0, "");
}
void
@@ -908,7 +904,6 @@ ospf_sh_iface(struct proto *P, const char *iff)
if (p->p.proto_state != PS_UP)
{
cli_msg(-1015, "%s: is not up", p->p.name);
- cli_msg(0, "");
return;
}
@@ -916,7 +911,6 @@ ospf_sh_iface(struct proto *P, const char *iff)
WALK_LIST(ifa, p->iface_list)
if ((iff == NULL) || patmatch(iff, ifa->ifname))
ospf_iface_info(ifa);
- cli_msg(0, "");
}
/* lsa_compare_for_state() - Compare function for 'show ospf state'
diff --git a/proto/rip/config.Y b/proto/rip/config.Y
index 6cea7dd0..55527feb 100644
--- a/proto/rip/config.Y
+++ b/proto/rip/config.Y
@@ -196,10 +196,10 @@ dynamic_attr: RIP_TAG { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_RIP_TAG)
CF_CLI_HELP(SHOW RIP, ..., [[Show information about RIP protocol]]);
CF_CLI(SHOW RIP INTERFACES, optproto opttext, [<name>] [\"<interface>\"], [[Show information about RIP interfaces]])
-{ rip_show_interfaces(proto_get_named($4, &proto_rip), $5); };
+{ PROTO_WALK_CMD($4, &proto_rip, p) rip_show_interfaces(p, $5); };
CF_CLI(SHOW RIP NEIGHBORS, optproto opttext, [<name>] [\"<interface>\"], [[Show information about RIP neighbors]])
-{ rip_show_neighbors(proto_get_named($4, &proto_rip), $5); };
+{ PROTO_WALK_CMD($4, &proto_rip, p) rip_show_neighbors(p, $5); };
CF_CODE
diff --git a/proto/rip/rip.c b/proto/rip/rip.c
index f3dc6353..5c53ab1e 100644
--- a/proto/rip/rip.c
+++ b/proto/rip/rip.c
@@ -1232,7 +1232,6 @@ rip_show_interfaces(struct proto *P, const char *iff)
if (p->p.proto_state != PS_UP)
{
cli_msg(-1021, "%s: is not up", p->p.name);
- cli_msg(0, "");
return;
}
@@ -1256,8 +1255,6 @@ rip_show_interfaces(struct proto *P, const char *iff)
cli_msg(-1021, "%-10s %-6s %6u %6u %7t",
ifa->iface->name, (ifa->up ? "Up" : "Down"), ifa->cf->metric, nbrs, timer);
}
-
- cli_msg(0, "");
}
void
@@ -1270,7 +1267,6 @@ rip_show_neighbors(struct proto *P, const char *iff)
if (p->p.proto_state != PS_UP)
{
cli_msg(-1022, "%s: is not up", p->p.name);
- cli_msg(0, "");
return;
}
@@ -1293,8 +1289,6 @@ rip_show_neighbors(struct proto *P, const char *iff)
n->nbr->addr, ifa->iface->name, ifa->cf->metric, n->uc, timer);
}
}
-
- cli_msg(0, "");
}
static void
diff --git a/proto/static/config.Y b/proto/static/config.Y
index 6e410879..41e10dbf 100644
--- a/proto/static/config.Y
+++ b/proto/static/config.Y
@@ -158,7 +158,7 @@ stat_route_opt_list:
CF_CLI(SHOW STATIC, optproto, [<name>], [[Show details of static protocol]])
-{ static_show(proto_get_named($3, &proto_static)); } ;
+{ PROTO_WALK_CMD($3, &proto_static, p) static_show(p); } ;
CF_CODE
diff --git a/proto/static/static.c b/proto/static/static.c
index c899cc87..72b14991 100644
--- a/proto/static/static.c
+++ b/proto/static/static.c
@@ -647,7 +647,6 @@ static_show(struct proto *P)
WALK_LIST(r, c->routes)
static_show_rt(r);
- cli_msg(0, "");
}