2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 05:28:00 +00:00

41111 Commits

Author SHA1 Message Date
Ondřej Surý
f93e1fed67 Merge branch 'ondrej/fix-load_names-rbt-name' into 'main'
Revert the s/rbt/qp/ change in load_names, it is still rbt

See merge request isc-projects/bind9!8833
2024-03-06 16:55:25 +00:00
Ondřej Surý
b0c9ca7a24
Revert the s/rbt/qp/ change in load_names, it is still rbt 2024-03-06 17:54:05 +01:00
Ondřej Surý
88a5befa25 Merge branch 'ondrej/restore-prune_tree-behaviour' into 'main'
Restore the parent cleaning logic in prune_tree()

See merge request isc-projects/bind9!8823
2024-03-06 12:04:39 +00:00
Ondřej Surý
454c75a33a
Restore the parent cleaning logic in prune_tree()
Reconstruct the variant of the prune_tree() parent cleaning to consider
all elibible parents in a single loop as we were doing before all the
changes that led to this commit.

Update code comments so that they more precisely describe what the
relevant bits of code actually do.
2024-03-06 13:03:17 +01:00
Matthijs Mekking
371d7f3716 Merge branch '4411-qpdb-lite' into 'main'
Replace rbt with qp

Closes #4411

See merge request isc-projects/bind9!8726
2024-03-06 10:19:36 +00:00
Evan Hunt
92b305be4b add a compile-time option to select default zone and cache DB
by default, QPDB is the database used by named and all tools and
unit tests. the old default of RBTDB can now be restored by using
"configure --with-zonedb=rbt --with-cachedb=rbt".

some tests have been fixed so they will work correctly with either
database.

CHANGES and release notes have been updated to reflect this change.
2024-03-06 10:49:02 +01:00
Matthijs Mekking
618c963cb7 Fix xferquota system test
The change from RBT to QP has changed the contents of generated zone
files slightly: node names are now always absolute, so instead of using
$ORIGIN and relative names, generated zone files use full names for all
records.

This caused a failure in the xferquota system test, which was looking
for a relative name in secondary zone files. Replace the string
matching with a regular expression to fix the test.
2024-03-06 10:49:02 +01:00
Matthijs Mekking
3facc5b51d Fix race condition crash
When running resolver benchmark pipeline, a crash occurred:

https://gitlab.isc.org/isc-projects/bind9-shotgun-ci/-/pipelines/163946

In the code we are doing a lookup, it fails (meaning there is no node
with lookup name), we create the node and insert it and it fails.
But dns_qp_insert can only return ISC_R_SUCCESS or ISC_R_EXISTS.
So it must have been inserted in between. This is a race condition bug.

The first lookup only requires a write lock and if the lookup failed
the lock gets upgraded to a write lock and we insert the missing data.

To fix the race condition bug, we need to do a lookup again after we
have upgraded the lock to make sure it wasn't inserted in the mean
time.
2024-03-06 10:49:02 +01:00
Matthijs Mekking
7db974b240 Remove pruning tree code
Since qp-tries does not store interior nodes, we can remove all code
related to pruning the tree.
2024-03-06 10:49:02 +01:00
Matthijs Mekking
78fd4e2b5c Update qpdb.c to make coccinelle happy
Applying semantic patch cocci/isc_mem_cget.spatch...
150 files match
diff -u -p a/lib/dns/qpdb.c b/lib/dns/qpdb.c
--- a/lib/dns/qpdb.c
+++ b/lib/dns/qpdb.c
@@ -3801,16 +3801,15 @@ dns__qpdb_create(isc_mem_t *mctx, const
		goto cleanup_tree_lock;
	}
	INSIST(qpdb->node_lock_count < (1 << DNS_RBT_LOCKLENGTH));
