]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Remove useless .expire initialization from rdataslab
authorOndřej Surý <ondrej@isc.org>
Wed, 14 Jan 2026 12:17:30 +0000 (13:17 +0100)
committerOndřej Surý <ondrej@isc.org>
Mon, 30 Mar 2026 19:46:44 +0000 (21:46 +0200)
dns_rdataslab_fromrdataset() set .expire to rdataset->ttl, but the
only consumer (qpcache_addrdataset) immediately overwrote it with
now + rdataset->ttl.  Remove the redundant initialization and set the
expire time only once.

lib/dns/include/dns/rdataslab.h
lib/dns/qpcache.c
lib/dns/rdataslab.c

index 51a179247b94fbc8da59078a2bec5de188f0e66f..5b7e8ffc76726a9f873200cb33f102f33ab4fe2c 100644 (file)
@@ -191,10 +191,8 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx,
  *
  * dns_rdataslab_fromrdataset() allocates space for a dns_slabheader object
  * and the memory needed for a raw slab, and partially initializes
- * it, setting the type, trust, and TTL fields to match rdataset->type,
- * rdataset->covers, rdataset->trust, and rdataset->ttl.  (Note that the
- * last field needs to be overridden when used in the cache database,
- * since cache headers use an expire time instead of a TTL.)
+ * it, setting the type, and trust fields to match rdataset->type,
+ * rdataset->covers, and rdataset->trust.
  *
  * Requires:
  *\li  'rdataset' is valid.
index 2b6eaac8c3e0aaa4ccc718828e66427dff5e999c..db0d4f99777c89fa632eb1706c0c8b069cbc3a1f 100644 (file)
@@ -2874,11 +2874,9 @@ qpcache_addrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
        dns_slabheader_reset(newheader, node);
 
        /*
-        * By default, dns_rdataslab_fromrdataset() sets newheader->ttl
-        * to the rdataset TTL. In the case of the cache, that's wrong;
-        * we need it to be set to the expire time instead.
+        * Set the correct expire time.
         */
-       setttl(newheader, rdataset->ttl + now);
+       setttl(newheader, now + rdataset->ttl);
        if (rdataset->ttl == 0U) {
                DNS_SLABHEADER_SETATTR(newheader, DNS_SLABHEADERATTR_ZEROTTL);
        }
index 64e955cad4e34603440039b8f081e983185e5a01..e0a43e84347e3c0f69f3773016e2bb2fd1251afd 100644 (file)
@@ -110,7 +110,6 @@ newslab(dns_rdataset_t *rdataset, isc_mem_t *mctx, isc_region_t *region,
        *header = (dns_slabheader_t){
                .headers_link = CDS_LIST_HEAD_INIT(header->headers_link),
                .trust = rdataset->trust,
-               .expire = rdataset->ttl,
                .dirtylink = ISC_LINK_INITIALIZER,
                .nitems = nitems,
        };