From: Otto Moerbeek Date: Tue, 10 Jun 2025 07:02:47 +0000 (+0200) Subject: rec: when using ZTC, do not store non-auth data if the name is subject to recursive... X-Git-Tag: rec-5.1.7^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=71dac15a11c11f473e6c94b94f0ae8a2f53e3956;p=thirdparty%2Fpdns.git rec: when using ZTC, do not store non-auth data if the name is subject to recursive forwarding Fixes #15651 Signed-off-by: Otto Moerbeek (cherry picked from commit 753ad2390bfbc90f6bc1b68f980ef4bcdc2cfddc) --- diff --git a/pdns/recursordist/rec-zonetocache.cc b/pdns/recursordist/rec-zonetocache.cc index f7fb5dc1c2..e1955a3599 100644 --- a/pdns/recursordist/rec-zonetocache.cc +++ b/pdns/recursordist/rec-zonetocache.cc @@ -418,10 +418,12 @@ void ZoneData::ZoneToCache(const RecZoneToCache::Config& config) sigsrr = iter->second; } bool auth = isRRSetAuth(qname, qtype); - // Same decision as updateCacheFromRecords() (we do not test for NSEC since we skip those completely) - if (auth || (qtype == QType::NS || qtype == QType::A || qtype == QType::AAAA || qtype == QType::DS)) { - g_recCache->replace(d_now, qname, qtype, v, sigsrr, - std::vector>(), auth, d_zone); + // Same list as updateCacheFromRecords() (we do not test for NSEC since we skip those completely) + // Issue #15651 + bool storeNonAuth = !SyncRes::isRecursiveForward(qname); + if (auth || (storeNonAuth && (qtype == QType::NS || qtype == QType::A || qtype == QType::AAAA || qtype == QType::DS))) { + g_recCache->replace(d_now, qname, qtype, v, sigsrr, {}, + auth, d_zone); } break; } diff --git a/pdns/recursordist/syncres.cc b/pdns/recursordist/syncres.cc index c27219f06c..e9aa2577af 100644 --- a/pdns/recursordist/syncres.cc +++ b/pdns/recursordist/syncres.cc @@ -1057,6 +1057,13 @@ bool SyncRes::isRecursiveForwardOrAuth(const DNSName& qname) return iter != t_sstorage.domainmap->end() && (iter->second.isAuth() || iter->second.shouldRecurse()); } +bool SyncRes::isRecursiveForward(const DNSName& qname) +{ + DNSName authname(qname); + const auto iter = getBestAuthZone(&authname); + return iter != t_sstorage.domainmap->end() && iter->second.shouldRecurse(); +} + bool SyncRes::isForwardOrAuth(const DNSName& qname) { DNSName authname(qname); diff --git a/pdns/recursordist/syncres.hh b/pdns/recursordist/syncres.hh index cfa081f623..55daa72ed7 100644 --- a/pdns/recursordist/syncres.hh +++ b/pdns/recursordist/syncres.hh @@ -282,6 +282,7 @@ public: { return t_sstorage.domainmap; } + static bool isRecursiveForward(const DNSName& qname); static void setECSScopeZeroAddress(const Netmask& scopeZeroMask) {