diff --git a/include/haproxy/quic_stream.h b/include/haproxy/quic_stream.h index 0550f4f0c..1107e86f2 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 91ff57032..a98373394 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 db16ca0cf..e129df818 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 bb9673879..3a7aed156 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 778f1971c..a83fb0c1c 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;