From aa72bd7e7fdda03c327d73b042f7d96042998d59 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Mon, 23 Nov 2020 14:29:40 +0000 Subject: [PATCH] bgpd: add peer description for each afi/safi line in show summary For each afi/safi of 'show bgp summary', display the peer description each time needed. This information is useful, for instance in the case of a device connected with multiple peers. The topotest all_protocol_startup is changed accordingly. Signed-off-by: Philippe Guibert --- bgpd/bgp_vty.c | 9 ++++++++- tests/topotests/all-protocol-startup/r1/bgpd.conf | 4 ++++ .../all-protocol-startup/r1/show_bgp_ipv6_summary.ref | 6 +++--- .../all-protocol-startup/r1/show_ip_bgp_summary.ref | 10 +++++----- .../bgp_multiview_topo1/test_bgp_multiview_topo1.py | 2 +- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 1a7a3543f9..03494f7a1f 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -10742,7 +10742,7 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, vty_out(vty, "EstdCnt DropCnt ResetTime Reason\n"); else vty_out(vty, - "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt\n"); + "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc\n"); } } @@ -10881,6 +10881,9 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, peer->established); json_object_int_add(json_peer, "connectionsDropped", peer->dropped); + if (peer->desc) + json_object_string_add( + json_peer, "desc", peer->desc); } /* Avoid creating empty peer dicts in JSON */ if (json_peer == NULL) @@ -10995,6 +10998,10 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, vty_out(vty, " %8u", 0); } + if (peer->desc) + vty_out(vty, " %s", peer->desc); + else + vty_out(vty, " N/A"); vty_out(vty, "\n"); } diff --git a/tests/topotests/all-protocol-startup/r1/bgpd.conf b/tests/topotests/all-protocol-startup/r1/bgpd.conf index d287b86175..32dcb727e5 100644 --- a/tests/topotests/all-protocol-startup/r1/bgpd.conf +++ b/tests/topotests/all-protocol-startup/r1/bgpd.conf @@ -13,6 +13,10 @@ router bgp 100 neighbor fc00:0:0:8::1000 remote-as 100 neighbor fc00:0:0:8::1000 timers 3 10 neighbor fc00:0:0:8::2000 remote-as 200 + neighbor 192.168.7.10 description Transit_cogent + neighbor 192.168.7.20 description Client_Bibi_Full + neighbor fc00:0:0:8::1000 description Transit_cogent_v6 + neighbor fc00:0:0:8::2000 description Client_Toto_default neighbor fc00:0:0:8::2000 timers 3 10 ! address-family ipv4 unicast diff --git a/tests/topotests/all-protocol-startup/r1/show_bgp_ipv6_summary.ref b/tests/topotests/all-protocol-startup/r1/show_bgp_ipv6_summary.ref index 1e41263e78..0246687200 100644 --- a/tests/topotests/all-protocol-startup/r1/show_bgp_ipv6_summary.ref +++ b/tests/topotests/all-protocol-startup/r1/show_bgp_ipv6_summary.ref @@ -3,6 +3,6 @@ BGP table version 1 RIB entries 1, using XXXX bytes of memory Peers 2, using XXXX KiB of memory -Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt -fc00:0:0:8::1000 4 100 0 0 0 0 0 never Active 0 -fc00:0:0:8::2000 4 200 0 0 0 0 0 never Active 0 +Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc +fc00:0:0:8::1000 4 100 0 0 0 0 0 never Active 0 Transit_cogent_v6 +fc00:0:0:8::2000 4 200 0 0 0 0 0 never Active 0 Client_Toto_default diff --git a/tests/topotests/all-protocol-startup/r1/show_ip_bgp_summary.ref b/tests/topotests/all-protocol-startup/r1/show_ip_bgp_summary.ref index 3ffbf3ff42..deeae87fa3 100644 --- a/tests/topotests/all-protocol-startup/r1/show_ip_bgp_summary.ref +++ b/tests/topotests/all-protocol-startup/r1/show_ip_bgp_summary.ref @@ -3,8 +3,8 @@ BGP table version 1 RIB entries 1, using XXXX bytes of memory Peers 4, using XXXX KiB of memory -Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt -192.168.7.10 4 100 0 0 0 0 0 never Active 0 -192.168.7.20 4 200 0 0 0 0 0 never Active 0 -fc00:0:0:8::1000 4 100 0 0 0 0 0 never Active 0 -fc00:0:0:8::2000 4 200 0 0 0 0 0 never Active 0 +Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc +192.168.7.10 4 100 0 0 0 0 0 never Active 0 Transit_cogent +192.168.7.20 4 200 0 0 0 0 0 never Active 0 Client_Bibi_Full +fc00:0:0:8::1000 4 100 0 0 0 0 0 never Active 0 Transit_cogent_v6 +fc00:0:0:8::2000 4 200 0 0 0 0 0 never Active 0 Client_Toto_default diff --git a/tests/topotests/bgp_multiview_topo1/test_bgp_multiview_topo1.py b/tests/topotests/bgp_multiview_topo1/test_bgp_multiview_topo1.py index 7635f74125..d8815a0d39 100644 --- a/tests/topotests/bgp_multiview_topo1/test_bgp_multiview_topo1.py +++ b/tests/topotests/bgp_multiview_topo1/test_bgp_multiview_topo1.py @@ -226,7 +226,7 @@ def test_bgp_converge(): for i in range(1, 2): for view in range(1, 4): notConverged = net["r%s" % i].cmd( - 'vtysh -c "show ip bgp view %s summary" 2> /dev/null | grep ^[0-9] | grep -vP " 11\s+(\d+)$"' + 'vtysh -c "show ip bgp view %s summary" 2> /dev/null | grep ^[0-9] | grep -vP " 11\s+(\d+)"' % view ) if notConverged: -- 2.39.5