]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: `SO_REUSEPORT` on DNSCrypt was only applied for TCP, not UDP
authorRemi Gacogne <remi.gacogne@powerdns.com>
Sat, 25 Jun 2016 15:08:45 +0000 (17:08 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Sat, 25 Jun 2016 15:08:45 +0000 (17:08 +0200)
pdns/dnsdist.cc

index 73a01953b039507bc619238733e65108e2427aac..fc1105c651c6148a4d03daf63ad6f69dfe3f4791 100644 (file)
@@ -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);
     }