2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00
Commit Graph

43020 Commits

Author SHA1 Message Date
Mark Andrews
5eeb31f0b9 Split EDNS COOKIE YAML into separate parts
Split the YAML display of the EDNS COOKIE option into CLIENT and SERVER
parts.  The STATUS of the EDNS COOKIE in the reply is now a YAML element
rather than a comment.
2025-04-22 09:24:18 +10:00
Mark Andrews
07c28652a3 Fix EDNS TCP-KEEPALIVE option YAML output
There was missing white space between the option name and its value.
2025-04-22 09:24:18 +10:00
Mark Andrews
81334113c3 Fix EDNS LLQ option YAML output
The EDNS LLQ option was not being emitted as valid YAML. Correct
the output to be valid YAML with each field of the LLQ being
individually selectable.
2025-04-22 09:24:18 +10:00
Mark Andrews
27e8732c17 Change the EDNS KEY-TAG YAML output format
When using YAML, print the EDNS KEY-TAG as an array of integers
for easier machine parsing. Check the validity of the YAML output.
2025-04-22 09:24:18 +10:00
Mark Andrews
378bc7cfa6 Use YAML comments for durations rather than parentheses
This will allow the values to be parsed using standard yaml processing
tools, and still provide the value in a human friendly form.
2025-04-22 09:24:18 +10:00
Mark Andrews
68cdc4774c Change the name and YAML format of EDNS UL
The offical EDNS option name for "UL" is "UPDATE-LEASE".  We now
emit "UPDATE-LEASE" instead of "UL", when printing messages, but
"UL" has been retained as an alias on the command line.

Update leases consist of 1 or 2 values, LEASE and KEY-LEASE.  These
components are now emitted separately so they can be easily extracted
from YAML output.  Tests have been added to check YAML correctness.
2025-04-22 09:24:18 +10:00
Mark Andrews
280e9b7cf4 Add YAML escaping where needed
When rendering text, such as domain names or the EXTRA-TEXT
field of the EDE option, backslashes and quotation marks must
be escaped to ensure that the emitted message is valid YAML.
2025-04-22 09:24:18 +10:00
Mark Andrews
e7ef4e41eb Collapse common switch cases when emitting EDNS options
The CHAIN and REPORT-CHANNEL EDNS options are both domain names, so they
can be combined.  THE CLIENT-TAG and SERVER-TAG EDNS options are both 16
bit integers, so they can be combined.
2025-04-22 09:23:53 +10:00
Ondřej Surý
6f3fea837f fix: usr: Disable own memory context for libxml2 on macOS
Apple broke custom memory allocation functions in the system-wide libxml2 starting with macOS Sequoia 15.4.  Usage of the custom memory allocation functions has been disabled on macOS.

Closes #5268

Merge branch '5268-disable-libxml2-memory-management-on-macos' into 'main'

See merge request isc-projects/bind9!10374
2025-04-18 18:50:18 +00:00
Ondřej Surý
bf1b8824ac Disable own memory context for libxml2 on macOS 15.4 Sequoia
The custom allocation API for libxml2 is deprecated starting in macOS
Sequoia 15.4, iOS 18.4, tvOS 18.4, visionOS 2.4, and tvOS 18.4.

Disable the memory function override for libxml2 when
LIBXML_HAS_DEPRECATED_MEMORY_ALLOCATION_FUNCTIONS is defined as Apple
broke the system-wide libxml2 starting with macOS Sequoia 15.4.
2025-04-18 20:16:13 +02:00
Matthijs Mekking
7211ba147a chg: test: Rewrite kasp system test to pytest (2)
Convert the first batch of tests from `kasp/tests.sh` to `kasp/tests_kasp.py`.

Merge branch 'matthijs-pytest-rewrite-kasp-system-test-2' into 'main'

See merge request isc-projects/bind9!10253
2025-04-17 12:25:36 +00:00
Matthijs Mekking
62a6b9faa7 Fix bugs in isctest.kasp
isctest.util was not imported so file_contents_contain could not be
found. And rename verify_keys to check_keys because it asserts in
isctest.run.retry_with_timeout.
2025-04-17 13:50:49 +02:00
Matthijs Mekking
46aead5a6d The kasp tests require dnspython >= 2.0.0
The kasp tests make use of dns.update.UpdateMessage and dns.tsig.Key,
that are introduced in dnspython 2.0.0.
2025-04-17 13:50:49 +02:00
Matthijs Mekking
07ac0e6036 Convert some special kasp test cases to pytest
This converts a special characters test case, a max-zone-ttl error
check, and two cases of insecure zones.

