]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
move DNS_RBT_NSEC_* to db.h
authorEvan Hunt <each@isc.org>
Thu, 5 Oct 2023 00:49:51 +0000 (17:49 -0700)
committerEvan Hunt <each@isc.org>
Wed, 14 Feb 2024 09:13:44 +0000 (01:13 -0800)
these values pertain to whether a node is in the main, nsec, or nsec3
tree of an RBTDB. they need to be moved to a more generic location so
they can also be used by QPDB.

(this is in db.h rather than db_p.h because rbt.c needs access to it.
technically, that's a layer violation, but it's a long-existing one;
refactoring to get rid of it would be a large hassle, and eventually
we expect to remove rbt.c anyway.)

lib/dns/include/dns/db.h
lib/dns/include/dns/rbt.h
lib/dns/rbt-zonedb.c
lib/dns/rbt.c
lib/dns/rbtdb.c

index b3657be2e880d3c46ba9675ceb56a76e5d6f840d..c82c694c5a4097267cb3fe0b5c1b0831d08b8a89 100644 (file)
@@ -228,6 +228,17 @@ struct dns_dbonupdatelistener {
        struct rcu_head         rcu_head;
 };
 
+/*%
+ * Used in composite databases such as RBTDB to indicate whether a node
+ * exists in a specal tree for NSEC or NSEC3.
+ */
+enum {
+       DNS_DB_NSEC_NORMAL = 0,   /* in main tree */
+       DNS_DB_NSEC_HAS_NSEC = 1, /* also has node in nsec tree */
+       DNS_DB_NSEC_NSEC = 2,     /* in nsec tree */
+       DNS_DB_NSEC_NSEC3 = 3     /* in nsec3 tree */
+};
+
 /*@{*/
 /*%
  * Options that can be specified for dns_db_find().
index 93e429069bbed92075fbfc7f75df7d6a718466ad..c37a3a98b31fafcdcf1f62701ebd55d48de6c0fe 100644 (file)
@@ -57,12 +57,6 @@ ISC_LANG_BEGINDECLS
  * appended to this structure.  Allocating a contiguous block of memory for
  * multiple dns_rbtnode structures will not work.
  */
