From: Otto Moerbeek Date: Wed, 23 Mar 2022 11:48:07 +0000 (+0100) Subject: Implement deferred mode for additionals X-Git-Tag: rec-4.7.0-beta1~10^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=606a29f19285581d153170a4bbffcac61f5e2c91;p=thirdparty%2Fpdns.git Implement deferred mode for additionals --- diff --git a/pdns/syncres.cc b/pdns/syncres.cc index 3f80f1caea..e5c22cdf95 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -302,12 +302,40 @@ void SyncRes::resolveAdditionals(const DNSName& qname, QType qtype, AdditionalMo } break; } - case AdditionalMode::ResolveDeferred: - // FIXME: Not yet implemented - // Look in cache for authoritative answer, if available return it - // If not, look in nergache and submit if not there as well. The logic should be the same as - // #11294, which is in review atm. + case AdditionalMode::ResolveDeferred: { + const bool oldCacheOnly = setCacheOnly(true); + set beenthere; + int res = doResolve(qname, qtype, addRecords, depth, beenthere, state); + setCacheOnly(oldCacheOnly); + if (res == 0 && addRecords.size() > 0) { + // We're conservative here. We do not add Bogus records in any circumstance, we add Indeterminates only if no + // validation is required. + if (vStateIsBogus(state)) { + return; + } + if (shouldValidate() && state != vState::Secure && state != vState::Insecure) { + return; + } + bool found = false; + for (auto& rec : addRecords) { + if (rec.d_place == DNSResourceRecord::ANSWER) { + found = true; + additionals.push_back(std::move(rec)); + } + } + if (found) { + return; + } + } + // Not found in cache, check negcache and push task if also not in negcache + NegCache::NegCacheEntry ne; + bool inNegCache = g_negCache->get(qname, qtype, d_now, ne, false); + if (!inNegCache) { + pushResolveTask(qname, qtype, d_now.tv_sec, d_now.tv_sec + 60); + } else { + } break; + } case AdditionalMode::Ignore: break; }