We no longer assert for having more than one DNSKEY and/or RRSIG
records. If the zone is insecure, this is no longer always true. And
we already check for the expected number of records in the
check_dnskeys/check_signatures functions.
2025-04-17 13:50:49 +02:00
Matthijs Mekking
0b41afbd15 Convert dynamic zone test cases to pytest
This commit deals with converting the dynamic zone test cases to
pytest. The tests for 'inline-signing.kasp' are similar to the default
case, so these are added to 'test_kasp_default'.

Unfortunately I need to add sleep calls in between freezing, updating,
and thawing a zone. Without it the intermittent failures are too
frequent.
2025-04-17 13:50:49 +02:00
Matthijs Mekking
4e22b019f5 Convert kasp default test cases to pytest
This commit deals with converting the test cases related to the default
dnssec-policy.

This requires a new method 'check_update_is_signed'. This method will
be used in future tests as well, and checks if an expected record is
in the zone and is properly signed.

Remove the counterparts for the newly added test from the kasp shell
tests script.
2025-04-17 13:50:49 +02:00
Matthijs Mekking
00ea2c2564 Convert kasp dnssectools tests to pytest
Convert the first couple of tests from 'kasp/tests.sh' to
'kasp/tests_kasp.py', those are test cases related to 'dnssec-keygen'
and 'dnssec-settime'.

For this, we also add a new KeyProperties method,
'policy_to_properties', that takes a list of strings which represent
the keys according to the dnssec-policy and the expected key states.
2025-04-17 13:50:49 +02:00
Michal Nowak
3a38a5fcad new: ci: Add Fedora 42
Merge branch 'mnowak/fedora-42' into 'main'

See merge request isc-projects/bind9!10404
2025-04-17 08:04:07 +00:00
Michal Nowak
dcccfb4cf8 Add Fedora 42 2025-04-16 20:18:00 +02:00
Arаm Sаrgsyаn
b3208da958 fix: test: Fix the isc_rwlock_tryupgrade() function's unit test
The pthread-based implementation of the isc_rwlock_tryupgrade()
function always returns ISC_R_LOCKBUSY. Fix the test by adding
conditional checks.

Closes #5287

Merge branch '5287-pthread-rwlock-tryupgrade-test-fix' into 'main'

See merge request isc-projects/bind9!10398
2025-04-16 16:00:29 +00:00
Aram Sargsyan
c27659bc62 Fix the isc_rwlock_tryupgrade() function's unit test
The pthread-based implementation of the isc_rwlock_tryupgrade()
function always returns ISC_R_LOCKBUSY. Fix the test by adding
conditional checks.
2025-04-16 15:59:42 +00:00
Nicki Křížek
3ae06d14d3 chg: ci: Remove allow_failure from cross-version-config-tests
v9.21.7 was released and the job now passes.

Merge branch 'nicki/ci-re-enable-cross-version-config-tests' into 'main'

See merge request isc-projects/bind9!10402
2025-04-16 13:58:18 +00:00
Nicki Křížek
7b1fe85cae Remove allow_failure from cross-version-config-tests
v9.21.7 was released and the job now passes.
2025-04-16 15:32:42 +02:00
Nicki Křížek
c5707cb75a Merge tag 'v9.21.7' 2025-04-16 15:23:14 +02:00
Ondřej Surý
e373f4062f fix: dev: Move the call_rcu_thread explicit create and shutdown to isc_loop
When isc__thread_initialize() is called from a library constructor, it
could be called before we fork the main process.  This happens with
named, and then we have the call_rcu_thread attached to the pre-fork
process and not the post-fork process, which means that the initial
process will never shutdown, because there's noone to tell it so.

Move the isc__thread_initialize() and isc__thread_shutdown() to the
isc_loop unit where we call it before creating the extra thread and
after joining all the extra threads respectively.

Closes #5281

Merge branch '5281-move-call_rcu-thread-ctor-dtor-to-main-thread' into 'main'

