From: Amaury Denoyelle Date: Wed, 15 Apr 2026 14:32:48 +0000 (+0200) Subject: BUG/MINOR: mux_quic: limit avail_streams() to 2^62 X-Git-Tag: v3.4-dev10~157 X-Git-Url: http://www.kaiwu.me/postgresql/commit/static/gitweb.js?a=commitdiff_plain;h=143d0034c912f1490812b6302f0dffb37f3ec02d;p=haproxy.git BUG/MINOR: mux_quic: limit avail_streams() to 2^62 QUIC streams ID are encoded as 62-bit integer and cannot reuse an ID within a connection. This is necessary to take into account this limitation for backend connections. This patch implements this via qmux_avail_streams() callback. In the case where the connection is approaching the encoding limit, reduce the advertised value until the limit is reached. Note that this is very unlikely to happen as the value is pretty high. This should be backported up to 3.3. --- diff --git a/include/haproxy/mux_quic.h b/include/haproxy/mux_quic.h index 2c8086297..0ab083018 100644 --- a/include/haproxy/mux_quic.h +++ b/include/haproxy/mux_quic.h @@ -62,6 +62,9 @@ static inline int qmux_stream_rx_bufsz(void) /* This bit is set for unidirectional streams */ #define QCS_ID_DIR_BIT 0x2 +/* Maximum bidirectional stream ID that a client can opened. */ +#define QCS_ID_MAX_STRM_CL_BIDI (QUIC_VARINT_8_BYTE_MAX - 3) + static inline enum qcs_type qcs_id_type(uint64_t id) { return id & QCS_ID_TYPE_MASK; diff --git a/src/mux_quic.c b/src/mux_quic.c index d0c84ccbe..0bd9327f0 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -3212,18 +3212,21 @@ static int qmux_avail_streams(struct connection *conn) { struct server *srv = __objt_server(conn->target); struct qcc *qcc = conn->ctx; - int max_fctl, max_reuse = 0; + int ret, max_reuse = 0; - max_fctl = qcc_fctl_avail_streams(qcc, 1); + ret = qcc_fctl_avail_streams(qcc, 1); if (srv->max_reuse >= 0) { max_reuse = qcc->tot_sc <= srv->max_reuse ? srv->max_reuse - qcc->tot_sc + 1: 0; - return MIN(max_fctl, max_reuse); - } - else { - return max_fctl; + ret = MIN(ret, max_reuse); } + + /* Ensure we do not exceed the maximum usable stream ID. */ + if (unlikely(ret > QCS_ID_MAX_STRM_CL_BIDI - qcc->next_bidi_l)) + ret = QCS_ID_MAX_STRM_CL_BIDI - qcc->next_bidi_l; + + return ret; } /* Returns the number of streams currently attached into connection.