]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
rename dns_qp_findname_ancestor() to dns_qp_lookup()
authorEvan Hunt <each@isc.org>
Wed, 27 Sep 2023 03:19:37 +0000 (20:19 -0700)
committerEvan Hunt <each@isc.org>
Thu, 28 Sep 2023 07:32:44 +0000 (00:32 -0700)
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.)

lib/dns/forward.c
lib/dns/include/dns/qp.h
lib/dns/keytable.c
lib/dns/nametree.c
lib/dns/nta.c
lib/dns/qp.c
lib/dns/zt.c
tests/bench/qplookups.c
tests/dns/qp_test.c

index 0be252f3ac4dccbaac118e07c002ee222689fb61..f48a3dc0767c70eb1b6988c22342da1ba2b348b7 100644 (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;
index f38eee37ac3ecfe09bf1af3b1e2ede8b7b92722f..cb92d4f78d34170786aec672f7ff854b9c4910b2 100644 (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 leaf values are assigned to whichever of `*pval_r` and `*ival_r`
- * are not null, unless the return value is ISC_R_NOTFOUND.
+ * 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.
+ *
+ * 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
index e8ce21fa1954beda1f4a2818c4aa3d8fc6db8678..7284140951344894a27fb67038b28b1594f10063 100644 (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) {
index 60fa9a97f029d2e7a59b1f301efb74fb0287d8af..f2b323272677f667d60544870b220332d1be01fc 100644 (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:
index c86b0ebf7b79c02499333af25d0c325d9c290611..060fa6c32d38a5576d75204d72431954c96436c4 100644 (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) {
index c554c85d2386e755b8c36188f55ebde03e36f77d..4bc75414c9d4ce86b4892d06a04bd2d172fdedc1 100644 (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;
index 147e6fc830cd1150f4c7dac094483d7d0936f7bc..7f1b4160234701f811d21094aa21cdc89ca646a7 100644 (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) {
index fd50ad37ca4d554baa751f1461d902d0c6812b31..be85825ec3da19dbe5879a5882048e7adecaae95 100644 (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));
index 6c83f8f365a3308936815f8d5311356997131dae..c0c399085f3c62c25e0a7fe2cfb9da17117ada11 100644 (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),