See merge request isc-projects/bind9!10394
2025-04-16 12:26:52 +00:00
Ondřej Surý
30d4939382 Move the call_rcu_thread explicit create and shutdown to isc_loop
When isc__thread_initialize() is called from a library constructor, it
could be called before we fork the main process.  This happens with
named, and then we have the call_rcu_thread attached to the pre-fork
process and not the post-fork process, which means that the initial
process will never shutdown, because there's noone to tell it so.

Move the isc__thread_initialize() and isc__thread_shutdown() to the
isc_loop unit where we call it before creating the extra thread and
after joining all the extra threads respectively.
2025-04-16 12:30:14 +02:00
Ondřej Surý
ed8421f405 chg: dev: Reduce QPDB_VIRTUAL to 10 seconds
The QPDB_VIRTUAL value was introduced to allow the clients (presumably
ns_clients) that has been running for some time to access the cached
data that was valid at the time of its inception.  The default value
of 5 minutes is way longer than longevity of the ns_client object as
the resolver will give up after 2 minutes.

Reduce the value to 10 seconds to accomodate to honour the original
more closely, but still allow some leeway for clients that started some
time in the past.

Our measurements show that even setting this value to 0 has no
statistically significant effect, thus the value of 10 seconds should be
on the safe side.

Merge branch 'ondrej/reduce-QPDB_VIRTUAL' into 'main'

See merge request isc-projects/bind9!10309
2025-04-16 10:19:50 +00:00
Ondřej Surý
6ed821beb4 Reduce QPDB_VIRTUAL to 10 seconds
The *DB_VIRTUAL value was introduced to allow the clients (presumably
ns_clients) that has been running for some time to access the cached
data that was valid at the time of its inception.  The default value
of 5 minutes is way longer than longevity of the ns_client object as
the resolver will give up after 2 minutes.

Reduce the value to 10 seconds to accomodate to honour the original
more closely, but still allow some leeway for clients that started some
time in the past.

Our measurements show that even setting this value to 0 has no
statistically significant effect, thus the value of 10 seconds should be
on the safe side.
2025-04-16 11:21:38 +02:00
Nicki Křížek
dfe755a5d6 chg: pkg: Use jinja2 templates in system tests
`python-jinja2` is now required to run system tests.

Related #4938

Merge branch 'nicki/replace-setup-sh-files-with-jinja2-templates' into 'main'

See merge request isc-projects/bind9!9588
2025-04-15 15:28:39 +00:00
Nicki Křížek
543ba8da5a Require python-jinja2 for system tests
Many of the system tests now use jinja2 template engine. Adding jinja2
as a hard dependency is preferable than potentially silently skipping
many system tests.
2025-04-15 16:46:54 +02:00
Nicki Křížek
e0f0c557a0 Replace selected setup.sh system test files
These setup.sh scripts only do templating and copying files. Both of
these can be replaced with either jinja templates, or using plain files.
Since each test invocation creates its own temporary directory, copying
files to ensure a "clean" state is no longer necessary.

In cases where named writes some content to the files, a jinja template
can be used instead of a plain file to avoid an artifact check which
would detect a change to a git-tracked file.
2025-04-15 14:11:20 +02:00
Nicki Křížek
a9f1b8d6a6 Replace the trivial setup.sh system test files
All these setup files only use copy_setports function which can be done
with jinja2 templates instead -- simply by renaming the .in files to
.j2, without any other changes. The pytest runner will render these
templates during test setup without any need for an additional script.
2025-04-15 14:11:16 +02:00
Mark Andrews
79c50d4538 fix: usr: Return DNS COOKIE and NSID with BADVERS
This change allows the client to identify the server that returns the
BADVERS and to provide a DNS SERVER COOKIE to be included in the
resend of the request.

Closes #5235

Merge branch '5235-return-the-server-cookie-when-returning-badvers' into 'main'

