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.
This commit is contained in:
Amaury Denoyelle 2026-04-15 16:32:48 +02:00
parent 4945d02c99
commit 143d0034c9
2 changed files with 12 additions and 6 deletions

View File

@ -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;

View File

@ -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 <conn> connection.