]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic-be: Do not redispatch the datagrams
authorFrederic Lecaille <flecaille@haproxy.com>
Wed, 10 Jan 2024 10:10:36 +0000 (11:10 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 11 Jun 2025 16:37:34 +0000 (18:37 +0200)
The QUIC datagram redispatch is there to counter the race condition which
exists only for QUIC connections to listener where datagrams may arrive
on the wrong socket between the bind() and connect() calls.
Run this code part only for listeners.

src/quic_sock.c

index 4cd9317cc42e9c9eec8e1f0087f8bcb0c74c6ad0..6aabb24a18378103e0634bdba8a91a4e00ef834a 100644 (file)
@@ -818,14 +818,12 @@ int qc_rcv_buf(struct quic_conn *qc)
        struct quic_dgram *new_dgram = NULL;
        struct buffer buf = BUF_NULL;
        unsigned char *dgram_buf;
-       struct listener *l;
        ssize_t ret = 0;
 
        /* Do not call this if quic-conn FD is uninitialized. */
        BUG_ON(qc->fd < 0);
 
        TRACE_ENTER(QUIC_EV_CONN_RCV, qc);
-       l = qc->li;
 
        do {
                if (!b_alloc(&buf, DB_MUX_RX))
@@ -871,7 +869,7 @@ int qc_rcv_buf(struct quic_conn *qc)
                        continue;
                }
 
-               if (!qc_check_dcid(qc, new_dgram->dcid, new_dgram->dcid_len)) {
+               if (qc_is_listener(qc) && !qc_check_dcid(qc, new_dgram->dcid, new_dgram->dcid_len)) {
                        /* Datagram received by error on the connection FD, dispatch it
                         * to its associated quic-conn.
                         *
@@ -881,6 +879,7 @@ int qc_rcv_buf(struct quic_conn *qc)
                        struct quic_dgram *tmp_dgram;
                        unsigned char *rxbuf_tail;
                        size_t cspace;
+                       struct listener *l = qc->li;
 
                        TRACE_STATE("datagram for other connection on quic-conn socket, requeue it", QUIC_EV_CONN_RCV, qc);