See merge request isc-projects/bind9!10334
2025-04-15 03:11:01 +00:00
Mark Andrews
f69b4bc5e0 Check DNS COOKIE, NSID and BADVERS
DNS COOKIE and NSID should also be being processed when returning
BADVERS.  Check that this has actually occured by looking for the
cookie and nsid in the response.
2025-04-15 02:38:37 +00:00
Mark Andrews
44140cad3b Extract and send server cookie with BADVERS retry
A BADVERS response can also include EDNS SERVER COOKIE.  Extract
that from the OPT record and use it when resending the request.
2025-04-15 02:38:37 +00:00
Mark Andrews
0d9cab1555 Process NSID and DNS COOKIE options when returning BADVERS
This will help identify the broken server if we happen to break
EDNS version negotiation.  It will also help protect the client
from spoofed BADVERSION responses.
2025-04-15 02:38:37 +00:00
Matthijs Mekking
488f0f876d chg: doc: Add a note on pregenerating keys
With `dnssec-policy` you can pregenerate keys and if they are eligible, rather than creating a new key, a key is selected from the pregenerated keys. A key is eligible if it is unused, i.e it has no key timing metadata set.

Merge branch 'matthijs-clarify-pregenerating-keys' into 'main'

See merge request isc-projects/bind9!10385
2025-04-14 15:01:49 +00:00
Matthijs Mekking
9880bfff63 Add a note about pregenarating keys for key rolls
With dnssec-policy you can pregenerate keys and if they are eligible,
rather than creating a new key, a key is selected from the pregenerated
keys. A key is eligible if it is unused, i.e it has no key timing
metadata set.
2025-04-14 14:27:25 +00:00
Michal Nowak
b3ee5dc8f7 fix: test: Fix check_pid() in runtime system test on FreeBSD
The original check_pid() always returned 0 on FreeBSD, even if the
process was still running. This makes the "verifying that named checks
for conflicting named processes" check fail on FreeBSD with TSAN.

Merge branch 'mnowak/fix-runtime-pid-check' into 'main'

See merge request isc-projects/bind9!10373
2025-04-14 10:56:13 +00:00
Michal Nowak
6acaca963d Fix check_pid() in runtime system test on FreeBSD
The original check_pid() always returned 0 on FreeBSD, even if the
process was still running. This makes the "verifying that named checks
for conflicting named processes" check fail on FreeBSD with TSAN.
2025-04-14 10:48:31 +00:00
Michał Kępień
b82d434be2 chg: test: Use isctest.asyncserver in the "forward" test
Replace the custom DNS servers used in the "forward" system test with new
code based on the isctest.asyncserver module.

For ans6, instead of configuring the responses to send at runtime, set
them up when the server is started.  Make sure the server supports
toggling response sending at runtime to enable simulating forwarder
timeouts as required by one of the checks.

For ans11, put most of the responses to be provided by that server into
a zone file, only retaining code modifying zone-based answers in the
form of a response handler, to improve code readability.  Use explicit
domain names instead of variables as that server only handles a single
domain and fixed strings improve readability in this case.  Make sure
the server supports toggling response sending at runtime to enable
simulating forwarder timeouts as required by one of the checks.

Migrate sendcmd() and its uses to the new way of sending control queries
to custom servers used in system tests.

Depends on !10339

Merge branch 'michal/forward-asyncserver' into 'main'

See merge request isc-projects/bind9!10340
2025-04-11 14:51:14 +00:00
Michał Kępień
23bc8430d9 Use isctest.asyncserver in the "forward" test
Replace the custom DNS servers used in the "forward" system test with
new code based on the isctest.asyncserver module.

For ans6, instead of configuring the responses to send at runtime, set
them up when the server is started.  Make sure the server supports
toggling response sending at runtime to enable simulating forwarder
timeouts as required by one of the checks.

For ans11, put most of the responses to be provided by that server into
a zone file, only retaining code modifying zone-based answers in the
form of a response handler, to improve code readability.  Use explicit
domain names instead of variables as that server only handles a single
domain and fixed strings improve readability in this case.  Make sure
the server supports toggling response sending at runtime to enable
simulating forwarder timeouts as required by one of the checks.

Migrate sendcmd() and its uses to the new way of sending control queries
to custom servers used in system tests.
2025-04-11 09:18:50 -05:00
Michał Kępień
b47be755db new: test: Add support for control commands to isctest.asyncserver
Some BIND 9 system tests need to dynamically change custom server
behavior at runtime.  Existing custom servers typically use a separate
TCP socket for listening to control commands, which mimics what `named`
does, but adds extra complexity to the custom server's networking code
for no gain (given the purpose at hand).  There is also no common way of
performing typical runtime actions (like toggling response dropping)
across all custom servers.

