From: Matthijs Mekking Date: Fri, 12 Mar 2021 15:27:45 +0000 (+0100) Subject: Use stale TTL as RRset TTL in dumpdb X-Git-Tag: v9.17.13~65^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a83c8cb0afd88d54b9cf67239f2495c9b0391e97;p=thirdparty%2Fbind9.git Use stale TTL as RRset TTL in dumpdb It is more intuitive to have the countdown 'max-stale-ttl' as the RRset TTL, instead of 0 TTL. This information was already available in a comment "; stale (will be retained for x more seconds", but Support suggested to put it in the TTL field instead. --- diff --git a/bin/tests/system/serve-stale/tests.sh b/bin/tests/system/serve-stale/tests.sh index 62f6bf8bec6..4a83e35ac65 100755 --- a/bin/tests/system/serve-stale/tests.sh +++ b/bin/tests/system/serve-stale/tests.sh @@ -111,10 +111,10 @@ sleep 2 echo_i "check rndc dump stale data.example ($n)" rndc_dumpdb ns1 || ret=1 awk '/; stale/ { x=$0; getline; print x, $0}' ns1/named_dump.db.test$n | - grep "; stale (will be retained for 3[56].. more seconds) data\.example.*A text record with a 2 second ttl" > /dev/null 2>&1 || ret=1 + grep "; stale data\.example.*3[56]...*TXT.*A text record with a 2 second ttl" > /dev/null 2>&1 || ret=1 # Also make sure the not expired data does not have a stale comment. awk '/; answer/ { x=$0; getline; print x, $0}' ns1/named_dump.db.test$n | - grep "; answer longttl\.example.*A text record with a 600 second ttl" > /dev/null 2>&1 || ret=1 + grep "; answer longttl\.example.*[56]...*TXT.*A text record with a 600 second ttl" > /dev/null 2>&1 || ret=1 if [ $ret != 0 ]; then echo_i "failed"; fi status=$((status+ret)) diff --git a/lib/dns/masterdump.c b/lib/dns/masterdump.c index 8a4eb4de473..c8dcce5aa2c 100644 --- a/lib/dns/masterdump.c +++ b/lib/dns/masterdump.c @@ -1108,10 +1108,7 @@ again: } else { isc_result_t result; if (STALE(rds)) { - fprintf(f, - "; stale (will be retained for %u more " - "seconds)\n", - rds->stale_ttl); + fprintf(f, "; stale\n"); } else if (ANCIENT(rds)) { isc_buffer_t b; char buf[sizeof("YYYYMMDDHHMMSS")]; diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c index f30d560e682..f9c93416eda 100644 --- a/lib/dns/rbtdb.c +++ b/lib/dns/rbtdb.c @@ -3160,7 +3160,7 @@ bind_rdataset(dns_rbtdb_t *rbtdb, dns_rbtnode_t *node, rdatasetheader_t *header, } rdataset->attributes |= DNS_RDATASETATTR_STALE; rdataset->stale_ttl = stale_ttl; - rdataset->ttl = 0; + rdataset->ttl = stale_ttl; } else if (IS_CACHE(rbtdb) && !ACTIVE(header, now)) { rdataset->attributes |= DNS_RDATASETATTR_ANCIENT; rdataset->stale_ttl = header->rdh_ttl; diff --git a/lib/dns/tests/db_test.c b/lib/dns/tests/db_test.c index c12e90ee1c1..e41a63c0cf4 100644 --- a/lib/dns/tests/db_test.c +++ b/lib/dns/tests/db_test.c @@ -248,7 +248,6 @@ dns_dbfind_staleok_test(void **state) { count++; assert_in_range(count, 0, 49); /* loop sanity */ assert_int_equal(result, ISC_R_SUCCESS); - assert_int_equal(rdataset.ttl, 0); assert_int_equal(rdataset.attributes & DNS_RDATASETATTR_STALE, DNS_RDATASETATTR_STALE);