]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: simplify the removal from ODCID tree
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 16 Dec 2021 15:15:18 +0000 (16:15 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 17 Dec 2021 09:59:36 +0000 (10:59 +0100)
With the DCID refactoring, the locking is more centralized. It is
possible to simplify the code for removal of a quic_conn from the ODCID
tree.

This operation can be conducted as soon as the connection has been
retrieved from the DCID tree, meaning that the peer now uses the final
DCID. Remove the bit to flag a connection for removal and just uses
ebmb_delete() on each sucessful lookup on the DCID tree. If the
quic_conn has already been removed, it is just a noop thanks to
eb_delete() implementation.

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

index 4651f018cf18afdd52ee029231a9b0a6648304a7..51b45871aead03227f02d389f74682cf67e16e88 100644 (file)
@@ -616,8 +616,6 @@ struct rxbuf {
 
 /* Flags at connection level */
 #define QUIC_FL_CONN_ANTI_AMPLIFICATION_REACHED (1U << 0)
-#define QUIC_FL_CONN_ODCID_NODE_TO_DELETE_BIT 1
-#define QUIC_FL_CONN_ODCID_NODE_TO_DELETE       (1U << QUIC_FL_CONN_ODCID_NODE_TO_DELETE_BIT)
 #define QUIC_FL_CONN_IMMEDIATE_CLOSE            (1U << 31)
 struct quic_conn {
        uint32_t version;
index 8e0234f68d516e3844bc8edad113a0b2d2c79af1..9c6ca9c122e111d9507648d2e695f843e3000ff6 100644 (file)
@@ -3927,8 +3927,7 @@ static struct quic_conn *qc_retrieve_conn_from_cid(struct quic_rx_packet *pkt,
        /* If found in DCIDs tree, remove the quic_conn from the ODCIDs tree.
         * If already done, this is a noop.
         */
-       if (HA_ATOMIC_BTR(&qc->flags, QUIC_FL_CONN_ODCID_NODE_TO_DELETE_BIT))
-               ebmb_delete(&qc->odcid_node);
+       ebmb_delete(&qc->odcid_node);
 
  end:
        HA_RWLOCK_RDUNLOCK(QUIC_LOCK, &l->rx.cids_lock);
@@ -4093,7 +4092,6 @@ static ssize_t qc_lstnr_pkt_rcv(unsigned char **buf, const unsigned char *end,
                        /* Insert the DCID the QUIC client has chosen (only for listeners) */
                        n = ebmb_insert(&l->rx.odcids, &qc->odcid_node,
                                        qc->odcid.len + qc->odcid.addrlen);
-                       HA_ATOMIC_OR(&qc->flags, QUIC_FL_CONN_ODCID_NODE_TO_DELETE);
                        HA_RWLOCK_WRUNLOCK(QUIC_LOCK, &l->rx.cids_lock);
 
                        /* If the insertion failed, it means that another