From d190894cf93c6db749c28bbee2d577f60a53020c Mon Sep 17 00:00:00 2001 From: bert hubert Date: Tue, 13 Sep 2016 15:56:44 +0200 Subject: [PATCH] reinstate shuffling in the new DNSZoneRecord world --- pdns/dnspacket.cc | 4 ---- pdns/misc.cc | 14 +++++++------- pdns/misc.hh | 4 +++- pdns/speedtest.cc | 2 +- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/pdns/dnspacket.cc b/pdns/dnspacket.cc index 36dae058f1..b61ef798f9 100644 --- a/pdns/dnspacket.cc +++ b/pdns/dnspacket.cc @@ -256,10 +256,6 @@ bool DNSPacket::isEmpty() return (d_rrs.empty()); } -static void shuffle(vector& rrs) -{ -} - /** Must be called before attempting to access getData(). This function stuffs all resource * records found in rrs into the data buffer. It also frees resource records queued for us. */ diff --git a/pdns/misc.cc b/pdns/misc.cc index 435434ccca..038500276c 100644 --- a/pdns/misc.cc +++ b/pdns/misc.cc @@ -533,25 +533,25 @@ string makeHexDump(const string& str) } // shuffle, maintaining some semblance of order -void shuffle(vector& rrs) +void shuffle(vector& rrs) { - vector::iterator first, second; + vector::iterator first, second; for(first=rrs.begin();first!=rrs.end();++first) - if(first->d_place==DNSResourceRecord::ANSWER && first->qtype.getCode() != QType::CNAME) // CNAME must come first + if(first->dr.d_place==DNSResourceRecord::ANSWER && first->dr.d_type != QType::CNAME) // CNAME must come first break; for(second=first;second!=rrs.end();++second) - if(second->d_place!=DNSResourceRecord::ANSWER) + if(second->dr.d_place!=DNSResourceRecord::ANSWER) break; - if(second-first>1) + if(second-first > 1) random_shuffle(first,second); // now shuffle the additional records for(first=second;first!=rrs.end();++first) - if(first->d_place==DNSResourceRecord::ADDITIONAL && first->qtype.getCode() != QType::CNAME) // CNAME must come first + if(first->dr.d_place==DNSResourceRecord::ADDITIONAL && first->dr.d_type != QType::CNAME) // CNAME must come first break; for(second=first;second!=rrs.end();++second) - if(second->d_place!=DNSResourceRecord::ADDITIONAL) + if(second->dr.d_place!=DNSResourceRecord::ADDITIONAL) break; if(second-first>1) diff --git a/pdns/misc.hh b/pdns/misc.hh index 5cb60a2705..225d8e9814 100644 --- a/pdns/misc.hh +++ b/pdns/misc.hh @@ -33,6 +33,7 @@ #include #include #include + using namespace ::boost::multi_index; #include "dns.hh" @@ -305,7 +306,8 @@ inline void unixDie(const string &why) string makeHexDump(const string& str); void shuffle(vector& rrs); -void shuffle(vector& rrs); +class DNSZoneRecord; +void shuffle(vector& rrs); void orderAndShuffle(vector& rrs); diff --git a/pdns/speedtest.cc b/pdns/speedtest.cc index 465f2c3024..d428721560 100644 --- a/pdns/speedtest.cc +++ b/pdns/speedtest.cc @@ -295,7 +295,7 @@ vector makeBigDNSPacketReferral() vector packet; DNSPacketWriter pw(packet, DNSName("www.google.com"), QType::A); - shuffle(records); + // shuffle(records); for(const auto& rec : records) { pw.startRecord(rec.qname, rec.qtype.getCode(), rec.ttl, 1, rec.d_place); auto drc = DNSRecordContent::mastermake(rec.qtype.getCode(), 1, rec.content); -- 2.47.2