From 71c93270f718d8be268301f4c9c88c7cbadf2579 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Fri, 7 Jul 2023 10:14:51 +0300 Subject: [PATCH 1/2] bgpd: Show neighbors software version if description is not set Also, this is visible only if `capability software-version` is enabled. Example: ``` r1# show ip bgp summary IPv4 Unicast Summary (VRF default): BGP router identifier 192.168.1.1, local AS number 65001 vrf-id 0 BGP table version 0 RIB entries 0, using 0 bytes of memory Peers 1, using 725 KiB of memory Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc 192.168.1.2 4 65002 54 54 0 0 0 00:00:52 0 0 FRRouting/9.1-dev-My Total number of neighbors 1 r1# ``` Signed-off-by: Donatas Abraitis --- bgpd/bgp_vty.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index e1cc59a318..ee0098bf5a 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -11930,14 +11930,23 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, } /* Make sure `Desc` column is the lastest in * the output. + * If the description is not set, try + * to print the software version if the + * capability is enabled and received. */ if (peer->desc) vty_out(vty, " %s", bgp_peer_description_stripped( peer->desc, show_wide ? 64 : 20)); - else + else if (peer->soft_version) { + vty_out(vty, " %s", + bgp_peer_description_stripped( + peer->soft_version, + show_wide ? 64 : 20)); + } else { vty_out(vty, " N/A"); + } vty_out(vty, "\n"); } From c10d1c8acacfc9406031cab2e69acd4fe33b76e9 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Fri, 7 Jul 2023 10:23:39 +0300 Subject: [PATCH 2/2] bgpd: Fix `show bgp summary wide` alignment Before: ``` r1# show ip bgp summary wide IPv4 Unicast Summary (VRF default): BGP router identifier 192.168.1.1, local AS number 65001 vrf-id 0 BGP table version 0 RIB entries 0, using 0 bytes of memory Peers 1, using 725 KiB of memory Neighbor V AS LocalAS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc 192.168.1.2 4 65002 65001 8 8 0 0 0 00:00:05 0 0 FRRouting/9.1-dev-MyOwnFRRVersion-gc5fc0beb46 Total number of neighbors 1 r1# ``` After: ``` r1# show ip bgp summary wide IPv4 Unicast Summary (VRF default): BGP router identifier 192.168.1.1, local AS number 65001 vrf-id 0 BGP table version 0 RIB entries 0, using 0 bytes of memory Peers 1, using 725 KiB of memory Neighbor V AS LocalAS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc 192.168.1.2 4 65002 65001 10 10 0 0 0 00:00:08 0 0 FRRouting/9.1-dev-MyOwnFRRVersion-g4be13ec347 Total number of neighbors 1 r1# ``` Signed-off-by: Donatas Abraitis --- bgpd/bgp_vty.c | 2 +- lib/asn.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index ee0098bf5a..07feed637a 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -11854,7 +11854,7 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, &peer->ibuf->count, memory_order_relaxed); - vty_out(vty, "4 "); + vty_out(vty, "4"); vty_out(vty, ASN_FORMAT_SPACE(bgp->asnotation), &peer->as); if (show_wide) diff --git a/lib/asn.h b/lib/asn.h index 81a42c658d..a7394fa52b 100644 --- a/lib/asn.h +++ b/lib/asn.h @@ -66,10 +66,10 @@ extern char *asn_asn2string(const as_t *as, char *buf, size_t len, ((mode == ASNOTATION_DOT) ? "%pASD" : \ ((mode == ASNOTATION_DOTPLUS) ? "%pASE" : \ "%pASP")) -#define ASN_FORMAT_SPACE(mode) \ - ((mode == ASNOTATION_DOT) ? "%10pASD" : \ - ((mode == ASNOTATION_DOTPLUS) ? "%10pASE" : \ - "%10pASP")) +#define ASN_FORMAT_SPACE(mode) \ + ((mode == ASNOTATION_DOT) \ + ? "%11pASD" \ + : ((mode == ASNOTATION_DOTPLUS) ? "%11pASE" : "%11pASP")) /* for test */ extern void asn_relax_as_zero(bool relax);