]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Add `setWHashedPertubation()` for consistent `whashed` results 4897/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 11 Jan 2017 12:24:58 +0000 (13:24 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 19 Jan 2017 19:48:29 +0000 (20:48 +0100)
pdns/README-dnsdist.md
pdns/dnsdist-lua2.cc
pdns/dnsdist.cc
pdns/dnsdist.hh

index 59d12320c14820bf5b9eedcf6f4ea7bd79c167b1..436dcc740b04f71a37d26249b5448edd51b0aef3 100644 (file)
@@ -1407,6 +1407,7 @@ instantiate a server with additional parameters
       function with the parameter `dr`, which returns an action to be taken on this response packet.
       Good for rare packets but where you want to do a lot of processing.
  * Server selection policy related:
+    * `setWHashedPertubation(value)`: set the hash perturbation value to be used in the `whashed` policy instead of a random one, allowing to have consistent `whashed` results on different instances
     * `setServerPolicy(policy)`: set server selection policy to that policy
     * `setServerPolicyLua(name, function)`: set server selection policy to one named 'name' and provided by 'function'
     * `showServerPolicy()`: show name of currently operational server selection policy
index 507a99daac5382e4b5cbac7df07aa192041310c0..0350806ed3cc52c0d5911fdf3e7772b0eb981f7e 100644 (file)
@@ -1160,4 +1160,9 @@ void moreLua(bool client)
       return std::shared_ptr<DNSRule>(new RDRule());
     });
 
+    g_lua.writeFunction("setWHashedPertubation", [](uint32_t pertub) {
+        setLuaSideEffect();
+        g_hashperturb = pertub;
+      });
+
 }
index 2002e6d0bd51b03d34b3bfd991c646794fa3e460..5627cb6ae615ff62997bd0a6030c88e5dfa225db 100644 (file)
@@ -610,7 +610,7 @@ shared_ptr<DownstreamState> wrandom(const NumberedServerVector& servers, const D
   return valrandom(random(), servers, dq);
 }
 
-static uint32_t g_hashperturb;
+uint32_t g_hashperturb;
 shared_ptr<DownstreamState> whashed(const NumberedServerVector& servers, const DNSQuestion* dq)
 {
   return valrandom(dq->qname->hash(g_hashperturb), servers, dq);
index ba2f8b72cfce956fc81bc87a6bd2425c9efbed0c..b9ddc67223205b941c148bc760b33f275e17a6a4 100644 (file)
@@ -637,6 +637,7 @@ extern uint32_t g_staleCacheEntriesTTL;
 extern bool g_apiReadWrite;
 extern std::string g_apiConfigDirectory;
 extern bool g_servFailOnNoPolicy;
+extern uint32_t g_hashperturb;
 
 struct ConsoleKeyword {
   std::string name;