Signed-off-by: Lou Berger <[email protected]>
---
 bgpd/bgp_encap.c   |  2 +-
 bgpd/bgp_mplsvpn.c | 14 ++++++++++++++
 bgpd/bgp_route.c   | 41 ++++++++++++++++++++++++++---------------
 3 files changed, 41 insertions(+), 16 deletions(-)

diff --git a/bgpd/bgp_encap.c b/bgpd/bgp_encap.c
index 235492d..d5aadf8 100644
--- a/bgpd/bgp_encap.c
+++ b/bgpd/bgp_encap.c
@@ -483,7 +483,7 @@ bgp_show_encap (
                if (tags)
                  route_vty_out_tag (vty, &rm->p, ri, 0, SAFI_ENCAP);
                else
-                 route_vty_out (vty, &rm->p, ri, 0, SAFI_ENCAP, 0);
+                 route_vty_out (vty, &rm->p, ri, 0, SAFI_ENCAP);
                 output_count++;
              }
         }
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index 6f51445..3d92397 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -474,6 +474,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)
     {
@@ -499,6 +502,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;
@@ -558,9 +562,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 ddd47b2..c98b02f 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -5920,8 +5920,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;
   
@@ -5929,7 +5933,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, " ");
@@ -6005,14 +6009,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));
     
@@ -6070,12 +6074,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, "       ");
       
@@ -6326,7 +6330,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
@@ -6480,9 +6488,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)) 
@@ -6492,6 +6502,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
@@ -6686,11 +6697,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;
 }
@@ -9766,7 +9777,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;
     }
   
@@ -9857,7 +9868,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)
-- 
2.1.3


_______________________________________________
Quagga-dev mailing list
[email protected]
https://lists.quagga.net/mailman/listinfo/quagga-dev

Reply via email to