]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: quic: Do not use another thread group's listener FD
authorOlivier Houchard <ohouchard@haproxy.com>
Wed, 29 Jul 2026 23:03:51 +0000 (01:03 +0200)
committerOlivier Houchard <cognet@ci0.org>
Thu, 30 Jul 2026 11:36:17 +0000 (13:36 +0200)
A datagram may be read by a thread of another group than the one owning
the connection it is for, and with per-thread-group file descriptor
tables, we can't assume that we can use that file descriptor, so find a
more fitting one if needed.

src/quic_rx.c

index 932058f0c086779648b02d4949f88381f3ac34f1..49db1f10ec2f6ac009335d846929aee43d24e410 100644 (file)
@@ -2429,6 +2429,24 @@ int quic_dgram_parse(struct quic_dgram *dgram, struct quic_conn *from_qc,
 
        TRACE_ENTER(QUIC_EV_CONN_LPKT);
 
+       /*
+        * Make sure we have a usable file descriptor. When each thread
+        * group has its own file descriptor tables, we can't just assume
+        * we can use the current listener, so find a more fitting one if
+        * needed.
+        */
+       if (li && (global.tune.options & GTUNE_NO_TG_FD_SHARING) &&
+           li->rx.bind_tgroup != tgid) {
+               struct listener *l2;
+
+               list_for_each_entry(l2, &li->bind_conf->listeners, by_bind) {
+                       if (l2->rx.bind_tgroup == tgid) {
+                               li = l2;
+                               break;
+                       }
+               }
+       }
+
        pos = dgram->buf;
        end = pos + dgram->len;
        do {
@@ -2458,7 +2476,8 @@ int quic_dgram_parse(struct quic_dgram *dgram, struct quic_conn *from_qc,
                        pkt->flags |= QUIC_FL_RX_PACKET_DGRAM_FIRST;
 
                quic_rx_packet_refinc(pkt);
-               if (quic_rx_pkt_parse(from_qc, pkt, pos, end, dgram, o))
+               if (quic_rx_pkt_parse(from_qc, pkt, pos, end, dgram,
+                                     li ? &li->obj_type : o))
                        goto next;
 
                /* Search quic-conn instance for first packet of the datagram.