From b61afc4ad1f96f74176a34db8d3eaf34a78e4aee Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 12 Oct 2020 10:36:37 -0400 Subject: [PATCH 1/2] bgpd: Correctly calculate threshold being reached if (pcout > (pcount * peer->max_threshold[afi][safi] / 100 )) is always true. So the very first route received will always trigger the warning. We actually want the warning to happen when we hit the threshold. Signed-off-by: Donald Sharp --- bgpd/bgp_route.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 88534f8fb85b..ae353e3870f9 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -3167,7 +3167,8 @@ bool bgp_maximum_prefix_overflow(struct peer *peer, afi_t afi, safi_t safi, UNSET_FLAG(peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); - if (pcount > (pcount * peer->pmax_threshold[afi][safi] / 100)) { + if (pcount + > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100)) { if (CHECK_FLAG(peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD) && !always) From 9a4f15228a790f1df60813792e869786a290ac72 Mon Sep 17 00:00:00 2001 From: Trey Aspelund Date: Mon, 12 Oct 2020 15:39:11 -0400 Subject: [PATCH 2/2] bgpd: fix show bgp neighbor routes for labeled-unicast bgp_show_neighbor_route() was rewriting safi from LU to uni before checking if the peer was enabled for LU. This resulted in the peer's address-family check looking for unicast, which would always fail for LU peers since unicast + LU are mutually-exclusive AFIs. This moves this safi reassignment after the peer AFI check, ensuring that the peer's address-family check looks for LU while the call to bgp_show() still uses uni. -- highlights from manual testing config: router bgp 2 neighbor 1.1.1.1 remote-as external neighbor 1.1.1.1 disable-connected-check neighbor 1.1.1.1 update-source 2.2.2.2 ! address-family ipv4 unicast no neighbor 1.1.1.1 activate exit-address-family ! address-family ipv4 labeled-unicast neighbor 1.1.1.1 activate exit-address-family before: spine01# show bgp ipv4 unicast neighbors 1.1.1.1 routes % No such neighbor or address family spine01# show bgp ipv4 labeled-unicast neighbors 1.1.1.1 routes % No such neighbor or address family after: spine01# show bgp ipv4 unicast neighbors 1.1.1.1 routes % No such neighbor or address family spine01# show bgp ipv4 label neighbors 1.1.1.1 routes BGP table version is 1, local router ID is 2.2.2.2 Status codes: s suppressed, d damped, h history, * valid, > best, = multipath, i internal, r RIB-failure, S Stale, R Removed Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 11.11.11.11/32 1.1.1.1 0 0 1 i Displayed 1 routes and 1 total paths Signed-off-by: Trey Aspelund Signed-off-by: Donatas Abraitis --- bgpd/bgp_route.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index ae353e3870f9..f3e57facf6d6 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -12658,10 +12658,6 @@ static int bgp_show_neighbor_route(struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, enum bgp_show_type type, bool use_json) { - /* labeled-unicast routes live in the unicast table */ - if (safi == SAFI_LABELED_UNICAST) - safi = SAFI_UNICAST; - if (!peer || !peer->afc[afi][safi]) { if (use_json) { json_object *json_no = NULL; @@ -12677,6 +12673,10 @@ static int bgp_show_neighbor_route(struct vty *vty, struct peer *peer, return CMD_WARNING; } + /* labeled-unicast routes live in the unicast table */ + if (safi == SAFI_LABELED_UNICAST) + safi = SAFI_UNICAST; + return bgp_show(vty, peer->bgp, afi, safi, type, &peer->su, use_json, false); }