]> granicus.if.org Git - pdns/commitdiff
rec: Fix ECS-specific NS AAAA not being returned from the cache
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 1 Mar 2018 20:09:36 +0000 (20:09 +0000)
committerPieter Lexis <pieter.lexis@powerdns.com>
Mon, 26 Mar 2018 09:15:21 +0000 (11:15 +0200)
Reported by Andreas Jakum (thanks!).

(cherry picked from commit 4474afe14deb3f34088f14c1abbada723458bdf8)

pdns/recursor_cache.cc
pdns/recursordist/test-recursorcache_cc.cc

index d3245420fb1d81014a0278fa25a6998fe1862714..ac983c152657b0e6765df4902d68fa3fccc0658d 100644 (file)
@@ -190,7 +190,7 @@ int32_t MemRecursorCache::get(time_t now, const DNSName &qname, const QType& qt,
       }
       auto entryAAAA = getEntryUsingECSIndex(now, qname, QType::AAAA, requireAuth, who);
       if (entryAAAA != d_cache.end()) {
-        int32_t ttdAAAA = handleHit(entryA, qname, who, res, signatures, authorityRecs, variable, state, wasAuth);
+        int32_t ttdAAAA = handleHit(entryAAAA, qname, who, res, signatures, authorityRecs, variable, state, wasAuth);
         if (ret > 0) {
           ret = std::min(ret, ttdAAAA);
         } else {
index 7d42aa03faf1b68f44fb042395ba50c7a918b6cc..953253d1815812c94673026e1c3b363f9dc1cef5 100644 (file)
@@ -173,9 +173,19 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheSimple) {
     // QType::ADDR should return both A and AAAA but no TXT, so two entries from the right subnet
     BOOST_CHECK_EQUAL(MRC.get(now, power, QType(QType::ADDR), false, &retrieved, ComboAddress("192.0.2.3"), nullptr), (ttd-now));
     BOOST_CHECK_EQUAL(retrieved.size(), 2);
+    bool gotA = false;
+    bool gotAAAA = false;
     for (const auto& rec : retrieved) {
       BOOST_CHECK(rec.d_type == QType::A || rec.d_type == QType::AAAA);
+      if (rec.d_type == QType::A) {
+        gotA = true;
+      }
+      else if (rec.d_type == QType::AAAA) {
+        gotAAAA = true;
+      }
     }
+    BOOST_CHECK(gotA);
+    BOOST_CHECK(gotAAAA);
     retrieved.clear();
 
     // but only the non-subnet specific one from the another subnet