]> git.ipfire.org Git - thirdparty/pdns.git/blobdiff - pdns/syncres.cc
Reformulate condition and comment to make it more clear.
[thirdparty/pdns.git] / pdns / syncres.cc
index 3af79100d42a200439120d5e050fc440b8e146e5..1b71d3c190b1ae2b27b3b308415aa292421e0dfe 100644 (file)
@@ -2421,14 +2421,13 @@ RCode::rcodes_ SyncRes::updateCacheFromRecords(unsigned int depth, LWResult& lwr
     */
     if (i->first.type != QType::NSEC3 && (i->first.type == QType::DS || i->first.type == QType::NS || i->first.type == QType::A || i->first.type == QType::AAAA || isAA || wasForwardRecurse)) {
 
-      bool doCache = i->first.place != DNSResourceRecord::ANSWER || !ednsmask;
-      // if ednsmask is relevant, we do not want to cache if the scope > ecslimit and TTL < limitttl
-      if (!doCache && ednsmask) {
-        bool manyMaskBits = (ednsmask->isIpv4() && ednsmask->getBits() > SyncRes::s_ecsipv4cachelimit) ||
+      bool doCache = true;
+      if (i->first.place == DNSResourceRecord::ANSWER && ednsmask) {
+        // If ednsmask is relevant, we do not want to cache if the scope prefix length is large and TTL is small
+        if (SyncRes::s_ecscachelimitttl > 0) {
+          bool manyMaskBits = (ednsmask->isIpv4() && ednsmask->getBits() > SyncRes::s_ecsipv4cachelimit) ||
             (ednsmask->isIpv6() && ednsmask->getBits() > SyncRes::s_ecsipv6cachelimit);
-        doCache = true;
 
-        if (SyncRes::s_ecscachelimitttl > 0) {
           if (manyMaskBits) {
             uint32_t minttl = UINT32_MAX;
             for (const auto &it : i->second.records) {