From: Otto Moerbeek Date: Tue, 8 Sep 2020 09:59:32 +0000 (+0200) Subject: Take into account a potentially more specific NS we might X-Git-Tag: rec-4.5.0-alpha0~11^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=afb1d0393abd613b2f362e48d1e3dde3d34689ca;p=thirdparty%2Fpdns.git Take into account a potentially more specific NS we might have in cache. Also, do the forward lookup only once before the loop. --- diff --git a/pdns/syncres.cc b/pdns/syncres.cc index 6638b0336d..ce6a5fe419 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -706,6 +706,12 @@ int SyncRes::doResolve(const DNSName &qname, const QType &qtype, vectorend(); + if (forwarded) { + QLOG("Step0 qname is in a forwarded domain " << fwdomain); + } + for (unsigned int i = 0; i <= qnamelen; ) { // Step 1 @@ -714,29 +720,25 @@ int SyncRes::doResolve(const DNSName &qname, const QType &qtype, vector beenthereIgnored; + getBestNSFromCache(nsdomain, qtype, bestns, &flawedNSSet, depth, beenthereIgnored); + } - DNSName fwdomain(qname); - bool forwarded = getBestAuthZone(&fwdomain) != t_sstorage.domainmap->end(); - if (forwarded) { - QLOG("Step1 qname is in a forwarded domain"); - } else { - // the two retries allow getBestNSFromCache&co to reprime the root - // hints, in case they ever go missing - for (int tries = 0; tries < 2 && bestns.empty(); ++tries) { - bool flawedNSSet = false; - set beenthereIgnored; - getBestNSFromCache(nsdomain, qtype, bestns, &flawedNSSet, depth, beenthereIgnored); - } - - if (bestns.size() == 0) { - // Something terrible is wrong - QLOG("Step1 No ancestor found return ServFail"); - return RCode::ServFail; - } - QLOG("Step1 Ancestor from cache is " << bestns[0].d_name); + if (bestns.size() == 0) { + // Something terrible is wrong + QLOG("Step1 No ancestor found return ServFail"); + return RCode::ServFail; } + QLOG("Step1 Ancestor from cache is " << bestns[0].d_name); - const DNSName& ancestor(forwarded ? fwdomain : bestns[0].d_name); + const DNSName& ancestor(!forwarded || bestns[0].d_name.isPartOf(fwdomain) ? bestns[0].d_name : fwdomain); + if (forwarded) { + QLOG("Step1 Final Ancestor (using forwarding info) is " << ancestor); + } child = ancestor;