]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Do cache negcache results, even when wasVariable() is true 11023/head
authorOtto <otto.moerbeek@open-xchange.com>
Fri, 19 Nov 2021 10:57:28 +0000 (11:57 +0100)
committerOtto <otto.moerbeek@open-xchange.com>
Tue, 23 Nov 2021 08:36:34 +0000 (09:36 +0100)
See https://datatracker.ietf.org/doc/html/rfc7871#section-7.4
Fixes #10994

(cherry picked from commit 2bcec14adbffbf4b28d698cb607877fb96054e87)

pdns/recursordist/test-syncres_cc2.cc
pdns/syncres.cc

index 2a3f01eae5059524de4600b37a6db7c4ec1859d7..f4cefa183402754dcba0b1ded6d8a212f6af91e6 100644 (file)
@@ -873,7 +873,7 @@ BOOST_AUTO_TEST_CASE(test_rfc8020_nodata_bis)
   BOOST_CHECK_EQUAL(SyncRes::getNegCacheSize(), 2U);
 }
 
-BOOST_AUTO_TEST_CASE(test_skip_negcache_for_variable_response)
+BOOST_AUTO_TEST_CASE(test_dont_skip_negcache_for_variable_response)
 {
   std::unique_ptr<SyncRes> sr;
   initSR(sr);
@@ -926,8 +926,7 @@ BOOST_AUTO_TEST_CASE(test_skip_negcache_for_variable_response)
   int res = sr->beginResolve(target, QType(QType::A), QClass::IN, ret);
   BOOST_CHECK_EQUAL(res, RCode::NXDomain);
   BOOST_CHECK_EQUAL(ret.size(), 2U);
-  /* no negative cache entry because the response was variable */
-  BOOST_CHECK_EQUAL(SyncRes::getNegCacheSize(), 0U);
+  BOOST_CHECK_EQUAL(SyncRes::getNegCacheSize(), 1U);
 }
 
 BOOST_AUTO_TEST_CASE(test_ecs_cache_limit_allowed)
index 2463b89fed857fe40265863945b4af1d273aa632..39facfe30af8fc2d883530e9a7d44c1e6718269b 100644 (file)
@@ -3443,7 +3443,7 @@ bool SyncRes::processRecords(const std::string& prefix, const DNSName& qname, co
          and do an additional query for the CNAME target.
          We have a regression test making sure we do exactly that.
       */
-      if(!wasVariable() && newtarget.empty()) {
+      if (newtarget.empty()) {
         t_sstorage.negcache.add(ne);
         if(s_rootNXTrust && ne.d_auth.isRoot() && auth.isRoot() && lwr.d_aabit) {
           ne.d_name = ne.d_name.getLastLabel();
@@ -3591,9 +3591,7 @@ bool SyncRes::processRecords(const std::string& prefix, const DNSName& qname, co
           }
           LOG(prefix<<qname<<": got negative indication of DS record for '"<<newauth<<"'"<<endl);
 
-          if(!wasVariable()) {
-            t_sstorage.negcache.add(ne);
-          }
+          t_sstorage.negcache.add(ne);
 
           if (qname == newauth && qtype == QType::DS) {
             /* we are actually done! */
@@ -3633,10 +3631,8 @@ bool SyncRes::processRecords(const std::string& prefix, const DNSName& qname, co
         }
         ne.d_ttd = d_now.tv_sec + lowestTTL;
 
-        if(!wasVariable()) {
-          if(qtype.getCode()) {  // prevents us from blacking out a whole domain
-            t_sstorage.negcache.add(ne);
-          }
+        if (qtype.getCode()) {  // prevents us from NXDOMAIN'ing a whole domain
+          t_sstorage.negcache.add(ne);
         }
 
         ret.push_back(rec);