From: Amaury Denoyelle Date: Thu, 16 Nov 2023 16:13:41 +0000 (+0100) Subject: BUG/MINOR: mux_h2: reject passive reverse conn if error on add to idle X-Git-Tag: v2.9-dev10~66 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a1457296d5688d6604ddc319f172f4d74fe163a4;p=thirdparty%2Fhaproxy.git BUG/MINOR: mux_h2: reject passive reverse conn if error on add to idle On passive reverse, H2 mux is responsible to insert the connection in the server idle list. This is done via srv_add_to_idle_list(). However, this function may fail for various reason, such as FD usage limit reached. Handle properly this error case. H2 mux flags the connection on error which will cause its release. Prior to this patch, the connection was only released on server timeout. This bug was found inspecting server curr_used_conns counter. Indeed, on connection reverse, this counter is first incremented. It is decremented just after on srv_add_to_idle_list() if insertion is validated. However, if insertion is rejected, the connection was not released which cause curr_used_conns to remains positive. This has the major downside to break the reusing of idle connection on rhttp causing spurrious 503 errors. No need to backport. --- diff --git a/src/mux_h2.c b/src/mux_h2.c index d70f5c5ba6..3883e15f6e 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -3295,7 +3295,8 @@ static int h2_conn_reverse(struct h2c *h2c) HA_ATOMIC_OR(&h2c->wait_event.tasklet->state, TASK_F_USR1); xprt_set_idle(conn, conn->xprt, conn->xprt_ctx); - srv_add_to_idle_list(srv, conn, 1); + if (!srv_add_to_idle_list(srv, conn, 1)) + goto err; } else { struct listener *l = __objt_listener(h2c->conn->target);