bind/backport-Fix-rndc-dumpdb-expired-for-stuck-cache-contents.patch
huangyu 07d38ea3cb bind:backport some patches
Signed-off-by: huangyu <huangyu106@huawei.com>
(cherry picked from commit cd59b6ec71f1147990c7f96b1e74baf413b7d4c9)
2022-12-28 16:00:11 +08:00

108 lines
3.2 KiB
Diff

From f8ad7501dcc3a4008764c5bdd78ae65622c8b905 Mon Sep 17 00:00:00 2001
From: Matthijs Mekking <matthijs@isc.org>
Date: Wed, 20 Jul 2022 11:22:01 +0200
Subject: [PATCH] Fix rndc dumpdb -expired for stuck cache contents
The command 'rndc dumpdb -expired' will include expired RRsets in the
output, but only for the RBTDB_VIRTUAL time (of 5 minutes). This means
that if there is a cache cleaning problem and contents are not cleaned
up, the rndc command has little diagnostic value. Fix this by including
all RRsets in the dumpdb output if the '-expired' flag is set.
(cherry picked from commit 930ba2c914a0abc07fd087d663a7bfb57850d4ca)
---
lib/dns/rbtdb.c | 43 +++++++------------------------------------
1 file changed, 7 insertions(+), 36 deletions(-)
diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c
index 87944980ec0..75832e32085 100644
--- a/lib/dns/rbtdb.c
+++ b/lib/dns/rbtdb.c
@@ -9102,15 +9102,10 @@ 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;
- isc_stdtime_t now;
+ rbtdb_serial_t serial = 1;
- if (IS_CACHE(rbtdb)) {
- serial = 1;
- now = rbtiterator->common.now;
- } else {
+ if (!IS_CACHE(rbtdb)) {
serial = rbtversion->serial;
- now = 0;
}
NODE_LOCK(&rbtdb->node_locks[rbtnode->locknum].lock,
@@ -9122,19 +9117,9 @@ rdatasetiter_first(dns_rdatasetiter_t *iterator) {
if (header->serial <= serial && !IGNORE(header)) {
/*
* Is this a "this rdataset doesn't exist"
- * 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.
+ * record?
*/
- if (NONEXISTENT(header) ||
- (now != 0 &&
- (now - RBTDB_VIRTUAL) >
- header->rdh_ttl +
- rbtdb->serve_stale_ttl))
- {
+ if (NONEXISTENT(header)) {
header = NULL;
}
break;
@@ -9166,22 +9151,17 @@ 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)) {
- serial = 1;
- now = rbtiterator->common.now;
- } else {
+ if (!IS_CACHE(rbtdb)) {
serial = rbtversion->serial;
- now = 0;
}
NODE_LOCK(&rbtdb->node_locks[rbtnode->locknum].lock,
@@ -9207,17 +9187,8 @@ 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) ||
- (now != 0 &&
- (now - RBTDB_VIRTUAL) >
- header->rdh_ttl))
- {
+ if (NONEXISTENT(header)) {
header = NULL;
}
break;
--
GitLab