From a7021a3a51446329922e790be0d0be61ab5d5dc0 Mon Sep 17 00:00:00 2001 From: Matthijs Mekking Date: Tue, 27 May 2025 10:57:11 +0200 Subject: [PATCH] Rename dns_qp_lookup2 back to dns_qp_lookup Now that we have to code working, rename 'dns_qp_lookup2' back to 'dns_qp_lookup' and adjust all remaining 'dns_qp_lookup' occurrences to take a space=0 parameter. --- lib/dns/forward.c | 2 +- lib/dns/include/dns/qp.h | 17 +++------- lib/dns/keytable.c | 4 +-- lib/dns/nametree.c | 2 +- lib/dns/nta.c | 2 +- lib/dns/qp.c | 14 ++------ lib/dns/qpcache.c | 12 +++---- lib/dns/qpzone.c | 70 +++++++++++++++++++--------------------- lib/dns/rpz.c | 2 +- lib/dns/zt.c | 2 +- tests/bench/qplookups.c | 4 +-- tests/dns/qp_test.c | 12 +++---- 12 files changed, 62 insertions(+), 81 deletions(-) diff --git a/lib/dns/forward.c b/lib/dns/forward.c index 5764917ed8..9defcadeda 100644 --- a/lib/dns/forward.c +++ b/lib/dns/forward.c @@ -163,7 +163,7 @@ dns_fwdtable_find(dns_fwdtable_t *fwdtable, const dns_name_t *name, REQUIRE(VALID_FWDTABLE(fwdtable)); dns_qpmulti_query(fwdtable->table, &qpr); - result = dns_qp_lookup(&qpr, name, NULL, NULL, NULL, &pval, NULL); + result = dns_qp_lookup(&qpr, name, 0, NULL, NULL, NULL, &pval, NULL); if (result == ISC_R_SUCCESS || result == DNS_R_PARTIALMATCH) { dns_forwarders_t *fwdrs = pval; *forwardersp = fwdrs; diff --git a/lib/dns/include/dns/qp.h b/lib/dns/include/dns/qp.h index 7fec992362..077a4d508a 100644 --- a/lib/dns/include/dns/qp.h +++ b/lib/dns/include/dns/qp.h @@ -545,11 +545,12 @@ dns_qp_getname(dns_qpreadable_t qpr, const dns_name_t *name, isc_result_t dns_qp_lookup(dns_qpreadable_t qpr, const dns_name_t *name, - dns_name_t *foundname, dns_qpiter_t *iter, dns_qpchain_t *chain, - void **pval_r, uint32_t *ival_r); + dns_namespace_t space, dns_name_t *foundname, dns_qpiter_t *iter, + dns_qpchain_t *chain, void **pval_r, uint32_t *ival_r); /*%< * Look up a leaf in a qp-trie that is equal to, or an ancestor domain of, - * 'name'. + * 'name' in the namespace 'space'. The namespace can either be + * DNS_DB_NSEC_NORMAL, DNS_DB_NSEC_NSEC, or DNS_DB_NSEC3. * * If 'foundname' is not NULL, it will be updated to contain the name * that was found (if any). The return code, ISC_R_SUCCESS or @@ -587,16 +588,6 @@ dns_qp_lookup(dns_qpreadable_t qpr, const dns_name_t *name, * \li ISC_R_NOTFOUND if no match was found */ -isc_result_t -dns_qp_lookup2(dns_qpreadable_t qpr, const dns_name_t *name, - dns_namespace_t space, dns_name_t *foundname, dns_qpiter_t *iter, - dns_qpchain_t *chain, void **pval_r, uint32_t *ival_r); -/*%< - * The same as 'dns_qp_lookup', but with the possibility to set a namespace, - * either DNS_DB_NSEC_NORMAL (or 0, which is the equivalent of 'dns_qp_lookup'), - * DNS_DB_NSEC_NSEC, OR DNS_DB_NSEC3. - */ - isc_result_t dns_qp_insert(dns_qp_t *qp, void *pval, uint32_t ival); /*%< diff --git a/lib/dns/keytable.c b/lib/dns/keytable.c index d4cc637dde..5175b90884 100644 --- a/lib/dns/keytable.c +++ b/lib/dns/keytable.c @@ -506,7 +506,7 @@ dns_keytable_finddeepestmatch(dns_keytable_t *keytable, const dns_name_t *name, REQUIRE(foundname != NULL); dns_qpmulti_query(keytable->table, &qpr); - result = dns_qp_lookup(&qpr, name, NULL, NULL, NULL, &pval, NULL); + result = dns_qp_lookup(&qpr, name, 0, NULL, NULL, NULL, &pval, NULL); keynode = pval; if (result == ISC_R_SUCCESS || result == DNS_R_PARTIALMATCH) { @@ -535,7 +535,7 @@ dns_keytable_issecuredomain(dns_keytable_t *keytable, const dns_name_t *name, REQUIRE(wantdnssecp != NULL); dns_qpmulti_query(keytable->table, &qpr); - result = dns_qp_lookup(&qpr, name, NULL, NULL, NULL, &pval, NULL); + result = dns_qp_lookup(&qpr, name, 0, NULL, NULL, NULL, &pval, NULL); if (result == ISC_R_SUCCESS || result == DNS_R_PARTIALMATCH) { keynode = pval; if (foundname != NULL) { diff --git a/lib/dns/nametree.c b/lib/dns/nametree.c index 13b65bfef0..03aad3408b 100644 --- a/lib/dns/nametree.c +++ b/lib/dns/nametree.c @@ -278,7 +278,7 @@ dns_nametree_covered(dns_nametree_t *nametree, const dns_name_t *name, REQUIRE(VALID_NAMETREE(nametree)); dns_qpmulti_query(nametree->table, &qpr); - result = dns_qp_lookup(&qpr, name, NULL, NULL, NULL, (void **)&node, + result = dns_qp_lookup(&qpr, name, 0, NULL, NULL, NULL, (void **)&node, NULL); if (result == ISC_R_SUCCESS || result == DNS_R_PARTIALMATCH) { if (found != NULL) { diff --git a/lib/dns/nta.c b/lib/dns/nta.c index 59613da29d..c7705fd2f9 100644 --- a/lib/dns/nta.c +++ b/lib/dns/nta.c @@ -412,7 +412,7 @@ dns_ntatable_covered(dns_ntatable_t *ntatable, isc_stdtime_t now, RWLOCK(&ntatable->rwlock, isc_rwlocktype_read); dns_qpmulti_query(ntatable->table, &qpr); - result = dns_qp_lookup(&qpr, name, NULL, NULL, NULL, &pval, NULL); + result = dns_qp_lookup(&qpr, name, 0, NULL, NULL, NULL, &pval, NULL); nta = pval; switch (result) { diff --git a/lib/dns/qp.c b/lib/dns/qp.c index f244178123..6cd9938165 100644 --- a/lib/dns/qp.c +++ b/lib/dns/qp.c @@ -2285,9 +2285,9 @@ fix_chain(dns_qpchain_t *chain, size_t offset) { } isc_result_t -dns_qp_lookup2(dns_qpreadable_t qpr, const dns_name_t *name, - dns_namespace_t space, dns_name_t *foundname, dns_qpiter_t *iter, - dns_qpchain_t *chain, void **pval_r, uint32_t *ival_r) { +dns_qp_lookup(dns_qpreadable_t qpr, const dns_name_t *name, + dns_namespace_t space, dns_name_t *foundname, dns_qpiter_t *iter, + dns_qpchain_t *chain, void **pval_r, uint32_t *ival_r) { dns_qpreader_t *qp = dns_qpreader(qpr); dns_qpkey_t search, found; size_t searchlen, foundlen; @@ -2433,12 +2433,4 @@ dns_qp_lookup2(dns_qpreadable_t qpr, const dns_name_t *name, return ISC_R_NOTFOUND; } -isc_result_t -dns_qp_lookup(dns_qpreadable_t qpr, const dns_name_t *name, - dns_name_t *foundname, dns_qpiter_t *iter, dns_qpchain_t *chain, - void **pval_r, uint32_t *ival_r) { - return dns_qp_lookup2(qpr, name, 0, foundname, iter, chain, pval_r, - ival_r); -} - /**********************************************************************/ diff --git a/lib/dns/qpcache.c b/lib/dns/qpcache.c index 49d06eb45d..06196d39d7 100644 --- a/lib/dns/qpcache.c +++ b/lib/dns/qpcache.c @@ -1395,8 +1395,8 @@ find_coveringnsec(qpc_search_t *search, const dns_name_t *name, /* * Look for the node in the auxilary tree. */ - result = dns_qp_lookup2(search->qpdb->nsec, name, DNS_DB_NSEC_NSEC, - NULL, &iter, NULL, (void **)&node, NULL); + result = dns_qp_lookup(search->qpdb->nsec, name, DNS_DB_NSEC_NSEC, NULL, + &iter, NULL, (void **)&node, NULL); if (result != DNS_R_PARTIALMATCH) { return ISC_R_NOTFOUND; } @@ -1524,7 +1524,7 @@ qpcache_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version, /* * Search down from the root of the tree. */ - result = dns_qp_lookup(search.qpdb->tree, name, NULL, NULL, + result = dns_qp_lookup(search.qpdb->tree, name, 0, NULL, NULL, &search.chain, (void **)&node, NULL); if (result != ISC_R_NOTFOUND && foundname != NULL) { dns_name_copy(&node->name, foundname); @@ -1964,7 +1964,7 @@ qpcache_findzonecut(dns_db_t *db, const dns_name_t *name, unsigned int options, /* * Search down from the root of the tree. */ - result = dns_qp_lookup(search.qpdb->tree, name, NULL, NULL, + result = dns_qp_lookup(search.qpdb->tree, name, 0, NULL, NULL, &search.chain, (void **)&node, NULL); switch (result) { @@ -3427,7 +3427,7 @@ resume_iteration(qpc_dbit_t *qpdbiter, bool continuing) { */ if (continuing && qpdbiter->node != NULL) { isc_result_t result; - result = dns_qp_lookup(qpdb->tree, qpdbiter->name, NULL, + result = dns_qp_lookup(qpdb->tree, qpdbiter->name, 0, NULL, &qpdbiter->iter, NULL, NULL, NULL); INSIST(result == ISC_R_SUCCESS); } @@ -3555,7 +3555,7 @@ dbiterator_seek(dns_dbiterator_t *iterator, dereference_iter_node(qpdbiter DNS__DB_FLARG_PASS); - result = dns_qp_lookup(qpdb->tree, name, NULL, &qpdbiter->iter, NULL, + result = dns_qp_lookup(qpdb->tree, name, 0, NULL, &qpdbiter->iter, NULL, (void **)&qpdbiter->node, NULL); if (result == ISC_R_SUCCESS || result == DNS_R_PARTIALMATCH) { diff --git a/lib/dns/qpzone.c b/lib/dns/qpzone.c index 9f11df0913..99cd54e058 100644 --- a/lib/dns/qpzone.c +++ b/lib/dns/qpzone.c @@ -2934,9 +2934,9 @@ find_wildcard(qpz_search_t *search, qpznode_t **nodep, const dns_name_t *qname, break; } - result = dns_qp_lookup2(&search->qpr, wname, nspace, - NULL, &wit, NULL, - (void **)&wnode, NULL); + result = dns_qp_lookup(&search->qpr, wname, nspace, + NULL, &wit, NULL, + (void **)&wnode, NULL); if (result == ISC_R_SUCCESS) { /* * We have found the wildcard node. If it @@ -3026,8 +3026,8 @@ previous_closest_nsec(dns_rdatatype_t type, qpz_search_t *search, * It is the first node sought in the NSEC tree. */ *firstp = false; - result = dns_qp_lookup2(&qpr, name, DNS_DB_NSEC_NSEC, - NULL, nit, NULL, NULL, NULL); + result = dns_qp_lookup(&qpr, name, DNS_DB_NSEC_NSEC, + NULL, nit, NULL, NULL, NULL); INSIST(result != ISC_R_NOTFOUND); if (result == ISC_R_SUCCESS) { /* @@ -3060,9 +3060,9 @@ previous_closest_nsec(dns_rdatatype_t type, qpz_search_t *search, } *nodep = NULL; - result = dns_qp_lookup2(&search->qpr, name, DNS_DB_NSEC_NORMAL, - NULL, &search->iter, &search->chain, - (void **)nodep, NULL); + result = dns_qp_lookup(&search->qpr, name, DNS_DB_NSEC_NORMAL, + NULL, &search->iter, &search->chain, + (void **)nodep, NULL); if (result == ISC_R_SUCCESS) { break; } @@ -3463,8 +3463,8 @@ qpzone_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version, /* * Search down from the root of the tree. */ - result = dns_qp_lookup2(&search.qpr, name, nspace, NULL, &search.iter, - &search.chain, (void **)&node, NULL); + result = dns_qp_lookup(&search.qpr, name, nspace, NULL, &search.iter, + &search.chain, (void **)&node, NULL); if (result != ISC_R_NOTFOUND) { dns_name_copy(&node->name, foundname); } @@ -4345,10 +4345,9 @@ dbiterator_first(dns_dbiterator_t *iterator DNS__DB_FLARG) { * NSEC3 follows after all non-nsec3 nodes, seek the NSEC3 * origin node. */ - result = dns_qp_lookup2(qpdbiter->snap, &qpdb->common.origin, - DNS_DB_NSEC_NSEC3, NULL, - &qpdbiter->iter, NULL, - (void **)&qpdbiter->node, NULL); + result = dns_qp_lookup(qpdbiter->snap, &qpdb->common.origin, + DNS_DB_NSEC_NSEC3, NULL, &qpdbiter->iter, + NULL, (void **)&qpdbiter->node, NULL); if (result != ISC_R_SUCCESS || QPDBITER_NSEC3_ORIGIN_NODE(qpdb, qpdbiter)) { @@ -4434,9 +4433,9 @@ dbiterator_last(dns_dbiterator_t *iterator DNS__DB_FLARG) { /* * The final non-nsec node is before the the NSEC origin node. */ - result = dns_qp_lookup2(qpdbiter->snap, &qpdb->common.origin, - DNS_DB_NSEC_NSEC, NULL, &qpdbiter->iter, - NULL, (void **)&qpdbiter->node, NULL); + result = dns_qp_lookup(qpdbiter->snap, &qpdb->common.origin, + DNS_DB_NSEC_NSEC, NULL, &qpdbiter->iter, + NULL, (void **)&qpdbiter->node, NULL); if (result == ISC_R_SUCCESS) { INSIST(QPDBITER_NSEC_ORIGIN_NODE(qpdb, qpdbiter)); /* skip the NSEC origin node */ @@ -4487,24 +4486,24 @@ dbiterator_seek(dns_dbiterator_t *iterator, switch (qpdbiter->nsec3mode) { case nsec3only: - result = dns_qp_lookup2(qpdbiter->snap, name, DNS_DB_NSEC_NSEC3, - NULL, &qpdbiter->iter, NULL, - (void **)&qpdbiter->node, NULL); + result = dns_qp_lookup(qpdbiter->snap, name, DNS_DB_NSEC_NSEC3, + NULL, &qpdbiter->iter, NULL, + (void **)&qpdbiter->node, NULL); break; case nonsec3: - result = dns_qp_lookup(qpdbiter->snap, name, NULL, - &qpdbiter->iter, NULL, + result = dns_qp_lookup(qpdbiter->snap, name, DNS_DB_NSEC_NORMAL, + NULL, &qpdbiter->iter, NULL, (void **)&qpdbiter->node, NULL); break; case full: - result = dns_qp_lookup(qpdbiter->snap, name, NULL, - &qpdbiter->iter, NULL, + result = dns_qp_lookup(qpdbiter->snap, name, DNS_DB_NSEC_NORMAL, + NULL, &qpdbiter->iter, NULL, (void **)&qpdbiter->node, NULL); if (result != ISC_R_SUCCESS) { - tresult = dns_qp_lookup2( - qpdbiter->snap, name, DNS_DB_NSEC_NSEC3, NULL, - &qpdbiter->iter, NULL, (void **)&qpdbiter->node, - NULL); + tresult = dns_qp_lookup(qpdbiter->snap, name, + DNS_DB_NSEC_NSEC3, NULL, + &qpdbiter->iter, NULL, + (void **)&qpdbiter->node, NULL); if (tresult == ISC_R_SUCCESS) { result = tresult; } @@ -4580,7 +4579,7 @@ dbiterator_prev(dns_dbiterator_t *iterator DNS__DB_FLARG) { } INSIST(qpdbiter->node->nspace == DNS_DB_NSEC_NSEC); - result = dns_qp_lookup2(qpdbiter->snap, &qpdb->common.origin, + result = dns_qp_lookup(qpdbiter->snap, &qpdb->common.origin, DNS_DB_NSEC_NSEC, NULL, &qpdbiter->iter, NULL, (void **)&qpdbiter->node, NULL); @@ -4669,10 +4668,9 @@ dbiterator_next(dns_dbiterator_t *iterator DNS__DB_FLARG) { } INSIST(qpdbiter->node->nspace == DNS_DB_NSEC_NSEC); - result = dns_qp_lookup2(qpdbiter->snap, &qpdb->common.origin, - DNS_DB_NSEC_NSEC3, NULL, - &qpdbiter->iter, NULL, - (void **)&qpdbiter->node, NULL); + result = dns_qp_lookup(qpdbiter->snap, &qpdb->common.origin, + DNS_DB_NSEC_NSEC3, NULL, &qpdbiter->iter, + NULL, (void **)&qpdbiter->node, NULL); if (result != ISC_R_SUCCESS || QPDBITER_NSEC3_ORIGIN_NODE(qpdb, qpdbiter)) { @@ -4775,9 +4773,9 @@ qpzone_createiterator(dns_db_t *db, unsigned int options, * NSEC3 follows after all non-nsec3 nodes, * seek the NSEC3 origin node. */ - result = dns_qp_lookup2(iter->snap, &qpdb->common.origin, - DNS_DB_NSEC_NSEC3, NULL, &iter->iter, - NULL, NULL, NULL); + result = dns_qp_lookup(iter->snap, &qpdb->common.origin, + DNS_DB_NSEC_NSEC3, NULL, &iter->iter, + NULL, NULL, NULL); INSIST(result == ISC_R_SUCCESS); break; default: diff --git a/lib/dns/rpz.c b/lib/dns/rpz.c index 35dd80577a..c72564b317 100644 --- a/lib/dns/rpz.c +++ b/lib/dns/rpz.c @@ -2516,7 +2516,7 @@ dns_rpz_find_name(dns_rpz_zones_t *rpzs, dns_rpz_type_t rpz_type, dns_qpmulti_query(rpzs->table, &qpr); dns_qpchain_init(&qpr, &chain); - result = dns_qp_lookup(&qpr, trig_name, NULL, NULL, &chain, + result = dns_qp_lookup(&qpr, trig_name, 0, NULL, NULL, &chain, (void **)&data, NULL); switch (result) { case ISC_R_SUCCESS: diff --git a/lib/dns/zt.c b/lib/dns/zt.c index 2ec4dd5fe2..113e5d0139 100644 --- a/lib/dns/zt.c +++ b/lib/dns/zt.c @@ -181,7 +181,7 @@ dns_zt_find(dns_zt_t *zt, const dns_name_t *name, dns_ztfind_t options, if (exactopts == DNS_ZTFIND_EXACT) { result = dns_qp_getname(&qpr, name, 0, &pval, NULL); } else { - result = dns_qp_lookup(&qpr, name, NULL, NULL, &chain, &pval, + result = dns_qp_lookup(&qpr, name, 0, NULL, NULL, &chain, &pval, NULL); if (exactopts == DNS_ZTFIND_NOEXACT && result == ISC_R_SUCCESS) { diff --git a/tests/bench/qplookups.c b/tests/bench/qplookups.c index 612d15e8cc..50921dada4 100644 --- a/tests/bench/qplookups.c +++ b/tests/bench/qplookups.c @@ -238,7 +238,7 @@ main(int argc, char **argv) { start = isc_time_monotonic(); for (i = 0; i < n; i++) { name = dns_fixedname_name(&items[i]); - dns_qp_lookup(qp, name, 0, NULL, NULL, NULL, NULL); + dns_qp_lookup(qp, name, 0, NULL, NULL, NULL, NULL, NULL); } stop = isc_time_monotonic(); @@ -263,7 +263,7 @@ main(int argc, char **argv) { ++search->ndata[1]; } - dns_qp_lookup(qp, search, 0, NULL, NULL, NULL, NULL); + dns_qp_lookup(qp, search, 0, NULL, NULL, NULL, NULL, NULL); } stop = isc_time_monotonic(); diff --git a/tests/dns/qp_test.c b/tests/dns/qp_test.c index 0bf75d3bbd..ef8cd56b26 100644 --- a/tests/dns/qp_test.c +++ b/tests/dns/qp_test.c @@ -415,8 +415,8 @@ check_partialmatch(dns_qp_t *qp, struct check_partialmatch check[], void *pval = NULL; dns_test_namefromstring(check[i].query, &fn1); - result = dns_qp_lookup2(qp, name, space, foundname, NULL, NULL, - &pval, NULL); + result = dns_qp_lookup(qp, name, space, foundname, NULL, NULL, + &pval, NULL); #if 0 fprintf(stderr, "%s%s %s (expected %s) " @@ -578,8 +578,8 @@ check_qpchainiter(dns_qp_t *qp, struct check_qpchain check[], dns_qpchain_init(qp, &chain); dns_test_namefromstring(check[i].query, &fn1); - result = dns_qp_lookup2(qp, name, check[i].space, NULL, iter, - &chain, NULL, NULL); + result = dns_qp_lookup(qp, name, check[i].space, NULL, iter, + &chain, NULL, NULL); #if 0 fprintf(stderr, "%s %s (expected %s), " @@ -800,8 +800,8 @@ check_predecessors_withchain(dns_qp_t *qp, struct check_predecessors check[], result = dns_name_tostring(expred, &predstr, mctx); assert_int_equal(result, ISC_R_SUCCESS); - result = dns_qp_lookup2(qp, name, check[i].space, NULL, &it, - chain, NULL, NULL); + result = dns_qp_lookup(qp, name, check[i].space, NULL, &it, + chain, NULL, NULL); #if 0 fprintf(stderr, "%s %s: expected %s got %s\n", check[i].query, check[i].space == DNS_DB_NSEC_NSEC3