]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-quic: define globally stream rxbuf size
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 26 Feb 2025 10:27:42 +0000 (11:27 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 7 Mar 2025 11:06:26 +0000 (12:06 +0100)
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
include/haproxy/mux_quic.h
src/h3.c
src/quic_tp.c

index f0c3577081eca7df692cbdae77dc4b8445b9d358..c92ed3644a4314499040fa1e9cd45f6e2fce050d 100644 (file)
@@ -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
index 8b2444ccc4c91b8daad5801cd6e62fa303ffa2b1..a2a1ecfb8fecfe8aa88220eabaa9b03b4ff6864a 100644 (file)
@@ -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
index 1f16caf1333836b402b0fd2073b731302fcd75cc..61d788f3fe2536f96fa9dbfc325cec8ba18377c7 100644 (file)
--- 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);
index 08d24b28f4701c863bf7adcf021c41c7e520c112..320e987834ebd2cfc511adad114d52e6eceb7908 100644 (file)
@@ -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;