From 1a9b7f5a97e97e371bd4b6043c14d9faccb9013c Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Tue, 12 Mar 2024 14:59:25 +0100 Subject: [PATCH] dnsdist: Fix first IPv6 console connection being rejected If we don't set the family of the client IP address, `ComboAddress::getSocklen()` will return the size of an IPv4 struct and thus the first IPv6 client address will get truncated. Subsequent connections will be fine because the family will have been set to IPv6. --- pdns/dnsdistdist/dnsdist-console.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pdns/dnsdistdist/dnsdist-console.cc b/pdns/dnsdistdist/dnsdist-console.cc index a175cae261..0828dcaa77 100644 --- a/pdns/dnsdistdist/dnsdist-console.cc +++ b/pdns/dnsdistdist/dnsdist-console.cc @@ -1034,6 +1034,11 @@ void controlThread(std::shared_ptr acceptFD, ComboAddress local) try { setThreadName("dnsdist/control"); ComboAddress client; + // make sure that the family matches the one from the listening IP, + // so that getSocklen() returns the correct size later, otherwise + // the first IPv6 console connection might get refused + client.sin4.sin_family = local.sin4.sin_family; + int sock{-1}; auto localACL = g_consoleACL.getLocal(); infolog("Accepting control connections on %s", local.toStringWithPort()); -- 2.47.2