Commit Graph

40169 Commits

Author SHA1 Message Date
Evan Hunt
3a206da456 check chain length is nonzero before examining last entry
It was possible to reach add_link() without visiting an
intermediate node first, and the check for a duplicate entry
could then cause a crash.

Credit to OSS-Fuzz for discovering this error.
2023-10-12 11:31:32 -07:00
Michał Kępień
a87436d3d5 Merge branch 'michal/remove-pdf-related-bits-from-the-build-system' into 'main'
Remove PDF-related bits from the build system

See merge request isc-projects/bind9!8350
2023-10-12 12:37:48 +00:00
Michał Kępień
561a83a291 Remove PDF-related bits from the build system
Read the Docs is capable of building the PDF version of the BIND 9 ARM
using just the contents of the doc/arm/ directory - it does not need the
build system to facilitate that.  Since the BIND 9 ARM is also built in
other formats when "make doc" is run, drop the parts of the build system
that enable building the PDF version as they pull in complexity without
bringing much added value in return.  Update related files accordingly.
2023-10-12 14:24:42 +02:00
Ondřej Surý
1da0af6d2f Merge branch '4326-remove-locking-from-copy_namehook_lists' into 'main'
Replace some ADB entry locking with atomics to reduce ADB contention

Closes #4326

See merge request isc-projects/bind9!8328
2023-10-12 10:43:50 +00:00
Ondřej Surý
6b306b9deb Add CHANGES note for [GL #4326] 2023-10-12 12:35:18 +02:00
Ondřej Surý
91f3b0edee Use mul and div instead of bitshifts to calculate srtt
There was a microoptimization for smoothing srtt with bitshifts.  Revert
the code to use * 98 / 100, it doesn't really make that difference on
modern CPUs, for comparison here:

    muldiv:
	    imul    eax, edi, 98
	    imul    rax, rax, 1374389535
	    shr     rax, 37
	    ret
    shift:
	    mov     eax, edi
	    sal     eax, 9
	    sub     eax, edi
	    shr     eax, 9
	    ret
2023-10-12 12:35:00 +02:00
Ondřej Surý
0635bd01cb Skip the no-op code in adjustsrtt()
If factor == DNS_ADB_RTTADJAGE and addr->entry->lastage == now we would
load value into new_srtt and then immediatelly store it back which
triggers the synchronization between threads using .srtt values.
2023-10-12 12:35:00 +02:00
Ondřej Surý
cb0db600e7 Replace some ADB entry locking with atomics to reduce ADB contention
Use atomics on couple of ADB entry members (.srtt, .flags, .expires, and
.lastage) to remove ADB entry locking from couple of hot spots.  The
most prominent place is copy_namehook_lists() that gets called under ADB
name lock and if the namehook list is long it acquires-releases quite a
few ADB entry locks.  Changing those ADB entry members to atomics
allowed us to new_adbaddrinfo() not require locked ADB entry and since
adbentry_overquota() already used atomics and handling lame information
was dropped in the previous commit, we could not make the
copy_namehook_lists() lockless.

The other hotspot is dns_adb_adjustsrtt() and dns_adb_agesrtt() that can
now use atomics because .srtt is already atomic_uint.

And the last place that could now use atomics is dns_adb_changeflags().
2023-10-12 12:35:00 +02:00
Ondřej Surý
2b20db05e3 Remove dns_adblameinfo from dns_adb
Keeping the information about lame server in the ADB was done in !322 to
fix following security issue:

    [CVE-2021-25219] Disable "lame-ttl" cache

The handling of the lame servers needs to be redesigned and it is not
going to be enabled any time soon, and the current code is just dead
code that takes up space, code and stands in the way of making ADB work
faster.

Remove all the internals needed for handling the lame servers in the ADB
for now.  It might get reintroduced later if and when we redesign ADB.
2023-10-12 12:35:00 +02:00
Arаm Sаrgsyаn
7fb4e354a9 Merge branch '4354-statschannel-test-opesbsd' into 'main'
Resolve "Checking zone transfer information in the statistics channel fails on OpenBSD"

Closes #4354

See merge request isc-projects/bind9!8367
2023-10-12 09:37:11 +00:00
Aram Sargsyan
39f46b8ca4 Make the statschannel system test portable
The usage of the newline in the replacement part of the 'sed' call
works in GNU systems, but not in OpenBSD. Use 'awk' instead.

Also use the extended syntax of regular expressions for 'grep', which
is similarly more portable across the supported systems.
2023-10-12 08:37:15 +00:00
Matthijs Mekking
ba20c4fbe1 Merge branch 'matthijs-fix-build-usdt' into 'main'
Fix build error related to USDT

See merge request isc-projects/bind9!8368
2023-10-10 15:43:59 +00:00
Matthijs Mekking
746e9809a8 Fix build error related to USDT
The trace.h file is listed twice in the Makefile. This incidentally
caused an error where the build refused to replace an earlier placed
trace.h file.
2023-10-10 16:57:18 +02:00
Evan Hunt
a2570851aa Merge branch 'each-qp-rpz' into 'main'
convert the RPZ summary database to to use a QP trie

See merge request isc-projects/bind9!8352
2023-10-10 06:56:21 +00:00
Evan Hunt
33a7c9b15f CHANGES for [GL !8352] 2023-10-09 13:29:02 -07:00
Evan Hunt
bf81ef3fc0 reduce search_lock coverage
now that we're using qpmulti for the summary database, we
no longer need to hold search_lock for it. we do still need
it for the radix tree and the trigger counts.
2023-10-09 13:29:02 -07:00
Evan Hunt
feea05d5c4 convert the RPZ summary database to to use a QP trie
now that we have the QP chain mechanism, we can convert the
RPZ summary database to use a QP trie instead of an RBT.

also revised comments throughout the file accordingly, and
incidentally cleaned up calls to new_node(), which can no
longer fail.
2023-10-09 13:29:02 -07:00
Evan Hunt
86fbfc22b4 fix build bug with DNS_RPZ_TRACE
nonstardard naming of ref/unref and attach/detach functions caused
build errors when using DNS_RPZ_TRACE; this has been fixed.
2023-10-09 13:29:02 -07:00
Evan Hunt
8f6a3f47db fix a QP chain bug
depending on how the QP trie is traversed during a lookup, it is
possible for a search to terminate on a leaf which is a partial
match, without that leaf being added to the chain. to ensure the
chain is correct in this case, when a partial match condition is
detected via qpkey_compare(), we will call add_link() again, just
in case.  (add_link() will check for a duplicated node, so it will
be harmless if it was already done.)
2023-10-09 13:29:02 -07:00
Ondřej Surý
8ca114ef88 Merge branch 'ondrej/fix-load_names-benchmark' into 'main'
Use read number of items instead of raw array size in load_names

See merge request isc-projects/bind9!8361
2023-10-09 19:09:25 +00:00
Ondřej Surý
1974a91e58 Add base testing set of names for load-names benchmark
This was generated from dnsperf queryfile with following script:

    #!/usr/bin/env python3
    names = {}

    import sys

    i = 0
    for line in iter(sys.stdin.readline, ''):
	name = line.rstrip('\n')
	if not name in names:
	    names[name] = line
	    print(f"{i},{name}")
	    i += 1
	if i >= 1024*1024:
	    break
2023-10-09 21:04:21 +02:00
Ondřej Surý
9a45fd6f33 Fix hashmap part of load-names benchmark
The name_match() was errorneously converting struct item into dns_name
pointer.  Correctly retype void *node to struct item * first and then
use item.fixed.name to pass the name to dns_name_equal() function.
2023-10-09 21:04:21 +02:00
Ondřej Surý
81f48e11e4 Use read number of items instead of raw array size in load_names
The load_names benchmark expected the input CSV with domains would fill
the whole item array and it would crash when the number of lines would
be less than that.

Fix the expectations by using the real number or lines read to calculate
the array start and end position for each benchmark thread.
2023-10-09 21:04:21 +02:00
Michał Kępień
1bd979167e Merge branch 'michal/move-linux-stress-tests-to-autoscaled-instances' into 'main'
Move Linux "stress" tests to autoscaled instances

See merge request isc-projects/bind9!8359
2023-10-06 11:09:41 +00:00
Michał Kępień
12ea994680 Move Linux "stress" tests to autoscaled instances
The autoscaling GitLab CI runners currently used for most GitLab CI jobs
spin up AWS EC2 instances that are at least as powerful as the dedicated
instances used for running "stress" tests.  Move all Linux-based
"stress" tests to autoscaling GitLab CI runners to enable deprovisioning
Linux AWS instances reserved for running "stress" tests.  Leave FreeBSD
"stress" tests intact as there is currently no support for autoscaling
BSD instances.
2023-10-06 13:07:55 +02:00
Michal Nowak
7339920948 Merge branch 'mnowak/monitor-stuck-system-tests' into 'main'
Report hung system tests

See merge request isc-projects/bind9!8245
2023-10-05 16:24:37 +00:00
Michal Nowak
35792b1700 Report hung system tests
At times, a problem might occur where a test is not responding,
especially in the CI, determining the specific test responsible can be
difficult. Fortunately, when running tests with the pytest runner,
pytest sets the PYTEST_CURRENT_TEST environment variable to the current
test nodeid and stage. Afterward, the variable can be examined to
identify the test that has stopped responding.

The monitoring script needs to be started in the background. Still, the
shell executor used for BSD and FIPS testing can't handle the background
process cleanly, and the script step will wait for the background
process for the entire duration of the background process (currently
3000 seconds). Therefore, run the monitoring script only when the Docker
executor is used where this is not a problem.
2023-10-05 14:57:26 +02:00
Mark Andrews
a6b5cf4c54 Merge branch '4253-detect-duplicate-controls' into 'main'
Detect duplicate "controls" configuration

Closes #4253

See merge request isc-projects/bind9!8313
2023-10-05 01:32:40 +00:00
Mark Andrews
e8a822d0a7 Add CHANGES note for [GL #4253] 2023-10-05 11:32:36 +11:00
Mark Andrews
1bf62b1c88 Check that duplicate control sockets are caught 2023-10-05 11:32:01 +11:00
Mark Andrews
d97dc03b8e Detect duplicate use of control sockets in named.conf
Specifying duplicate control sockets can lead to hard to diagnose
rndc connection failures.
2023-10-05 11:32:01 +11:00
Petr Špaček
a2c771d994 Merge branch 'pspacek/cross-version-tests-junit' into 'main'
Generate and capture JUnit XML output from cross-version-config-tests

See merge request isc-projects/bind9!8354
2023-10-04 12:51:02 +00:00
Petr Špaček
f2a3eb00b9 Generate and capture JUnit XML output from cross-version-config-tests 2023-10-04 14:50:25 +02:00
Petr Špaček
bfc6b43319 Merge branch 'pspacek/fix-no-case-compression-docs' into 'main'
Fix no-case-compress description in the ARM

See merge request isc-projects/bind9!8312
2023-10-03 12:36:41 +00:00
Petr Špaček
6451462a93 Fix no-case-compress description in the ARM
We confused ourselves, it seems.
2023-10-03 14:35:49 +02:00
Arаm Sаrgsyаn
23b52fb6a0 Merge branch '4343-cid-465861-unnecessary-null-check-in-ns__client_setup' into 'main'
Remove unnecessary NULL-checks in ns__client_setup()

Closes #4343

See merge request isc-projects/bind9!8347
2023-09-28 14:49:28 +00:00
Aram Sargsyan
b970556f21 Remove unnecessary NULL-checks in ns__client_setup()
All these pointers are guaranteed to be non-NULL.

Additionally, update a comment to remove obviously outdated
information about the function's requirements.
2023-09-28 13:43:18 +00:00
Arаm Sаrgsyаn
5a9ca612ee Merge branch '4331-resolver.c-assert-uninitialized-link' into 'main'
Don't use an uninitialized link on an error path

Closes #4331

See merge request isc-projects/bind9!8343
2023-09-28 09:32:04 +00:00
Aram Sargsyan
9c545c3513 Add a CHANGES note for [GL #4331] 2023-09-28 08:14:31 +00:00
Aram Sargsyan
fb7bbbd1be Don't use an uninitialized link on an error path
Move the block on the error path, where the link is checked, to a place
where it makes sense, to avoid accessing an unitialized link when
jumping to the 'cleanup_query' label from 4 different places. The link
is initialized only after those jumps happen.

In addition, initilize the link when creating the object, to avoid
similar errors.
2023-09-28 08:14:05 +00:00
Evan Hunt
98cbf4ebfc Merge branch 'each-qp-extensions' into 'main'
extensions to QP trie to support DNS databases

See merge request isc-projects/bind9!8338
2023-09-28 07:41:51 +00:00
Evan Hunt
9736497d8a CHANGES for [GL !8338] 2023-09-28 00:32:47 -07:00
Evan Hunt
03016902dd rename dns_qp_findname_ancestor() to dns_qp_lookup()
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.)
2023-09-28 00:32:44 -07:00
Evan Hunt
6231fd66af rename QP-related types to use standard BIND nomenclature
changed type names in QP trie code to match the usual convention:
 - qp_node_t -> dns_qpnode_t
 - qp_ref_t -> dns_qpref_t
 - qp_shift_t -> dns_qpshift_t
 - qp_weight_t -> dns_qpweight_t
 - qp_chunk_t -> dns_qpchunk_t
 - qp_cell_t -> dns_qpcell_t
2023-09-28 00:32:39 -07:00
Evan Hunt
4e3e61806c get predecessor name in dns_qp_findname_ancestor()
dns_qp_findname_ancestor() now takes an optional 'predecessor'
parameter, which if non-NULL is updated to contain the DNSSEC
predecessor of the name searched for. this is done by constructing
an iterator stack while carrying out the search, so it can be used
to step backward if needed.
2023-09-28 00:32:37 -07:00
Evan Hunt
606232b8d5 remove DNS_QPFIND_NOEXACT
since dns_qp_findname_ancestor() can now return a chain object, it is no
longer necessary to provide a _NOEXACT search option. if we want to look
up the closest ancestor of a name, we can just do a normal search, and
if successful, retrieve the second-to-last node from the QP chain.

this makes ancestor lookups slightly more complicated for the caller,
but allows us to simplify the code in dns_qp_findname_ancestor(), making
it easier to ensure correctness.  this was a fairly rare use case:
outside of unit tests, DNS_QPFIND_NOEXACT was only used in the zone
table, which has now been updated to use the QP chain.  the equivalent
RBT feature is only used by the resolver for cache lookups of 'atparent'
types (i.e, DS records).
2023-09-28 00:30:57 -07:00
Evan Hunt
3bf23fadb0 improvements to the QP iterator
- make iterators reversible: refactor dns_qpiter_next() and add a new
  dns_qpiter_prev() function to support iterating both forwards and
  backwards through a QP trie.
- added a 'name' parameter to dns_qpiter_next() (as well as _prev())
  to make it easier to retrieve the nodename while iterating, without
  having to construct it from pointer value data.
2023-09-28 00:30:51 -07:00
Evan Hunt
7f0242b8c7 tidy the helper functions for retrieving twigs
- the helper functions for accessing twigs beneath a branch
  (branch_twig_pos(), branch_twig_ptr(), etc) were somewhat confusing
  to read, since several of them were implemented by calling other
  helper functions. they now all show what they're really doing.
- branch_twigs_vector() has been renamed to simply branch_twigs().
- revised some unrelated comments in qp_p.h for clarity.
2023-09-28 00:30:47 -07:00
Evan Hunt
7f766ba7c4 add a node chain traversal mechanism
dns_qp_findname_ancestor() now takes an optional 'chain' parameter;
if set, the dns_qpchain object it points to will be updated with an
array of pointers to the populated nodes between the tree root and the
requested name. the number of nodes in the chain can then be accessed
using dns_qpchain_length() and the individual nodes using
dns_qpchain_node().
2023-09-28 00:30:43 -07:00
Evan Hunt
29cf7dceb7 modify dns_qp_findname_ancestor() to return found name
add a 'foundname' parameter to dns_qp_findname_ancestor(),
and use it to set the found name in dns_nametree.

this required adding a dns_qpkey_toname() function; that was
done by moving qp_test_keytoname() from the test library to qp.c.
added some more test cases and fixed bugs with the handling of
relative and empty names.
2023-09-28 07:01:13 +00:00