2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 22:15:20 +00:00

Print in dump-file stale ttl

This change makes rndc dumpdb correctly print the "; stale" line.
It also provides extra information on how long this data may still
be served to clients (in other words how long the stale RRset may
still be used).
This commit is contained in:
Matthijs Mekking
2019-01-24 10:24:44 +01:00
committed by Evan Hunt
parent 9a58b25f7f
commit 924ebc605d
4 changed files with 29 additions and 10 deletions

View File

@@ -108,6 +108,7 @@ struct dns_rdataset {
unsigned int magic; /* XXX ? */
dns_rdatasetmethods_t * methods;
ISC_LINK(dns_rdataset_t) link;
/*
* XXX do we need these, or should they be retrieved by methods?
* Leaning towards the latter, since they are not frequently required
@@ -116,12 +117,19 @@ struct dns_rdataset {
dns_rdataclass_t rdclass;
dns_rdatatype_t type;
dns_ttl_t ttl;
/*
* Stale ttl is used to see how long this RRset can still be used
* to serve to clients, after the TTL has expired.
*/
dns_ttl_t stale_ttl;
dns_trust_t trust;
dns_rdatatype_t covers;
/*
* attributes
*/
unsigned int attributes;
/*%
* the counter provides the starting point in the "cyclic" order.
* The value UINT32_MAX has a special meaning of "picking up a
@@ -129,11 +137,13 @@ struct dns_rdataset {
* increment the counter.
*/
uint32_t count;
/*
* This RRSIG RRset should be re-generated around this time.
* Only valid if DNS_RDATASETATTR_RESIGN is set in attributes.
*/
isc_stdtime_t resign;
/*@{*/
/*%
* These are for use by the rdataset implementation, and MUST NOT

View File

@@ -81,6 +81,9 @@ struct dns_master_style {
*/
#define DNS_TOTEXT_LINEBREAK_MAXLEN 100
/*% Does the rdataset 'r' contain a stale answer? */
#define STALE(r) (((r)->attributes & DNS_RDATASETATTR_STALE) != 0)
/*%
* Context structure for a masterfile dump in progress.
*/
@@ -1040,8 +1043,11 @@ dump_rdatasets_text(isc_mem_t *mctx, const dns_name_t *name,
/* Omit negative cache entries */
} else {
isc_result_t result;
if (rds->ttl < ctx->serve_stale_ttl)
fprintf(f, "; stale\n");
if (STALE(rds)) {
fprintf(f, "; stale (for %u more seconds)\n",
(rds->stale_ttl -
ctx->serve_stale_ttl));
}
result = dump_rdataset(mctx, name, rds, ctx, buffer, f);
if (result != ISC_R_SUCCESS)
dumpresult = result;
@@ -1509,13 +1515,14 @@ dumpctx_create(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
dctx->do_date = dns_db_iscache(dctx->db);
if (dctx->do_date) {
/*
* Adjust the date backwards by the serve-stale TTL, if any.
* This is so the TTL will be loaded correctly when next started.
*/
(void)dns_db_getservestalettl(dctx->db,
&dctx->tctx.serve_stale_ttl);
dctx->now -= dctx->tctx.serve_stale_ttl;
/*
* Adjust the date backwards by the serve-stale TTL, if any.
* This is so the TTL will be loaded correctly when next
* started.
*/
(void)dns_db_getservestalettl(dctx->db,
&dctx->tctx.serve_stale_ttl);
dctx->now -= dctx->tctx.serve_stale_ttl;
}
if (dctx->format == dns_masterformat_text &&

View File

@@ -2979,6 +2979,8 @@ bind_rdataset(dns_rbtdb_t *rbtdb, dns_rbtnode_t *node,
rdataset->attributes |= DNS_RDATASETATTR_PREFETCH;
if (STALE(header)) {
rdataset->attributes |= DNS_RDATASETATTR_STALE;
rdataset->stale_ttl =
(rbtdb->serve_stale_ttl + header->rdh_ttl) - now;
rdataset->ttl = 0;
}
rdataset->private1 = rbtdb;

View File

@@ -149,7 +149,7 @@ do { \
#define NOQNAME(r) (((r)->attributes & \
DNS_RDATASETATTR_NOQNAME) != 0)
/*% Does the rdataset 'r' contains a stale answer? */
/*% Does the rdataset 'r' contain a stale answer? */
#define STALE(r) (((r)->attributes & \
DNS_RDATASETATTR_STALE) != 0)