]> 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)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 1 Mar 2018 20:09:36 +0000 (20:09 +0000)
Reported by Andreas Jakum (thanks!).

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

index 23dee223fb38cecceaaf292a54b5518cb097c092..30286064f173ceddc5f0a305838a818def2f0acf 100644 (file)
@@ -189,7 +189,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 0780b62b2fcd4c38458e99c138a7ea01a4f0a877..d69c07047e9941c84b9e03eda10dd92953862197 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