]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Add 'maxInFlight' parameter to 'newServer()' and '*Local()'
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 9 Sep 2020 15:20:30 +0000 (17:20 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 10 Nov 2020 08:46:54 +0000 (09:46 +0100)
pdns/dnsdist-lua.cc
pdns/dnsdistdist/docs/reference/config.rst

index 16276d1b103354a4e52192c1b70749e2315b3c74..752babf1510f3883780ffd141b036161bdc35942 100644 (file)
@@ -98,7 +98,7 @@ void resetLuaSideEffect()
 
 typedef std::unordered_map<std::string, boost::variant<bool, int, std::string, std::vector<std::pair<int,int> >, std::vector<std::pair<int, std::string> >, std::map<std::string,std::string>  > > localbind_t;
 
-static void parseLocalBindVars(boost::optional<localbind_t> vars, bool& reusePort, int& tcpFastOpenQueueSize, std::string& interface, std::set<int>& cpus, int& tcpListenQueueSize)
+static void parseLocalBindVars(boost::optional<localbind_t> vars, bool& reusePort, int& tcpFastOpenQueueSize, std::string& interface, std::set<int>& cpus, int& tcpListenQueueSize, size_t& maxInFlightQueriesPerConnection)
 {
   if (vars) {
     if (vars->count("reusePort")) {
@@ -110,6 +110,9 @@ static void parseLocalBindVars(boost::optional<localbind_t> vars, bool& reusePor
     if (vars->count("tcpListenQueueSize")) {
       tcpListenQueueSize = boost::get<int>((*vars)["tcpListenQueueSize"]);
     }
+    if (vars->count("maxInFlight")) {
+      maxInFlightQueriesPerConnection = boost::get<int>((*vars)["maxInFlight"]);
+    }
     if (vars->count("interface")) {
       interface = boost::get<std::string>((*vars)["interface"]);
     }
@@ -401,6 +404,10 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
         }
       }
 
+      if(vars.count("maxInFlight")) {
+        ret->d_maxInFlightQueriesPerConn = std::stoi(boost::get<string>(vars["maxInFlight"]));
+      }
+
       if(vars.count("name")) {
         ret->setName(boost::get<string>(vars["name"]));
       }
@@ -585,10 +592,11 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
       bool reusePort = false;
       int tcpFastOpenQueueSize = 0;
       int tcpListenQueueSize = 0;
+      size_t maxInFlightQueriesPerConn = 0;
       std::string interface;
       std::set<int> cpus;
 
-      parseLocalBindVars(vars, reusePort, tcpFastOpenQueueSize, interface, cpus, tcpListenQueueSize);
+      parseLocalBindVars(vars, reusePort, tcpFastOpenQueueSize, interface, cpus, tcpListenQueueSize, maxInFlightQueriesPerConn);
 
       try {
        ComboAddress loc(addr, 53);
@@ -608,6 +616,9 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
         if (tcpListenQueueSize > 0) {
           tcpCS->tcpListenQueueSize = tcpListenQueueSize;
         }
+        if (maxInFlightQueriesPerConn > 0) {
+          tcpCS->d_maxInFlightQueriesPerConn = maxInFlightQueriesPerConn;
+        }
         g_frontends.push_back(std::move(tcpCS));
       }
       catch(const std::exception& e) {
@@ -626,10 +637,11 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
       bool reusePort = false;
       int tcpFastOpenQueueSize = 0;
       int tcpListenQueueSize = 0;
+      size_t maxInFlightQueriesPerConn = 0;
       std::string interface;
       std::set<int> cpus;
 
-      parseLocalBindVars(vars, reusePort, tcpFastOpenQueueSize, interface, cpus, tcpListenQueueSize);
+      parseLocalBindVars(vars, reusePort, tcpFastOpenQueueSize, interface, cpus, tcpListenQueueSize, maxInFlightQueriesPerConn);
 
       try {
        ComboAddress loc(addr, 53);
@@ -639,6 +651,9 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
         if (tcpListenQueueSize > 0) {
           tcpCS->tcpListenQueueSize = tcpListenQueueSize;
         }
+        if (maxInFlightQueriesPerConn > 0) {
+          tcpCS->d_maxInFlightQueriesPerConn = maxInFlightQueriesPerConn;
+        }
         g_frontends.push_back(std::move(tcpCS));
       }
       catch(std::exception& e) {
@@ -1248,11 +1263,12 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
       bool reusePort = false;
       int tcpFastOpenQueueSize = 0;
       int tcpListenQueueSize = 0;
+      size_t maxInFlightQueriesPerConn = 0;
       std::string interface;
       std::set<int> cpus;
       std::vector<DNSCryptContext::CertKeyPaths> certKeys;
 
-      parseLocalBindVars(vars, reusePort, tcpFastOpenQueueSize, interface, cpus, tcpListenQueueSize);
+      parseLocalBindVars(vars, reusePort, tcpFastOpenQueueSize, interface, cpus, tcpListenQueueSize, maxInFlightQueriesPerConn);
 
       if (certFiles.type() == typeid(std::string) && keyFiles.type() == typeid(std::string)) {
         auto certFile = boost::get<std::string>(certFiles);
@@ -1950,11 +1966,12 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
     bool reusePort = false;
     int tcpFastOpenQueueSize = 0;
     int tcpListenQueueSize = 0;
+    size_t maxInFlightQueriesPerConn = 0;
     std::string interface;
     std::set<int> cpus;
 
     if (vars) {
-      parseLocalBindVars(vars, reusePort, tcpFastOpenQueueSize, interface, cpus, tcpListenQueueSize);
+      parseLocalBindVars(vars, reusePort, tcpFastOpenQueueSize, interface, cpus, tcpListenQueueSize, maxInFlightQueriesPerConn);
 
       if (vars->count("idleTimeout")) {
         frontend->d_idleTimeout = boost::get<int>((*vars)["idleTimeout"]);
@@ -2136,11 +2153,12 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
         bool reusePort = false;
         int tcpFastOpenQueueSize = 0;
         int tcpListenQueueSize = 0;
+        size_t maxInFlightQueriesPerConn = 0;
         std::string interface;
         std::set<int> cpus;
 
         if (vars) {
-          parseLocalBindVars(vars, reusePort, tcpFastOpenQueueSize, interface, cpus, tcpListenQueueSize);
+          parseLocalBindVars(vars, reusePort, tcpFastOpenQueueSize, interface, cpus, tcpListenQueueSize, maxInFlightQueriesPerConn);
 
           if (vars->count("provider")) {
             frontend->d_provider = boost::get<const string>((*vars)["provider"]);
@@ -2168,6 +2186,10 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
           if (tcpListenQueueSize > 0) {
             cs->tcpListenQueueSize = tcpListenQueueSize;
           }
+          if (maxInFlightQueriesPerConn > 0) {
+            cs->d_maxInFlightQueriesPerConn = maxInFlightQueriesPerConn;
+          }
+
           g_tlslocals.push_back(cs->tlsFrontend);
           g_frontends.push_back(std::move(cs));
         }
index a347229ccd2ec9160d152d247ae4ea20d8b12b30..e5877e233a4b646e6693722dd411f41265682659 100644 (file)
@@ -73,6 +73,9 @@ Listen Sockets
   .. versionchanged:: 1.5.0
     Added ``tcpListenQueueSize`` parameter.
 
+  .. versionchanged:: 1.6.0
+    Added ``maxInFlight`` parameter.
+
   Add to the list of listen addresses.
 
   :param str address: The IP Address with an optional port to listen on.
@@ -87,6 +90,7 @@ Listen Sockets
   * ``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.
   * ``tcpListenQueueSize=SOMAXCONN``: int - Set the size of the listen queue. Default is ``SOMAXCONN``.
+  * ``maxInFlight=0``: int - Maximum number of in-flight queries. The default is 0, which disables out-of-order processing.
 
   .. code-block:: lua
 
@@ -164,6 +168,8 @@ Listen Sockets
     ``ciphersTLS13``, ``minTLSVersion``, ``ocspResponses``, ``preferServerCiphers``, ``keyLogFile`` options added.
   .. versionchanged:: 1.5.0
     ``sessionTimeout`` and ``tcpListenQueueSize`` options added.
+  .. versionchanged:: 1.6.0
+    Added ``maxInFlight`` parameter.
 
   Listen on the specified address and TCP port for incoming DNS over TLS connections, presenting the specified X.509 certificate.
 
@@ -193,6 +199,7 @@ Listen Sockets
   * ``preferServerCiphers``: bool - Whether to prefer the order of ciphers set by the server instead of the one set by the client. Default is true, meaning that the order of the server is used. For OpenSSL >= 1.1.1, setting this option also enables the temporary re-prioritization of the ChaCha20-Poly1305 cipher if the client prioritizes it.
   * ``keyLogFile``: str - Write the TLS keys in the specified file so that an external program can decrypt TLS exchanges, in the format described in https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/Key_Log_Format. Note that this feature requires OpenSSL >= 1.1.1.
   * ``tcpListenQueueSize=SOMAXCONN``: int - Set the size of the listen queue. Default is ``SOMAXCONN``.
+  * ``maxInFlight=0``: int - Maximum number of in-flight queries. The default is 0, which disables out-of-order processing.
 
 .. function:: setLocal(address[, options])
 
@@ -474,6 +481,9 @@ Servers
   .. versionchanged:: 1.5.0
     Added ``useProxyProtocol`` to server_table.
 
+  .. versionchanged:: 1.6.0
+    Added ``maxInFlight`` to server_table.
+
   Add a new backend server. Call this function with either a string::
 
     newServer(
@@ -518,7 +528,8 @@ Servers
       disableZeroScope=BOOL, -- Disable the EDNS Client Subnet 'zero scope' feature, which does a cache lookup for an answer valid for all subnets (ECS scope of 0) before adding ECS information to the query and doing the regular lookup. This requires the ``parseECS`` option of the corresponding cache to be set to true
       rise=NUM,              -- Require NUM consecutive successful checks before declaring the backend up, default: 1
       useProxyProtocol=BOOL, -- Add a proxy protocol header to the query, passing along the client's IP address and port along with the original destination address and port. Default is disabled.
-      reconnectOnUp=BOOL     -- Close and reopen the sockets when a server transits from Down to Up. This helps when an interface is missing when dnsdist is started. Default is disabled.
+      reconnectOnUp=BOOL,    -- Close and reopen the sockets when a server transits from Down to Up. This helps when an interface is missing when dnsdist is started. Default is disabled.
+      maxInFlight            -- Maximum number of in-flight queries. The default is 0, which disables out-of-order processing. It should only be enabled if the backend does support out-of-order processing.
     })
 
   :param str server_string: A simple IP:PORT string.