2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

Add -expired flag to rndc dumpdb command

This flag is the same as -cache, but will use a different style format
that will also print expired entries (awaiting cleanup) from the cache.
This commit is contained in:
Matthijs Mekking
2020-08-13 07:42:36 +02:00
parent c7156d2116
commit 8beda7d2ea
7 changed files with 54 additions and 6 deletions

View File

@@ -85,6 +85,8 @@ struct dns_master_style {
/*% Does the rdataset 'r' contain a stale answer? */
#define STALE(r) (((r)->attributes & DNS_RDATASETATTR_STALE) != 0)
/*% Does the rdataset 'r' contain an expired answer? */
#define ANCIENT(r) (((r)->attributes & DNS_RDATASETATTR_ANCIENT) != 0)
/*%
* Context structure for a masterfile dump in progress.
@@ -171,6 +173,21 @@ LIBDNS_EXTERNAL_DATA const dns_master_style_t dns_master_style_cache = {
UINT_MAX
};
LIBDNS_EXTERNAL_DATA const dns_master_style_t
dns_master_style_cache_with_expired = {
DNS_STYLEFLAG_OMIT_OWNER | DNS_STYLEFLAG_OMIT_CLASS |
DNS_STYLEFLAG_MULTILINE | DNS_STYLEFLAG_RRCOMMENT |
DNS_STYLEFLAG_TRUST | DNS_STYLEFLAG_NCACHE |
DNS_STYLEFLAG_EXPIRED,
24,
32,
32,
40,
80,
8,
UINT_MAX
};
LIBDNS_EXTERNAL_DATA const dns_master_style_t dns_master_style_simple = {
0, 24, 32, 32, 40, 80, 8, UINT_MAX
};
@@ -1065,6 +1082,14 @@ again:
for (i = 0; i < n; i++) {
dns_rdataset_t *rds = sorted[i];
if (ANCIENT(rds) &&
(ctx->style.flags & DNS_STYLEFLAG_EXPIRED) == 0) {
/* Omit expired entries */
dns_rdataset_disassociate(rds);
continue;
}
if ((ctx->style.flags & DNS_STYLEFLAG_TRUST) != 0) {
if ((ctx->style.flags & DNS_STYLEFLAG_INDENT) != 0 ||
(ctx->style.flags & DNS_STYLEFLAG_YAML) != 0)
@@ -1084,10 +1109,12 @@ again:
isc_result_t result;
if (STALE(rds)) {
fprintf(f,
"; stale (will be retained for "
"%u more seconds)\n",
"; stale (will be retained for %u more "
"seconds)\n",
(rds->stale_ttl -
ctx->serve_stale_ttl));
} else if (ANCIENT(rds)) {
fprintf(f, "; expired (awaiting cleanup)\n");
}
result = dump_rdataset(mctx, name, rds, ctx, buffer, f);
if (result != ISC_R_SUCCESS) {