]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
sdig now works with fastopen
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 20 Jan 2021 10:04:50 +0000 (11:04 +0100)
committerOtto <otto.moerbeek@open-xchange.com>
Wed, 24 Mar 2021 10:14:23 +0000 (11:14 +0100)
pdns/lwres.cc
pdns/pdns_recursor.cc
pdns/sdig.cc
pdns/sstuff.hh

index 4ff3809f11fa3d0905c43aeded70a4d5e3343ac1..96f353b4878d9d88c40eba35e29f3fd72e487660 100644 (file)
@@ -329,7 +329,7 @@ LWResult::Result asyncresolve(const ComboAddress& ip, const DNSName& domain, int
       s.setNonBlocking();
       ComboAddress local = pdns::getQueryLocalAddress(ip.sin4.sin_family, 0);
       if (SyncRes::s_tcp_fast_open > 0) {
-        s.setFastOpen(SyncRes::s_tcp_fast_open);
+        s.setFastOpenConnect();
       }
 
       s.bind(local);
index d9ec1ad2292e9f17c048c4ef0a2af84b4bb0e63d..58546cd921184420dc6981ffbdf5a92515a7e024 100644 (file)
@@ -3292,7 +3292,7 @@ static void makeTCPServerSockets(deferredAdd_t& deferredAdds, std::set<int>& tcp
 
     if (SyncRes::s_tcp_fast_open > 0) {
 #ifdef TCP_FASTOPEN
-      if (setsockopt(fd, IPPROTO_TCP, TCP_FASTOPEN, &SyncRes::tcp_fast_open, sizeof SyncRes::tcp_fast_open) < 0) {
+      if (setsockopt(fd, IPPROTO_TCP, TCP_FASTOPEN, &SyncRes::s_tcp_fast_open, sizeof SyncRes::s_tcp_fast_open) < 0) {
         int err = errno;
         g_log<<Logger::Error<<"Failed to enable TCP Fast Open for listening socket: "<<strerror(err)<<endl;
       }
index e2857f9ed7598c53810e39f3bb6f2209c25ca370..f57da7ef1ee1413a892a87e232bcdb463029e67f 100644 (file)
@@ -38,9 +38,14 @@ static void usage()
 {
   cerr << "sdig" << endl;
   cerr << "Syntax: sdig IP-ADDRESS-OR-DOH-URL PORT QNAME QTYPE "
+<<<<<<< HEAD
           "[dnssec] [ednssubnet SUBNET/MASK] [hidesoadetails] [hidettl] [recurse] [showflags] "
           "[tcp] [dot] [insecure] [fastOpen] [subjectName name] [caStore file] [tlsProvider openssl|gnutls] "
           "[xpf XPFDATA] [class CLASSNUM] "
+=======
+          "[dnssec] [ednssubnet SUBNET/MASK] [hidesoadetails] [hidettl] "
+          "[recurse] [showflags] [tcp] [fastopen] [xpf XPFDATA] [class CLASSNUM] "
+>>>>>>> 5b8fccd32 (sdig now works with fastopen)
           "[proxy UDP(0)/TCP(1) SOURCE-IP-ADDRESS-AND-PORT DESTINATION-IP-ADDRESS-AND-PORT]"
           "dumpluaraw"
        << endl;
@@ -212,6 +217,7 @@ try {
   bool dnssec = false;
   bool recurse = false;
   bool tcp = false;
+  bool fastopen = false;
   bool showflags = false;
   bool hidesoadetails = false;
   bool doh = false;
@@ -262,6 +268,7 @@ try {
         hidettl = true;
       else if (strcmp(argv[i], "tcp") == 0)
         tcp = true;
+<<<<<<< HEAD
       else if (strcmp(argv[i], "dot") == 0)
         dot = true;
       else if (strcmp(argv[i], "insecure") == 0)
@@ -269,6 +276,11 @@ try {
       else if (strcmp(argv[i], "fastOpen") == 0)
         fastOpen = true;
       else if (strcmp(argv[i], "ednssubnet") == 0) {
+=======
+      if (strcmp(argv[i], "fastopen") == 0)
+        fastopen = true;
+      if (strcmp(argv[i], "ednssubnet") == 0) {
+>>>>>>> 5b8fccd32 (sdig now works with fastopen)
         if (argc < i + 2) {
           cerr << "ednssubnet needs an argument" << endl;
           exit(EXIT_FAILURE);
index 548e0d0729b9d0ba8c0ef33cd700e160ef6a7726..31f3d007b8a5a182951a81d817e84ad3b6a95b99 100644 (file)
@@ -29,6 +29,7 @@
 #include <unistd.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
+#include <netinet/tcp.h>
 #include <arpa/inet.h>
 #include <sys/select.h>
 #include <fcntl.h>
@@ -127,10 +128,12 @@ public:
     }
   }
 
-  void setFastOpen(int fastOpenQueueSize)
+  void setFastOpenConnect()
   {
 #ifdef TCP_FASTOPEN_CONNECT
-    setsockopt(d_socket, IPPROTO_TCP, TCP_FASTOPEN_CONNECT, &fastOpenQueueSize, sizeof fastOpenQueueSize);
+    int on = 1;
+    if (setsockopt(d_socket, IPPROTO_TCP, TCP_FASTOPEN_CONNECT, &on, sizeof(on)) < 0)
+      throw NetworkError("While setting TCP_FASTOPEN_CONNECT: " + stringerror());
 #endif
   }