]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
simplify dns_ncache_add()
authorEvan Hunt <each@isc.org>
Wed, 26 Feb 2025 21:47:40 +0000 (13:47 -0800)
committerEvan Hunt <each@isc.org>
Wed, 26 Feb 2025 23:28:57 +0000 (15:28 -0800)
there's no longer any reason to have both dns_ncache_add() and
dns_ncache_addoptout().

lib/dns/include/dns/ncache.h
lib/dns/ncache.c
lib/dns/resolver.c

index 4c196aa7fab72b9b54b9f2b47e953a635b486fd5..6eded5dd8bdb983cde7a29da4d62d988d295a83d 100644 (file)
 isc_result_t
 dns_ncache_add(dns_message_t *message, dns_db_t *cache, dns_dbnode_t *node,
               dns_rdatatype_t covers, isc_stdtime_t now, dns_ttl_t minttl,
-              dns_ttl_t maxttl, dns_rdataset_t *addedrdataset);
-isc_result_t
-dns_ncache_addoptout(dns_message_t *message, dns_db_t *cache,
-                    dns_dbnode_t *node, dns_rdatatype_t covers,
-                    isc_stdtime_t now, dns_ttl_t minttl, dns_ttl_t maxttl,
-                    bool optout, dns_rdataset_t *addedrdataset);
+              dns_ttl_t maxttl, bool optout, bool secure,
+              dns_rdataset_t *addedrdataset);
 /*%<
  * Convert the authority data from 'message' into a negative cache
  * rdataset, and store it in 'cache' at 'node' with a TTL limited to
  * 'maxttl'.
  *
- * \li dns_ncache_add produces a negative cache entry with a trust of no
- *     more than answer
- * \li dns_ncache_addoptout produces a negative cache entry which will have
- *     a trust of secure if all the records that make up the entry are secure.
+ * \li if 'secure' is true and all the records that make up the entry
+ *     are secure, then dns_ncache_add produces a negative cache entry
+ *     with trust level secure.
  *
  * The 'covers' argument is the RR type whose nonexistence we are caching,
  * or dns_rdatatype_any when caching a NXDOMAIN response.
index bd9c43288b52219f0a1d2b010d47886c788769fc..3f42c5724eefee768915dafa1167429b794ca9d5 100644 (file)
@@ -50,12 +50,6 @@ atomic_getuint8(isc_buffer_t *b) {
        return ret;
 }
 
-static isc_result_t
-addoptout(dns_message_t *message, dns_db_t *cache, dns_dbnode_t *node,
-         dns_rdatatype_t covers, isc_stdtime_t now, dns_ttl_t minttl,
-         dns_ttl_t maxttl, bool optout, bool secure,
-         dns_rdataset_t *addedrdataset);
-
 static isc_result_t
 copy_rdataset(dns_rdataset_t *rdataset, isc_buffer_t *buffer) {
        isc_result_t result;
@@ -107,25 +101,8 @@ copy_rdataset(dns_rdataset_t *rdataset, isc_buffer_t *buffer) {
 isc_result_t
 dns_ncache_add(dns_message_t *message, dns_db_t *cache, dns_dbnode_t *node,
               dns_rdatatype_t covers, isc_stdtime_t now, dns_ttl_t minttl,
-              dns_ttl_t maxttl, dns_rdataset_t *addedrdataset) {
-       return addoptout(message, cache, node, covers, now, minttl, maxttl,
-                        false, false, addedrdataset);
-}
-
-isc_result_t
-dns_ncache_addoptout(dns_message_t *message, dns_db_t *cache,
-                    dns_dbnode_t *node, dns_rdatatype_t covers,
-                    isc_stdtime_t now, dns_ttl_t minttl, dns_ttl_t maxttl,
-                    bool optout, dns_rdataset_t *addedrdataset) {
-       return addoptout(message, cache, node, covers, now, minttl, maxttl,
-                        optout, true, addedrdataset);
-}
-
-static isc_result_t
-addoptout(dns_message_t *message, dns_db_t *cache, dns_dbnode_t *node,
-         dns_rdatatype_t covers, isc_stdtime_t now, dns_ttl_t minttl,
-         dns_ttl_t maxttl, bool optout, bool secure,
-         dns_rdataset_t *addedrdataset) {
+              dns_ttl_t maxttl, bool optout, bool secure,
+              dns_rdataset_t *addedrdataset) {
        isc_result_t result;
        isc_buffer_t buffer;
        isc_region_t r;
index 1bbd455af0afbe1366bc3198c681d4cbb473bfe7..92e32d98746adc557d049dbf3f08f2bcb5357e78 100644 (file)
@@ -6382,8 +6382,7 @@ cache_message(fetchctx_t *fctx, dns_message_t *message,
 }
 
 /*
- * Do what dns_ncache_addoptout() does, and then compute an appropriate
- * eresult.
+ * Call dns_ncache_add() and then compute an appropriate eresult.
  */
 static isc_result_t
 ncache_adderesult(dns_message_t *message, dns_db_t *cache, dns_dbnode_t *node,
@@ -6397,14 +6396,9 @@ ncache_adderesult(dns_message_t *message, dns_db_t *cache, dns_dbnode_t *node,
                dns_rdataset_init(&rdataset);
                ardataset = &rdataset;
        }
-       if (secure) {
-               result = dns_ncache_addoptout(message, cache, node, covers, now,
-                                             minttl, maxttl, optout,
-                                             ardataset);
-       } else {
-               result = dns_ncache_add(message, cache, node, covers, now,
-                                       minttl, maxttl, ardataset);
-       }
+
+       result = dns_ncache_add(message, cache, node, covers, now, optout,
+                               secure, minttl, maxttl, ardataset);
        if (result == DNS_R_UNCHANGED || result == ISC_R_SUCCESS) {
                /*
                 * If the cache now contains a negative entry and we