From: Remi Gacogne Date: Tue, 12 Sep 2017 12:34:09 +0000 (+0200) Subject: rec: Separate the actual code checking if a cut exists for refactoring X-Git-Tag: rec-4.1.0-rc1~18^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c405e222f93481e5fbd1d5ac293177704a0a2682;p=thirdparty%2Fpdns.git rec: Separate the actual code checking if a cut exists for refactoring --- diff --git a/pdns/syncres.cc b/pdns/syncres.cc index f6a959e939..05ecb7dc3f 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -1431,6 +1431,40 @@ vState SyncRes::getValidationStatus(const DNSName& subdomain) return result; } +bool SyncRes::lookForCut(const DNSName& qname, unsigned int depth, const vState existingState, vState& newState) +{ + bool foundCut = false; + std::set beenthere; + std::vector nsrecords; + + int rcode = doResolve(qname, QType(QType::NS), nsrecords, depth, beenthere, newState); + + if (rcode == RCode::NoError && !nsrecords.empty()) { + for (const auto& record : nsrecords) { + if(record.d_type != QType::NS || record.d_name != qname) + continue; + foundCut = true; + break; + } + + if (foundCut) { + dsmap_t ds; + vState dsState = getDSRecords(qname, ds, newState == Bogus || existingState == Insecure || existingState == Bogus, depth); + if (dsState != Indeterminate) { + newState = dsState; + } + if (newState == TA) { + newState = Secure; + } + else if (newState == NTA) { + newState = Insecure; + } + } + } + + return foundCut; +} + void SyncRes::computeZoneCuts(const DNSName& begin, const DNSName& end, unsigned int depth) { if(!begin.isPartOf(end)) { @@ -1466,7 +1500,6 @@ void SyncRes::computeZoneCuts(const DNSName& begin, const DNSName& end, unsigned d_requireAuthData = false; while(qname != begin) { - bool foundCut = false; if (labelsToAdd.empty()) break; @@ -1482,45 +1515,20 @@ void SyncRes::computeZoneCuts(const DNSName& begin, const DNSName& end, unsigned } } - std::set beenthere; - std::vector nsrecords; - - vState state = Indeterminate; + vState newState = Indeterminate; /* temporarily mark as Indeterminate, so that we won't enter an endless loop trying to determine that zone cut again. */ - d_cutStates[qname] = state; - int rcode = doResolve(qname, QType(QType::NS), nsrecords, depth + 1, beenthere, state); - - if (rcode == RCode::NoError && !nsrecords.empty()) { - for (const auto& record : nsrecords) { - if(record.d_type != QType::NS || record.d_name != qname) - continue; - foundCut = true; - break; - } - if (foundCut) { - LOG(d_prefix<<": - Found cut at "<