From: Kees Monshouwer Date: Tue, 10 Nov 2020 19:17:33 +0000 (+0100) Subject: auth: avoid the use of getSOAUncached() in single backend setups X-Git-Tag: auth-4.4.0-beta1~3^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=79a8e56f455f8d03bf3b1e4ec9ac127566a02019;p=thirdparty%2Fpdns.git auth: avoid the use of getSOAUncached() in single backend setups --- diff --git a/pdns/packethandler.cc b/pdns/packethandler.cc index 333d05df15..e6724687de 100644 --- a/pdns/packethandler.cc +++ b/pdns/packethandler.cc @@ -717,10 +717,11 @@ void PacketHandler::addNSEC3(DNSPacket& p, std::unique_ptr& r, const { DLOG(g_log<<"addNSEC3() mode="<& r, const hashed=hashQNameWithSalt(ns3rc, unhashed); DLOG(g_log<<"1 hash: "<& r, const hashed=hashQNameWithSalt(ns3rc, unhashed); DLOG(g_log<<"1 hash: "<& r, const hashed=hashQNameWithSalt(ns3rc, unhashed); DLOG(g_log<<"2 hash: "<& r, const hashed=hashQNameWithSalt(ns3rc, unhashed); DLOG(g_log<<"3 hash: "<& r, const D { DLOG(g_log<<"addNSEC() mode="<getBeforeAndAfterNames(sd.domain_id, auth, target, before, after); + d_sd.db->getBeforeAndAfterNames(d_sd.domain_id, auth, target, before, after); if (mode != 5 || before == target) - emitNSEC(r, sd, before, after, mode); + emitNSEC(r, d_sd, before, after, mode); if (mode == 2 || mode == 4) { // wildcard NO-DATA or wildcard denial @@ -819,8 +822,8 @@ void PacketHandler::addNSEC(DNSPacket& p, std::unique_ptr& r, const D closest.chopOff(); closest.prependRawLabel("*"); } - sd.db->getBeforeAndAfterNames(sd.domain_id, auth, closest, before, after); - emitNSEC(r, sd, before, after, mode); + d_sd.db->getBeforeAndAfterNames(d_sd.domain_id, auth, closest, before, after); + emitNSEC(r, d_sd, before, after, mode); } return; } @@ -1343,6 +1346,8 @@ std::unique_ptr PacketHandler::doQuestion(DNSPacket& p) d_dnssec=(p.d_dnssecOk && d_dk.isSecuredZone(sd.qname)); doSigs |= d_dnssec; + d_sd = sd; // Room for improvement, use d_sd everywhere + if(!retargetcount) r->qdomainzone=sd.qname; if(sd.qname==p.qdomain) { diff --git a/pdns/packethandler.hh b/pdns/packethandler.hh index bb56440148..1bd0c541dc 100644 --- a/pdns/packethandler.hh +++ b/pdns/packethandler.hh @@ -109,6 +109,7 @@ private: bool d_doDNAME; bool d_doExpandALIAS; bool d_dnssec; + SOAData d_sd; std::unique_ptr d_pdl; std::unique_ptr d_update_policy_lua; diff --git a/pdns/ueberbackend.cc b/pdns/ueberbackend.cc index aedc02813d..e3a852747a 100644 --- a/pdns/ueberbackend.cc +++ b/pdns/ueberbackend.cc @@ -332,7 +332,11 @@ bool UeberBackend::getAuth(const DNSName &target, const QType& qtype, SOAData* s DLOG(g_log<db = nullptr; + if (backends.size() == 1) { + sd->db = *backends.begin(); + } else { + sd->db = nullptr; + } sd->qname = shorter; goto found; } else if(cstat == 0 && d_negcache_ttl) {