]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Initialize hash perturbation later, and only if needed
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 19 Sep 2025 12:14:23 +0000 (14:14 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 20 Oct 2025 08:58:22 +0000 (10:58 +0200)
As suggested by Robert Edmonds (many thanks!).

Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
(cherry picked from commit 1362f8c0d846113f32d837a7be9af62c40c67a14)

pdns/dnsdistdist/dnsdist.cc

index e75ac1a7ca12549ae032f753c7cb7be2556dcced..670db0ccf1bfa285b555faa2694f047ce76b8fd7 100644 (file)
@@ -3446,9 +3446,6 @@ int main(int argc, char** argv)
     }
 #endif
     dnsdist::initRandom();
-    dnsdist::configuration::updateImmutableConfiguration([](dnsdist::configuration::ImmutableConfiguration& config) {
-      config.d_hashPerturbation = dnsdist::getRandomValue(0xffffffff);
-    });
 
 #ifdef HAVE_XSK
     try {
@@ -3533,6 +3530,14 @@ int main(int argc, char** argv)
 #endif
     }
 
+    // we only want to update this value if it has not been set by either the Lua or YAML configuration,
+    // and we need to stop touching this value once the backends' hashes have been computed, in setupPools()
+    dnsdist::configuration::updateImmutableConfiguration([](dnsdist::configuration::ImmutableConfiguration& config) {
+      if (config.d_hashPerturbation == 0) {
+        config.d_hashPerturbation = dnsdist::getRandomValue(0xffffffff);
+      }
+    });
+
     setupPools();
 
     initFrontends(cmdLine);