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.
M
Manu Nicolas committed
bc20f8c0bce282fca58009db721f00c3dc2fb690
Parent: 9909d63
Committed by Christopher Faulet <cfaulet@haproxy.com>
on 9/2/2026, 11:41:18 AM