]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: dns: don't call connect to dest socket for AF_INET*
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Wed, 13 Aug 2025 13:48:47 +0000 (15:48 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 19 Aug 2025 09:26:02 +0000 (11:26 +0200)
commit2c7e05f80e3b4bacad84eb213b9db3bc5d8963dc
treeea04a53609dec17a9a5d929d486dfa267b338b9e
parent8ac54cafcda749a5b50532b3a10d39a5a37ce9b3
MEDIUM: dns: don't call connect to dest socket for AF_INET*

When we perform connect call for a datagram socket, used to send DNS requests,
we set for it the default destination address to some given nameserver. Then we
simply use send(), as the destination address is already set. In some usecases
described in GitHub issues #3001 and #2654, this approach becames inefficient,
nameservers change its IP addresses dynamically, this triggers DNS resolution
errors.

To fix this, let's perform the bind() on the wildcard address for the datagram
AF_INET* client socket. Like this we will allocate a port for it. Then let's
use sendto() instead of send().

If the nameserver is local and is listening on the UNIX domain socket, we
continue to use the existed approach (connect() and then send()).

This fixes issues #3001 and #2654.
This may be backported in all stable versions.
src/dns.c