]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: Delete the ODCIDs asap
authorFrédéric Lécaille <flecaille@haproxy.com>
Tue, 30 Nov 2021 11:01:32 +0000 (12:01 +0100)
committerFrédéric Lécaille <flecaille@haproxy.com>
Tue, 30 Nov 2021 11:01:32 +0000 (12:01 +0100)
As soon as the connection ID (the one choosen by the QUIC server) has been used
by the client, we can delete its original destination connection ID from its tree.

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

index cd2a2c804329aaeb6f708a5e03de66da79193b15..ec18c1ec67ad3506e478bf08cd76bf8a491d31fc 100644 (file)
@@ -619,6 +619,8 @@ struct rxbuf {
 #define QUIC_FL_PKTNS_ACK_REQUIRED  (1UL << QUIC_FL_PKTNS_ACK_REQUIRED_BIT)
 
 #define QUIC_FL_CONN_ANTI_AMPLIFICATION_REACHED (1U << 1)
+#define QUIC_FL_CONN_ODCID_NODE_TO_DELETE_BIT 2
+#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 9732ec17dfdbd302cbfcafb27726de208b0227af..c7056c07a4dc4c18b59eb9ad5be28aea0b93903f 100644 (file)
@@ -3996,6 +3996,7 @@ static ssize_t qc_lstnr_pkt_rcv(unsigned char **buf, const unsigned char *end,
                        HA_RWLOCK_WRLOCK(QUIC_LOCK, &l->rx.cids_lock);
                        /* Insert the DCID the QUIC client has chosen (only for listeners) */
                        n = ebmb_insert(&l->rx.odcids, &qc->odcid_node, qc->odcid.len);
+                       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
@@ -4025,6 +4026,12 @@ static ssize_t qc_lstnr_pkt_rcv(unsigned char **buf, const unsigned char *end,
                        else {
                                struct quic_connection_id *cid = ebmb_entry(node, struct quic_connection_id, node);
                                qc = cid->qc;
+                               if (HA_ATOMIC_BTR(&qc->flags, QUIC_FL_CONN_ODCID_NODE_TO_DELETE_BIT)) {
+                                       /* Delete the ODCID from its tree */
+                                       HA_RWLOCK_WRLOCK(QUIC_LOCK, &l->rx.cids_lock);
+                                       ebmb_delete(&qc->odcid_node);
+                                       HA_RWLOCK_WRUNLOCK(QUIC_LOCK, &l->rx.cids_lock);
+                               }
                        }
                        pkt->qc = qc;
                        if (HA_ATOMIC_LOAD(&qc->conn))