]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: server: Use the configured address family for the initial resolution
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 20 Dec 2023 11:21:57 +0000 (12:21 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 20 Dec 2023 11:21:59 +0000 (12:21 +0100)
A regression was introduced by the commit c886fb58eb ("MINOR: server/ip:
centralize server ip updates"). The configured address family is lost when the
server address is initialized during the startup, for the resolution based on
the libc or based on the server state-file. Thus, "ipv4@" and "ipv6@" prefixed
are ignored.

To fix the bug, we take care to use the configured address family before calling
str2ip2() in srv_apply_lastaddr() and srv_apply_via_libc() functions.

This patch should fix the issue #2393. It must be backported to 2.9.

src/server.c

index 0824ae695629f1f871ccfc40d3fe7ae4195cea01..8dc57f10f3b4e7c273cb50f56d1fc458fa169047 100644 (file)
@@ -4433,6 +4433,9 @@ int srv_set_addr_via_libc(struct server *srv, int *err_code)
        struct sockaddr_storage new_addr;
 
        memset(&new_addr, 0, sizeof(new_addr));
+
+       /* Use the preferred family, if configured */
+       new_addr.ss_family = srv->addr.ss_family;
        if (str2ip2(srv->hostname, &new_addr, 1) == NULL) {
                if (err_code)
                        *err_code |= ERR_WARN;
@@ -4517,6 +4520,9 @@ static int srv_apply_lastaddr(struct server *srv, int *err_code)
        struct sockaddr_storage new_addr;
 
        memset(&new_addr, 0, sizeof(new_addr));
+
+       /* Use the preferred family, if configured */
+       new_addr.ss_family = srv->addr.ss_family;
        if (!str2ip2(srv->lastaddr, &new_addr, 0)) {
                if (err_code)
                        *err_code |= ERR_WARN;