From: Remi Gacogne Date: Wed, 17 Apr 2019 08:45:11 +0000 (+0200) Subject: dnsdist: Add TFO, reuseport, interface and CPU pinning for DoH X-Git-Tag: dnsdist-1.4.0-alpha2~6^2~14 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2b0cb8f800c72d704a8f2b3744347cf68a5abb7b;p=pdns dnsdist: Add TFO, reuseport, interface and CPU pinning for DoH --- diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index dc43dc93b..0897b03f7 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -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 cpus; + (void) doTCP; + if(vars) { + parseLocalBindVars(vars, doTCP, reusePort, tcpFastOpenQueueSize, interface, cpus); + if (vars->count("idleTimeout")) { frontend->d_idleTimeout = boost::get((*vars)["idleTimeout"]); } @@ -1685,7 +1694,7 @@ void setupLuaConfig(bool client) } } g_dohlocals.push_back(frontend); - auto cs = std::unique_ptr(new ClientState(frontend->d_local, true, false, 0, "", {})); + auto cs = std::unique_ptr(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")) { diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index 28a9d5fc5..f6a37a634 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -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; diff --git a/pdns/dnsdistdist/docs/reference/config.rst b/pdns/dnsdistdist/docs/reference/config.rst index 8f8cb47c6..075268b54 100644 --- a/pdns/dnsdistdist/docs/reference/config.rst +++ b/pdns/dnsdistdist/docs/reference/config.rst @@ -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.