From: Remi Gacogne Date: Sat, 25 Jun 2016 15:08:45 +0000 (+0200) Subject: dnsdist: `SO_REUSEPORT` on DNSCrypt was only applied for TCP, not UDP X-Git-Tag: rec-4.0.2~48^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=055109031c04e4fd4538213dd1e9c7332dc6fac8;p=thirdparty%2Fpdns.git dnsdist: `SO_REUSEPORT` on DNSCrypt was only applied for TCP, not UDP --- diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index 73a01953b0..fc1105c651 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -1751,6 +1751,13 @@ try setsockopt(cs->udpFD, IPPROTO_IP, GEN_IP_PKTINFO, &one, sizeof(one)); // linux supports this, so why not - might fail on other systems #ifdef IPV6_RECVPKTINFO setsockopt(cs->udpFD, IPPROTO_IPV6, IPV6_RECVPKTINFO, &one, sizeof(one)); +#endif + } + if (std::get<2>(dcLocal)) { +#ifdef SO_REUSEPORT + SSetsockopt(cs->udpFD, SOL_SOCKET, SO_REUSEPORT, 1); +#else + warnlog("SO_REUSEPORT has been configured on local address '%s' but is not supported", std::get<0>(dcLocal).toStringWithPort()); #endif } #ifdef HAVE_EBPF @@ -1779,13 +1786,12 @@ try warnlog("TCP Fast Open has been configured on local address '%s' but is not supported", std::get<0>(dcLocal).toStringWithPort()); #endif } - if (std::get<2>(dcLocal)) { #ifdef SO_REUSEPORT + /* no need to warn again if configured but support is not available, we already did for UDP */ + if (std::get<2>(dcLocal)) { SSetsockopt(cs->tcpFD, SOL_SOCKET, SO_REUSEPORT, 1); -#else - warnlog("SO_REUSEPORT has been configured on local address '%s' but is not supported", std::get<0>(dcLocal).toStringWithPort()); -#endif } +#endif if(cs->local.sin4.sin_family == AF_INET6) { SSetsockopt(cs->tcpFD, IPPROTO_IPV6, IPV6_V6ONLY, 1); }