From 2cccc3770bd4d155191929a95eb1b8cda2323d84 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Sun, 21 Aug 2016 15:01:17 +0200 Subject: [PATCH] so what broke the ordering was the RRSIGs interspersed with the answers. With this commit, RRSIGs get explicitly put at the back, and also not shuffled within the actual answer records. --- pdns/misc.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pdns/misc.cc b/pdns/misc.cc index 4c20b2cbd6..185a8ab3d5 100644 --- a/pdns/misc.cc +++ b/pdns/misc.cc @@ -561,7 +561,7 @@ void shuffle(vector& rrs) if(first->d_place==DNSResourceRecord::ANSWER && first->d_type != QType::CNAME) // CNAME must come first break; for(second=first;second!=rrs.end();++second) - if(second->d_place!=DNSResourceRecord::ANSWER) + if(second->d_place!=DNSResourceRecord::ANSWER || second->d_type == QType::RRSIG) // leave RRSIGs at the end break; if(second-first>1) @@ -581,10 +581,12 @@ void shuffle(vector& rrs) // we don't shuffle the rest } -static uint16_t mapCnameToFirst(uint16_t type) +static uint16_t mapTypesToOrder(uint16_t type) { if(type == QType::CNAME) return 0; + if(type == QType::RRSIG) + return 65535; else return 1; } @@ -594,7 +596,7 @@ static uint16_t mapCnameToFirst(uint16_t type) void orderAndShuffle(vector& rrs) { std::stable_sort(rrs.begin(), rrs.end(), [](const DNSRecord&a, const DNSRecord& b) { - return std::make_tuple(a.d_place, mapCnameToFirst(a.d_type)) < std::make_tuple(b.d_place, mapCnameToFirst(b.d_type)); + return std::make_tuple(a.d_place, mapTypesToOrder(a.d_type)) < std::make_tuple(b.d_place, mapTypesToOrder(b.d_type)); }); shuffle(rrs); } -- 2.47.2