]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: str2ip: make getaddrinfo() consider local address selection policy
authorDmitry Sivachenko <trtrmitya@gmail.com>
Thu, 1 Oct 2015 23:01:58 +0000 (01:01 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 1 Oct 2015 23:01:58 +0000 (01:01 +0200)
When first parameter to getaddrinfo() is not NULL (it is always not NULL
in str2ip()), on Linux AI_PASSIVE value for ai_flags is ignored. On
FreeBSD, when AI_PASSIVE is specified and hostname parameter is not NULL,
getaddrinfo() ignores local address selection policy, always returning
AAAA record. Pass zero ai_flags to behave correctly on FreeBSD, this
change should be no-op for Linux.

This fix should be backported to 1.5 as well, after some observation
period.

src/standard.c

index a468700b1973fc4e4d30112efef4709d74545b1b..b5f4bf40462f4adacbfcff9dd34ff18ea1ed1778 100644 (file)
@@ -665,7 +665,7 @@ struct sockaddr_storage *str2ip2(const char *str, struct sockaddr_storage *sa, i
                memset(&hints, 0, sizeof(hints));
                hints.ai_family = sa->ss_family ? sa->ss_family : AF_UNSPEC;
                hints.ai_socktype = SOCK_DGRAM;
-               hints.ai_flags = AI_PASSIVE;
+               hints.ai_flags = 0;
                hints.ai_protocol = 0;
 
                if (getaddrinfo(str, NULL, &hints, &result) == 0) {