if (qtype == QType::DS) {
nsdomain.chopOff();
}
- // 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<GetBestNSAnswer> 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<GetBestNSAnswer> 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);