]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: Make the quic_conn be aware of the number of streams
authorFrédéric Lécaille <flecaille@haproxy.com>
Mon, 2 May 2022 16:46:58 +0000 (18:46 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 3 May 2022 08:13:40 +0000 (10:13 +0200)
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.

include/haproxy/quic_stream.h
include/haproxy/xprt_quic-t.h
src/mux_quic.c
src/quic_stream.c
src/xprt_quic.c

index 0550f4f0c3181ce9c6370fd84d25383103387259..1107e86f2e52874e04ec55a28fcc311720662f62 100644 (file)
@@ -3,11 +3,12 @@
 
 #ifdef USE_QUIC
 
+#include <haproxy/mux_quic-t.h>
 #include <haproxy/quic_stream-t.h>
 
 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);
index 91ff5703221828837ee91cd3dadd1ccc38b6e1b8..a983733941063a2cf52d0c6fe895e93acf0be6fa 100644 (file)
@@ -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;
index db16ca0cf8873aa6d85cb54f9411cd45666123da..e129df818acc6940e57dfe88fac7cdcf4433a7fa 100644 (file)
@@ -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;
 
index bb96738798e1fd00bb7fb4c4ef27692154450857..3a7aed156ee16e23682345aa0e7446296761d689 100644 (file)
@@ -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;
index 778f1971c0bbbe0d9f8defdf7b3b2301e4967e52..a83fb0c1c903f4dbd7381869e04e0c63df4b8c20 100644 (file)
@@ -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;