From: bert hubert Date: Tue, 6 Jan 2015 15:12:09 +0000 (+0100) Subject: put our loop detection on a diet, plus make it IPv6 aware (again) X-Git-Tag: rec-3.7.0-rc1~53 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=891fbf888ccac074e3edc38864641ca774f2f03c;p=thirdparty%2Fpdns.git put our loop detection on a diet, plus make it IPv6 aware (again) --- diff --git a/pdns/syncres.cc b/pdns/syncres.cc index 10675693a5..df184f1b63 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -438,7 +438,7 @@ int SyncRes::doResolve(const string &qname, const QType &qtype, vector SyncRes::getAddrs(const string &qname, int depth, set rbeenthere(beenthere); bool done=false; - // j=0: ANY - // j=1: A - // j=2: AAAA - switch(j) { case 0: type = QType::ANY; @@ -488,7 +483,7 @@ vector SyncRes::getAddrs(const string &qname, int depth, setqtype.getCode()==QType::A || i->qtype.getCode()==QType::AAAA) { ret.push_back(ComboAddress(i->content, 53)); @@ -520,7 +515,7 @@ vector SyncRes::getAddrs(const string &qname, int depth, set&bestns, bool* flawedNSSet, int depth, set& beenthere) +void SyncRes::getBestNSFromCache(const string &qname, const QType& qtype, set&bestns, bool* flawedNSSet, int depth, set& beenthere) { string prefix, subdomain(qname); if(doLog()) { @@ -560,12 +555,16 @@ void SyncRes::getBestNSFromCache(const string &qname, set&bes } if(!bestns.empty()) { GetBestNSAnswer answer; - answer.qname=qname; answer.bestns=bestns; + answer.qname=qname; + answer.qtype=qtype.getCode(); + BOOST_FOREACH(const DNSResourceRecord& rr, bestns) + answer.bestns.insert(make_pair(rr.qname, rr.content)); + if(beenthere.count(answer)) { LOG(prefix<::const_iterator j=beenthere.begin();j!=beenthere.end();++j) { - LOG(prefix<qname<<" ("<<(unsigned int)j->bestns.size()<<")"<qname<<"|"<qtype)<<" ("<<(unsigned int)j->bestns.size()<<")"<& nsset, bool* flawedNSSet, int depth, set&beenthere) +string SyncRes::getBestNSNamesFromCache(const string &qname, const QType& qtype, set& nsset, bool* flawedNSSet, int depth, set&beenthere) { string subdomain(qname); string authdomain(qname); @@ -615,7 +614,7 @@ string SyncRes::getBestNSNamesFromCache(const string &qname, set bestns; - getBestNSFromCache(subdomain, bestns, flawedNSSet, depth, beenthere); + getBestNSFromCache(subdomain, qtype, bestns, flawedNSSet, depth, beenthere); for(set::const_iterator k=bestns.begin();k!=bestns.end();++k) { nsset.insert(k->content); diff --git a/pdns/syncres.hh b/pdns/syncres.hh index 4d701552f2..d345dd91cf 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -443,9 +443,8 @@ private: domainmap_t::const_iterator getBestAuthZone(string* qname); bool doCNAMECacheCheck(const string &qname, const QType &qtype, vector&ret, int depth, int &res); bool doCacheCheck(const string &qname, const QType &qtype, vector&ret, int depth, int &res); - void getBestNSFromCache(const string &qname, set&bestns, bool* flawedNSSet, int depth, set& beenthere); - string getBestNSNamesFromCache(const string &qname,set& nsset, bool* flawedNSSet, int depth, set&beenthere); - void addAuthorityRecords(const string& qname, vector& ret, int depth); + void getBestNSFromCache(const string &qname, const QType &qtype, set&bestns, bool* flawedNSSet, int depth, set& beenthere); + string getBestNSNamesFromCache(const string &qname, const QType &qtype, set& nsset, bool* flawedNSSet, int depth, set&beenthere); inline vector shuffleInSpeedOrder(set &nameservers, const string &prefix); bool moreSpecificThan(const string& a, const string &b); @@ -463,14 +462,12 @@ private: struct GetBestNSAnswer { string qname; - set bestns; + set > bestns; + uint8_t qtype; // only A and AAAA anyhow bool operator<(const GetBestNSAnswer &b) const { - if(qname