From: Dewi Morgan Date: Thu, 14 Jan 2021 14:01:26 +0000 (+0000) Subject: bgpd: clear max prefix overflow on de-config X-Git-Tag: base_7.6~37^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=ac4522e6216caa3c56547b55334f14dee98a72f2;p=mirror%2Ffrr.git bgpd: clear max prefix overflow on de-config A bgp neighbor remains in Idle state in the event that the number of received prefixes exceeds the configured maximum prefix for the neighbor. The neighbor remains in idle state even after de-configuring the maximum prefix limit for the neighbor. The fix is to clear the neighbor overflow state if set, after de-configuring the neighbor maximum-prefix commnd. This allows the neighbor to establish without having to perform a clear operation. It also avoids the misleading neigbor summary indicating that the neighbor is in prefix overflow state (PfxCt) when no limit is configured for the neighbor. Signed-off-by: Dewi Morgan --- diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 9a2693fd56..9297ec4711 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -6974,6 +6974,22 @@ int peer_advertise_map_unset(struct peer *peer, afi_t afi, safi_t safi, return 0; } +static bool peer_maximum_prefix_clear_overflow(struct peer *peer) +{ + if (!CHECK_FLAG(peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) + return false; + + UNSET_FLAG(peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); + if (peer->t_pmax_restart) { + BGP_TIMER_OFF(peer->t_pmax_restart); + if (bgp_debug_neighbor_events(peer)) + zlog_debug("%s Maximum-prefix restart timer cancelled", + peer->host); + } + BGP_EVENT_ADD(peer, BGP_Start); + return true; +} + int peer_maximum_prefix_set(struct peer *peer, afi_t afi, safi_t safi, uint32_t max, uint8_t threshold, int warning, uint16_t restart, bool force) @@ -7095,7 +7111,11 @@ int peer_maximum_prefix_unset(struct peer *peer, afi_t afi, safi_t safi) member->pmax[afi][safi] = 0; member->pmax_threshold[afi][safi] = 0; member->pmax_restart[afi][safi] = 0; + + peer_maximum_prefix_clear_overflow(member); } + } else { + peer_maximum_prefix_clear_overflow(peer); } return 0; @@ -7298,18 +7318,8 @@ int peer_clear(struct peer *peer, struct listnode **nnode) { if (!CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) || !CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHUTDOWN)) { - if (CHECK_FLAG(peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { - UNSET_FLAG(peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); - if (peer->t_pmax_restart) { - BGP_TIMER_OFF(peer->t_pmax_restart); - if (bgp_debug_neighbor_events(peer)) - zlog_debug( - "%s Maximum-prefix restart timer canceled", - peer->host); - } - BGP_EVENT_ADD(peer, BGP_Start); + if (peer_maximum_prefix_clear_overflow(peer)) return 0; - } peer->v_start = BGP_INIT_START_TIMER; if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status))