From: Remi Gacogne Date: Tue, 12 Mar 2024 13:59:25 +0000 (+0100) Subject: dnsdist: Fix first IPv6 console connection being rejected X-Git-Tag: rec-5.1.0-alpha1~124^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1a9b7f5a97e97e371bd4b6043c14d9faccb9013c;p=thirdparty%2Fpdns.git 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. --- 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());