From f3b0ba7dc946aceb7b4e643f8787465fcca8869a Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Wed, 8 Dec 2021 15:12:01 +0100 Subject: [PATCH] BUG/MINOR: mux-quic: properly initialize flow control Initialize all flow control members on the qcc instance. Without this, the value are undefined and it may be possible to have errors about reached streams limit. --- include/haproxy/mux_quic-t.h | 3 +++ src/mux_quic.c | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/include/haproxy/mux_quic-t.h b/include/haproxy/mux_quic-t.h index eb3d6e902..0a60868a0 100644 --- a/include/haproxy/mux_quic-t.h +++ b/include/haproxy/mux_quic-t.h @@ -42,6 +42,9 @@ struct qcc { } tx; } strms[QCS_MAX_TYPES]; + struct { + uint64_t max_data; /* Maximum number of bytes which may be received */ + } rx; struct { uint64_t max_data; /* Maximum number of bytes which may be sent */ } tx; diff --git a/src/mux_quic.c b/src/mux_quic.c index 89d7875e8..c4bd1bfd5 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -312,6 +312,7 @@ static int qc_init(struct connection *conn, struct proxy *prx, struct session *sess, struct buffer *input) { struct qcc *qcc; + struct quic_transport_params *srv_params; qcc = pool_alloc(pool_head_qcc); if (!qcc) @@ -325,14 +326,37 @@ static int qc_init(struct connection *conn, struct proxy *prx, qcc->streams_by_id = EB_ROOT_UNIQUE; + /* Server parameters, params used for RX flow control. */ + srv_params = &conn->qc->rx.params; + + qcc->rx.max_data = srv_params->initial_max_data; + qcc->tx.max_data = 0; + + /* Client initiated streams must respect the server flow control. */ + qcc->strms[QCS_CLT_BIDI].max_streams = srv_params->initial_max_streams_bidi; qcc->strms[QCS_CLT_BIDI].nb_streams = 0; qcc->strms[QCS_CLT_BIDI].largest_id = -1; + qcc->strms[QCS_CLT_BIDI].rx.max_data = 0; + qcc->strms[QCS_CLT_BIDI].tx.max_data = srv_params->initial_max_stream_data_bidi_remote; + + qcc->strms[QCS_CLT_UNI].max_streams = srv_params->initial_max_streams_uni; qcc->strms[QCS_CLT_UNI].nb_streams = 0; qcc->strms[QCS_CLT_UNI].largest_id = -1; + qcc->strms[QCS_CLT_UNI].rx.max_data = 0; + qcc->strms[QCS_CLT_UNI].tx.max_data = srv_params->initial_max_stream_data_uni; + + /* Server initiated streams must respect the server flow control. */ + qcc->strms[QCS_SRV_BIDI].max_streams = 0; qcc->strms[QCS_SRV_BIDI].nb_streams = 0; qcc->strms[QCS_SRV_BIDI].largest_id = -1; + qcc->strms[QCS_SRV_BIDI].rx.max_data = srv_params->initial_max_stream_data_bidi_local; + qcc->strms[QCS_SRV_BIDI].tx.max_data = 0; + + qcc->strms[QCS_SRV_UNI].max_streams = 0; qcc->strms[QCS_SRV_UNI].nb_streams = 0; qcc->strms[QCS_SRV_UNI].largest_id = -1; + qcc->strms[QCS_SRV_UNI].rx.max_data = srv_params->initial_max_stream_data_uni; + qcc->strms[QCS_SRV_UNI].tx.max_data = 0; qcc->wait_event.tasklet = tasklet_new(); if (!qcc->wait_event.tasklet)