]> granicus.if.org Git - pdns/commitdiff
rec: Add server-side TCP Fast Open support
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 17 Mar 2017 14:42:38 +0000 (15:42 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 17 Mar 2017 14:42:38 +0000 (15:42 +0100)
docs/markdown/recursor/settings.md
pdns/pdns_recursor.cc

index cb71da62afc05ce56edcbe9c5ac6d9bb159a1087..c79cfbc93d33361a137377c515ae80cc3801954e 100644 (file)
@@ -866,6 +866,14 @@ Size of the stack per thread.
 Number of entries in the remotes ringbuffer, which keeps statistics on who is
 querying your server. Can be read out using `rec_control top-remotes`.
 
+## `tcp-fast-open`
+* Integer
+* Default: 0 (Disabled)
+* Available since: 4.1
+
+Enable TCP Fast Open support, if available, on the listening sockets. The numerical
+value supplied is used as the queue size, 0 meaning disabled.
+
 ## `threads`
 * Integer
 * Default: 2
index d038455b5565415eac8161ef98293482d1e8edad..bb4db079b8e2682c04eb3c856a2eadb8ff9c7fb7 100644 (file)
@@ -1844,6 +1844,17 @@ static void makeTCPServerSockets()
     }
 #endif
 
+    if (::arg().asNum("tcp-fast-open") > 0) {
+#ifdef TCP_FASTOPEN
+      int fastOpenQueueSize = ::arg().asNum("tcp-fast-open");
+      if (setsockopt(fd, IPPROTO_TCP, TCP_FASTOPEN, &fastOpenQueueSize, sizeof fastOpenQueueSize) < 0) {
+        L<<Logger::Error<<"Failed to enable TCP Fast Open for listening socket: "<<strerror(errno)<<endl;
+      }
+#else
+      L<<Logger::Warning<<"TCP Fast Open configured but not supported for listening socket"<<endl;
+#endif
+    }
+
     sin.sin4.sin_port = htons(st.port);
     socklen_t socklen=sin.sin4.sin_family==AF_INET ? sizeof(sin.sin4) : sizeof(sin.sin6);
     if (::bind(fd, (struct sockaddr *)&sin, socklen )<0)
@@ -3159,6 +3170,8 @@ int main(int argc, char **argv)
     ::arg().setSwitch("snmp-agent", "If set, register as an SNMP agent")="no";
     ::arg().setSwitch("snmp-master-socket", "If set and snmp-agent is set, the socket to use to register to the SNMP master")="";
 
+    ::arg().set("tcp-fast-open", "Enable TCP Fast Open support on the listening sockets, using the supplied numerical value as the queue size")="0";
+
     ::arg().setCmd("help","Provide a helpful message");
     ::arg().setCmd("version","Print version string");
     ::arg().setCmd("config","Output blank configuration");