]> granicus.if.org Git - pdns/commitdiff
dnsdist: Add TFO, reuseport, interface and CPU pinning for DoH
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 17 Apr 2019 08:45:11 +0000 (10:45 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 17 Apr 2019 09:15:42 +0000 (11:15 +0200)
pdns/dnsdist-lua.cc
pdns/dnsdist.cc
pdns/dnsdistdist/docs/reference/config.rst

index dc43dc93bd59a1e72c7ad49ae5210dde849965f5..0897b03f74464fe76dc483f0a62ae03d77774e10 100644 (file)
@@ -1673,7 +1673,16 @@ void setupLuaConfig(bool client)
       frontend->d_urls = {"/"};
     }
 
+    bool doTCP = true;
+    bool reusePort = false;
+    int tcpFastOpenQueueSize = 0;
+    std::string interface;
+    std::set<int> cpus;
+    (void) doTCP;
+
     if(vars) {
+      parseLocalBindVars(vars, doTCP, reusePort, tcpFastOpenQueueSize, interface, cpus);
+
       if (vars->count("idleTimeout")) {
         frontend->d_idleTimeout = boost::get<int>((*vars)["idleTimeout"]);
       }
@@ -1685,7 +1694,7 @@ void setupLuaConfig(bool client)
       }
     }
     g_dohlocals.push_back(frontend);
-    auto cs = std::unique_ptr<ClientState>(new ClientState(frontend->d_local, true, false, 0, "", {}));
+    auto cs = std::unique_ptr<ClientState>(new ClientState(frontend->d_local, true, reusePort, tcpFastOpenQueueSize, interface, cpus));
     cs->dohFrontend = frontend;
     g_frontends.push_back(std::move(cs));
 #else
@@ -1768,7 +1777,6 @@ void setupLuaConfig(bool client)
         (void) doTCP;
 
         if (vars) {
-          bool doTCP = true;
           parseLocalBindVars(vars, doTCP, reusePort, tcpFastOpenQueueSize, interface, cpus);
 
           if (vars->count("provider")) {
index 28a9d5fc5505645b5806137a4a54be294ec7f2e5..f6a37a6345ee6d9b7a0bd878815634002e7cecc7 100644 (file)
@@ -2709,6 +2709,9 @@ try
     if (cs->dohFrontend != nullptr) {
 #ifdef HAVE_DNS_OVER_HTTPS
       std::thread t1(dohThread, cs.get());
+      if (!cs->cpus.empty()) {
+        mapThreadToCPUList(t1.native_handle(), cs->cpus);
+      }
       t1.detach();
 #endif /* HAVE_DNS_OVER_HTTPS */
       continue;
index 8f8cb47c676607fb1388b08de4a5caf56b0ea211..075268b541eec37defc23a16f6669e307ac86c1a 100644 (file)
@@ -115,6 +115,10 @@ Listen Sockets
 
   Options:
 
+  * ``reusePort=false``: bool - Set the ``SO_REUSEPORT`` socket option.
+  * ``tcpFastOpenSize=0``: int - Set the TCP Fast Open queue size, enabling TCP Fast Open when available and the value is larger than 0.
+  * ``interface=""``: str - Set the network interface to use.
+  * ``cpus={}``: table - Set the CPU affinity for this listener thread, asking the scheduler to run it on a single CPU id, or a set of CPU ids. This parameter is only available if the OS provides the pthread_setaffinity_np() function.
   * ``idleTimeout=30``: int - Set the idle timeout, in seconds.
   * ``ciphers``: str - The TLS ciphers to use, in OpenSSL format. Ciphers for TLS 1.3 must be specified via ``ciphersTLS13``.
   * ``ciphersTLS13``: str - The TLS ciphers to use for TLS 1.3, in OpenSSL format.