From: Aurelien DARRAGON Date: Thu, 9 Nov 2023 14:00:34 +0000 (+0100) Subject: BUG/MINOR: sink: don't learn srv port from srv addr X-Git-Tag: v2.9-dev10~97 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d710dfbaccf6a9c1aa969319849ed67dac29c154;p=thirdparty%2Fhaproxy.git BUG/MINOR: sink: don't learn srv port from srv addr Since 04276f3d ("MEDIUM: server: split the address and the port into two different fields") we should not use srv->addr to store server's port and rely on srv->svc_port instead. For sink servers, we correctly set >svc_port upon server creation but we didn't use it when initializing address for the connection. As a result, FQDN resolution will not work properly with sink servers. Hopefully, this used to work by accident because sink servers were resolved using the PA_O_RESOLVE flag in str2sa_range(), which made the srv->addr contain the port in addition to the address. But this will fail to work when FQDN resolution is postponed because only ->svc_port will contain the proper server port upon resolution. For instance, FQDN resolution with servers from log backends (which are resolved as regular servers, that is, without the PA_O_RESOLVE) will fail to work because of this. This may be backported as far as 2.2 even though the bug didn't have noticeable effects for versions below 2.9 [In 2.2, sink_forward_session_init() didn't exist it should be applied in sink_forward_session_create()] --- diff --git a/src/sink.c b/src/sink.c index 42c15b4906..555752f2e8 100644 --- a/src/sink.c +++ b/src/sink.c @@ -577,6 +577,8 @@ static int sink_forward_session_init(struct appctx *appctx) if (!sockaddr_alloc(&addr, &sft->srv->addr, sizeof(sft->srv->addr))) goto out_error; + /* srv port should be learned from srv->svc_port not from srv->addr */ + set_host_port(addr, sft->srv->svc_port); if (appctx_finalize_startup(appctx, sft->srv->proxy, &BUF_NULL) == -1) goto out_free_addr;