From: Peter van Dijk Date: Tue, 2 Jun 2015 15:34:00 +0000 (+0200) Subject: recursor snap X-Git-Tag: dnsdist-1.0.0-alpha1~248^2~58^2~21^2~5^2~49 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0ad83dabffa6b0b44d298adfa3055b1eed7e0b03;p=pdns recursor snap --- diff --git a/pdns/recursor_cache.cc b/pdns/recursor_cache.cc index bcc6d898f..53affea3e 100644 --- a/pdns/recursor_cache.cc +++ b/pdns/recursor_cache.cc @@ -312,7 +312,7 @@ int MemRecursorCache::doWipeCache(const DNSName& name, uint16_t qtype) return count; } -bool MemRecursorCache::doAgeCache(time_t now, const string& name, uint16_t qtype, int32_t newTTL) +bool MemRecursorCache::doAgeCache(time_t now, const DNSName& name, uint16_t qtype, int32_t newTTL) { cache_t::iterator iter = d_cache.find(tie(name, qtype)); uint32_t maxTTD=std::numeric_limits::min(); diff --git a/pdns/recursor_cache.hh b/pdns/recursor_cache.hh index 73ada3bdb..c316ca5cd 100644 --- a/pdns/recursor_cache.hh +++ b/pdns/recursor_cache.hh @@ -42,7 +42,7 @@ public: uint64_t doDumpNSSpeeds(int fd); int doWipeCache(const DNSName& name, uint16_t qtype=0xffff); - bool doAgeCache(time_t now, const string& name, uint16_t qtype, int32_t newTTL); + bool doAgeCache(time_t now, const DNSName& name, uint16_t qtype, int32_t newTTL); uint64_t cacheHits, cacheMisses; private: diff --git a/pdns/syncres.cc b/pdns/syncres.cc index f53d2c0ae..da03bacd5 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -702,8 +702,8 @@ bool SyncRes::doCacheCheck(const DNSName &qname, const QType &qtype, vector "< "< range; QType qtnull(0); @@ -744,7 +744,7 @@ bool SyncRes::doCacheCheck(const DNSName &qname, const QType &qtype, vectornegcache, ni); } } @@ -812,7 +812,7 @@ struct speedOrder map& d_speeds; }; -inline vector SyncRes::shuffleInSpeedOrder(set &tnameservers, const string &prefix) +inline vector SyncRes::shuffleInSpeedOrder(set &tnameservers, const string &prefix) { vector rnameservers; rnameservers.reserve(tnameservers.size()); @@ -867,7 +867,7 @@ static bool magicAddrMatch(const QType& query, const QType& answer) } /** returns -1 in case of no results, rcode otherwise */ -int SyncRes::doResolveAt(set nameservers, string auth, bool flawedNSSet, const string &qname, const QType &qtype, +int SyncRes::doResolveAt(set nameservers, DNSName auth, bool flawedNSSet, const DNSName &qname, const QType &qtype, vector&ret, int depth, set&beenthere) { @@ -880,13 +880,13 @@ int SyncRes::doResolveAt(set nameservers, string auth, bool flawedNSSet LOG(prefix< rnameservers = shuffleInSpeedOrder(nameservers, doLog() ? (prefix+qname+": ") : string() ); - - for(vector::const_iterator tns=rnameservers.begin();;++tns) { + vector rnameservers = shuffleInSpeedOrder(nameservers, doLog() ? (prefix+qname+": ") : string() ); + + for(vector::const_iterator tns=rnameservers.begin();;++tns) { if(tns==rnameservers.end()) { LOG(prefix<doAgeCache(d_now.tv_sec, auth, QType::NS, 10)) g_stats.nsSetInvalidations++; } @@ -972,15 +972,15 @@ int SyncRes::doResolveAt(set nameservers, string auth, bool flawedNSSet } else { s_outqueries++; d_outqueries++; - if(d_outqueries + d_throttledqueries > s_maxqperq) throw ImmediateServFailException("more than "+lexical_cast(s_maxqperq)+" (max-qperq) queries sent while resolving "+qname); + if(d_outqueries + d_throttledqueries > s_maxqperq) throw ImmediateServFailException("more than "+lexical_cast(s_maxqperq)+" (max-qperq) queries sent while resolving "+qname.toString()); TryTCP: if(doTCP) { LOG(prefix<toStringWithPort() < s_maxtotusec) - throw ImmediateServFailException("Too much time waiting for "+qname+"|"+qtype.getName()+", timeouts: "+boost::lexical_cast(d_timeouts) +", throttles: "+boost::lexical_cast(d_throttledqueries) + ", queries: "+lexical_cast(d_outqueries)+", "+lexical_cast(d_totUsec/1000)+"msec"); + + if(s_maxtotusec && d_totUsec > s_maxtotusec) + throw ImmediateServFailException("Too much time waiting for "+qname.toString()+"|"+qtype.getName()+", timeouts: "+boost::lexical_cast(d_timeouts) +", throttles: "+boost::lexical_cast(d_throttledqueries) + ", queries: "+lexical_cast(d_outqueries)+", "+lexical_cast(d_totUsec/1000)+"msec"); if(d_pdl && d_pdl->preoutquery(*remoteIP, d_requestor, qname, qtype, lwr.d_result, resolveret)) { LOG(prefix< nameservers, string auth, bool flawedNSSet d_totUsec += lwr.d_usec; if(resolveret != 1) { if(resolveret==0) { - LOG(prefix< nameservers, string auth, bool flawedNSSet // code below makes sure we don't filter COM or the root if (s_serverdownmaxfails > 0 && (auth.find('.')+1 != auth.size()) && t_sstorage->fails.incr(*remoteIP) >= s_serverdownmaxfails) { - LOG(prefix<toString() <<". Going full throttle for 1 minute" <toString() <<". Going full throttle for 1 minute" <throttle.throttle(d_now.tv_sec, boost::make_tuple(*remoteIP, "", 0), s_serverdownthrottletime, 10000); // mark server as down } else if(resolveret==-1) t_sstorage->throttle.throttle(d_now.tv_sec, boost::make_tuple(*remoteIP, qname, qtype.getCode()), 60, 100); // unreachable, 1 minute or 100 queries @@ -1026,7 +1026,7 @@ int SyncRes::doResolveAt(set nameservers, string auth, bool flawedNSSet // if(d_timeouts + 0.5*d_throttledqueries > 6.0 && d_timeouts > 2) throw ImmediateServFailException("Too much work resolving "+qname+"|"+qtype.getName()+", timeouts: "+boost::lexical_cast(d_timeouts) +", throttles: "+boost::lexical_cast(d_throttledqueries)); if(lwr.d_rcode==RCode::ServFail || lwr.d_rcode==RCode::Refused) { - LOG(prefix<throttle.throttle(d_now.tv_sec,boost::make_tuple(*remoteIP, qname, qtype.getCode()),60,3); // servfail or refused continue; } @@ -1036,7 +1036,7 @@ int SyncRes::doResolveAt(set nameservers, string auth, bool flawedNSSet break; // this IP address worked! wasLame:; // well, it didn't - LOG(prefix<toString() <<") is lame for '"<toString() <<") is lame for '"<throttle.throttle(d_now.tv_sec, boost::make_tuple(*remoteIP, qname, qtype.getCode()), 60, 100); // lame } } @@ -1047,14 +1047,14 @@ int SyncRes::doResolveAt(set nameservers, string auth, bool flawedNSSet if(lwr.d_tcbit) { if(!doTCP) { doTCP=true; - LOG(prefix<toString() <<"), rcode="<toString() <<"), rcode="<sin4.sin_family==AF_INET6) @@ -1077,32 +1077,17 @@ int SyncRes::doResolveAt(set nameservers, string auth, bool flawedNSSet // reap all answers from this packet that are acceptable for(LWResult::res_t::iterator i=lwr.d_result.begin();i != lwr.d_result.end();++i) { if(i->qtype.getCode() == QType::OPT) { - LOG(prefix<qname<<"' from '"<qname.toString()<<"' from '"<qname<<"|"<qtype.getName()<<"|"<content<<"' from '"<qname.toString()<<"|"<qtype.getName()<<"|"<content<<"' from '"<qtype.getCode()==QType::ANY) { LOG("NO! - we don't accept 'ANY' data"<domainmap->empty()) { - string tmp_qname(i->qname); - auto auth_domain_iter=getBestAuthZone(&tmp_qname); - if(auth_domain_iter!=t_sstorage->domainmap->end()) { - if (auth_domain_iter->first != auth) { - LOG("NO! - we are authoritative for the zone "<first<qname, auth)) { - if(lwr.d_aabit && lwr.d_rcode==RCode::NoError && i->d_place==DNSResourceRecord::ANSWER && ::arg().contains("delegation-only",auth)) { + + if(i->qname.isPartOf(auth)) { + if(lwr.d_aabit && lwr.d_rcode==RCode::NoError && i->d_place==DNSResourceRecord::ANSWER && ::arg().contains("delegation-only",auth.toString() /* ugh */)) { LOG("NO! Is from delegation-only zone"< nameservers, string auth, bool flawedNSSet t_RC->replace(d_now.tv_sec, i->first.first, i->first.second, i->second, lwr.d_aabit); } - set nsset; - LOG(prefix< nsset; + LOG(prefix< nameservers, string auth, bool flawedNSSet for(LWResult::res_t::iterator i=lwr.d_result.begin();i!=lwr.d_result.end();++i) { if(i->d_place==DNSResourceRecord::AUTHORITY && i->qtype.getCode()==QType::SOA && lwr.d_rcode==RCode::NXDomain && dottedEndsOn(qname,i->qname) && dottedEndsOn(i->qname, auth)) { - LOG(prefix<ttl = min(i->ttl, s_maxnegttl); if(!newtarget.length()) // only add a SOA if we're not going anywhere after this ret.push_back(*i); @@ -1183,8 +1168,8 @@ int SyncRes::doResolveAt(set nameservers, string auth, bool flawedNSSet ) ) { - - LOG(prefix<content<<"|"<qtype.getName()<<"'"<content<<"|"<qtype.getName()<<"'"< nameservers, string auth, bool flawedNSSet else if(i->d_place==DNSResourceRecord::AUTHORITY && dottedEndsOn(qname,i->qname) && i->qtype.getCode()==QType::NS) { if(moreSpecificThan(i->qname,auth)) { newauth=i->qname; - LOG(prefix<qname<<"' -> '"<content<<"'"<qname<<"' -> '"<content<<"'"<qname<<"' -> '"<content<<"', had '"<qname<<"' -> '"<content<<"', had '"<content); } else if(!done && i->d_place==DNSResourceRecord::AUTHORITY && dottedEndsOn(qname,i->qname) && i->qtype.getCode()==QType::SOA && lwr.d_rcode==RCode::NoError) { - LOG(prefix< ttl = min(s_maxnegttl, i->ttl); @@ -1222,34 +1207,34 @@ int SyncRes::doResolveAt(set nameservers, string auth, bool flawedNSSet } } - if(done){ - LOG(prefix< 10) { - LOG(prefix< beenthere2; return doResolve(newtarget, qtype, ret, depth + 1, beenthere2); } if(lwr.d_rcode==RCode::NXDomain) { - LOG(prefix<