]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Do not attach nodep in sdlz_find() and builtin_find()
authorOndřej Surý <ondrej@isc.org>
Wed, 5 Aug 2026 14:26:13 +0000 (16:26 +0200)
committerAlessio Podda <alessio@isc.org>
Wed, 12 Aug 2026 19:57:34 +0000 (19:57 +0000)
As a consequence of the simplification of the dns_db_find() API,
we can avoid attaching the node in sdlz_find() and builtin_find().
The local node reference is only needed while assembling the answer
and can be released before the function returns.

bin/named/builtin.c
lib/dns/sdlz.c

index c0e159cd625fedc375f1d2224b2e60731559b6c9..49defd05ad651001efd186a3487949eb2a1107ac 100644 (file)
@@ -855,12 +855,13 @@ findnode(dns_db_t *db, const dns_name_t *name, bool create,
 }
 
 static isc_result_t
-find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
-     dns_rdatatype_t type, unsigned int options, isc_stdtime_t now,
-     dns_dbnode_t **nodep, dns_name_t *foundname,
-     dns_clientinfomethods_t *methods ISC_ATTR_UNUSED,
-     dns_clientinfo_t *clientinfo ISC_ATTR_UNUSED, dns_rdataset_t *rdataset,
-     dns_rdataset_t *sigrdataset DNS__DB_FLARG) {
+builtin_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
+            dns_rdatatype_t type, unsigned int options, isc_stdtime_t now,
+            dns_dbnode_t **nodep ISC_ATTR_UNUSED, dns_name_t *foundname,
+            dns_clientinfomethods_t *methods ISC_ATTR_UNUSED,
+            dns_clientinfo_t *clientinfo ISC_ATTR_UNUSED,
+            dns_rdataset_t *rdataset,
+            dns_rdataset_t *sigrdataset DNS__DB_FLARG) {
        bdb_t *bdb = (bdb_t *)db;
        isc_result_t result;
        dns_dbnode_t *node = NULL;
@@ -871,7 +872,6 @@ find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
        bool dns64;
 
        REQUIRE(VALID_BDB(bdb));
-       REQUIRE(nodep == NULL || *nodep == NULL);
        REQUIRE(version == NULL || version == (dns_dbversion_t *)&dummy);
 
        if (!dns_name_issubdomain(name, &db->origin)) {
@@ -1005,9 +1005,7 @@ find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
                dns_name_copy(xname, foundname);
        }
 
-       if (nodep != NULL) {
-               *nodep = node;
-       } else if (node != NULL) {
+       if (node != NULL) {
                bdbnode_detachnode(&node DNS__DB_FLARG_PASS);
        }
 
@@ -1098,7 +1096,7 @@ static dns_dbmethods_t bdb_methods = {
        .findrdataset = findrdataset,
        .allrdatasets = allrdatasets,
        .findnode = findnode,
-       .find = find,
+       .find = builtin_find,
 };
 
 static isc_result_t
index 198967f738b321ecfeb6c3dd94cab19aec4bbc3a..cdd2f438c5a3e91646e448cedaec37d77269ecdd 100644 (file)
@@ -763,11 +763,12 @@ findrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
 }
 
 static isc_result_t
-find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
-     dns_rdatatype_t type, unsigned int options, isc_stdtime_t now,
-     dns_dbnode_t **nodep, dns_name_t *foundname,
-     dns_clientinfomethods_t *methods, dns_clientinfo_t *clientinfo,
-     dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset DNS__DB_FLARG) {
+sdlz_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
+         dns_rdatatype_t type, unsigned int options, isc_stdtime_t now,
+         dns_dbnode_t **nodep ISC_ATTR_UNUSED, dns_name_t *foundname,
+         dns_clientinfomethods_t *methods, dns_clientinfo_t *clientinfo,
+         dns_rdataset_t *rdataset,
+         dns_rdataset_t *sigrdataset DNS__DB_FLARG) {
        dns_sdlz_db_t *sdlz = (dns_sdlz_db_t *)db;
        dns_dbnode_t *node = NULL;
        dns_fixedname_t fname;
@@ -778,7 +779,6 @@ find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
        unsigned int i;
 
        REQUIRE(VALID_SDLZDB(sdlz));
-       REQUIRE(nodep == NULL || *nodep == NULL);
        REQUIRE(version == NULL || version == (void *)&sdlz->dummy_version ||
                version == sdlz->future_version);
 
@@ -926,9 +926,7 @@ find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
                }
        }
 
-       if (nodep != NULL) {
-               *nodep = node;
-       } else if (node != NULL) {
+       if (node != NULL) {
                sdlznode_detachnode(&node DNS__DB_FLARG_PASS);
        }
 
@@ -1098,7 +1096,7 @@ static dns_dbmethods_t sdlzdb_methods = {
        .attachversion = attachversion,
        .closeversion = closeversion,
        .findnode = findnode,
-       .find = find,
+       .find = sdlz_find,
        .createiterator = createiterator,
        .findrdataset = findrdataset,
        .allrdatasets = allrdatasets,