]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: Do not try to accept a connection more than one time
authorFrédéric Lécaille <flecaille@haproxy.com>
Fri, 28 Jan 2022 20:43:48 +0000 (21:43 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 31 Jan 2022 15:40:23 +0000 (16:40 +0100)
We add a new flag to mark a connection as already enqueued for acception.
This is useful for 0-RTT session where a connection is first enqueued for
acception as soon as 0-RTT RX secrets could be derived. Then as for any other
connection, we could accept one more time this connection after handshake
completion which lead to very bad side effects.

Thank you to Amaury for this nice patch.

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

index 157d81d45688e62b3a8e08cd64257cb8b91aaf40..0f1004fd8428373c8db99966ded779c7075b9b1f 100644 (file)
@@ -657,6 +657,8 @@ enum qc_mux_state {
 
 #define QUIC_FL_POST_HANDSHAKE_FRAMES_BUILT     (1U << 2)
 #define QUIC_FL_CONN_LISTENER                   (1U << 3)
+#define QUIC_FL_ACCEPT_REGISTERED_BIT                  4
+#define QUIC_FL_ACCEPT_REGISTERED               (1U << QUIC_FL_ACCEPT_REGISTERED_BIT)
 #define QUIC_FL_CONN_IMMEDIATE_CLOSE            (1U << 31)
 struct quic_conn {
        /* The quic_conn instance is refcounted as it can be used by threads
index 5533b01d5ea31e83197c78634f9b146ad834bd10..087a65dedb0402fc090f10b163efd29db389bcfa 100644 (file)
@@ -255,13 +255,19 @@ void quic_sock_fd_iocb(int fd)
 struct quic_accept_queue *quic_accept_queues;
 
 /* Install <qc> on the queue ready to be accepted. The queue task is then woken
- * up.
+ * up. If <qc> accept is already scheduled or done, nothing is done.
  */
 void quic_accept_push_qc(struct quic_conn *qc)
 {
        struct quic_accept_queue *queue = &quic_accept_queues[qc->tid];
        struct li_per_thread *lthr = &qc->li->per_thr[qc->tid];
 
+       /* early return if accept is already in progress/done for this
+        * connection
+        */
+       if (HA_ATOMIC_BTS(&qc->flags, QUIC_FL_ACCEPT_REGISTERED_BIT))
+               return;
+
        BUG_ON(MT_LIST_INLIST(&qc->accept_list));
 
        /* 1. insert the listener in the accept queue