]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
BGP: Do shutdown heavy lifting in threads mq-bgp-faster-shutdown
authorMaria Matejka <mq@ucw.cz>
Mon, 19 Jan 2026 19:29:40 +0000 (20:29 +0100)
committerMaria Matejka <mq@ucw.cz>
Mon, 19 Jan 2026 19:29:40 +0000 (20:29 +0100)
Freeing the export table is surprisingly expensive. When it's called from bgp_stop()
immediately, it may get called in the main loop while reconfiguring or shutting down,
and that is unnecessarily slow. Moving that code to the bgp_decision() event so that
it can run in threads.

Discovered by randomly checking perf tests.

proto/bgp/bgp.c

index d3d61eafd15a9f3d4171adf735250bff66848551..3343b857619a069977e58f1a3a2cc7538fbed2b3 100644 (file)
@@ -1210,7 +1210,13 @@ bgp_decision(void *vp)
   if ((p->p.proto_state == PS_STOP) &&
       (p->outgoing_conn.state == BS_IDLE) &&
       (p->incoming_conn.state == BS_IDLE))
+  {
+    struct bgp_channel *c;
+    BGP_WALK_CHANNELS(p, c)
+      bgp_free_pending_tx(c);
+
     bgp_down(p);
+  }
 }
 
 static void
@@ -1257,10 +1263,6 @@ bgp_stop(struct bgp_proto *p, int subcode, byte *data, uint len)
 
   p->p.reload_routes = NULL;
 
-  struct bgp_channel *c;
-  BGP_WALK_CHANNELS(p, c)
-    bgp_free_pending_tx(c);
-
   proto_send_event(&p->p, p->event);
 }