From 64a8b6a1c1e1f165c8eb716f399e4da6d71156e7 Mon Sep 17 00:00:00 2001 From: Pieter Lexis Date: Mon, 29 Aug 2016 11:05:17 +0200 Subject: [PATCH] Make the negcache forwarded zones aware Because of DNSSEC (without NTAs configured), we 'leak' the forwarded name to the cache when looking for the DNSKEY. This resulted in NXDOMAIN answers for actual NXDOMAINs, but with the root SOA record. Leading to inconsistent answers to the client. --- pdns/syncres.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pdns/syncres.cc b/pdns/syncres.cc index 2894f1701..7ad3503ab 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -758,9 +758,13 @@ bool SyncRes::doCacheCheck(const DNSName &qname, const QType &qtype, vector range; QType qtnull(0); + DNSName authname(qname); + bool wasForwardedOrAuth = (getBestAuthZone(&authname) != t_sstorage->domainmap->end()); + if(s_rootNXTrust && (range.first=t_sstorage->negcache.find(tie(getLastLabel(qname), qtnull))) != t_sstorage->negcache.end() && - range.first->d_qname.isRoot() && (uint32_t)d_now.tv_sec < range.first->d_ttd ) { + !(wasForwardedOrAuth && !authname.isRoot()) && // when forwarding, the root may only neg-cache if it was forwarded to. + range.first->d_qname.isRoot() && (uint32_t)d_now.tv_sec < range.first->d_ttd) { sttl=range.first->d_ttd - d_now.tv_sec; LOG(prefix<d_name<<"' & '"<d_qname<<"' for another "<d_qtype.getCode() == 0 || ni->d_qtype == qtype) { + if(!(wasForwardedOrAuth && ni->d_qname != authname) && // Only the authname nameserver can neg cache entries + (ni->d_qtype.getCode() == 0 || ni->d_qtype == qtype)) { res=0; if((uint32_t)d_now.tv_sec < ni->d_ttd) { sttl=ni->d_ttd - d_now.tv_sec; -- 2.40.0