From: Kees Monshouwer Date: Wed, 14 Sep 2016 21:55:37 +0000 (+0200) Subject: auth: getAuth() in ueberbackend is very length orientated X-Git-Tag: dnsdist-1.2.0~10^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=942d472903ac854c72c99bc05abe69de8ccbaf7e;p=pdns auth: getAuth() in ueberbackend is very length orientated --- diff --git a/pdns/ueberbackend.cc b/pdns/ueberbackend.cc index 40665bea1..b30783d8b 100644 --- a/pdns/ueberbackend.cc +++ b/pdns/ueberbackend.cc @@ -257,65 +257,66 @@ void UeberBackend::getUpdatedMasters(vector* domains) bool UeberBackend::getAuth(const DNSName &target, const QType& qtype, SOAData* sd, bool cachedOk) { + // A backend can respond to our authority request with the 'best' match it + // has. For example, when asked for a.b.c.example.com. it might respond with + // com. We then store that and keep querying the other backends in case one + // of them has a more specific zone but don't bother asking this specific + // backend again for b.c.example.com., c.example.com. and example.com. + // If a backend has no match it may respond with an enmpty qname. + bool found = false; int cstat; - DNSName choppedOff(target); + DNSName shorter(target); vector > bestmatch (backends.size(), make_pair(target.wirelength()+1, SOAData())); do { // Check cache if(cachedOk && (d_cache_ttl || d_negcache_ttl)) { d_question.qtype = QType::SOA; - d_question.qname = choppedOff; + d_question.qname = shorter; d_question.zoneId = -1; cstat = cacheHas(d_question,d_answers); if(cstat == 1 && !d_answers.empty() && d_cache_ttl) { - DLOG(L<db = 0; - sd->qname = choppedOff; + sd->qname = shorter; goto found; } else if(cstat == 0 && d_negcache_ttl) { - DLOG(L<::const_iterator i = backends.begin(); vector >::iterator j = bestmatch.begin(); for(; i != backends.end() && j != bestmatch.end(); ++i, ++j) { - DLOG(L<first < choppedOff.wirelength()) { - DLOG(L<second.qname<first < shorter.wirelength()) { + DLOG(L<second.qname<first == choppedOff.wirelength()) { - DLOG(L<second.qname<first == shorter.wirelength()) { + DLOG(L<second.qname<second; break; } else { - DLOG(L<getAuth(choppedOff, sd)) { + DLOG(L<getAuth(shorter, sd)) { DLOG(L<qname<first = sd->qname.wirelength(); j->second = *sd; - if(sd->qname == choppedOff) { + if(sd->qname == shorter) { break; } } else { - DLOG(L<qname<