Instead of listening on a separate TCP socket in `asyncserver.py`, make
it detect DNS queries to a "magic" domain (`_control.`) on the same port
as the one it uses for receiving "production" DNS traffic.  This enables
query/response logging code to be reused for control traffic, clearly
denotes behavior changes in packet captures, facilitates implementing
commonly used features as reusable chunks of code (by making them "own"
distinct subdomains of the control domain), voids the need for separate
tools sending control commands, and enables using DNS facilities for
returning information to the user (e.g. RCODE for status codes, TXT
records for additional information, etc.).

Merge branch 'michal/asyncserver-control-commands' into 'main'

See merge request isc-projects/bind9!10339
2025-04-11 14:17:22 +00:00
Michał Kępień
92b39f8352 Add control command for toggling response dropping
Implement a reusable control command that makes it possible to
dynamically disable/enable sending responses to clients.  This is a
typical use case for custom DNS servers employed in various BIND 9
system tests.
2025-04-11 09:14:57 -05:00
Michał Kępień
a7e1de716b Implement control query handling
Some BIND 9 system tests need to dynamically change custom server
behavior at runtime.  Existing custom servers typically use a separate
TCP socket for listening to control commands, which mimics what named
does, but adds extra complexity to the custom server's networking code
for no gain (given the purpose at hand).  There is also no common way of
performing typical runtime actions (like toggling response dropping)
across all custom servers.

Instead of listening on a separate TCP socket in asyncserver.py, make it
detect DNS queries to a "magic" domain ("_control.") on the same port as
the one it uses for receiving "production" DNS traffic.  This enables
query/response logging code to be reused for control traffic, clearly
denotes behavior changes in packet captures, facilitates implementing
commonly used features as reusable chunks of code (by making them "own"
distinct subdomains of the control domain), voids the need for separate
tools sending control commands, and enables using DNS facilities for
returning information to the user (e.g. RCODE for status codes, TXT
records for additional information, etc.).
2025-04-11 09:14:57 -05:00
Michał Kępień
5e71fd081e Add debug logs for response handler matching
With multiple and/or dynamically managed response handlers at play, it
becomes useful for debugging purposes to know which handler (if any) was
used for preparing each response sent by the server.  Add debug logs
providing that information.  Make class name the default string
representation of each response handler to prettify logs.
2025-04-11 09:14:57 -05:00
Michał Kępień
92b072bff4 Make response handler management more flexible
Extend AsyncDnsServer.install_response_handler() so that the provided
response handler can be inserted at the beginning of the handler list.
This enables installing a response handler that takes priority over all
previously installed handlers.

Add a new method, AsyncDnsServer.uninstall_response_handler(), which
enables removing a previously installed response handler.

Together, these two methods provide full control over the response
handler list at runtime.
2025-04-11 09:14:57 -05:00
Michał Kępień
8cb51d4c2b Avoid global namespace pollution
Add a main() function to all custom servers based on isctest.asyncserver
and move server startup code there.  This prevents redefining variables
from outer scope in custom server code as it evolves.
2025-04-11 09:14:57 -05:00
Michał Kępień
fd0290c919 Gracefully handle invalid queries
Prevent custom servers based on asyncserver.py from exiting prematurely
due to unhandled exceptions raised as a result of attempting to parse
invalid queries sent by clients.
2025-04-11 09:14:57 -05:00
Michał Kępień
715bd1b667 Fix Python 3.6 StreamWriter compatibility issue
The StreamWriter.wait_closed() method was introduced in Python 3.7, so
attempting to use it with Python 3.6 raises an exception.  This has not
been noticed before because awaiting StreamWriter.wait_closed() is the
last action taken for each TCP connection and unhandled exceptions were
not causing the scripts based on AsyncServer to exit prematurely until
the previous commit.

As per Python documentation [1], awaiting StreamWriter.wait_closed()
after calling StreamWriter.close() is recommended, but not mandatory, so
try to use it if it is available, without taking any fallback action in
case it isn't.

[1] https://docs.python.org/3.13/library/asyncio-stream.html#asyncio.StreamWriter.close
2025-04-11 09:14:57 -05:00