summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
authorLou Berger <lberger@labn.net>2016-01-12 13:42:08 -0500
committerPaul Jakma <paul.jakma@hpe.com>2016-02-26 14:11:45 +0000
commitbf1ae6c683a53d7f43c273afb55d52ccc233296b (patch)
tree3224355a90930170b47cccfafbeabe6bb9f27d09 /bgpd
parent651b402d32b52ecf7ea1d979bf83b88ff799e134 (diff)
downloadquagga-bf1ae6c683a53d7f43c273afb55d52ccc233296b.tar.bz2
quagga-bf1ae6c683a53d7f43c273afb55d52ccc233296b.tar.xz
bgpd: drop machineparse / random "show" improvements
Signed-off-by: Lou Berger <lberger@labn.net>
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_mplsvpn.c14
-rw-r--r--bgpd/bgp_route.c41
2 files changed, 40 insertions, 15 deletions
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index 9f06538e..99e86b43 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -484,6 +484,9 @@ bgp_show_mpls_vpn(
char v4_header[] = " Network Next Hop Metric LocPrf Weight Path%s";
char v4_header_tag[] = " Network Next Hop In tag/Out tag%s";
+ unsigned long output_count = 0;
+ unsigned long total_count = 0;
+
bgp = bgp_get_default ();
if (bgp == NULL)
{
@@ -509,6 +512,7 @@ bgp_show_mpls_vpn(
for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm))
for (ri = rm->info; ri; ri = ri->next)
{
+ total_count++;
if (type == bgp_show_type_neighbor)
{
union sockunion *su = output_arg;
@@ -568,9 +572,19 @@ bgp_show_mpls_vpn(
route_vty_out_tag (vty, &rm->p, ri, 0, SAFI_MPLS_VPN);
else
route_vty_out (vty, &rm->p, ri, 0, SAFI_MPLS_VPN);
+ output_count++;
}
}
}
+
+ if (output_count == 0)
+ {
+ vty_out (vty, "No prefixes displayed, %ld exist%s", total_count, VTY_NEWLINE);
+ }
+ else
+ vty_out (vty, "%sDisplayed %ld out of %ld total prefixes%s",
+ VTY_NEWLINE, output_count, total_count, VTY_NEWLINE);
+
return CMD_SUCCESS;
}
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 0ea7ced8..7890e3aa 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -5940,8 +5940,12 @@ route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo)
/* called from terminal list command */
void
-route_vty_out (struct vty *vty, struct prefix *p,
- struct bgp_info *binfo, int display, safi_t safi)
+route_vty_out(
+ struct vty *vty,
+ struct prefix *p,
+ struct bgp_info *binfo,
+ int display,
+ safi_t safi)
{
struct attr *attr;
@@ -5949,7 +5953,7 @@ route_vty_out (struct vty *vty, struct prefix *p,
route_vty_short_status_out (vty, binfo);
/* print prefix and mask */
- if (! display)
+ if (!display)
route_vty_out_route (p, vty);
else
vty_out (vty, "%*s", 17, " ");
@@ -6025,14 +6029,14 @@ route_vty_out (struct vty *vty, struct prefix *p,
if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
- vty_out (vty, "%10u", attr->med);
+ vty_out (vty, "%10u ", attr->med);
else
- vty_out (vty, " ");
+ vty_out (vty, " ");
if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
- vty_out (vty, "%7u", attr->local_pref);
+ vty_out (vty, "%7u ", attr->local_pref);
else
- vty_out (vty, " ");
+ vty_out (vty, " ");
vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0));
@@ -6090,12 +6094,12 @@ route_vty_out_tmp (struct vty *vty, struct prefix *p,
#endif /* HAVE_IPV6 */
if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
- vty_out (vty, "%10u", attr->med);
+ vty_out (vty, "%10u ", attr->med);
else
vty_out (vty, " ");
if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
- vty_out (vty, "%7u", attr->local_pref);
+ vty_out (vty, "%7u ", attr->local_pref);
else
vty_out (vty, " ");
@@ -6346,7 +6350,11 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p,
vty_out (vty, " (inaccessible)");
else if (binfo->extra && binfo->extra->igpmetric)
vty_out (vty, " (metric %u)", binfo->extra->igpmetric);
- vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN));
+ if (!sockunion2str (&binfo->peer->su, buf, sizeof(buf))) {
+ buf[0] = '?';
+ buf[1] = 0;
+ }
+ vty_out (vty, " from %s", buf);
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id));
else
@@ -6500,9 +6508,11 @@ bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router
int header = 1;
int display;
unsigned long output_count;
+ unsigned long total_count;
/* This is first entry point, so reset total line. */
output_count = 0;
+ total_count = 0;
/* Start processing of routes. */
for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
@@ -6512,6 +6522,7 @@ bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router
for (ri = rn->info; ri; ri = ri->next)
{
+ total_count++;
if (type == bgp_show_type_flap_statistics
|| type == bgp_show_type_flap_address
|| type == bgp_show_type_flap_prefix
@@ -6706,11 +6717,11 @@ bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router
if (output_count == 0)
{
if (type == bgp_show_type_normal)
- vty_out (vty, "No BGP network exists%s", VTY_NEWLINE);
+ vty_out (vty, "No BGP prefixes displayed, %ld exist%s", total_count, VTY_NEWLINE);
}
else
- vty_out (vty, "%sTotal number of prefixes %ld%s",
- VTY_NEWLINE, output_count, VTY_NEWLINE);
+ vty_out (vty, "%sDisplayed %ld out of %ld total prefixes%s",
+ VTY_NEWLINE, output_count, total_count, VTY_NEWLINE);
return CMD_SUCCESS;
}
@@ -9786,7 +9797,7 @@ bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi)
if (!bgp->rib[afi][safi])
{
- vty_out (vty, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE);
+ vty_out (vty, "%% No RIB exists for the AFI/SAFI%s", VTY_NEWLINE);
return CMD_WARNING;
}
@@ -9877,7 +9888,7 @@ bgp_table_stats_vty (struct vty *vty, const char *name,
if (!bgp)
{
- vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
+ vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE);
return CMD_WARNING;
}
if (strncmp (afi_str, "ipv", 3) == 0)