-	qpdb->node_locks = isc_mem_get(mctx, qpdb->node_lock_count *
-						      sizeof(db_nodelock_t));
+	qpdb->node_locks = isc_mem_cget(mctx, qpdb->node_lock_count,
+					 sizeof(db_nodelock_t));

	qpdb->common.update_listeners = cds_lfht_new(16, 16, 0, 0, NULL);

	if (IS_CACHE(qpdb)) {
		dns_rdatasetstats_create(mctx, &qpdb->rrsetstats);
-		qpdb->lru = isc_mem_get(mctx,
-					 qpdb->node_lock_count *
-						 sizeof(dns_slabheaderlist_t));
+		qpdb->lru = isc_mem_cget(mctx, qpdb->node_lock_count,
+					  sizeof(dns_slabheaderlist_t));
		for (i = 0; i < (int)qpdb->node_lock_count; i++) {
			ISC_LIST_INIT(qpdb->lru[i]);
		}
@@ -3819,8 +3818,8 @@ dns__qpdb_create(isc_mem_t *mctx, const
	/*
	 * Create the heaps.
	 */
-	qpdb->heaps = isc_mem_get(hmctx, qpdb->node_lock_count *
-						  sizeof(isc_heap_t *));
+	qpdb->heaps = isc_mem_cget(hmctx, qpdb->node_lock_count,
+				    sizeof(isc_heap_t *));
	for (i = 0; i < (int)qpdb->node_lock_count; i++) {
		qpdb->heaps[i] = NULL;
	}
@@ -3834,8 +3833,8 @@ dns__qpdb_create(isc_mem_t *mctx, const
	/*
	 * Create deadnode lists.
	 */
-	qpdb->deadnodes = isc_mem_get(mctx, qpdb->node_lock_count *
-						     sizeof(dns_qpdatalist_t));
+	qpdb->deadnodes = isc_mem_cget(mctx, qpdb->node_lock_count,
+					sizeof(dns_qpdatalist_t));
	for (i = 0; i < (int)qpdb->node_lock_count; i++) {
		ISC_LIST_INIT(qpdb->deadnodes[i]);
	}
2024-03-06 10:49:02 +01:00
Matthijs Mekking
a49a211852 Add CHANGES and release notes for #4411
It is worthwile mentioning the switch to qp-tries.
2024-03-06 10:49:02 +01:00
Evan Hunt
89c4c1aa87 add dns_db_nodefullname()
the dyndb test requires a mechanism to retrieve the name associated
with a database node, and since the database no longer uses RBT for
its underlying storage, dns_rbt_fullnamefromnode() doesn't work.
addressed this by adding dns_db_nodefullname() to the database API.
2024-03-06 10:49:02 +01:00
Matthijs Mekking
cdf62a18e7 Rework dbiterator implementation
If the iterator is paused, the tree is unlocked and may change.

In an RBT tree it's always possible to resume iteration as long
as a valid node pointer was still held, but now that the underlying
database structure is a QP trie, the iterator needs to be initialized
based on the existing structure of the trie or it will return
inconsistent results. We now call dns_qp_lookup() to reinitialize
the QP iterator whenever dbiterator_next() or dbiterator_prev() is
called on a paused iterator.
2024-03-06 10:49:02 +01:00
Evan Hunt
6df391d610 use masterfile-style full in tests where appropriate
the change from RBT to QP has changed the contents of generated zone
files slightly: node names are now always absolute, so instead of using
$ORIGIN and relative names, generated zone files use full names for all
records.

this caused a failure in the stub system test, which was grepping for a
relative name in a dumped zone file. using "masterfile-style full" makes
the test pass regardless of the database being used.
2024-03-06 10:49:02 +01:00
Matthijs Mekking
e91fbd8dea Improve node reference counting
QP database node data is not reference counted the same way RBT nodes
were: in the RBT, node->references could be zero if the node was in the
tree but was not in use by any caller, whereas in the QP trie, the
database itself uses reference counting of nodes internally.

this caused some subtle errors. in RBTDB, when the newref() function is
called and the node reference count was zero, the node lock reference
counter would also be incremented. in the QP trie, this can never
happen - because as long as the node is in the database its reference
count cannot be zero - and so the node lock reference counter was never
incremented.

reference counting will probably need to be refactored in more detail
later; the node lock reference count may not be needed at all.  but
for now, as a temporary measure, we add a third reference counter,
'erefs' (external references), to the dns_qpdata structure. this is
counted separately from the main reference counter, and should match
the node reference count as it would have been in RBTDB.

this change revealed a number of places where the node reference counter
was being incremented on behalf of a caller without newref() being
called; those were cleaned up as well.

This is an adaptation of commit 3dd686261d2c4bcd15a96ebfea10baffa277732b
2024-03-06 10:49:02 +01:00
Evan Hunt
815f54ec27 revise test for ENT NSEC3 cleanup
as a side effect of the switch from RBT to QBDB, NSEC3 records
are no longer created for empty non-terminal nodes when the
node only contains insecure delegations in an opt-out range.

such NSEC3 records are optional according to RFC 5155 (and,
for example, they are not created by dnssec-signzone), but they were
previously created by named, as a harmless side effect of the RBT
structure, which contains empty internal nodes that can be reached
by a DB iterator. these nodes are not present in the QPDB, so
NSEC3 records are not created unless they're actually required.

the autosign system test contained a test case (added in commit
ad91a70d as part of GL #4027) that checked whether ENT NSEC3
records were deleted when the delegations under the ENT removed.
this test no longer passes, because the NSEC3's are not created
in the first place, and therefore cannot be removed.

rather than "fix" the QPDB to add unnecessary NSEC3 records, this
commit instead revises the test to check for removal of ENT NSEC3
records when *not* using opt-out.
2024-03-06 10:49:02 +01:00
Matthijs Mekking
91a2755433 No special logic for relative names
Nodes in a QP-trie contain the full domain name, while nodes in a
red-black tree only contain names relative to a parent.
2024-03-06 10:49:02 +01:00
Matthijs Mekking
1a068c9656 Change free_gluetable
Fixes a crash at shutdown.
2024-03-06 09:57:25 +01:00
Matthijs Mekking
10efb6fdc2 Calculating hashsize is obsolete
We don't have hash tables for qp.
2024-03-06 09:57:25 +01:00
Matthijs Mekking
820abdb80a Add proper qp cleanup
Fix reference counting: unreference nodes that are succesfully inserted
in the tree, detach created nodes, and cleanup the interior data in
dns_qpdata_destroy().
2024-03-06 09:57:25 +01:00
Matthijs Mekking
fe97aa59b9 Replace dns_rbtnode_t with dns_qpdata_t
This for now has almost the same structure contents except for
dns_qpdata_t has 'fn' and 'name' to store the domain name.
2024-03-06 09:57:25 +01:00
Matthijs Mekking
cc3a40dafa Replace dns_rbt_nodecount with dns_qp_memusage
We now count the nodes by getting the memory usage and return the
number of leaves.
2024-03-06 09:57:25 +01:00
Matthijs Mekking
e95dfc0119 Replace dns_rbt_namefromnode with dns_name_copy
The name will be stored inside the node now so we can just copy it.

These are leftovers, most of the namefromnode code has been replaced
already in previous commits.
2024-03-06 09:57:24 +01:00
Matthijs Mekking
6a5de6390f Replace rbtnodechain with qpchain and qpiter
The qp approach pulled apart the chain and iterator into two separate
things. Replace the rbtnodechain with qpchain and qpiter. Most of the
times we are interested in the iterator only, the rbtnodechain was
mainly used as an an iterator to get the previous and next name in the
DNS canonical order.

Since dns_qpiter_prev() and dns_qpiter_next() store the name, origin,
and node in the provided parameters, often there is no need to call
a current() function anymore.

Getting the first or last item from the iterator is done by
re-initializing the iterator and then call dns_qpiter_next() or
dns_qpiter_prev() respectively.

The dbiterator no longer needs to maintain a chain, only an iterator.
2024-03-06 09:57:24 +01:00
Matthijs Mekking
8572435a31 Replace rbt_findnode with qp_lookup
All dns_qp_lookup() calls assume it is okay to find empty data, so
we don't need to do anything special for the DNS_RBTFIND_EMPTYDATA.

You can pass a callback function to dns_rbt_findnode(), something that
qp does not support. Instead, call the function afterwards. This has
the drawback that we do more lookup work if there was a zonecut.

With dns_qp_lookup() we also don't pass any options. In this case,
when DNS_RBTFIND_NOEXACT was set, we adapt the result after the lookup.
2024-03-06 09:57:24 +01:00
Matthijs Mekking
8fcfa36660 Replace rbt_deletenode with qp_deletename
Replace dns_rbt_deletenode calls with dns_qp_deletename. For removing
the name from the nsec tree, we no longer first have to find it: we can
just remove the key (retrieved by name).
2024-03-06 09:57:24 +01:00
Matthijs Mekking
c53b95e134 Replace rbt_addnode with qp_insert
Replace dns_rbt_addnode calls with dns_qp_insert. With QP, it sometimes
makes more sense to first lookup the name and see if there is an
existing node (rather than create new data, insert, find out a node
already exists, and destroy the data again). This is done with
dns_qp_getname(), which is more lightweight than dns_qp_lookup(),
and we are only interested in if there is already a leaf node for this
name or not.
2024-03-06 09:57:24 +01:00
Evan Hunt
bb4464181a switch database defaults from "rbt" to "qp"
replace the string "rbt" throughout BIND with "qp" so that
qpdb databases will be used by default instead of rbtdb.
rbtdb databases can still be used by specifying "database rbt;"
in a zone statement.
2024-03-06 09:57:24 +01:00
Evan Hunt
845f832308 rename dns_rbtdb to dns_qpdb
this commit renames all variables and macros with the string "rbtdb"
or "RBDTB" to "qpdb" or "QPDB".
2024-03-06 09:57:24 +01:00
Matthijs Mekking
2edf73dc05 Begin replacement of rbt with qp in rbtdb
- Copy rbtdb.c, rbt-zonedb.c and rbt-cachedb.c to qp-*.
- Added qpmethods.
- Added a new structure dns_qpdata that will replace dns_rbtnode.
- Replaced normal, nsec, and nsec3 dns_rbt trees with dns_qp tries.
- Replaced dns_rbt_create() calls with dns_qp_create().
- Replaced the dns_rbt_destroy() call with dns_qp_destroy().
- Create a dns_qpdata struct and create/destroy methods.

This commit will not build.
2024-03-06 09:57:24 +01:00
Mark Andrews
522b6eced0 Merge branch '4612-resolver-crashes-on-10-0-0-38-abcdefghijklmnopqrstuvwxyz012345-plex-direct-ds-query' into 'main'
Resolve "resolver crashes on 10-0-0-38.abcdefghijklmnopqrstuvwxyz012345.plex.direct DS query"

Closes #4612

See merge request isc-projects/bind9!8794
2024-03-06 00:16:13 +00:00
Mark Andrews
f4f7f23d9d Add CHANGES note for [GL #4612] 2024-03-06 10:09:05 +11:00
Mark Andrews
3fedbb1a66 test: DS query against broken NODATA responses
This is a regresssion test for GL #4621 where the NODATA responses
are SOA records that match the QNAME rather than the zone name. In
particular for NS queries.
2024-03-06 10:09:05 +11:00
Mark Andrews
5ff55e13e8 Restore the disassociate call to before the fetch
[GL #3709] reordered the dns_rdataset_disassociate call to after
the dns_resolver_createfetch call resulting in qctx->nsrrset still
being associated when dns_resolver_createfetch is called in
resume_dslookup (7e4e125e).  Revert that part of the change and add
comments as to why the multiple dns_rdataset_disassociate calls are
where they are.
2024-03-06 10:08:30 +11:00
Ondřej Surý
470bfcaa19 Merge branch '4600-call-dispatch-connect-callbacks-asynchronously' into 'main'
Pin the xfr to a specific loop

Closes #4600

See merge request isc-projects/bind9!8821
2024-03-04 15:34:51 +00:00
Ondřej Surý
e74c7dcf51
Always call the TCP dispatch connected callbacks asynchronously
The TCP dispatch connected callbacks could be called synchronously which
in turn could destroy xfrin before we return from dns_xfrin_create().

Delay the calling the callback called from tcp_dispatch_connect() by
calling it always asynchronously.
2024-03-04 16:34:14 +01:00
Ondřej Surý
98d59bdf62
Pin the xfr to a specific loop
Instead of getting the loop from the zone every time, attach the xfrin
directly to the loop.  This also allows to remove the extra safety tid
checks from the dns_xfrin unit.
2024-03-04 16:34:14 +01:00
Petr Špaček
42e7f6b003 Merge branch 'pspacek/cve-bug-report-template' into 'main'
Fix typos in Security bug issue template

See merge request isc-projects/bind9!8822
2024-03-04 14:18:13 +00:00
Petr Špaček
feab0d638a Fix typos in Security bug issue template 2024-03-04 15:16:10 +01:00
Petr Špaček
a6da5e9faa Merge branch 'pspacek/cve-bug-report-template' into 'main'
Security bug issue template improvements

See merge request isc-projects/bind9!8820
2024-03-04 13:13:36 +00:00
Petr Špaček
eb93c915d3 Adjust line breaks in CVE report template 2024-03-04 13:13:30 +00:00
Petr Špaček
30d57b93a7 Add questions about multiple implementations into CVE report template 2024-03-04 13:13:30 +00:00
Evan Hunt
b62a9fd900 Merge branch 'each-move-rrl-broken-config-test-case-to-checkconf' into 'main'
Move RRL broken-config check to checkconf

See merge request isc-projects/bind9!8795
2024-03-01 23:34:05 +00:00
Evan Hunt
05398c1488 move RRL broken-config check to checkconf
the RRL test included a test case that tried to start named with
a broken configuration.  the same error could be found with
named-checkconf, so it should have been tested in the checkconf
system test.
2024-03-01 14:29:30 -08:00
Ondřej Surý
7111ea3669 Merge branch '4591-improve-ttl-based-cleaning' into 'main'
Remove expired rdataset headers from the heap

Closes #4591

See merge request isc-projects/bind9!8754
2024-02-29 12:33:58 +00:00
Ondřej Surý
db69cc7891
Add CHANGES note for [GL #4591] 2024-02-29 12:57:06 +01:00
Ondřej Surý
d8220ca4ca
Make the TTL-based cleaning more aggressive
It was discovered that the TTL-based cleaning could build up
a significant backlog of the rdataset headers during the periods where
the top of the TTL heap isn't expired yet.  Make the TTL-based cleaning
more aggressive by cleaning more headers from the heap when we are
adding new header into the RBTDB.
2024-02-29 12:57:06 +01:00
Ondřej Surý
a9383e4b95
Remove expired rdataset headers from the heap
It was discovered that an expired header could sit on top of the heap
a little longer than desireable.  Remove expired headers (headers with
rdh_ttl set to 0) from the heap completely, so they don't block the next
TTL-based cleaning.
2024-02-29 12:56:36 +01:00
Ondřej Surý
96171e9879 Merge branch '4596-regression-in-cache-cleaning' into 'main'
Reduce lock contention during RBTDB tree pruning

Closes #4596

See merge request isc-projects/bind9!8765
2024-02-29 11:33:05 +00:00
Ondřej Surý
f447557667
Add CHANGES and release note for [GL #4596] 2024-02-29 11:23:04 +01:00