From: Olivier Houchard Date: Thu, 19 Nov 2026 17:00:34 +0000 (+0100) Subject: BUG/MEDIUM: quic: refuse handshakes completed after the listener unbind X-Git-Url: https://git.kaiwu.me/web/%22data:,/doc/static/gitweb.js?a=commitdiff_plain;h=f569d81646c47c851bb66a895f5160f3edbf69f5;p=haproxy.git BUG/MEDIUM: quic: refuse handshakes completed after the listener unbind QUIC connections are accepted once their handshake is complete. When a soft-stop unbinds the listener in the meantime, the connection is still queued, but listener_accept() does not call accept_conn() anymore on the unbound receiver. The connection never gets its mux and the client waits until its timeout, while the stopping process keeps it until its idle timeout and quic_accept_run() wakes itself up in a loop, using 100% of a thread. Let's close such connections with a CONNECTION_REFUSED error instead, when their handshake completes on an unbound listener, or when they are still queued once it is unbound. The client gets the error right after its handshake and the stopping process can leave. This was introduced in 2.8 with the soft-stop support for connections with their own socket, by commit fb375574f ("MINOR: quic: mark quic-conn as jobs on socket allocation"). It should be backported to all stable versions. This was reported in GitHub issue #3578. --- diff --git a/src/quic_sock.c b/src/quic_sock.c index 2af4b8f3e..de665d5f8 100644 --- a/src/quic_sock.c +++ b/src/quic_sock.c @@ -1078,6 +1078,16 @@ void qc_want_recv(struct quic_conn *qc) /* per-thread accept queues */ struct quic_accept_queue *quic_accept_queues; +/* Closes whose handshake is complete but which cannot be accepted + * anymore. + */ +static void quic_accept_refuse_qc(struct quic_conn *qc) +{ + TRACE_STATE("refusing connection on unbound listener", QUIC_EV_CONN_CLOSE, qc); + quic_set_connection_close(qc, quic_err_transport(QC_ERR_CONNECTION_REFUSED)); + tasklet_wakeup(qc->wait_event.tasklet); +} + /* Install on the queue ready to be accepted. The queue task is then woken * up. */ @@ -1091,9 +1101,15 @@ void quic_accept_push_qc(struct quic_conn *qc) BUG_ON(qc->flags & QUIC_FL_CONN_ACCEPT_REGISTERED); BUG_ON(MT_LIST_INLIST(&qc->accept_list)); - HA_ATOMIC_INC(&l->rx.quic_curr_accept); - qc->flags |= QUIC_FL_CONN_ACCEPT_REGISTERED; + + /* the listener was unbound meanwhile, e.g. by a soft-stop */ + if (!(l->rx.flags & RX_F_BOUND)) { + quic_accept_refuse_qc(qc); + return; + } + + HA_ATOMIC_INC(&l->rx.quic_curr_accept); /* 1. insert the listener in the accept queue * * Use TRY_APPEND as there is a possible race even with INLIST if @@ -1120,7 +1136,19 @@ struct task *quic_accept_run(struct task *t, void *ctx, unsigned int i) struct quic_accept_queue *queue = &quic_accept_queues[tid]; MT_LIST_FOR_EACH_ENTRY_LOCKED(lthr, &queue->listeners, quic_accept.list, back) { - listener_accept(lthr->li); + if (!(lthr->li->rx.flags & RX_F_BOUND)) { + struct quic_conn *qc; + + /* the listener was unbound, nothing can be accepted anymore */ + while ((qc = MT_LIST_POP(<hr->quic_accept.conns, struct quic_conn *, accept_list))) { + BUG_ON(lthr->li->rx.quic_curr_accept <= 0); + HA_ATOMIC_DEC(<hr->li->rx.quic_curr_accept); + quic_accept_refuse_qc(qc); + } + } + else + listener_accept(lthr->li); + if (!MT_LIST_ISEMPTY(<hr->quic_accept.conns)) { /* entry is left in queue */ tasklet_wakeup((struct tasklet*)t);