]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Merge pull request #12537 from rgacogne/ddist-faster-maxqpsiprule
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 14 Feb 2023 11:40:05 +0000 (12:40 +0100)
committerGitHub <noreply@github.com>
Tue, 14 Feb 2023 11:40:05 +0000 (12:40 +0100)
dnsdist: Improve the scalability of MaxQPSIPRule()

1  2 
pdns/dnsdist-lua-rules.cc

index 7aa16c855fc7e8f4ee64178dc9747dd2285009e6,12a6e4a8491585845c0a7ecc0f8286b7e89f3a73..4a8eeb44670f0efa92b3447f2af267c415ae68e9
@@@ -383,11 -383,11 +383,11 @@@ void setupLuaRules(LuaContext& luaCtx
    luaCtx.writeFunction("topSelfAnsweredResponseRules", [](boost::optional<unsigned int> top, boost::optional<ruleparams_t> vars) {
      setLuaNoSideEffect();
      auto rules = g_selfansweredrespruleactions.getLocal();
 -    return rulesToString(getTopRules(*rules, top.get_value_or(10)), vars);
 +    return rulesToString(getTopRules(*rules, (top ? *top : 10)), vars);
    });
  
-   luaCtx.writeFunction("MaxQPSIPRule", [](unsigned int qps, boost::optional<unsigned int> ipv4trunc, boost::optional<unsigned int> ipv6trunc, boost::optional<unsigned int> burst, boost::optional<unsigned int> expiration, boost::optional<unsigned int> cleanupDelay, boost::optional<unsigned int> scanFraction) {
-       return std::shared_ptr<DNSRule>(new MaxQPSIPRule(qps, burst.get_value_or(qps), ipv4trunc.get_value_or(32), ipv6trunc.get_value_or(64), expiration.get_value_or(300), cleanupDelay.get_value_or(60), scanFraction.get_value_or(10)));
+   luaCtx.writeFunction("MaxQPSIPRule", [](unsigned int qps, boost::optional<unsigned int> ipv4trunc, boost::optional<unsigned int> ipv6trunc, boost::optional<unsigned int> burst, boost::optional<unsigned int> expiration, boost::optional<unsigned int> cleanupDelay, boost::optional<unsigned int> scanFraction, boost::optional<unsigned int> shards) {
+     return std::shared_ptr<DNSRule>(new MaxQPSIPRule(qps, (burst ? *burst : qps), (ipv4trunc ? *ipv4trunc : 32), (ipv6trunc ? *ipv6trunc : 64), (expiration ? *expiration : 300), (cleanupDelay ? *cleanupDelay : 60), (scanFraction ? *scanFraction : 10), (shards ? *shards : 10)));
      });
  
    luaCtx.writeFunction("MaxQPSRule", [](unsigned int qps, boost::optional<unsigned int> burst) {