]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Print the expiration time of the stale records (not ancient)
authorOndřej Surý <ondrej@isc.org>
Mon, 3 Feb 2025 10:15:15 +0000 (11:15 +0100)
committerOndřej Surý <ondrej@isc.org>
Tue, 4 Feb 2025 17:07:30 +0000 (18:07 +0100)
In #1870, the expiration time of ANCIENT records were printed, but
actually the ancient records are very short lived, and the information
carries a little value.

Instead of printing the expiration of ANCIENT records, print the
expiration time of STALE records.

bin/tests/system/serve-stale/tests.sh
lib/dns/include/dns/rdataset.h
lib/dns/masterdump.c
lib/dns/rbtdb.c

index 37dafa33f77657a1e47b017576f42e3238c9ef39..fee2b376b720ff1b1eee81accd0a6f797e5b9f3e 100755 (executable)
@@ -115,8 +115,8 @@ sleep 2
 # stale for somewhere between 3500-3599 seconds.
 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 data\.example.*3[56]...*TXT.*A text record with a 2 second ttl" >/dev/null 2>&1 || ret=1
+awk '/; stale since [0-9]*/ { x=$0; getline; print x, $0}' ns1/named_dump.db.test$n \
+  | grep "; stale since [0-9]* 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 '/; authanswer/ { x=$0; getline; print x, $0}' ns1/named_dump.db.test$n \
   | grep "; authanswer longttl\.example.*[56]...*TXT.*A text record with a 600 second ttl" >/dev/null 2>&1 || ret=1
index 3a852268363dea115dad759f051d3b72017c251a..caa49c5845a115144c725aa408d8cdbaae7e080e 100644 (file)
@@ -131,7 +131,10 @@ struct dns_rdataset {
         * This RRSIG RRset should be re-generated around this time.
         * Only valid if DNS_RDATASETATTR_RESIGN is set in attributes.
         */
-       isc_stdtime_t resign;
+       union {
+               isc_stdtime_t resign;
+               isc_stdtime_t expire;
+       };
 
        /*@{*/
        /*%
index 5dc474d7453c6e108d88a3a8ab1e2131899df7e1..1c850d912547b4b3fea726db0292f52b37c84555 100644 (file)
@@ -1155,7 +1155,12 @@ again:
                } else {
                        isc_result_t result;
                        if (STALE(rds)) {
-                               fprintf(f, "; stale\n");
+                               isc_buffer_t b;
+                               char buf[sizeof("YYYYMMDDHHMMSS")];
+                               memset(buf, 0, sizeof(buf));
+                               isc_buffer_init(&b, buf, sizeof(buf) - 1);
+                               dns_time64_totext((uint64_t)rds->expire, &b);
+                               fprintf(f, "; stale since %s\n", buf);
                        } else if (ANCIENT(rds)) {
                                fprintf(f, "; expired (awaiting cleanup)\n");
                        }
index 572c55e2cc0a5e65cf1f81e4cc53eae733608047..8a63d5312a863b25d0ac504b58bc577c8908585d 100644 (file)
@@ -3180,6 +3180,7 @@ bind_rdataset(dns_rbtdb_t *rbtdb, dns_rbtnode_t *node, rdatasetheader_t *header,
                        rdataset->attributes |= DNS_RDATASETATTR_STALE_WINDOW;
                }
                rdataset->attributes |= DNS_RDATASETATTR_STALE;
+               rdataset->expire = header->rdh_ttl;
        } else if (IS_CACHE(rbtdb) && !ACTIVE(header, now)) {
                rdataset->attributes |= DNS_RDATASETATTR_ANCIENT;
                rdataset->ttl = 0;