From: Remi Gacogne Date: Tue, 1 Dec 2020 09:52:37 +0000 (+0100) Subject: rec: Do not chase CNAME during qname minization step 4 X-Git-Tag: rec-4.5.0-alpha1~100^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F9790%2Fhead;p=thirdparty%2Fpdns.git rec: Do not chase CNAME during qname minization step 4 --- diff --git a/pdns/syncres.cc b/pdns/syncres.cc index 92f674e4de..2a0c357db9 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -771,9 +771,12 @@ int SyncRes::doResolve(const DNSName &qname, const QType &qtype, vector SyncRes::getAddrs(const DNSName &qname, unsigned int depth, bool oldCacheOnly = setCacheOnly(cacheOnly); bool oldRequireAuthData = d_requireAuthData; bool oldValidationRequested = d_DNSSECValidationRequested; + bool oldFollowCNAME = d_followCNAME; const unsigned int startqueries = d_outqueries; d_requireAuthData = false; d_DNSSECValidationRequested = false; + d_followCNAME = true; try { vState newState = vState::Indeterminate; @@ -1077,6 +1082,7 @@ vector SyncRes::getAddrs(const DNSName &qname, unsigned int depth, d_requireAuthData = oldRequireAuthData; d_DNSSECValidationRequested = oldValidationRequested; setCacheOnly(oldCacheOnly); + d_followCNAME = oldFollowCNAME; /* we need to remove from the nsSpeeds collection the existing IPs for this nameserver that are no longer in the set, even if there @@ -1444,7 +1450,7 @@ bool SyncRes::doCNAMECacheCheck(const DNSName &qname, const QType &qtype, vector DNSName newTarget; if (foundQT == QType::DNAME) { if (qtype == QType::DNAME && qname == foundName) { // client wanted the DNAME, no need to synthesize a CNAME - res = 0; + res = RCode::NoError; return true; } // Synthesize a CNAME @@ -1473,12 +1479,12 @@ bool SyncRes::doCNAMECacheCheck(const DNSName &qname, const QType &qtype, vector } if(qtype == QType::CNAME) { // perhaps they really wanted a CNAME! - res = 0; + res = RCode::NoError; return true; } if (qtype == QType::DS || qtype == QType::DNSKEY) { - res = 0; + res = RCode::NoError; return true; } @@ -1505,6 +1511,11 @@ bool SyncRes::doCNAMECacheCheck(const DNSName &qname, const QType &qtype, vector setQNameMinimization(false); } + if (!d_followCNAME) { + res = RCode::NoError; + return true; + } + // Check to see if we already have seen the new target as a previous target if (scanForCNAMELoop(newTarget, ret)) { string msg = "got a CNAME referral (from cache) that causes a loop"; @@ -3722,6 +3733,11 @@ void SyncRes::handleNewTarget(const std::string& prefix, const DNSName& qname, c return; } + if (!d_followCNAME) { + rcode = RCode::NoError; + return; + } + // Check to see if we already have seen the new target as a previous target if (scanForCNAMELoop(newtarget, ret)) { LOG(prefix<