[PATCH] BGP: Do not start connect retry timer if connect immediately succeeds

Ze Xia billxia135 at gmail.com
Fri Oct 17 15:43:26 CEST 2025


BGP connect retry timer is unconditionally started in bgp_connect(),
which will be stopped by bgp_send_open() in bgp_connected() with
successful connection. However, if the sk_connect() in sk_open()
immediately succeeds, this code path will be immediately called.
This happens before the timer is even started, thus the timer will
never be stopped again.

Signed-off-by: Ze Xia <billxia135 at gmail.com>
---
 proto/bgp/bgp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c
index ad51e626..6358afc6 100644
--- a/proto/bgp/bgp.c
+++ b/proto/bgp/bgp.c
@@ -1628,8 +1628,10 @@ bgp_connect(struct bgp_proto *p)	/* Enter Connect state and start establishing c
   s->ao_keys_num = 0;
   s->ao_keys_init = NULL;
 
-  DBG("BGP: Waiting for connect success\n");
-  bgp_start_timer(conn->connect_timer, p->cf->connect_retry_time);
+  if (s->type == SK_TCP_ACTIVE) {
+    DBG("BGP: Waiting for connect success\n");
+    bgp_start_timer(p, conn->connect_timer, p->cf->connect_retry_time);
+  }
   return;
 
 err:
-- 
2.45.2



More information about the Bird-users mailing list