]> 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>
Fri, 19 Sep 2025 12:14:23 +0000 (14:14 +0200)
As suggested by Robert Edmonds (many thanks!).

Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
pdns/dnsdistdist/dnsdist.cc

index edbd952fd51359422a583816b7d845f86bbd31d2..520bcc57398edaf1449ddfc6352316bb03a02344 100644 (file)
@@ -3458,9 +3458,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 {
@@ -3545,6 +3542,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);