From: Ondřej Surý Date: Tue, 21 Jul 2020 09:35:42 +0000 (+0200) Subject: Expire the 0 TTL RRSet quickly rather using them for serve-stale X-Git-Tag: v9.17.4~16^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6ffa2ddae0bc31271492481ec50f99d68263b25b;p=thirdparty%2Fbind9.git Expire the 0 TTL RRSet quickly rather using them for serve-stale 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". --- diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c index 0e26425a301..9ca6de2ae08 100644 --- a/lib/dns/rbtdb.c +++ b/lib/dns/rbtdb.c @@ -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);