From f85a2551b248312984c451d7522a16cf710429d8 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Wed, 2 Oct 2019 18:06:37 +0300 Subject: [PATCH] bgpd: Keep the session down if maximum-prefix is reached Under high load instances with hundreds of thousands of prefixes this could result in very unstable systems. When maximum-prefix is set, but restart timer is not set then the session flaps between Idle(Pfx) -> Established -> Idle(Pfx) states. Signed-off-by: Donatas Abraitis --- bgpd/bgp_network.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c index f76ae4290f..90629d79b2 100644 --- a/bgpd/bgp_network.c +++ b/bgpd/bgp_network.c @@ -382,12 +382,15 @@ static int bgp_accept(struct thread *thread) return -1; } - /* Check whether max prefix restart timer is set for the peer */ - if (peer1->t_pmax_restart) { + /* Do not try to reconnect if the peer reached maximum + * prefixes, restart timer is still running or the peer + * is shutdown. + */ + if (BGP_PEER_START_SUPPRESSED(peer1)) { if (bgp_debug_neighbor_events(peer1)) zlog_debug( - "%s - incoming conn rejected - " - "peer max prefix timer is active", + "[Event] Incoming BGP connection rejected from %s " + "due to maximum-prefix or shutdown", peer1->host); close(bgp_sock); return -1; -- 2.39.5