-enum {
-       DNS_RBT_NSEC_NORMAL = 0,   /* in main tree */
-       DNS_RBT_NSEC_HAS_NSEC = 1, /* also has node in nsec tree */
-       DNS_RBT_NSEC_NSEC = 2,     /* in nsec tree */
-       DNS_RBT_NSEC_NSEC3 = 3     /* in nsec3 tree */
-};
 struct dns_rbtnode {
 #if DNS_RBT_USEMAGIC
        unsigned int magic;
index fc3fee92a4b0474111d45a497c42d6da9b8a9eb6..18294595debd48909ed8aea5e2b70e376ede5e9d 100644 (file)
@@ -1621,7 +1621,7 @@ loadnode(dns_rbtdb_t *rbtdb, const dns_name_t *name, dns_rbtnode_t **nodep,
                 * Add a node to the auxiliary NSEC tree for an old node
                 * just now getting an NSEC record.
                 */
-               if (node->nsec == DNS_RBT_NSEC_HAS_NSEC) {
+               if (node->nsec == DNS_DB_NSEC_HAS_NSEC) {
                        goto done;
                }
        } else if (noderesult != ISC_R_SUCCESS) {
@@ -1638,8 +1638,8 @@ loadnode(dns_rbtdb_t *rbtdb, const dns_name_t *name, dns_rbtnode_t **nodep,
         */
        nsecresult = dns_rbt_addnode(rbtdb->nsec, name, &nsecnode);
        if (nsecresult == ISC_R_SUCCESS) {
-               nsecnode->nsec = DNS_RBT_NSEC_NSEC;
-               node->nsec = DNS_RBT_NSEC_HAS_NSEC;
+               nsecnode->nsec = DNS_DB_NSEC_NSEC;
+               node->nsec = DNS_DB_NSEC_HAS_NSEC;
                goto done;
        }
 
@@ -1649,7 +1649,7 @@ loadnode(dns_rbtdb_t *rbtdb, const dns_name_t *name, dns_rbtnode_t **nodep,
                              DNS_LOGMODULE_CACHE, ISC_LOG_WARNING,
                              "addnode: NSEC node already exists");
 #endif /* if 1 */
-               node->nsec = DNS_RBT_NSEC_HAS_NSEC;
+               node->nsec = DNS_DB_NSEC_HAS_NSEC;
                goto done;
        }
 
@@ -1734,7 +1734,7 @@ loading_addrdataset(void *arg, const dns_name_t *name,
        {
                result = dns_rbt_addnode(rbtdb->nsec3, name, &node);
                if (result == ISC_R_SUCCESS) {
-                       node->nsec = DNS_RBT_NSEC_NSEC3;
+                       node->nsec = DNS_DB_NSEC_NSEC3;
                }
        } else if (rdataset->type == dns_rdatatype_nsec) {
                result = loadnode(rbtdb, name, &node, true);
@@ -2469,7 +2469,7 @@ dns__zonerbt_wildcardmagic(dns_rbtdb_t *rbtdb, const dns_name_t *name,
                return (result);
        }
        if (result == ISC_R_SUCCESS) {
-               node->nsec = DNS_RBT_NSEC_NORMAL;
+               node->nsec = DNS_DB_NSEC_NORMAL;
        }
        node->find_callback = 1;
        if (lock) {
@@ -2509,7 +2509,7 @@ dns__zonerbt_addwildcards(dns_rbtdb_t *rbtdb, const dns_name_t *name,
                                return (result);
                        }
                        if (result == ISC_R_SUCCESS) {
-                               node->nsec = DNS_RBT_NSEC_NORMAL;
+                               node->nsec = DNS_DB_NSEC_NORMAL;
                        }
                }
                i++;
index 54ddfd917514b9710784b1d9226f83531873d6bb..cfcda98f95555adc6c1767b91844d2b1502bcaeb 100644 (file)
@@ -36,6 +36,7 @@
 
 #include <isc/result.h>
 
+#include <dns/db.h>
 #include <dns/fixedname.h>
 #include <dns/log.h>
 #include <dns/rbt.h>
@@ -594,8 +595,8 @@ dns_rbt_addnode(dns_rbt_t *rbt, const dns_name_t *name, dns_rbtnode_t **nodep) {
                                 * current node.
                                 */
                                new_current->is_root = current->is_root;
-                               if (current->nsec == DNS_RBT_NSEC_HAS_NSEC) {
-                                       new_current->nsec = DNS_RBT_NSEC_NORMAL;
+                               if (current->nsec == DNS_DB_NSEC_HAS_NSEC) {
+                                       new_current->nsec = DNS_DB_NSEC_NORMAL;
                                } else {
                                        new_current->nsec = current->nsec;
                                }
@@ -1515,8 +1516,8 @@ create_node(isc_mem_t *mctx, const dns_name_t *name, dns_rbtnode_t **nodep) {
        nodelen = sizeof(dns_rbtnode_t) + region.length + labels + 1;
        node = isc_mem_get(mctx, nodelen);
        *node = (dns_rbtnode_t){
-               .nsec = DNS_RBT_NSEC_NORMAL,
                .color = BLACK,
+               .nsec = DNS_DB_NSEC_NORMAL,
        };
 
        ISC_LINK_INIT(node, deadlink);
index 215d84e6da93fa6bf152a994e429be699b2a6e15..06ac203308ef72c15f7719561e9497def04e26f9 100644 (file)
@@ -1072,10 +1072,10 @@ delete_node(dns_rbtdb_t *rbtdb, dns_rbtnode_t *node) {
        }
 
        switch (node->nsec) {
-       case DNS_RBT_NSEC_NORMAL:
+       case DNS_DB_NSEC_NORMAL:
                result = dns_rbt_deletenode(rbtdb->tree, node, false);
                break;
-       case DNS_RBT_NSEC_HAS_NSEC:
+       case DNS_DB_NSEC_HAS_NSEC:
                /*
                 * Though this may be wasteful, it has to be done before
                 * node is deleted.
@@ -1110,10 +1110,10 @@ delete_node(dns_rbtdb_t *rbtdb, dns_rbtnode_t *node) {
                }
                result = dns_rbt_deletenode(rbtdb->tree, node, false);
                break;
-       case DNS_RBT_NSEC_NSEC:
+       case DNS_DB_NSEC_NSEC:
                result = dns_rbt_deletenode(rbtdb->nsec, node, false);
                break;
-       case DNS_RBT_NSEC_NSEC3:
+       case DNS_DB_NSEC_NSEC3:
                result = dns_rbt_deletenode(rbtdb->nsec3, node, false);
                break;
        }
@@ -2077,7 +2077,7 @@ dns__rbtdb_findnodeintree(dns_rbtdb_t *rbtdb, dns_rbt_t *tree,
                                }
                        }
                        if (tree == rbtdb->nsec3) {
-                               node->nsec = DNS_RBT_NSEC_NSEC3;
+                               node->nsec = DNS_DB_NSEC_NSEC3;
                        }
                } else if (result == ISC_R_EXISTS) {
                        result = ISC_R_SUCCESS;
@@ -2087,7 +2087,7 @@ dns__rbtdb_findnodeintree(dns_rbtdb_t *rbtdb, dns_rbt_t *tree,
        }
 
        if (tree == rbtdb->nsec3) {
-               INSIST(node->nsec == DNS_RBT_NSEC_NSEC3);
+               INSIST(node->nsec == DNS_DB_NSEC_NSEC3);
        }
 
        reactivate_node(rbtdb, node, tlocktype DNS__DB_FLARG_PASS);
@@ -3208,10 +3208,10 @@ dns__rbtdb_addrdataset(dns_db_t *db, dns_dbnode_t *node,
                        return (DNS_R_NOTZONETOP);
                }
                TREE_RDLOCK(&rbtdb->tree_lock, &tlocktype);
-               REQUIRE(((rbtnode->nsec == DNS_RBT_NSEC_NSEC3 &&
+               REQUIRE(((rbtnode->nsec == DNS_DB_NSEC_NSEC3 &&
                          (rdataset->type == dns_rdatatype_nsec3 ||
                           rdataset->covers == dns_rdatatype_nsec3)) ||
-                        (rbtnode->nsec != DNS_RBT_NSEC_NSEC3 &&
+                        (rbtnode->nsec != DNS_DB_NSEC_NSEC3 &&
                          rdataset->type != dns_rdatatype_nsec3 &&
                          rdataset->covers != dns_rdatatype_nsec3)));
                TREE_UNLOCK(&rbtdb->tree_lock, &tlocktype);
@@ -3314,7 +3314,7 @@ dns__rbtdb_addrdataset(dns_db_t *db, dns_dbnode_t *node,
         * Add to the auxiliary NSEC tree if we're adding an NSEC record.
         */
        TREE_RDLOCK(&rbtdb->tree_lock, &tlocktype);
-       if (rbtnode->nsec != DNS_RBT_NSEC_HAS_NSEC &&
+       if (rbtnode->nsec != DNS_DB_NSEC_HAS_NSEC &&
            rdataset->type == dns_rdatatype_nsec)
        {
                newnsec = true;
@@ -3384,10 +3384,10 @@ dns__rbtdb_addrdataset(dns_db_t *db, dns_dbnode_t *node,
 
                result = dns_rbt_addnode(rbtdb->nsec, name, &nsecnode);
                if (result == ISC_R_SUCCESS) {
-                       nsecnode->nsec = DNS_RBT_NSEC_NSEC;
-                       rbtnode->nsec = DNS_RBT_NSEC_HAS_NSEC;
+                       nsecnode->nsec = DNS_DB_NSEC_NSEC;
+                       rbtnode->nsec = DNS_DB_NSEC_HAS_NSEC;
                } else if (result == ISC_R_EXISTS) {
-                       rbtnode->nsec = DNS_RBT_NSEC_HAS_NSEC;
+                       rbtnode->nsec = DNS_DB_NSEC_HAS_NSEC;
                        result = ISC_R_SUCCESS;
                }
        }
@@ -3443,10 +3443,10 @@ dns__rbtdb_subtractrdataset(dns_db_t *db, dns_dbnode_t *node,
 
        if (!IS_CACHE(rbtdb)) {
                TREE_RDLOCK(&rbtdb->tree_lock, &tlocktype);
-               REQUIRE(((rbtnode->nsec == DNS_RBT_NSEC_NSEC3 &&
+               REQUIRE(((rbtnode->nsec == DNS_DB_NSEC_NSEC3 &&
                          (rdataset->type == dns_rdatatype_nsec3 ||
                           rdataset->covers == dns_rdatatype_nsec3)) ||
-                        (rbtnode->nsec != DNS_RBT_NSEC_NSEC3 &&
+                        (rbtnode->nsec != DNS_DB_NSEC_NSEC3 &&
                          rdataset->type != dns_rdatatype_nsec3 &&
                          rdataset->covers != dns_rdatatype_nsec3)));
                TREE_UNLOCK(&rbtdb->tree_lock, &tlocktype);
@@ -3975,7 +3975,7 @@ dns__rbtdb_create(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
                        return (result);
                }
                INSIST(rbtdb->origin_node != NULL);
-               rbtdb->origin_node->nsec = DNS_RBT_NSEC_NORMAL;
+               rbtdb->origin_node->nsec = DNS_DB_NSEC_NORMAL;
                /*
                 * We need to give the origin node the right locknum.
                 */
@@ -3995,7 +3995,7 @@ dns__rbtdb_create(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
                        free_rbtdb(rbtdb, false);
                        return (result);
                }
-               rbtdb->nsec3_origin_node->nsec = DNS_RBT_NSEC_NSEC3;
+               rbtdb->nsec3_origin_node->nsec = DNS_DB_NSEC_NSEC3;
                /*
                 * We need to give the nsec3 origin node the right locknum.
                 */