rename dns_qp_findname_ancestor() to dns_qp_lookup()

I am weary of typing so long a name. (plus, the name has become slightly
misleading now that the DNS_QPFIND_NOEXACT option no longer exists.)
This commit is contained in:
Evan Hunt
2023-09-26 20:19:37 -07:00
parent 6231fd66af
commit 03016902dd
9 changed files with 44 additions and 43 deletions

View File

@@ -168,8 +168,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_findname_ancestor(&qpr, name, NULL, NULL, NULL, &pval,
NULL);
result = dns_qp_lookup(&qpr, name, NULL, NULL, NULL, &pval, NULL);
if (result == ISC_R_SUCCESS || result == DNS_R_PARTIALMATCH) {
dns_forwarders_t *fwdrs = pval;
*forwardersp = fwdrs;

View File

@@ -235,10 +235,10 @@ typedef struct dns_qpiter {
/*%
* A QP chain holds references to each populated node between the root and
* a given leaf. It is used internally by `dns_qp_findname_ancestor()` to
* return a partial match if the specific name requested is not found;
* optionally it can be passed back to the caller so that individual nodes
* can be accessed.
* a given leaf. It is used internally by `dns_qp_lookup()` to return a
* partial match if the specific name requested is not found; optionally it
* can be passed back to the caller so that individual nodes can be
* accessed.
*/
typedef struct dns_qpchain {
unsigned int magic;
@@ -527,24 +527,33 @@ dns_qp_getname(dns_qpreadable_t qpr, const dns_name_t *name, void **pval_r,
*/
isc_result_t
dns_qp_findname_ancestor(dns_qpreadable_t qpr, const dns_name_t *name,
dns_name_t *foundname, dns_name_t *predecessor,
dns_qpchain_t *chain, void **pval_r, uint32_t *ival_r);
dns_qp_lookup(dns_qpreadable_t qpr, const dns_name_t *name,
dns_name_t *foundname, dns_name_t *predecessor,
dns_qpchain_t *chain, void **pval_r, uint32_t *ival_r);
/*%<
* Find a leaf in a qp-trie that is an ancestor domain of, or equal to, the
* given DNS name.
* Look up a leaf in a qp-trie that is equal to, or an ancestor domain of,
* 'name'.
*
* If 'foundname' is not NULL, it is updated to contain the name found.
*
* If 'predecessor' is not NULL, it is updated to contain the DNSSEC
* predecessor of the searched-for name.
* 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
* DNS_R_PARTIALMATCH, indicates whether the name found is name that
* was requested, or an ancestor. If the result is ISC_R_NOTFOUND,
* 'foundname' will not be updated.
*
* If 'chain' is not NULL, it is updated to contain a QP chain with
* references to the populated nodes in the tree between the root and
* the name found.
* the name that was found. If the return code is DNS_R_PARTIALMATCH
* then the chain terminates at the closest ancestor found; if it is
* ISC_R_SUCCESS then it terminates at the name that was requested.
* If the result is ISC_R_NOTFOUND, 'chain' will not be updated.
*
* The leaf values are assigned to whichever of `*pval_r` and `*ival_r`
* are not null, unless the return value is ISC_R_NOTFOUND.
* If 'predecessor' is not NULL, it will be updated to contain the
* closest predecessor of the searched-for name that exists in the
* trie.
*
* The leaf data for the node that was found will be assigned to
* whichever of `*pval_r` and `*ival_r` are not NULL, unless the
* return value is ISC_R_NOTFOUND.
*
* Requires:
* \li `qpr` is a pointer to a readable qp-trie

View File

@@ -518,8 +518,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_findname_ancestor(&qpr, name, NULL, NULL, NULL, &pval,
NULL);
result = dns_qp_lookup(&qpr, name, NULL, NULL, NULL, &pval, NULL);
keynode = pval;
if (result == ISC_R_SUCCESS || result == DNS_R_PARTIALMATCH) {
@@ -548,8 +547,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_findname_ancestor(&qpr, name, NULL, NULL, NULL, &pval,
NULL);
result = dns_qp_lookup(&qpr, name, NULL, NULL, NULL, &pval, NULL);
if (result == ISC_R_SUCCESS || result == DNS_R_PARTIALMATCH) {
keynode = pval;
if (foundname != NULL) {

View File

@@ -289,8 +289,8 @@ 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_findname_ancestor(&qpr, name, found, NULL, NULL,
(void **)&node, NULL);
result = dns_qp_lookup(&qpr, name, found, NULL, NULL, (void **)&node,
NULL);
if (result == ISC_R_SUCCESS || result == DNS_R_PARTIALMATCH) {
switch (nametree->type) {
case DNS_NAMETREE_BOOL:

View File

@@ -413,8 +413,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_findname_ancestor(&qpr, name, NULL, NULL, NULL, &pval,
NULL);
result = dns_qp_lookup(&qpr, name, NULL, NULL, NULL, &pval, NULL);
nta = pval;
switch (result) {

View File

@@ -2012,10 +2012,9 @@ prevleaf(dns_qpiter_t *it) {
}
isc_result_t
dns_qp_findname_ancestor(dns_qpreadable_t qpr, const dns_name_t *name,
dns_name_t *foundname, dns_name_t *predecessor,
dns_qpchain_t *chain, void **pval_r,
uint32_t *ival_r) {
dns_qp_lookup(dns_qpreadable_t qpr, const dns_name_t *name,
dns_name_t *foundname, dns_name_t *predecessor,
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;

View File

@@ -178,8 +178,7 @@ dns_zt_find(dns_zt_t *zt, const dns_name_t *name, dns_ztfind_t options,
dns_qpmulti_query(zt->multi, &qpr);
result = dns_qp_findname_ancestor(&qpr, name, NULL, NULL, &chain, &pval,
NULL);
result = dns_qp_lookup(&qpr, name, NULL, NULL, &chain, &pval, NULL);
if (exactopts == DNS_ZTFIND_EXACT && result == DNS_R_PARTIALMATCH) {
result = ISC_R_NOTFOUND;
} else if (exactopts == DNS_ZTFIND_NOEXACT && result == ISC_R_SUCCESS) {

View File

@@ -250,12 +250,11 @@ main(int argc, char **argv) {
start = isc_time_monotonic();
for (i = 0; i < n; i++) {
name = dns_fixedname_name(&items[i]);
dns_qp_findname_ancestor(qp, name, 0, NULL, NULL, NULL, NULL);
dns_qp_lookup(qp, name, 0, NULL, NULL, NULL, NULL);
}
stop = isc_time_monotonic();
snprintf(buf, sizeof(buf),
"look up %zd names (dns_qp_findname_ancestor):", n);
snprintf(buf, sizeof(buf), "look up %zd names (dns_qp_lookup):", n);
printf("%-57s%7.3fsec\n", buf, (stop - start) / (double)NS_PER_SEC);
start = isc_time_monotonic();
@@ -276,12 +275,12 @@ main(int argc, char **argv) {
++search->ndata[1];
}
dns_qp_findname_ancestor(qp, search, 0, NULL, NULL, NULL, NULL);
dns_qp_lookup(qp, search, 0, NULL, NULL, NULL, NULL);
}
stop = isc_time_monotonic();
snprintf(buf, sizeof(buf),
"look up %zd wrong names (dns_qp_findname_ancestor):", n);
"look up %zd wrong names (dns_qp_lookup):", n);
printf("%-57s%7.3fsec\n", buf, (stop - start) / (double)NS_PER_SEC);
isc_mem_cput(mctx, items, n, sizeof(dns_fixedname_t));

View File

@@ -349,8 +349,8 @@ check_partialmatch(dns_qp_t *qp, struct check_partialmatch check[]) {
void *pval = NULL;
dns_test_namefromstring(check[i].query, &fn1);
result = dns_qp_findname_ancestor(qp, name, foundname, NULL,
NULL, &pval, NULL);
result = dns_qp_lookup(qp, name, foundname, NULL, NULL, &pval,
NULL);
#if 0
fprintf(stderr, "%s %s (expected %s) "
@@ -496,8 +496,8 @@ check_qpchain(dns_qp_t *qp, struct check_qpchain check[]) {
dns_qpchain_init(qp, &chain);
dns_test_namefromstring(check[i].query, &fn1);
result = dns_qp_findname_ancestor(qp, name, NULL, NULL, &chain,
NULL, NULL);
result = dns_qp_lookup(qp, name, NULL, NULL, &chain, NULL,
NULL);
#if 0
fprintf(stderr, "%s %s (expected %s), "
@@ -574,8 +574,7 @@ check_predecessors(dns_qp_t *qp, struct check_predecessors check[]) {
char *predname = NULL;
dns_test_namefromstring(check[i].query, &fn1);
result = dns_qp_findname_ancestor(qp, name, NULL, pred, NULL,
NULL, NULL);
result = dns_qp_lookup(qp, name, NULL, pred, NULL, NULL, NULL);
#if 0
fprintf(stderr, "%s: expected %s got %s\n", check[i].query,
isc_result_totext(check[i].result),