]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Revert "Fix rndc dumpdb -expired for stuck cache contents"
authorMark Andrews <marka@isc.org>
Tue, 15 Nov 2022 05:35:32 +0000 (16:35 +1100)
committerMark Andrews <marka@isc.org>
Wed, 7 Dec 2022 23:46:18 +0000 (10:46 +1100)
This reverts commit f8d866c6efa4c9c2726f8ebcf2e66122198576c4.

(cherry picked from commit 90249e4aa574016b61fbd550bf038efcd85a5d15)

lib/dns/rbtdb.c

index b36cdf22059c27fc7e78e6a4edd4fdf9f8b5de63..4534de37728290cfc9de61512ea2d240b755e97d 100644 (file)
@@ -9158,10 +9158,15 @@ rdatasetiter_first(dns_rdatasetiter_t *iterator) {
        dns_rbtnode_t *rbtnode = rbtiterator->common.node;
        rbtdb_version_t *rbtversion = rbtiterator->common.version;
        rdatasetheader_t *header, *top_next;
-       rbtdb_serial_t serial = 1;
+       rbtdb_serial_t serial;
+       isc_stdtime_t now;
 
-       if (!IS_CACHE(rbtdb)) {
+       if (IS_CACHE(rbtdb)) {
+               serial = 1;
+               now = rbtiterator->common.now;
+       } else {
                serial = rbtversion->serial;
+               now = 0;
        }
 
        NODE_LOCK(&rbtdb->node_locks[rbtnode->locknum].lock,
@@ -9173,9 +9178,19 @@ rdatasetiter_first(dns_rdatasetiter_t *iterator) {
                        if (header->serial <= serial && !IGNORE(header)) {
                                /*
                                 * Is this a "this rdataset doesn't exist"
-                                * record?
+                                * record?  Or is it too old in the cache?
+                                *
+                                * Note: unlike everywhere else, we
+                                * check for now > header->rdh_ttl instead
+                                * of ">=".  This allows ANY and RRSIG
+                                *  queries for 0 TTL rdatasets to work.
                                 */
-                               if (NONEXISTENT(header)) {
+                               if (NONEXISTENT(header) ||
+                                   (now != 0 &&
+                                    (now - RBTDB_VIRTUAL) >
+                                            header->rdh_ttl +
+                                                    rbtdb->serve_stale_ttl))
+                               {
                                        header = NULL;
                                }
                                break;
@@ -9207,17 +9222,22 @@ rdatasetiter_next(dns_rdatasetiter_t *iterator) {
        dns_rbtnode_t *rbtnode = rbtiterator->common.node;
        rbtdb_version_t *rbtversion = rbtiterator->common.version;
        rdatasetheader_t *header, *top_next;
+       rbtdb_serial_t serial;
+       isc_stdtime_t now;
        rbtdb_rdatatype_t type, negtype;
        dns_rdatatype_t rdtype, covers;
-       rbtdb_serial_t serial = 1;
 
        header = rbtiterator->current;
        if (header == NULL) {
                return (ISC_R_NOMORE);
        }
 
-       if (!IS_CACHE(rbtdb)) {
+       if (IS_CACHE(rbtdb)) {
+               serial = 1;
+               now = rbtiterator->common.now;
+       } else {
                serial = rbtversion->serial;
+               now = 0;
        }
 
        NODE_LOCK(&rbtdb->node_locks[rbtnode->locknum].lock,
@@ -9243,8 +9263,17 @@ rdatasetiter_next(dns_rdatasetiter_t *iterator) {
                                        /*
                                         * Is this a "this rdataset doesn't
                                         * exist" record?
+                                        *
+                                        * Note: unlike everywhere else, we
+                                        * check for now > header->ttl instead
+                                        * of ">=".  This allows ANY and RRSIG
+                                        * queries for 0 TTL rdatasets to work.
                                         */
-                                       if (NONEXISTENT(header)) {
+                                       if (NONEXISTENT(header) ||
+                                           (now != 0 &&
+                                            (now - RBTDB_VIRTUAL) >
+                                                    header->rdh_ttl))
+                                       {
                                                header = NULL;
                                        }
                                        break;