mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-01 15:05:23 +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:
@@ -243,6 +243,7 @@ struct dumpcontext {
|
|||||||
bool dumpzones;
|
bool dumpzones;
|
||||||
bool dumpadb;
|
bool dumpadb;
|
||||||
bool dumpbad;
|
bool dumpbad;
|
||||||
|
bool dumpexpired;
|
||||||
bool dumpfail;
|
bool dumpfail;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
ISC_LIST(struct viewlistentry) viewlist;
|
ISC_LIST(struct viewlistentry) viewlist;
|
||||||
@@ -11052,7 +11053,11 @@ resume:
|
|||||||
dns_cache_getname(dctx->view->view->cache));
|
dns_cache_getname(dctx->view->view->cache));
|
||||||
} else if (dctx->zone == NULL && dctx->cache == NULL && dctx->dumpcache)
|
} else if (dctx->zone == NULL && dctx->cache == NULL && dctx->dumpcache)
|
||||||
{
|
{
|
||||||
style = &dns_master_style_cache;
|
if (dctx->dumpexpired) {
|
||||||
|
style = &dns_master_style_cache_with_expired;
|
||||||
|
} else {
|
||||||
|
style = &dns_master_style_cache;
|
||||||
|
}
|
||||||
/* start cache dump */
|
/* start cache dump */
|
||||||
if (dctx->view->view->cachedb != NULL) {
|
if (dctx->view->view->cachedb != NULL) {
|
||||||
dns_db_attach(dctx->view->view->cachedb, &dctx->cache);
|
dns_db_attach(dctx->view->view->cachedb, &dctx->cache);
|
||||||
@@ -11186,6 +11191,7 @@ named_server_dumpdb(named_server_t *server, isc_lex_t *lex,
|
|||||||
dctx->dumpcache = true;
|
dctx->dumpcache = true;
|
||||||
dctx->dumpadb = true;
|
dctx->dumpadb = true;
|
||||||
dctx->dumpbad = true;
|
dctx->dumpbad = true;
|
||||||
|
dctx->dumpexpired = false;
|
||||||
dctx->dumpfail = true;
|
dctx->dumpfail = true;
|
||||||
dctx->dumpzones = false;
|
dctx->dumpzones = false;
|
||||||
dctx->fp = NULL;
|
dctx->fp = NULL;
|
||||||
@@ -11216,6 +11222,10 @@ named_server_dumpdb(named_server_t *server, isc_lex_t *lex,
|
|||||||
} else if (ptr != NULL && strcmp(ptr, "-cache") == 0) {
|
} else if (ptr != NULL && strcmp(ptr, "-cache") == 0) {
|
||||||
/* this is the default */
|
/* this is the default */
|
||||||
ptr = next_token(lex, NULL);
|
ptr = next_token(lex, NULL);
|
||||||
|
} else if (ptr != NULL && strcmp(ptr, "-expired") == 0) {
|
||||||
|
/* this is the same as -cache but includes expired data */
|
||||||
|
dctx->dumpexpired = true;
|
||||||
|
ptr = next_token(lex, NULL);
|
||||||
} else if (ptr != NULL && strcmp(ptr, "-zones") == 0) {
|
} else if (ptr != NULL && strcmp(ptr, "-zones") == 0) {
|
||||||
/* only dump zones, suppress caches */
|
/* only dump zones, suppress caches */
|
||||||
dctx->dumpadb = false;
|
dctx->dumpadb = false;
|
||||||
|
@@ -124,7 +124,7 @@ command is one of the following:\n\
|
|||||||
Close, truncate and re-open the DNSTAP output file.\n\
|
Close, truncate and re-open the DNSTAP output file.\n\
|
||||||
dnstap -roll count\n\
|
dnstap -roll count\n\
|
||||||
Close, rename and re-open the DNSTAP output file(s).\n\
|
Close, rename and re-open the DNSTAP output file(s).\n\
|
||||||
dumpdb [-all|-cache|-zones|-adb|-bad|-fail] [view ...]\n\
|
dumpdb [-all|-cache|-zones|-adb|-bad|-expired|-fail] [view ...]\n\
|
||||||
Dump cache(s) to the dump file (named_dump.db).\n\
|
Dump cache(s) to the dump file (named_dump.db).\n\
|
||||||
flush Flushes all of the server's caches.\n\
|
flush Flushes all of the server's caches.\n\
|
||||||
flush [view] Flushes the server's cache for a view.\n\
|
flush [view] Flushes the server's cache for a view.\n\
|
||||||
|
@@ -186,7 +186,7 @@ Currently supported commands are:
|
|||||||
output file is moved to ".1", and so on. If ``number`` is specified, then
|
output file is moved to ".1", and so on. If ``number`` is specified, then
|
||||||
the number of backup log files is limited to that number.
|
the number of backup log files is limited to that number.
|
||||||
|
|
||||||
``dumpdb`` [**-all** | **-cache** | **-zones** | **-adb** | **-bad** | **-fail**] [*view ...*]
|
``dumpdb`` [**-all** | **-cache** | **-zones** | **-adb** | **-bad** | **-expired** | **-fail**] [*view ...*]
|
||||||
This command dumps the server's caches (default) and/or zones to the dump file for
|
This command dumps the server's caches (default) and/or zones to the dump file for
|
||||||
the specified views. If no view is specified, all views are dumped.
|
the specified views. If no view is specified, all views are dumped.
|
||||||
(See the ``dump-file`` option in the BIND 9 Administrator Reference
|
(See the ``dump-file`` option in the BIND 9 Administrator Reference
|
||||||
|
@@ -186,7 +186,7 @@ output file has ".0" appended to its name; the previous most recent
|
|||||||
output file is moved to ".1", and so on. If \fBnumber\fP is specified, then
|
output file is moved to ".1", and so on. If \fBnumber\fP is specified, then
|
||||||
the number of backup log files is limited to that number.
|
the number of backup log files is limited to that number.
|
||||||
.TP
|
.TP
|
||||||
\fBdumpdb\fP [\fB\-all\fP | \fB\-cache\fP | \fB\-zones\fP | \fB\-adb\fP | \fB\-bad\fP | \fB\-fail\fP] [\fIview ...\fP]
|
\fBdumpdb\fP [\fB\-all\fP | \fB\-cache\fP | \fB\-zones\fP | \fB\-adb\fP | \fB\-bad\fP | \fB\-expired\fP | \fB\-fail\fP] [\fIview ...\fP]
|
||||||
This command dumps the server\(aqs caches (default) and/or zones to the dump file for
|
This command dumps the server\(aqs caches (default) and/or zones to the dump file for
|
||||||
the specified views. If no view is specified, all views are dumped.
|
the specified views. If no view is specified, all views are dumped.
|
||||||
(See the \fBdump\-file\fP option in the BIND 9 Administrator Reference
|
(See the \fBdump\-file\fP option in the BIND 9 Administrator Reference
|
||||||
|
@@ -110,6 +110,9 @@ typedef struct dns_master_style dns_master_style_t;
|
|||||||
/*% Print ECS cache entries as comments (reserved for future use). */
|
/*% Print ECS cache entries as comments (reserved for future use). */
|
||||||
#define DNS_STYLEFLAG_ECSCACHE 0x100000000ULL
|
#define DNS_STYLEFLAG_ECSCACHE 0x100000000ULL
|
||||||
|
|
||||||
|
/*% Print expired cache entries. */
|
||||||
|
#define DNS_STYLEFLAG_EXPIRED 0x200000000ULL
|
||||||
|
|
||||||
ISC_LANG_BEGINDECLS
|
ISC_LANG_BEGINDECLS
|
||||||
|
|
||||||
/***
|
/***
|
||||||
@@ -145,6 +148,13 @@ LIBDNS_EXTERNAL_DATA extern const dns_master_style_t
|
|||||||
*/
|
*/
|
||||||
LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_cache;
|
LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_cache;
|
||||||
|
|
||||||
|
/*%
|
||||||
|
* A master style format designed for cache files. The same as above but
|
||||||
|
* this also prints expired entries.
|
||||||
|
*/
|
||||||
|
LIBDNS_EXTERNAL_DATA extern const dns_master_style_t
|
||||||
|
dns_master_style_cache_with_expired;
|
||||||
|
|
||||||
/*%
|
/*%
|
||||||
* A master style that prints name, ttl, class, type, and value on
|
* A master style that prints name, ttl, class, type, and value on
|
||||||
* every line. Similar to explicitttl above, but more verbose.
|
* every line. Similar to explicitttl above, but more verbose.
|
||||||
|
@@ -188,6 +188,7 @@ struct dns_rdataset {
|
|||||||
#define DNS_RDATASETATTR_PREFETCH 0x00400000
|
#define DNS_RDATASETATTR_PREFETCH 0x00400000
|
||||||
#define DNS_RDATASETATTR_CYCLIC 0x00800000 /*%< Cyclic ordering. */
|
#define DNS_RDATASETATTR_CYCLIC 0x00800000 /*%< Cyclic ordering. */
|
||||||
#define DNS_RDATASETATTR_STALE 0x01000000
|
#define DNS_RDATASETATTR_STALE 0x01000000
|
||||||
|
#define DNS_RDATASETATTR_ANCIENT 0x02000000
|
||||||
|
|
||||||
/*%
|
/*%
|
||||||
* _OMITDNSSEC:
|
* _OMITDNSSEC:
|
||||||
|
@@ -85,6 +85,8 @@ struct dns_master_style {
|
|||||||
|
|
||||||
/*% Does the rdataset 'r' contain a stale answer? */
|
/*% Does the rdataset 'r' contain a stale answer? */
|
||||||
#define STALE(r) (((r)->attributes & DNS_RDATASETATTR_STALE) != 0)
|
#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.
|
* 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
|
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 = {
|
LIBDNS_EXTERNAL_DATA const dns_master_style_t dns_master_style_simple = {
|
||||||
0, 24, 32, 32, 40, 80, 8, UINT_MAX
|
0, 24, 32, 32, 40, 80, 8, UINT_MAX
|
||||||
};
|
};
|
||||||
@@ -1065,6 +1082,14 @@ again:
|
|||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
dns_rdataset_t *rds = sorted[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_TRUST) != 0) {
|
||||||
if ((ctx->style.flags & DNS_STYLEFLAG_INDENT) != 0 ||
|
if ((ctx->style.flags & DNS_STYLEFLAG_INDENT) != 0 ||
|
||||||
(ctx->style.flags & DNS_STYLEFLAG_YAML) != 0)
|
(ctx->style.flags & DNS_STYLEFLAG_YAML) != 0)
|
||||||
@@ -1084,10 +1109,12 @@ again:
|
|||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
if (STALE(rds)) {
|
if (STALE(rds)) {
|
||||||
fprintf(f,
|
fprintf(f,
|
||||||
"; stale (will be retained for "
|
"; stale (will be retained for %u more "
|
||||||
"%u more seconds)\n",
|
"seconds)\n",
|
||||||
(rds->stale_ttl -
|
(rds->stale_ttl -
|
||||||
ctx->serve_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);
|
result = dump_rdataset(mctx, name, rds, ctx, buffer, f);
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
|
Reference in New Issue
Block a user