]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Print in dump-file stale ttl
authorMatthijs Mekking <matthijs@isc.org>
Thu, 24 Jan 2019 09:24:44 +0000 (10:24 +0100)
committerEvan Hunt <each@isc.org>
Thu, 31 Jan 2019 18:30:11 +0000 (10:30 -0800)
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).

lib/dns/include/dns/rdataset.h
lib/dns/masterdump.c
lib/dns/rbtdb.c
lib/ns/query.c

index f48e32d55c775d6eec85f1cfcf7ad50455c6766c..91fa8a68797169cc4743cae8ec069e4a397e595d 100644 (file)
@@ -109,6 +109,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
@@ -117,12 +118,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
@@ -130,11 +138,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
index bf8260878d75882c47cb98ff378bc5c3fc11fc85..129ab996d418ab1b9524d5fe723d101c698495de 100644 (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.
  */
@@ -1039,8 +1042,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;
@@ -1508,13 +1514,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 &&
index f1b0ab5fa8efe8213e2fd85c4c2ad71eba171472..b34bd6cff24726fe29b2cbaec892351f221ff734 100644 (file)
@@ -3316,6 +3316,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;
index ce89b20c23f1521d09a62b066455cc44b5b5799d..ef5fc3360c69d3e2114fabd9578f7ebe5eedcf2d 100644 (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)