]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Reformulate condition and comment to make it more clear.
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 1 Apr 2019 12:27:27 +0000 (14:27 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 1 Apr 2019 14:30:51 +0000 (14:30 +0000)
(cherry picked from commit 73d9bf3ad13de7031a71700d00fb4efbab8ca938)

pdns/recursordist/docs/settings.rst
pdns/recursordist/test-syncres_cc.cc
pdns/syncres.cc

index 7f59901c1fab77160e19e53fe4c9ddf856a7576d..15a8f53ea1823c59f13a4ff439d4d2a8c187939d 100644 (file)
@@ -407,7 +407,7 @@ Can be set at runtime using ``rec_control set-ecs-minimum-ttl 3600``.
 -  Integer
 -  Default: 0 (disabled)
 
-The minumum TTL for an ECS-specific answer to be inserted into the query cache. This condition applies in conjunction with ``ecs-ipv4-cache-bits`` or ``ecs-ipv6-cache-bits``.
+The minimum TTL for an ECS-specific answer to be inserted into the query cache. This condition applies in conjunction with ``ecs-ipv4-cache-bits`` or ``ecs-ipv6-cache-bits``.
 That is, only if both the limits apply, the record will not be cached.
 
 .. _setting-ecs-scope-zero-address:
index 6fc96c86d2c96eabb21d4bc55e37a63f0623a7ce..2288143dd2e82bc20f12005327e66ef02742014a 100644 (file)
@@ -1982,7 +1982,7 @@ BOOST_AUTO_TEST_CASE(test_ecs_cache_limit_no_ttl_limit_allowed) {
   BOOST_CHECK_EQUAL(res, RCode::NoError);
   BOOST_CHECK_EQUAL(ret.size(), 1);
 
-  /* should have been cached because /24 is more specific than /16 but TTL limit is nof efective */
+  /* should have been cached because /24 is more specific than /16 but TTL limit is nof effective */
   const ComboAddress who("192.0.2.128");
   vector<DNSRecord> cached;
   BOOST_REQUIRE_GT(t_RC->get(now, target, QType(QType::A), true, &cached, who), 0);
index bf46ff238f0b139dc296ea3dece0b04ff79cc941..77d0153dd1747c779de902d987d148458b4149ed 100644 (file)
@@ -2142,14 +2142,13 @@ RCode::rcodes_ SyncRes::updateCacheFromRecords(unsigned int depth, LWResult& lwr
     */
     if (i->first.type != QType::NSEC3 && (i->first.type == QType::DS || i->first.type == QType::NS || i->first.type == QType::A || i->first.type == QType::AAAA || isAA || wasForwardRecurse)) {
 
-      bool doCache = i->first.place != DNSResourceRecord::ANSWER || !ednsmask;
-      // if ednsmask is relevant, we do not want to cache if the scope > ecslimit and TTL < limitttl
-      if (!doCache && ednsmask) {
-        bool manyMaskBits = (ednsmask->isIpv4() && ednsmask->getBits() > SyncRes::s_ecsipv4cachelimit) ||
+      bool doCache = true;
+      if (i->first.place == DNSResourceRecord::ANSWER && ednsmask) {
+        // If ednsmask is relevant, we do not want to cache if the scope prefix length is large and TTL is small
+        if (SyncRes::s_ecscachelimitttl > 0) {
+          bool manyMaskBits = (ednsmask->isIpv4() && ednsmask->getBits() > SyncRes::s_ecsipv4cachelimit) ||
             (ednsmask->isIpv6() && ednsmask->getBits() > SyncRes::s_ecsipv6cachelimit);
-        doCache = true;
 
-        if (SyncRes::s_ecscachelimitttl > 0) {
           if (manyMaskBits) {
             uint32_t minttl = UINT32_MAX;
             for (const auto &it : i->second.records) {