summaryrefslogtreecommitdiff
path: root/bgpd
diff options
context:
space:
mode:
authorDenis Ovsienko <infrastation@yandex.ru>2011-08-05 21:47:08 +0400
committerPaul Jakma <paul@quagga.net>2012-01-08 11:31:17 +0000
commit318f0d8a7f5e8e87086bbf2a9e7c4b35638951ac (patch)
treedeab95315df2b315ba5b03162c43b61cb6c9ff2b /bgpd
parent8e80bdf20f493a71bcf74262ed3aa3a2437f4df6 (diff)
bgpd: add "show ip bgp scan detail" command
* bgp_nexthop.c: (show_ip_bgp_scan) transform into show_ip_bgp_scan_tables(), which uses inet_ntop() and can dump nexthops on request; (show_ip_bgp_scan_detail_cmd) new function
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_nexthop.c59
1 files changed, 44 insertions, 15 deletions
diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c
index d888c8f2..db121d2c 100644
--- a/bgpd/bgp_nexthop.c
+++ b/bgpd/bgp_nexthop.c
@@ -1192,16 +1192,13 @@ ALIAS (no_bgp_scan_time,
"Configure background scanner interval\n"
"Scanner interval (seconds)\n")
-DEFUN (show_ip_bgp_scan,
- show_ip_bgp_scan_cmd,
- "show ip bgp scan",
- SHOW_STR
- IP_STR
- BGP_STR
- "BGP scan status\n")
+static int
+show_ip_bgp_scan_tables (struct vty *vty, const char detail)
{
struct bgp_node *rn;
struct bgp_nexthop_cache *bnc;
+ char buf[INET6_ADDRSTRLEN];
+ u_char i;
if (bgp_scan_thread)
vty_out (vty, "BGP scan is running%s", VTY_NEWLINE);
@@ -1214,28 +1211,37 @@ DEFUN (show_ip_bgp_scan,
if ((bnc = rn->info) != NULL)
{
if (bnc->valid)
+ {
vty_out (vty, " %s valid [IGP metric %d]%s",
- inet_ntoa (rn->p.u.prefix4), bnc->metric, VTY_NEWLINE);
+ inet_ntop (AF_INET, &rn->p.u.prefix4, buf, INET6_ADDRSTRLEN), bnc->metric, VTY_NEWLINE);
+ if (detail)
+ for (i = 0; i < bnc->nexthop_num; i++)
+ vty_out (vty, " %s%s", inet_ntop (AF_INET, &bnc->nexthop[i].gate.ipv4, buf, INET6_ADDRSTRLEN), VTY_NEWLINE);
+ }
else
vty_out (vty, " %s invalid%s",
- inet_ntoa (rn->p.u.prefix4), VTY_NEWLINE);
+ inet_ntop (AF_INET, &rn->p.u.prefix4, buf, INET6_ADDRSTRLEN), VTY_NEWLINE);
}
#ifdef HAVE_IPV6
{
- char buf[BUFSIZ];
for (rn = bgp_table_top (bgp_nexthop_cache_table[AFI_IP6]);
rn;
rn = bgp_route_next (rn))
if ((bnc = rn->info) != NULL)
{
if (bnc->valid)
+ {
vty_out (vty, " %s valid [IGP metric %d]%s",
- inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, BUFSIZ),
+ inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, INET6_ADDRSTRLEN),
bnc->metric, VTY_NEWLINE);
+ if (detail)
+ for (i = 0; i < bnc->nexthop_num; i++)
+ vty_out (vty, " %s%s", inet_ntop (AF_INET6, &bnc->nexthop[i].gate.ipv4, buf, INET6_ADDRSTRLEN), VTY_NEWLINE);
+ }
else
vty_out (vty, " %s invalid%s",
- inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, BUFSIZ),
+ inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, INET6_ADDRSTRLEN),
VTY_NEWLINE);
}
}
@@ -1251,14 +1257,12 @@ DEFUN (show_ip_bgp_scan,
#ifdef HAVE_IPV6
{
- char buf[BUFSIZ];
-
for (rn = bgp_table_top (bgp_connected_table[AFI_IP6]);
rn;
rn = bgp_route_next (rn))
if (rn->info != NULL)
vty_out (vty, " %s/%d%s",
- inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, BUFSIZ),
+ inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, INET6_ADDRSTRLEN),
rn->p.prefixlen,
VTY_NEWLINE);
}
@@ -1267,6 +1271,29 @@ DEFUN (show_ip_bgp_scan,
return CMD_SUCCESS;
}
+DEFUN (show_ip_bgp_scan,
+ show_ip_bgp_scan_cmd,
+ "show ip bgp scan",
+ SHOW_STR
+ IP_STR
+ BGP_STR
+ "BGP scan status\n")
+{
+ return show_ip_bgp_scan_tables (vty, 0);
+}
+
+DEFUN (show_ip_bgp_scan_detail,
+ show_ip_bgp_scan_detail_cmd,
+ "show ip bgp scan detail",
+ SHOW_STR
+ IP_STR
+ BGP_STR
+ "BGP scan status\n"
+ "More detailed output\n")
+{
+ return show_ip_bgp_scan_tables (vty, 1);
+}
+
int
bgp_config_write_scan_time (struct vty *vty)
{
@@ -1308,8 +1335,10 @@ bgp_scan_init (void)
install_element (BGP_NODE, &no_bgp_scan_time_cmd);
install_element (BGP_NODE, &no_bgp_scan_time_val_cmd);
install_element (VIEW_NODE, &show_ip_bgp_scan_cmd);
+ install_element (VIEW_NODE, &show_ip_bgp_scan_detail_cmd);
install_element (RESTRICTED_NODE, &show_ip_bgp_scan_cmd);
install_element (ENABLE_NODE, &show_ip_bgp_scan_cmd);
+ install_element (ENABLE_NODE, &show_ip_bgp_scan_detail_cmd);
}
void