From 4b1e63d191d13a66940035d16bc5f2c7c4a138d6 Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Wed, 26 Feb 2025 11:27:42 +0100 Subject: [PATCH] MINOR: mux-quic: define globally stream rxbuf size QCS uses ncbuf for STREAM data storage. This serves as a limit for maximum STREAM buffering capacity, advertised via QUIC transport parameters for initial flow-control values. Define a new function qmux_stream_rx_bufsz() which can be used to retrieve this Rx buffer size. This can be used both in MUX/H3 layers and in QUIC transport parameters. --- include/haproxy/mux_quic-t.h | 3 --- include/haproxy/mux_quic.h | 5 +++++ src/h3.c | 2 +- src/quic_tp.c | 10 +++++----- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/include/haproxy/mux_quic-t.h b/include/haproxy/mux_quic-t.h index f0c357708..c92ed3644 100644 --- a/include/haproxy/mux_quic-t.h +++ b/include/haproxy/mux_quic-t.h @@ -112,9 +112,6 @@ struct qcc { void *ctx; /* Application layer context */ }; -/* Maximum size of stream Rx buffer. */ -#define QC_S_RX_BUF_SZ (global.tune.bufsize - NCB_RESERVED_SZ) - /* QUIC stream states * * On initialization a stream is put on idle state. It is opened as soon as diff --git a/include/haproxy/mux_quic.h b/include/haproxy/mux_quic.h index 8b2444ccc..a2a1ecfb8 100644 --- a/include/haproxy/mux_quic.h +++ b/include/haproxy/mux_quic.h @@ -46,6 +46,11 @@ int qcc_recv_max_stream_data(struct qcc *qcc, uint64_t id, uint64_t max); int qcc_recv_reset_stream(struct qcc *qcc, uint64_t id, uint64_t err, uint64_t final_size); int qcc_recv_stop_sending(struct qcc *qcc, uint64_t id, uint64_t err); +static inline int qmux_stream_rx_bufsz(void) +{ + return global.tune.bufsize - NCB_RESERVED_SZ; +} + /* Bit shift to get the stream sub ID for internal use which is obtained * shifting the stream IDs by this value, knowing that the * QCS_ID_TYPE_SHIFT less significant bits identify the stream ID diff --git a/src/h3.c b/src/h3.c index 1f16caf13..61d788f3f 100644 --- a/src/h3.c +++ b/src/h3.c @@ -1380,7 +1380,7 @@ static ssize_t h3_rcv_buf(struct qcs *qcs, struct buffer *b, int fin) * SETTINGS_MAX_FIELD_SECTION_SIZE parameter to prevent * excessive decompressed size. */ - if (flen > QC_S_RX_BUF_SZ) { + if (flen > qmux_stream_rx_bufsz()) { TRACE_ERROR("received a too big frame", H3_EV_RX_FRAME, qcs->qcc->conn, qcs); qcc_set_error(qcs->qcc, H3_ERR_EXCESSIVE_LOAD, 1); qcc_report_glitch(qcs->qcc, 1); diff --git a/src/quic_tp.c b/src/quic_tp.c index 08d24b28f..320e98783 100644 --- a/src/quic_tp.c +++ b/src/quic_tp.c @@ -46,7 +46,7 @@ static void quic_dflt_transport_params_cpy(struct quic_transport_params *dst) */ void quic_transport_params_init(struct quic_transport_params *p, int server) { - const uint64_t ncb_size = global.tune.bufsize - NCB_RESERVED_SZ; + const uint64_t stream_rx_bufsz = qmux_stream_rx_bufsz(); const int max_streams_bidi = global.tune.quic_frontend_max_streams_bidi; const int max_streams_uni = 3; @@ -64,10 +64,10 @@ void quic_transport_params_init(struct quic_transport_params *p, int server) p->initial_max_streams_bidi = max_streams_bidi; p->initial_max_streams_uni = max_streams_uni; - p->initial_max_stream_data_bidi_local = ncb_size; - p->initial_max_stream_data_bidi_remote = ncb_size; - p->initial_max_stream_data_uni = ncb_size; - p->initial_max_data = (max_streams_bidi + max_streams_uni) * ncb_size; + p->initial_max_stream_data_bidi_local = stream_rx_bufsz; + p->initial_max_stream_data_bidi_remote = stream_rx_bufsz; + p->initial_max_stream_data_uni = stream_rx_bufsz; + p->initial_max_data = (max_streams_bidi + max_streams_uni) * stream_rx_bufsz; if (server) { p->with_stateless_reset_token = 1;