]> 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>
Mon, 3 Feb 2025 14:47:06 +0000 (15:47 +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/qpcache.c

index 6dc3c20308a10aba8c08ad4f8011bcfaedb6445e..42b94dbeb5a0ebce3b0782ce587415dad5e31a12 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 89518b0ebfcb5fd1f056e9467363d36d08b1a74b..027d70cc040b55b18086a29e06fc714e5ea4c512 100644 (file)
@@ -143,7 +143,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;
+       };
 
        /*%
         * Extra fields used by various rdataset implementations, that is, by
index 89ae4154b1e01864b255f69e9290d5d209ade9bd..f2df38687db685dddc418bad3f3e16eb394692e7 100644 (file)
@@ -1160,7 +1160,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 4c3a0754cb5dc4b75f9b8f975d0114bca2196644..560812a6d17c06ef1e4868604a49132fb2db4c2d 100644 (file)
@@ -1105,6 +1105,7 @@ bindrdataset(qpcache_t *qpdb, qpcnode_t *node, dns_slabheader_t *header,
                        rdataset->attributes |= DNS_RDATASETATTR_STALE_WINDOW;
                }
                rdataset->attributes |= DNS_RDATASETATTR_STALE;
+               rdataset->expire = header->expire;
        } else if (!ACTIVE(header, now)) {
                rdataset->attributes |= DNS_RDATASETATTR_ANCIENT;
                rdataset->ttl = 0;