From: Frédéric Lécaille Date: Mon, 2 May 2022 16:46:58 +0000 (+0200) Subject: MINOR: quic: Make the quic_conn be aware of the number of streams X-Git-Tag: v2.6-dev9~113 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=664741e1c54809209bf4569c78019b57253e5eb9;p=thirdparty%2Fhaproxy.git MINOR: quic: Make the quic_conn be aware of the number of streams This is required when the retransmitted frame types when the mux is released. We add a counter for the number of streams which were opened or closed by the mux. After the mux has been released, we can rely on this counter to know if the STREAM frames are retransmitted ones or not. --- diff --git a/include/haproxy/quic_stream.h b/include/haproxy/quic_stream.h index 0550f4f0c3..1107e86f2e 100644 --- a/include/haproxy/quic_stream.h +++ b/include/haproxy/quic_stream.h @@ -3,11 +3,12 @@ #ifdef USE_QUIC +#include #include struct quic_conn; -struct qc_stream_desc *qc_stream_desc_new(uint64_t id, void *ctx, +struct qc_stream_desc *qc_stream_desc_new(uint64_t id, enum qcs_type, void *ctx, struct quic_conn *qc); void qc_stream_desc_release(struct qc_stream_desc *stream); int qc_stream_desc_ack(struct qc_stream_desc **stream, size_t offset, size_t len); diff --git a/include/haproxy/xprt_quic-t.h b/include/haproxy/xprt_quic-t.h index 91ff570322..a983733941 100644 --- a/include/haproxy/xprt_quic-t.h +++ b/include/haproxy/xprt_quic-t.h @@ -743,6 +743,10 @@ struct quic_conn { /* RX buffer */ struct buffer buf; struct list pkt_list; + struct { + /* Number of open or closed streams */ + uint64_t nb_streams; + } strms[QCS_MAX_TYPES]; } rx; struct { struct quic_tls_kp prv_rx; diff --git a/src/mux_quic.c b/src/mux_quic.c index db16ca0cf8..e129df818a 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -123,7 +123,7 @@ struct qcs *qcs_new(struct qcc *qcc, uint64_t id, enum qcs_type type) * TODO qc_stream_desc is only useful for Tx buffering. It should not * be required for unidirectional remote streams. */ - qcs->stream = qc_stream_desc_new(id, qcs, qcc->conn->handle.qc); + qcs->stream = qc_stream_desc_new(id, type, qcs, qcc->conn->handle.qc); if (!qcs->stream) goto err; diff --git a/src/quic_stream.c b/src/quic_stream.c index bb96738798..3a7aed156e 100644 --- a/src/quic_stream.c +++ b/src/quic_stream.c @@ -20,7 +20,7 @@ DECLARE_STATIC_POOL(pool_head_quic_conn_stream_buf, "qc_stream_buf", * * Returns the newly allocated instance on success or else NULL. */ -struct qc_stream_desc *qc_stream_desc_new(uint64_t id, void *ctx, +struct qc_stream_desc *qc_stream_desc_new(uint64_t id, enum qcs_type type, void *ctx, struct quic_conn *qc) { struct qc_stream_desc *stream; @@ -31,6 +31,7 @@ struct qc_stream_desc *qc_stream_desc_new(uint64_t id, void *ctx, stream->by_id.key = id; eb64_insert(&qc->streams_by_id, &stream->by_id); + qc->rx.strms[type].nb_streams++; stream->qc = qc; stream->buf = NULL; diff --git a/src/xprt_quic.c b/src/xprt_quic.c index 778f1971c0..a83fb0c1c9 100644 --- a/src/xprt_quic.c +++ b/src/xprt_quic.c @@ -4365,6 +4365,8 @@ static struct quic_conn *qc_new_conn(unsigned int version, int ipv4, /* RX part. */ qc->rx.bytes = 0; qc->rx.buf = b_make(buf_area, QUIC_CONN_RX_BUFSZ, 0, 0); + for (i = 0; i < QCS_MAX_TYPES; i++) + qc->rx.strms[i].nb_streams = 0; qc->nb_pkt_for_cc = 1; qc->nb_pkt_since_cc = 0;