]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Expire the 0 TTL RRSet quickly rather using them for serve-stale
authorOndřej Surý <ondrej@isc.org>
Tue, 21 Jul 2020 09:35:42 +0000 (11:35 +0200)
committerMatthijs Mekking <matthijs@isc.org>
Tue, 4 Aug 2020 08:50:31 +0000 (10:50 +0200)
When a received RRSet has TTL 0, they would be preserved for
serve-stale (default `max-stale-cache` is 12 hours) rather than expiring
them quickly from the cache database.

This commit makes sure the RRSet didn't have TTL 0 before marking the
entry in the database as "stale".

lib/dns/rbtdb.c

index 0e26425a301c850371cf0b3a5304c7074ba3a6e5..9ca6de2ae08bfe4665bf8cf1e164190fa36869ca 100644 (file)
@@ -1630,6 +1630,8 @@ mark_header_stale(dns_rbtdb_t *rbtdb, rdatasetheader_t *header) {
        uint_least16_t attributes = atomic_load_acquire(&header->attributes);
        uint_least16_t newattributes = 0;
 
+       INSIST((attributes & RDATASET_ATTR_ZEROTTL) == 0);
+
        /*
         * If we are already stale there is nothing to do.
         */
@@ -4522,9 +4524,11 @@ check_stale_header(dns_rbtnode_t *node, rdatasetheader_t *header,
                /*
                 * If this data is in the stale window keep it and if
                 * DNS_DBFIND_STALEOK is not set we tell the caller to
-                * skip this record.
+                * skip this record.  We skip the records with ZEROTTL
+                * (these records should not be cached anyway).
                 */
-               if (KEEPSTALE(search->rbtdb) && stale > search->now) {
+               if (!ZEROTTL(header) && KEEPSTALE(search->rbtdb) &&
+                   stale > search->now) {
                        mark_header_stale(search->rbtdb, header);
                        *header_prev = header;
                        return ((search->options & DNS_DBFIND_STALEOK) == 0);