From: Maria Matejka Date: Mon, 19 Jan 2026 19:29:40 +0000 (+0100) Subject: BGP: Do shutdown heavy lifting in threads X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cc15b0fb5299a77ad656cf5d76546f4290ce4f66;p=thirdparty%2Fbird.git BGP: Do shutdown heavy lifting in threads 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. --- diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c index d3d61eafd..3343b8576 100644 --- a/proto/bgp/bgp.c +++ b/proto/bgp/bgp.c @@ -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); }