From 7691e7df32baefdea20823507ca8597580baa393 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Sun, 22 Nov 2015 17:01:51 +0100 Subject: [PATCH] as noted by winfried, we could end up using same hash on packets in multiple places, leading to "hot" CPUs on some nodes. Turned out we perturbed the hash already on the side of pdns_recursor, but this adds perturbation to dnsdist too. --- pdns/dnsdist.cc | 14 +++++++++++++- pdns/dnsname.hh | 4 ++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index d745343c4..ec201a35f 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -297,9 +297,10 @@ shared_ptr wrandom(const NumberedServerVector& servers, const C return valrandom(random(), servers, remote, qname, qtype, dh); } +static uint32_t g_hashperturb; shared_ptr whashed(const NumberedServerVector& servers, const ComboAddress& remote, const DNSName& qname, uint16_t qtype, dnsheader* dh) { - return valrandom(qname.hash(), servers, remote, qname, qtype, dh); + return valrandom(qname.hash(g_hashperturb), servers, remote, qname, qtype, dh); } @@ -1076,11 +1077,22 @@ try openlog("dnsdist", LOG_PID, LOG_DAEMON); g_console=true; + #ifdef HAVE_LIBSODIUM if (sodium_init() == -1) { cerr<<"Unable to initialize crypto library"<