From: Otto Moerbeek Date: Mon, 14 Feb 2022 11:26:20 +0000 (+0100) Subject: Allow not shuffling the Additionals X-Git-Tag: rec-4.7.0-alpha1~8^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=88da1249d34d190755260dae729ff5128c18f9da;p=thirdparty%2Fpdns.git Allow not shuffling the Additionals --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 66802f84cf..e755ccd15d 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -1259,7 +1259,7 @@ void startDoResolve(void* p) } if (ret.size()) { - pdns::orderAndShuffle(ret); + pdns::orderAndShuffle(ret, false); if (auto sl = luaconfsLocal->sortlist.getOrderCmp(dc->d_source)) { stable_sort(ret.begin(), ret.end(), *sl); variableAnswer = true; diff --git a/pdns/rec-lua-conf.cc b/pdns/rec-lua-conf.cc index fd50f5aa05..c5c71b2e96 100644 --- a/pdns/rec-lua-conf.cc +++ b/pdns/rec-lua-conf.cc @@ -709,8 +709,7 @@ void loadRecursorLuaConfig(const std::string& fname, luaConfigDelayedThreads& de {"CacheOnly", AdditionalMode::CacheOnly}, {"CacheOnlyRequireAuth", AdditionalMode::CacheOnlyRequireAuth}, {"ResolveImmediately", AdditionalMode::ResolveImmediately}, - {"ResolveDeferred", AdditionalMode::ResolveDeferred} - }; + {"ResolveDeferred", AdditionalMode::ResolveDeferred}}; if (modeMap.find(it->second) == modeMap.end()) { g_log << Logger::Error << "addAllowedAdditionalQType: unknown mode " << it->second << endl; return; diff --git a/pdns/shuffle.cc b/pdns/shuffle.cc index 1dd1353b00..0b89037655 100644 --- a/pdns/shuffle.cc +++ b/pdns/shuffle.cc @@ -73,7 +73,7 @@ void pdns::shuffle(std::vector& rrs) } // shuffle, maintaining some semblance of order -static void shuffle(std::vector& rrs) +static void shuffle(std::vector& rrs, bool includingAdditionals) { // This shuffles in the same style as the above method, keeping CNAME in the front and RRSIGs at the end std::vector::iterator first, second; @@ -93,6 +93,10 @@ static void shuffle(std::vector& rrs) shuffle(first, second, r); } + if (!includingAdditionals) { + return; + } + // now shuffle the additional records for (first = second; first != rrs.end(); ++first) { if (first->d_place == DNSResourceRecord::ADDITIONAL && first->d_type != QType::CNAME) { @@ -123,10 +127,10 @@ static uint16_t mapTypesToOrder(uint16_t type) // make sure rrs is sorted in d_place order to avoid surprises later // then shuffle the parts that desire shuffling -void pdns::orderAndShuffle(vector& rrs) +void pdns::orderAndShuffle(vector& rrs, bool includingAdditionals) { std::stable_sort(rrs.begin(), rrs.end(), [](const DNSRecord& a, const DNSRecord& b) { return std::make_tuple(a.d_place, mapTypesToOrder(a.d_type)) < std::make_tuple(b.d_place, mapTypesToOrder(b.d_type)); }); - shuffle(rrs); + shuffle(rrs, includingAdditionals); } diff --git a/pdns/shuffle.hh b/pdns/shuffle.hh index 8917204904..54a04ecd90 100644 --- a/pdns/shuffle.hh +++ b/pdns/shuffle.hh @@ -28,5 +28,5 @@ struct DNSZoneRecord; namespace pdns { void shuffle(std::vector& rrs); -void orderAndShuffle(std::vector& rrs); +void orderAndShuffle(std::vector& rrs, bool includingAdditionals); }