From 2564e16cd2ca8e073ee44e68288ec80a4870ee44 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Sat, 9 May 2020 21:33:51 +0300 Subject: [PATCH 1/2] bgpd: Use default AFI_IP6/SAFI_UNICAST when displaying statistics Without specifying a default afi/safi we get a segfault: ``` (gdb) frame 4 bgp_table_stats (..., afi=32724, safi=SAFI_UNICAST, ... 11349 if (!bgp->rib[afi][safi]) { (gdb) ``` Signed-off-by: Donatas Abraitis --- bgpd/bgp_route.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 78f077eaca..e8151d94ed 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -10567,8 +10567,8 @@ DEFUN(show_ip_bgp_statistics_all, show_ip_bgp_statistics_all_cmd, { bool uj = use_json(argc, argv); struct bgp *bgp = NULL; - safi_t safi; - afi_t afi; + safi_t safi = SAFI_UNICAST; + afi_t afi = AFI_IP6; int idx = 0; struct json_object *json_all = NULL; struct json_object *json_afi_safi = NULL; @@ -10626,8 +10626,8 @@ DEFUN (show_ip_bgp_l2vpn_evpn_statistics, "BGP RIB advertisement statistics\n" JSON_STR) { - afi_t afi; - safi_t safi; + afi_t afi = AFI_IP6; + safi_t safi = SAFI_UNICAST; struct bgp *bgp = NULL; int idx = 0, ret; bool uj = use_json(argc, argv); @@ -10666,8 +10666,8 @@ DEFUN(show_ip_bgp_afi_safi_statistics, show_ip_bgp_afi_safi_statistics_cmd, BGP_SAFI_WITH_LABEL_HELP_STR "BGP RIB advertisement statistics\n" JSON_STR) { - afi_t afi; - safi_t safi; + afi_t afi = AFI_IP6; + safi_t safi = SAFI_UNICAST; struct bgp *bgp = NULL; int idx = 0, ret; bool uj = use_json(argc, argv); From 90a80a85c4a1780aaa0a5dfd8b6af8fff7f49d22 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Sun, 3 May 2020 21:16:45 +0300 Subject: [PATCH 2/2] bgpd: Set a proper SAFI for labaled-unicast when looking for scount The problem is that peer_af_array returns NULL when SAFI is changed to unicast. We use unicast table, but peer is created and activated under labeled-unicast, hence we should lookup with a proper SAFI id. Without this patch peer_af_find() returns NULL and we can't show PfxSnt in `show bgp summary`. Signed-off-by: Donatas Abraitis --- bgpd/bgp_vty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 0f09369860..ac5e7e5bf5 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -9066,7 +9066,7 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, } } - paf = peer_af_find(peer, afi, pfx_rcd_safi); + paf = peer_af_find(peer, afi, safi); filter = &peer->filter[afi][safi]; count++;