From c42eab4bf54897d26ab590734232e2de9d4af87b Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 11 May 2018 07:40:55 -0400 Subject: [PATCH] bgpd: Respect ability to reach nexthop if available When bgp is thinking about opening a connection to a peer, if we are connected to zebra, allow that to influence our decision to start the connection. Found Scenario: Both bgp and zebra are started up at the same time. Zebra is being used to create the connected route through which bgp will establish a peering relationship. The machine is a bit loaded due to other startup conditions and as such bgp gets to the connection stage here before zebra has installed the route. If bgp does not respect zebra data when it does have a connection then we will attempt to connect. The connect will fail because there is no route. At that time we will go into the connect timeout(2 minutes) and delay connection. What this does. If we have established a zebra connection and we do not have a clear path to the destination at this point do not allow the connection to proceed. Signed-off-by: Donald Sharp --- bgpd/bgp_fsm.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index a22feaec84..3f5ff12cbc 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -52,6 +52,7 @@ #include "bgpd/bgp_memory.h" #include "bgpd/bgp_keepalives.h" #include "bgpd/bgp_io.h" +#include "bgpd/bgp_zebra.h" DEFINE_HOOK(peer_backward_transition, (struct peer * peer), (peer)) DEFINE_HOOK(peer_established, (struct peer * peer), (peer)) @@ -1398,13 +1399,14 @@ int bgp_start(struct peer *peer) if (!bgp_find_or_add_nexthop(peer->bgp, peer->bgp, family2afi(peer->su.sa.sa_family), NULL, peer, connected)) { -#if defined(HAVE_CUMULUS) - if (bgp_debug_neighbor_events(peer)) - zlog_debug("%s [FSM] Waiting for NHT", peer->host); + if (bgp_zebra_num_connects()) { + if (bgp_debug_neighbor_events(peer)) + zlog_debug("%s [FSM] Waiting for NHT", + peer->host); - BGP_EVENT_ADD(peer, TCP_connection_open_failed); - return 0; -#endif + BGP_EVENT_ADD(peer, TCP_connection_open_failed); + return 0; + } } assert(!peer->t_write); -- 2.39.5