From: Alessio Podda Date: Fri, 17 Jul 2026 13:34:12 +0000 (+0200) Subject: Do not attach nodep in qpzone_find() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ac471f7198caeeb9bbd8fb1ebbd19faf4b39e09f;p=thirdparty%2Fbind9.git Do not attach nodep in qpzone_find() As a consequence of the simplification of the dns_db_find() API, we can avoid attaching the node in certain situations. We only need to attach the node on zonecuts to keep alive the header pointers. --- diff --git a/lib/dns/qpzone.c b/lib/dns/qpzone.c index 9f55e51c480..547db093bae 100644 --- a/lib/dns/qpzone.c +++ b/lib/dns/qpzone.c @@ -265,7 +265,6 @@ typedef struct { dns_qpchain_t chain; dns_qpiter_t iter; bool copy_name; - bool need_cleanup; bool wild; qpznode_t *zonecut; dns_vecheader_t *zonecut_header; @@ -974,11 +973,9 @@ qpznode_erefs_increment(qpznode_t *node DNS__DB_FLARG) { #if DNS_DB_NODETRACE fprintf(stderr, "incr:node:%s:%s:%u:%p->erefs = %" PRIuFAST32 "\n", func, file, line, node, refs + 1); +#else + UNUSED(refs); #endif - - if (refs > 0) { - return; - } } static void @@ -2741,8 +2738,8 @@ matchparams(dns_vecheader_t *header, qpz_search_t *search) { } static isc_result_t -qpzone_setup_delegation(qpz_search_t *search, dns_dbnode_t **nodep, - dns_name_t *foundname, dns_rdataset_t *rdataset, +qpzone_setup_delegation(qpz_search_t *search, dns_name_t *foundname, + dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset DNS__DB_FLARG) { dns_name_t *zcname = NULL; dns_typepair_t typepair; @@ -2770,15 +2767,6 @@ qpzone_setup_delegation(qpz_search_t *search, dns_dbnode_t **nodep, zcname = dns_fixedname_name(&search->zonecut_name); dns_name_copy(zcname, foundname); } - if (nodep != NULL) { - /* - * Note that we don't have to increment the node's reference - * count here because we're going to use the reference we - * already have in the search block. - */ - *nodep = (dns_dbnode_t *)node; - search->need_cleanup = false; - } if (rdataset != NULL) { isc_rwlocktype_t nlocktype = isc_rwlocktype_none; isc_rwlock_t *nlock = qpzone_get_lock(node); @@ -3160,10 +3148,9 @@ previous_closest_nsec(dns_rdatatype_t type, qpz_search_t *search, * current NSEC3PARAM record are considered. */ static isc_result_t -find_closest_nsec(qpz_search_t *search, dns_dbnode_t **nodep, - dns_name_t *foundname, dns_rdataset_t *rdataset, - dns_rdataset_t *sigrdataset, bool nsec3, - bool secure DNS__DB_FLARG) { +find_closest_nsec(qpz_search_t *search, dns_name_t *foundname, + dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset, + bool nsec3, bool secure DNS__DB_FLARG) { qpznode_t *node = NULL, *prevnode = NULL; dns_qpiter_t nseciter; bool empty_node; @@ -3248,11 +3235,6 @@ again: * the case. */ dns_name_copy(name, foundname); - if (nodep != NULL) { - qpznode_acquire( - node DNS__DB_FLARG_PASS); - *nodep = (dns_dbnode_t *)node; - } bindrdataset(search->qpdb, found, rdataset DNS__DB_FLARG_PASS); if (foundsig != NULL) { @@ -3385,7 +3367,6 @@ qpzone_check_zonecut(qpznode_t *node, void *arg DNS__DB_FLARG) { qpznode_acquire(node DNS__DB_FLARG_PASS); search->zonecut = node; search->zonecut_header = found; - search->need_cleanup = true; /* * Since we've found a zonecut, anything beneath it is * glue and is not subject to wildcard matching, so we @@ -3451,7 +3432,6 @@ qpz_search_init(qpz_search_t *search, qpzonedb_t *db, qpz_version_t *version, * qpiter -- init in dns_qp_lookup */ search->copy_name = false; - search->need_cleanup = false; search->wild = false; search->zonecut = NULL; search->zonecut_header = NULL; @@ -3462,8 +3442,8 @@ qpz_search_init(qpz_search_t *search, qpzonedb_t *db, qpz_version_t *version, static isc_result_t qpzone_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 ISC_ATTR_UNUSED, dns_dbnode_t **nodep, - dns_name_t *foundname, + isc_stdtime_t now ISC_ATTR_UNUSED, + 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, @@ -3472,7 +3452,7 @@ qpzone_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version, qpzonedb_t *qpdb = (qpzonedb_t *)db; qpznode_t *node = NULL; bool cname_ok = true, close_version = false; - bool maybe_zonecut = false, at_zonecut = false; + bool maybe_zonecut = false; bool wild = false, empty_node = false; bool nsec3 = false; dns_vecheader_t *found = NULL, *nsecheader = NULL; @@ -3546,7 +3526,7 @@ qpzone_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version, partial_match: if (search.zonecut != NULL) { result = qpzone_setup_delegation( - &search, nodep, foundname, rdataset, + &search, foundname, rdataset, sigrdataset DNS__DB_FLARG_PASS); goto tree_exit; } @@ -3586,8 +3566,8 @@ qpzone_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version, nsec3) { result = find_closest_nsec( - &search, nodep, foundname, rdataset, - sigrdataset, nsec3, + &search, foundname, rdataset, sigrdataset, + nsec3, search.version->secure DNS__DB_FLARG_PASS); if (result == ISC_R_SUCCESS) { result = active ? DNS_R_EMPTYNAME @@ -3680,9 +3660,7 @@ found: search.zonecut = node; search.zonecut_header = header; search.zonecut_sigheader = NULL; - search.need_cleanup = true; maybe_zonecut = false; - at_zonecut = true; if ((search.options & DNS_DBFIND_GLUEOK) == 0 && type != dns_rdatatype_nsec) @@ -3832,7 +3810,7 @@ found: } NODE_UNLOCK(nlock, &nlocktype); result = qpzone_setup_delegation( - &search, nodep, foundname, rdataset, + &search, foundname, rdataset, sigrdataset DNS__DB_FLARG_PASS); goto tree_exit; } @@ -3854,18 +3832,14 @@ found: NODE_UNLOCK(nlock, &nlocktype); result = find_closest_nsec( - &search, nodep, foundname, rdataset, - sigrdataset, false, + &search, foundname, rdataset, sigrdataset, + false, search.version->secure DNS__DB_FLARG_PASS); if (result == ISC_R_SUCCESS) { result = DNS_R_EMPTYWILD; } goto tree_exit; } - if (nodep != NULL) { - qpznode_acquire(node DNS__DB_FLARG_PASS); - *nodep = (dns_dbnode_t *)node; - } if (search.version->secure && !search.version->havensec3) { bindrdataset(search.qpdb, nsecheader, rdataset DNS__DB_FLARG_PASS); @@ -3916,15 +3890,6 @@ found: result = ISC_R_SUCCESS; } - if (nodep != NULL) { - if (!at_zonecut) { - qpznode_acquire(node DNS__DB_FLARG_PASS); - } else { - search.need_cleanup = false; - } - *nodep = (dns_dbnode_t *)node; - } - if (type != dns_rdatatype_any) { bindrdataset(search.qpdb, found, rdataset DNS__DB_FLARG_PASS); if (foundsig != NULL) { @@ -3947,7 +3912,7 @@ tree_exit: * If we found a zonecut but aren't going to use it, we have to * let go of it. */ - if (search.need_cleanup) { + if (search.zonecut != NULL) { node = search.zonecut; INSIST(node != NULL); nlock = qpzone_get_lock(node);