]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Warn if unsupported SO_REUSEPORT or TCP Fast Open has been configured
authorRemi Gacogne <remi.gacogne@powerdns.com>
Sat, 25 Jun 2016 15:02:18 +0000 (17:02 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Sat, 25 Jun 2016 15:02:18 +0000 (17:02 +0200)
pdns/dnsdist.cc

index 7b911fb1182db99b92d412adfecb6bf699413373..73a01953b039507bc619238733e65108e2427aac 100644 (file)
@@ -1667,11 +1667,13 @@ try
       setsockopt(cs->udpFD, IPPROTO_IPV6, IPV6_RECVPKTINFO, &one, sizeof(one));
 #endif
     }
-#ifdef SO_REUSEPORT
     if (std::get<2>(local)) {
+#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>(local).toStringWithPort());
 #endif
+    }
 
 #ifdef HAVE_EBPF
     if (g_defaultBPFFilter) {
@@ -1700,15 +1702,18 @@ try
 #ifdef TCP_DEFER_ACCEPT
     SSetsockopt(cs->tcpFD, SOL_TCP,TCP_DEFER_ACCEPT, 1);
 #endif
-#ifdef TCP_FASTOPEN
     if (std::get<3>(local) > 0) {
+#ifdef TCP_FASTOPEN
       SSetsockopt(cs->tcpFD, SOL_TCP, TCP_FASTOPEN, std::get<3>(local));
-    }
+#else
+      warnlog("TCP Fast Open has been configured on local address '%s' but is not supported", std::get<0>(local).toStringWithPort());
 #endif
+    }
     if(cs->local.sin4.sin_family == AF_INET6) {
       SSetsockopt(cs->tcpFD, IPPROTO_IPV6, IPV6_V6ONLY, 1);
     }
 #ifdef SO_REUSEPORT
+    /* no need to warn again if configured but support is not available, we already did for UDP */
     if (std::get<2>(local)) {
       SSetsockopt(cs->tcpFD, SOL_SOCKET, SO_REUSEPORT, 1);
     }
@@ -1767,16 +1772,20 @@ try
 #ifdef TCP_DEFER_ACCEPT
     SSetsockopt(cs->tcpFD, SOL_TCP,TCP_DEFER_ACCEPT, 1);
 #endif
-#ifdef TCP_FASTOPEN
     if (std::get<3>(dcLocal) > 0) {
+#ifdef TCP_FASTOPEN
       SSetsockopt(cs->tcpFD, SOL_TCP, TCP_FASTOPEN, std::get<3>(dcLocal));
-    }
+#else
+      warnlog("TCP Fast Open has been configured on local address '%s' but is not supported", std::get<0>(dcLocal).toStringWithPort());
 #endif
-#ifdef SO_REUSEPORT
+    }
     if (std::get<2>(dcLocal)) {
+#ifdef SO_REUSEPORT
       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
+    }
     if(cs->local.sin4.sin_family == AF_INET6) {
       SSetsockopt(cs->tcpFD, IPPROTO_IPV6, IPV6_V6ONLY, 1);
     }