#3503·haproxy

QUIC wildcard bind: Retry/Stateless Reset/Version Negotiation don't apply IP_PKTINFO source address correction

Author: ygkatCreated Sep 22, 2026Updated Sep 22, 2026

Detailed Description of the Problem

On a wildcard QUIC bind (e.g. bind quic4@:443), the three pre-connection response paths (RFC 9000 Retry, Stateless Reset, and Version Negotiation) send their reply with whatever source address the kernel's route lookup happens to pick, instead of the actual destination address the client's packet targeted. This is fine on a single-address host, but breaks behind IPVS/DR, NAT, anycast, or any multi-VIP setup where the datagram's ingress destination differs from the host's default egress source: a real client using a connected UDP socket (as Chrome/quiche and Firefox/neqo both do) silently drops the reply because its source doesn't match what it sent to, and the handshake hangs.

Commit 2d380926b ("MEDIUM: quic-sock: fix udp source address for send on listener socket", 2023-01-19) already fixed exactly this class of problem, but only for the qc_snd_buf() send path used once a quic_conn exists. The three functions below run before any quic_conn is created, so qc_may_use_saddr() / qc->local_addr / cmsg_set_saddr() are all unreachable from them, and none was ever updated to match. All three use a bare sendto() on src/quic_tx.c, with no ancillary data:

The correct destination address is already available at every one of these call sites: quic_recv() captures it via IP_PKTINFO/IPV6_PKTINFO into dgram->daddr at receive time (quic_sock.c:296, :537, :891; field defined quic_sock-t.h:41), and that same dgram is passed down to all three functions. They just never look at daddr, only at dgram->saddr (the client's address, used correctly as the sendto destination).

Confirmed present, unchanged, on both v3.2.23 and current master (3.5-dev7).

Expected Behavior

A reply from a wildcard QUIC listener should carry the client's original destination address as its source, the same way qc_snd_buf() already does. This should hold for Retry, Stateless Reset, and Version Negotiation too, since the destination is already captured and available at each call site.

Steps to Reproduce the Behavior

Reproduced with an ordinary, unmodified QUIC client (no packet-level manipulation) in a Linux container topology shaped like IPVS Direct Routing (a "VIP" address assigned to lo, client in a separate network namespace):

  1. Wildcard-only QUIC bind (bind quic4@:443 ssl crt ... alpn h3), tune.quic.retry-threshold 2 (so Retry triggers reliably at low concurrency instead of needing 100+ half-open connections).
  2. 40 concurrent QUIC handshakes from a real client (aioquic 1.3.0) targeting the VIP, no quic-force-retry needed.
  3. Capture on the loopback interface: every Retry packet carries the host's default-route source instead of the VIP; every other packet (Initial, Handshake, 1-RTT) is correct:
quic_retry_sent: 59
server->client packets by (source addr, quic packet type):
     59 10.10.0.1  first_pkt=Retry        <- wrong source (host default route addr)
     45 10.20.0.7  first_pkt=1-RTT/Short  <- correct (VIP)
     54 10.20.0.7  first_pkt=Handshake    <- correct (VIP)
     38 10.20.0.7  first_pkt=Initial      <- correct (VIP)
  1. To confirm this breaks a real client, not just packet contents: emulated a connected-UDP-socket client (what Chrome/quiche and Firefox/neqo use, unlike aioquic which doesn't connect() its socket and is more permissive) via iptables -A INPUT -p udp --sport 443 ! -s <VIP> -j DROP in the client namespace. Under the same load, the client got stuck retrying indefinitely and never completed the handshake, identically under both tune.quic.socket-owner connection (default) and listener.
  2. Same load with an explicit non-wildcard bind (bind quic4@"<VIP>:443") instead: handshake completed every time.

Ruled out: a destination not locally bindable at all (kernel drops the packet before HAProxy sees it, a different failure mode); a qc->local_addr population race on the normal post-handshake path (60 concurrent connections across 2 VIPs, 117/117 correct); and the shards bind keyword (irrelevant, pure SO_REUSEPORT/IRQ-affinity feature). Not tested: connection migration and 0-RTT resumption (both should route through the already-fixed qc_snd_buf() path, unverified).

Do you have any idea what may have caused this?

Unknown whether this was an intentional scoping decision or an oversight. The fix only touched qc_snd_buf(), and the three functions above still don't use the destination address that's already sitting in dgram->daddr at their call sites. If there's a reason they're intentionally excluded (e.g. some constraint on responding to unauthenticated/pre-validation traffic we're not aware of), we'd appreciate understanding it.

Do you have an idea how to solve the issue?

Thread dgram->daddr into the three functions (send_stateless_reset() already has the listener and could reach it directly; the other two only take a bare fd today) and use sendmsg() with an IP_PKTINFO/IPV6_PKTINFO cmsg via the existing cmsg_set_saddr() helper, gated the same way qc_may_use_saddr() gates the connection-path fix (wildcard-bound listener only; not usable on FreeBSD per the existing comment there).

We wanted to report the finding first rather than propose a specific patch, since the exact approach for threading the destination through send_retry()/send_version_negotiation()'s signatures may be something the maintainers have a preferred way to handle.

What is your configuration?

The production configuration that led us to investigate this uses explicit per-VIP binds alongside the wildcard one specifically to work around this issue:

haproxy
bind quic4@:443 ssl crt-list /path/to/crt-list.txt alpn h3
bind quic4@"${vip0}:443" ssl crt-list /path/to/crt-list.txt alpn h3 shards "${irq_cnt}"

The repro itself only needs a minimal wildcard-only frontend plus tune.quic.retry-threshold 2 as shown in the reproduction steps above.

Output of haproxy -vv

Reproduced on a plain, unpatched build of the v3.2.23 tag with USE_OPENSSL=1 USE_QUIC=1 (+QUIC +OPENSSL +SSL), and independently confirmed present in current master (3.5-dev7) by reading the source.

Last Outputs and Backtraces

Not applicable, this is a source-address correctness bug, not a crash.

Additional Information

  • tune.quic.retry-threshold has no bounds check at parse time, and the trigger is half_open_conn >= threshold, so 0 means Retry is sent unconditionally.
  • send_stateless_reset() has no way to be disabled short of no-quic (turns off QUIC entirely), and triggers easily on any reload, since clients holding pre-reload connection IDs will hit it.
  • Happy to share the container-based repro setup (netns/veth topology, HAProxy config, aioquic client driver) if useful.