]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: proto_reverse_connect: fix preconnect with startup name resolution
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 21 Sep 2023 13:44:17 +0000 (15:44 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 21 Sep 2023 14:57:30 +0000 (16:57 +0200)
addr member of server structure is not set consistently depending on the
server address type. When using <IP:PORT> notation, its port is properly
set. However, when using <HOSTNAME:PORT>, only IP address is set after
startup name resolution but its port is left to 0.

This behavior causes preconnect to not be functional when using server
with hostname for startup name resolution. Indeed, only srv.addr is used
as connect argument through function new_reverse_conn(). To fix this,
rely on srv.svc_port : this member is always set for servers using IP or
hostname. This is similar to connect_server() on the backend side.

This does not need to be backported.

src/proto_reverse_connect.c

index 66bcb8ba0fb83e06570ae40b6ad530ff9de5b7f2..efaf81507de425dd0202abeb06c32d75c4a3ffc3 100644 (file)
@@ -62,6 +62,7 @@ static struct connection *new_reverse_conn(struct listener *l, struct server *sr
        if (!conn->dst)
                goto err;
        *conn->dst = srv->addr;
+       set_host_port(conn->dst, srv->svc_port);
 
        if (conn_prepare(conn, protocol_lookup(conn->dst->ss_family, PROTO_TYPE_STREAM, 0), srv->xprt))
                goto err;