From 4474afe14deb3f34088f14c1abbada723458bdf8 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Thu, 1 Mar 2018 20:09:36 +0000 Subject: [PATCH] rec: Fix ECS-specific NS AAAA not being returned from the cache Reported by Andreas Jakum (thanks!). --- pdns/recursor_cache.cc | 2 +- pdns/recursordist/test-recursorcache_cc.cc | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pdns/recursor_cache.cc b/pdns/recursor_cache.cc index 23dee223fb..30286064f1 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 0780b62b2f..d69c07047e 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 -- 2.47.2