]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Allow not shuffling the Additionals
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 14 Feb 2022 11:26:20 +0000 (12:26 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 22 Feb 2022 15:24:23 +0000 (16:24 +0100)
pdns/pdns_recursor.cc
pdns/rec-lua-conf.cc
pdns/shuffle.cc
pdns/shuffle.hh

index 66802f84cff6b8b53dfe3e64d3dd8c79654f2e99..e755ccd15de0fdbcf68c4168e54356e249359bfa 100644 (file)
@@ -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;
index fd50f5aa056688d260125ad29e61b4b724209c49..c5c71b2e965bfc4264d75fafc0f7b35d35026720 100644 (file)
@@ -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;
index 1dd1353b0002a3a2bea02ef0db07fc37d9a7a0c3..0b890376550a82d87feadc1384314babdaff17cf 100644 (file)
@@ -73,7 +73,7 @@ void pdns::shuffle(std::vector<DNSZoneRecord>& rrs)
 }
 
 // shuffle, maintaining some semblance of order
-static void shuffle(std::vector<DNSRecord>& rrs)
+static void shuffle(std::vector<DNSRecord>& 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<DNSRecord>::iterator first, second;
@@ -93,6 +93,10 @@ static void shuffle(std::vector<DNSRecord>& 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<DNSRecord>& rrs)
+void pdns::orderAndShuffle(vector<DNSRecord>& 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);
 }
index 89172049044bcd471a7b089624e1494ea2b096b3..54a04ecd9043beef4f5c679c911d7c1f6f48c5d5 100644 (file)
@@ -28,5 +28,5 @@ struct DNSZoneRecord;
 namespace pdns
 {
 void shuffle(std::vector<DNSZoneRecord>& rrs);
-void orderAndShuffle(std::vector<DNSRecord>& rrs);
+void orderAndShuffle(std::vector<DNSRecord>& rrs, bool includingAdditionals);
 }