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".
This commit is contained in:
Ondřej Surý 2020-07-21 11:35:42 +02:00 committed by Matthijs Mekking
parent ce53db34d6
commit 6ffa2ddae0

View 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);