]> git.kaiwu.me - haproxy.git/commit
MEDIUM: resolvers: retry truncated UDP responses over TCP
authorManu Nicolas <e.nicolas@criteo.com>
Wed, 2 Sep 2026 10:09:14 +0000 (10:09 +0000)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 2 Sep 2026 11:41:18 +0000 (13:41 +0200)
commitbc20f8c0bce282fca58009db721f00c3dc2fb690
treef917acacd3a1196f71b685e6db6f6dfb9255e0da
parent9909d634c5f7113c959e882ed336854ba86e6dd2
MEDIUM: resolvers: retry truncated UDP responses over TCP

RFC 1123 and RFC 2181 recommend retrying a truncated DNS response
over a transport capable of carrying a larger message. HAProxy instead
treats TC as a resolver error unless the nameserver is configured to
use TCP for every query.

Give unprefixed IPv4, IPv6 and hostname nameservers both a datagram and
a stream server. Queries use UDP first and the existing stream code
opens TCP connections lazily. Explicit datagram prefixes remain
UDP-only, explicit stream prefixes remain TCP-only, and nameservers
loaded from resolv.conf gain the default fallback behavior.

When a valid UDP response is truncated, rebuild its query over TCP with
the same ID, question type and nameserver. Taking the type from the
response preserves late A or AAAA responses received after a query-type
switch. Queueing the fallback refreshes the retry deadline without
consuming a retry or initiating another A/AAAA switch.

A truncated SRV response can still be partially processed when no TCP
fallback can be initiated for that response. This preserves existing
behavior for explicit UDP and TCP nameservers and processes a partial
SRV response received during TCP fallback. Other truncated TCP
responses follow the normal error path, and no TCP response triggers
another fallback.

Failed queue operations use the existing send-error path, while
connection failures are handled by the resolver timeout and retry path.

Add a tcp_fallback counter to the CLI, resolver statistics and
Prometheus output. It counts fallback queries successfully queued to the
stream server.
addons/promex/README
doc/configuration.txt
include/haproxy/dns-t.h
include/haproxy/dns.h
include/haproxy/resolvers-t.h
src/resolvers.c