]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: Do not allocate too much ack ranges
authorFrédéric Lécaille <flecaille@haproxy.com>
Mon, 17 Apr 2023 12:10:14 +0000 (14:10 +0200)
committerFrédéric Lécaille <flecaille@haproxy.com>
Wed, 19 Apr 2023 09:36:54 +0000 (11:36 +0200)
Limit the maximum number of ack ranges to QUIC_MAX_ACK_RANGES(32).

Must be backported to 2.6 and 2.7.

include/haproxy/quic_conn-t.h
src/quic_conn.c

index 26fd60b8e40c59e1079c5938ed94ca51a1370784..113cc61bbfdab27167040a680e716f04fe5986f5 100644 (file)
@@ -321,6 +321,9 @@ struct quic_arng_node {
        uint64_t last;
 };
 
+/* The maximum number of ack ranges to be built in ACK frames */
+#define QUIC_MAX_ACK_RANGES   32
+
 /* Structure to maintain a set of ACK ranges to be used to build ACK frames. */
 struct quic_arngs {
        /* ebtree of ACK ranges organized by their first value. */
index 2992ba0a964f7dd36ec48b703f596d159405da5b..86fcc1e0e4c408a0df8e23c7048750c07ebe4e97 100644 (file)
@@ -4246,6 +4246,16 @@ struct quic_arng_node *quic_insert_new_range(struct quic_conn *qc,
 
        TRACE_ENTER(QUIC_EV_CONN_RXPKT, qc);
 
+       if (arngs->sz >= QUIC_MAX_ACK_RANGES) {
+               struct eb64_node *last;
+
+               last = eb64_last(&arngs->root);
+               BUG_ON(last == NULL);
+               eb64_delete(last);
+               pool_free(pool_head_quic_arng, last);
+               arngs->sz--;
+       }
+
        new_ar = pool_alloc(pool_head_quic_arng);
        if (!new_ar) {
                TRACE_ERROR("ack range allocation failed", QUIC_EV_CONN_RXPKT, qc);