From: Matthijs Mekking Date: Thu, 24 Jan 2019 09:24:44 +0000 (+0100) Subject: Print in dump-file stale ttl X-Git-Tag: v9.13.6~21^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=924ebc605db798e2a383ee5eaaebad739e7c789c;p=thirdparty%2Fbind9.git 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). --- diff --git a/lib/dns/include/dns/rdataset.h b/lib/dns/include/dns/rdataset.h index 6a07d214c93..027e60fd93b 100644 --- a/lib/dns/include/dns/rdataset.h +++ b/lib/dns/include/dns/rdataset.h @@ -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 diff --git a/lib/dns/masterdump.c b/lib/dns/masterdump.c index 1eff6f53833..74b5df96241 100644 --- a/lib/dns/masterdump.c +++ b/lib/dns/masterdump.c @@ -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 && diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c index bf70561b2a7..9ed7c943f44 100644 --- a/lib/dns/rbtdb.c +++ b/lib/dns/rbtdb.c @@ -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; diff --git a/lib/ns/query.c b/lib/ns/query.c index 0798e2c817b..b6c20fb1853 100644 --- a/lib/ns/query.c +++ b/lib/ns/query.c @@ -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)