]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
fixup! fixup! BGP runs TX as a deferred routine
authorMaria Matejka <mq@ucw.cz>
Thu, 27 Jun 2024 11:34:22 +0000 (13:34 +0200)
committerMaria Matejka <mq@ucw.cz>
Thu, 27 Jun 2024 11:34:22 +0000 (13:34 +0200)
proto/bgp/attrs.c
proto/bgp/packets.c

index 7cc3e514259f3e361d940c22f74bd0ffabb8bc1e..6da6e1a869221eef8952f125294b0947bf2ed02d 100644 (file)
@@ -1841,32 +1841,34 @@ bgp_done_prefix(struct bgp_ptx_private *c, struct bgp_prefix *px, struct bgp_buc
 void
 bgp_tx_resend(struct bgp_proto *p, struct bgp_channel *bc)
 {
-  BGP_PTX_LOCK(bc->tx, c);
-
-  ASSERT_DIE(bc->tx_keep);
   uint seen = 0;
-
-  HASH_WALK(c->prefix_hash, next, px)
   {
-    if (!px->cur)
+    BGP_PTX_LOCK(bc->tx, c);
+
+    ASSERT_DIE(bc->tx_keep);
+
+    HASH_WALK(c->prefix_hash, next, px)
     {
-      ASSERT_DIE(px->last);
-      struct bgp_bucket *last = px->last;
+      if (!px->cur)
+      {
+       ASSERT_DIE(px->last);
+       struct bgp_bucket *last = px->last;
 
-      /* Remove the last reference, we wanna resend the route */
-      px->last->px_uc--;
-      px->last = NULL;
+       /* Remove the last reference, we wanna resend the route */
+       px->last->px_uc--;
+       px->last = NULL;
 
-      /* And send it once again */
-      seen += bgp_update_prefix(c, px, last);
+       /* And send it once again */
+       seen += bgp_update_prefix(c, px, last);
+      }
     }
-  }
-  HASH_WALK_END;
+    HASH_WALK_END;
 
-  if (bc->c.debug & D_EVENTS)
-    log(L_TRACE "%s.%s: TX resending %u routes",
-       bc->c.proto->name, bc->c.name, seen);
+    if (bc->c.debug & D_EVENTS)
+      log(L_TRACE "%s.%s: TX resending %u routes",
+         bc->c.proto->name, bc->c.name, seen);
 
+  }
   if (seen)
     bgp_schedule_packet(p->conn, bc, PKT_UPDATE);
 }
index 77a4646e07ec248e4836fdd751d1f4d0a4e0e7ac..10ee4bc0395cc4a39e80c3fcfae57a0b284f62ab 100644 (file)
@@ -1052,9 +1052,12 @@ bgp_rx_open(struct bgp_conn *conn, byte *pkt, uint len)
       conn->hold_time, conn->keepalive_time, p->remote_as, p->remote_id, conn->as4_session);
 
   bgp_schedule_packet(conn, NULL, PKT_KEEPALIVE);
-  bgp_start_timer(p, conn->hold_timer, conn->hold_time);
-  bgp_start_timer(p, conn->send_hold_timer, conn->send_hold_time);
-  bgp_conn_enter_openconfirm_state(conn);
+  if (conn->sk)
+  {
+    bgp_start_timer(p, conn->hold_timer, conn->hold_time);
+    bgp_start_timer(p, conn->send_hold_timer, conn->send_hold_time);
+    bgp_conn_enter_openconfirm_state(conn);
+  }
 }
 
 
@@ -3186,7 +3189,8 @@ bgp_schedule_packet(struct bgp_conn *conn, struct bgp_channel *c, int type)
   if (was_active || (conn->sk->tpos != conn->sk->tbuf))
     return;
   else if ((type == PKT_KEEPALIVE) || (this_birdloop != p->p.loop))
-    bgp_fire_tx(conn);
+    while (bgp_fire_tx(conn) > 0)
+      ;
   else
   {
     struct bgp_tx_deferred_call btdc = {