From: Remi Gacogne Date: Thu, 1 Mar 2018 20:09:36 +0000 (+0000) Subject: rec: Fix ECS-specific NS AAAA not being returned from the cache X-Git-Tag: dnsdist-1.3.0~67^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4474afe14deb3f34088f14c1abbada723458bdf8;p=pdns rec: Fix ECS-specific NS AAAA not being returned from the cache Reported by Andreas Jakum (thanks!). --- diff --git a/pdns/recursor_cache.cc b/pdns/recursor_cache.cc index 23dee223f..30286064f 100644 --- a/pdns/recursor_cache.cc +++ b/pdns/recursor_cache.cc @@ -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 { diff --git a/pdns/recursordist/test-recursorcache_cc.cc b/pdns/recursordist/test-recursorcache_cc.cc index 0780b62b2..d69c07047 100644 --- a/pdns/recursordist/test-recursorcache_cc.cc +++ b/pdns/recursordist/test-recursorcache_cc.cc @@ -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