From: Evan Hunt Date: Thu, 5 Oct 2023 00:49:51 +0000 (-0700) Subject: move DNS_RBT_NSEC_* to db.h X-Git-Tag: v9.19.22~39^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=78d173b5489bd2bef8db5b55e840c356a6e59968;p=thirdparty%2Fbind9.git move DNS_RBT_NSEC_* to db.h 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.) --- diff --git a/lib/dns/include/dns/db.h b/lib/dns/include/dns/db.h index b3657be2e88..c82c694c5a4 100644 --- a/lib/dns/include/dns/db.h +++ b/lib/dns/include/dns/db.h @@ -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(). diff --git a/lib/dns/include/dns/rbt.h b/lib/dns/include/dns/rbt.h index 93e429069bb..c37a3a98b31 100644 --- a/lib/dns/include/dns/rbt.h +++ b/lib/dns/include/dns/rbt.h @@ -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; diff --git a/lib/dns/rbt-zonedb.c b/lib/dns/rbt-zonedb.c index fc3fee92a4b..18294595deb 100644 --- a/lib/dns/rbt-zonedb.c +++ b/lib/dns/rbt-zonedb.c @@ -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++; diff --git a/lib/dns/rbt.c b/lib/dns/rbt.c index 54ddfd91751..cfcda98f955 100644 --- a/lib/dns/rbt.c +++ b/lib/dns/rbt.c @@ -36,6 +36,7 @@ #include +#include #include #include #include @@ -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); diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c index 215d84e6da9..06ac203308e 100644 --- a/lib/dns/rbtdb.c +++ b/lib/dns/rbtdb.c @@ -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. */