Commit 99a9377912 for bind
commit 99a93779120886d65d886f635dfea74e28f21234
Author: Matthijs Mekking <matthijs@isc.org>
Date: Thu Oct 29 10:19:28 2026 +0100
Remove unused count nametree
The DNS_NAMETREE_COUNT nametree is now no longer used, and can be
removed.
diff --git a/lib/dns/include/dns/nametree.h b/lib/dns/include/dns/nametree.h
index d603f5a97c..a1efd68567 100644
--- a/lib/dns/include/dns/nametree.h
+++ b/lib/dns/include/dns/nametree.h
@@ -41,7 +41,6 @@
typedef enum {
DNS_NAMETREE_BOOL,
DNS_NAMETREE_BITS,
- DNS_NAMETREE_COUNT
} dns_nametree_type_t;
void
@@ -54,8 +53,7 @@ dns_nametree_create(isc_mem_t *mctx, dns_nametree_type_t type, const char *name,
* for debugging purposes.
*
* 'type' indicates whether the tree will be used for storing boolean
- * values (DNS_NAMETREE_BOOL), bitfields (DNS_NAMETREE_BITS), or counters
- * (DNS_NAMETREE_COUNT).
+ * values (DNS_NAMETREE_BOOL), or bitfields (DNS_NAMETREE_BITS).
*
* Requires:
*
@@ -73,12 +71,6 @@ dns_nametree_add(dns_nametree_t *nametree, const dns_name_t *name,
* represents a single boolean value, true or false. If the name already
* exists within the tree, then return ISC_R_EXISTS.
*
- * If the nametree type was set to DNS_NAMETREE_COUNT, then 'value'
- * can only be true. Each time the same name is added to the tree,
- * ISC_R_SUCCESS is returned and a counter is incremented.
- * dns_nametree_delete() must be deleted the same number of times
- * as dns_nametree_add() before the name is removed from the tree.
- *
* If the nametree type was set to DNS_NAMETREE_BITS, then 'value' is
* a bit number within a bit field, which is sized to accommodate at least
* 'value' bits. If the name already exists, then that bit will be set
@@ -103,10 +95,6 @@ dns_nametree_delete(dns_nametree_t *nametree, const dns_name_t *name);
/*%<
* Delete 'name' from 'nametree'.
*
- * If the nametree type was set to DNS_NAMETREE_COUNT, then this must
- * be called for each name the same number of times as dns_nametree_add()
- * was called before the name is removed.
- *
* Requires:
*
*\li 'nametree' points to a valid nametree.
diff --git a/lib/dns/nametree.c b/lib/dns/nametree.c
index 987b0cbeab..6f58b713dd 100644
--- a/lib/dns/nametree.c
+++ b/lib/dns/nametree.c
@@ -160,17 +160,6 @@ dns_nametree_add(dns_nametree_t *nametree, const dns_name_t *name,
new = newnode(nametree->mctx, name);
new->set = value;
break;
-
- case DNS_NAMETREE_COUNT:
- new = newnode(nametree->mctx, name);
- new->set = true;
- result = dns_qp_deletename(qp, name, DNS_DBNAMESPACE_NORMAL,
- (void **)&old, &count);
- if (result == ISC_R_SUCCESS) {
- count += 1;
- }
- break;
-
case DNS_NAMETREE_BITS:
result = dns_qp_getname(qp, name, DNS_DBNAMESPACE_NORMAL,
(void **)&old, NULL);
@@ -231,16 +220,6 @@ dns_nametree_delete(dns_nametree_t *nametree, const dns_name_t *name) {
case DNS_NAMETREE_BOOL:
case DNS_NAMETREE_BITS:
break;
-
- case DNS_NAMETREE_COUNT:
- if (result == ISC_R_SUCCESS && count-- != 0) {
- dns_ntnode_t *new = newnode(nametree->mctx, name);
- new->set = true;
- result = dns_qp_insert(qp, new, count);
- INSIST(result == ISC_R_SUCCESS);
- dns_ntnode_detach(&new);
- }
- break;
default:
UNREACHABLE();
}
@@ -293,9 +272,6 @@ dns_nametree_covered(dns_nametree_t *nametree, const dns_name_t *name,
case DNS_NAMETREE_BOOL:
ret = node->set;
break;
- case DNS_NAMETREE_COUNT:
- ret = true;
- break;
case DNS_NAMETREE_BITS:
ret = matchbit(node->bits, bit);
break;
diff --git a/tests/dns/nametree_test.c b/tests/dns/nametree_test.c
index 56b94c6a8e..b402aba184 100644
--- a/tests/dns/nametree_test.c
+++ b/tests/dns/nametree_test.c
@@ -41,7 +41,6 @@
dns_nametree_t *booltree = NULL;
dns_nametree_t *bitstree = NULL;
-dns_nametree_t *counttree = NULL;
/*
* Test utilities. In general, these assume input parameters are valid
@@ -60,8 +59,6 @@ setup(void **state ISC_ATTR_UNUSED) {
&booltree);
dns_nametree_create(isc_g_mctx, DNS_NAMETREE_BITS, "bits test",
&bitstree);
- dns_nametree_create(isc_g_mctx, DNS_NAMETREE_COUNT, "count test",
- &counttree);
/* Add a positive boolean node */
dns_test_namefromstring("example.com.", &fn);
@@ -91,7 +88,6 @@ static int
teardown(void **state ISC_ATTR_UNUSED) {
dns_nametree_detach(&booltree);
dns_nametree_detach(&bitstree);
- dns_nametree_detach(&counttree);
rcu_barrier();
return 0;
}
@@ -160,38 +156,6 @@ ISC_RUN_TEST_IMPL(add_bits) {
dns_ntnode_detach(&node);
}
-ISC_RUN_TEST_IMPL(add_count) {
- dns_fixedname_t fn;
- dns_name_t *name = dns_name(&fn);
-
- /* add a counter node five times */
- dns_test_namefromstring("example.com.", &fn);
- assert_int_equal(dns_nametree_add(counttree, name, 0), ISC_R_SUCCESS);
- assert_int_equal(dns_nametree_add(counttree, name, 0), ISC_R_SUCCESS);
- assert_int_equal(dns_nametree_add(counttree, name, 0), ISC_R_SUCCESS);
- assert_int_equal(dns_nametree_add(counttree, name, 0), ISC_R_SUCCESS);
- assert_int_equal(dns_nametree_add(counttree, name, 0), ISC_R_SUCCESS);
-
- /* delete it five times, checking coverage each time */
- assert_true(dns_nametree_covered(counttree, name, NULL, 0));
- assert_int_equal(dns_nametree_delete(counttree, name), ISC_R_SUCCESS);
-
- assert_true(dns_nametree_covered(counttree, name, NULL, 0));
- assert_int_equal(dns_nametree_delete(counttree, name), ISC_R_SUCCESS);
-
- assert_true(dns_nametree_covered(counttree, name, NULL, 0));
- assert_int_equal(dns_nametree_delete(counttree, name), ISC_R_SUCCESS);
-
- assert_true(dns_nametree_covered(counttree, name, NULL, 0));
- assert_int_equal(dns_nametree_delete(counttree, name), ISC_R_SUCCESS);
-
- assert_true(dns_nametree_covered(counttree, name, NULL, 0));
- assert_int_equal(dns_nametree_delete(counttree, name), ISC_R_SUCCESS);
-
- assert_false(dns_nametree_covered(counttree, name, NULL, 0));
- assert_int_equal(dns_nametree_delete(counttree, name), ISC_R_NOTFOUND);
-}
-
ISC_RUN_TEST_IMPL(covered_bool) {
dns_fixedname_t fn, fn2;
dns_name_t *name = dns_fixedname_initname(&fn);
@@ -325,7 +289,6 @@ ISC_RUN_TEST_IMPL(find) {
ISC_TEST_LIST_START
ISC_TEST_ENTRY_CUSTOM(add_bool, setup, teardown)
ISC_TEST_ENTRY_CUSTOM(add_bits, setup, teardown)
-ISC_TEST_ENTRY_CUSTOM(add_count, setup, teardown)
ISC_TEST_ENTRY_CUSTOM(covered_bool, setup, teardown)
ISC_TEST_ENTRY_CUSTOM(covered_bits, setup, teardown)
ISC_TEST_ENTRY_CUSTOM(delete, setup, teardown)