From: Otto Moerbeek Date: Mon, 7 Sep 2020 10:17:30 +0000 (+0200) Subject: We only want to do QName Minimization for the names in a forwarded X-Git-Tag: rec-4.5.0-alpha0~11^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=21af3294a6fdacd9632ecb3a05eb2ccf204d2fdb;p=thirdparty%2Fpdns.git We only want to do QName Minimization for the names in a forwarded domain. E.g. if foo.bar.com is forwarded and the qname is x.foo.bar.com, start the QM process with ancestor foo.bar.com, so the query is directed to the forwarder. But if the qname is baz.bar.com, we do regular QM, starting with the regular ancestor. Should fix #9438 without breaking having forward for . --- diff --git a/pdns/syncres.cc b/pdns/syncres.cc index df689a6f69..6638b0336d 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -714,22 +714,30 @@ int SyncRes::doResolve(const DNSName &qname, const QType &qtype, vector 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; + 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); } - const DNSName& ancestor(bestns[0].d_name); - QLOG("Step1 Ancestor from cache is " << ancestor.toString()); + const DNSName& ancestor(forwarded ? fwdomain : bestns[0].d_name); + child = ancestor; unsigned int targetlen = std::min(child.countLabels() + (i > 3 ? 3 : 1), qnamelen);