]> git.ipfire.org Git - thirdparty/bind9.git/log
thirdparty/bind9.git
3 years agoMark selected statschannel tests as xfail
Tom Krizek [Tue, 4 Apr 2023 08:34:37 +0000 (10:34 +0200)] 
Mark selected statschannel tests as xfail

The test_zone_timers_secondary_json() and
test_zone_timers_secondary_xml() tests are affected by issue #3983. Due
to the way tests are run, they are only affected when executing them
with the pytest runner.

Strict mode is set for pytest runner, as it always fails there. The
strict mode ensures we'll catch the change when the it starts passing
once the underlying issue is fixed. It can't be set for the legacy
runner, since the test (incorrectly) passes there.

Related #3983

3 years agoEnsure assertions and exceptions end up in system test log
Tom Krizek [Mon, 3 Apr 2023 16:05:29 +0000 (18:05 +0200)] 
Ensure assertions and exceptions end up in system test log

If a test fails with an assertion failure or exception, its content
along with traceback is displayed in pytest output. This information
should be preserved in the test-specific logger for a given system test
to make it easier to debug test failures.

3 years agoUse raw byte format of env variables in pytest
Petr Špaček [Tue, 28 Mar 2023 09:52:38 +0000 (11:52 +0200)] 
Use raw byte format of env variables in pytest

In order to avoid issues with decoding/encoding env variables due to
different encodings on different systems, deal with the environment
variables directly as bytes.

3 years agoDisplay pytest failures for system:gcc:tarball
Tom Krizek [Thu, 23 Mar 2023 15:47:32 +0000 (16:47 +0100)] 
Display pytest failures for system:gcc:tarball

Since the tarball build&tests happen in a subdirectory, ensure the
after_script switches to it, so artifacts can be found properly.

3 years agoHandle missing test_results due to pytest runner interrupt
Tom Krizek [Wed, 22 Mar 2023 14:52:05 +0000 (15:52 +0100)] 
Handle missing test_results due to pytest runner interrupt

If pytest execution is interrupted, the hook that exposes test_results
to the pytest session is never called so the results can't be
interpreted.

3 years agoRun system tests sequentially if xdist is not available
Tom Krizek [Tue, 28 Mar 2023 14:42:31 +0000 (16:42 +0200)] 
Run system tests sequentially if xdist is not available

3 years agoInclude logs from failing tests in JUnit output
Petr Špaček [Fri, 17 Mar 2023 12:20:59 +0000 (13:20 +0100)] 
Include logs from failing tests in JUnit output

3 years agoEnable live logging for non-parallel pytest runs
Petr Špaček [Thu, 16 Mar 2023 17:40:59 +0000 (18:40 +0100)] 
Enable live logging for non-parallel pytest runs

This provides incremental output when test is running _without xdist_,
just like the old runner did.

With xdist the live output is not available, I believe because of
https://github.com/pytest-dev/pytest-xdist/issues/402
https://github.com/pytest-dev/pytest-xdist/pull/883 might help with
that, but I'm not going to hold my breath until it is available on
distros we use.

3 years agoEnsure --dist=loadscope is used when running pytest in parallel
Tom Krizek [Tue, 28 Mar 2023 14:52:49 +0000 (16:52 +0200)] 
Ensure --dist=loadscope is used when running pytest in parallel

The loadscope setting is required for parallel execution of our system
tests using pytest. The option ensure that all tests within a single
(module) scope will be assigned to the same worker.

This is neccessary because the worker sets up the nameservers for all
the tests within a module scope. If tests from the same module would be
assigned to different workers, then the setup could happen multiple
times, causing a race condition. This happens because each module uses
deterministic port numbers for the nameservers.

3 years agoInvoke pytest runner from run.sh
Tom Krizek [Fri, 13 Jan 2023 15:32:39 +0000 (16:32 +0100)] 
Invoke pytest runner from run.sh

Utilize developers' muscle memory to incentivize using the pytest runner
instead of the legacy one. The script also serves as basic examples of
how to run the pyest command to achieve the same results as the legacy
runner.

Invoking pytest directly should be the end goal, since it offers many
potentially useful options (refer to pytest --help).

3 years agoUse pytest system test runner in CI
Tom Krizek [Tue, 22 Nov 2022 09:47:15 +0000 (10:47 +0100)] 
Use pytest system test runner in CI

Replace the legacy system test runner by the pytest system test runner.
Since EL7 and OpenBSD have only ancient versions of pytest / xdist, keep
using the legacy test runner there for now.

Out of tree tests aren't supported by the pytest runner yet. Use the
legacy test runner for that purpose as well.

Use awk to display failures and errors at the end of the log for
convenience, since pytest displays them first, which makes them
difficult to find.

3 years agoAdd developer docs for pytest system test runner
Tom Krizek [Fri, 13 Jan 2023 15:06:01 +0000 (16:06 +0100)] 
Add developer docs for pytest system test runner

3 years agoUpdate user docs with pytest system test runner
Tom Krizek [Wed, 11 Jan 2023 15:37:45 +0000 (16:37 +0100)] 
Update user docs with pytest system test runner

3 years agoAdd pytest functions for shell system tests
Tom Krizek [Tue, 29 Nov 2022 14:07:02 +0000 (15:07 +0100)] 
Add pytest functions for shell system tests

In order to run the shell system tests, the pytest runner has to pick
them up somehow. Adding an extra python file with a single function
for the shell tests for each system test proved to be the most
compatible way of running the shell tests across older pytest/xdist
versions.

Modify the legacy run.sh script to ignore these pytest-runner specific
glue files when executing tests written in pytest.

3 years agoIgnore tempdirs during pytest collection phase
Tom Krizek [Thu, 12 Jan 2023 17:02:39 +0000 (18:02 +0100)] 
Ignore tempdirs during pytest collection phase

3 years agoEnsure compatiblity with older pytest
Tom Krizek [Thu, 12 Jan 2023 17:01:02 +0000 (18:01 +0100)] 
Ensure compatiblity with older pytest

Special care needs to be taken to support older pytest / xdist versions.
The target versions are what is available in EL8, since that seems to
have the oldest versions that can be reasonably supported.

3 years agoKeep the tempdir in case test setup/teardown fails
Tom Krizek [Thu, 12 Jan 2023 16:59:51 +0000 (17:59 +0100)] 
Keep the tempdir in case test setup/teardown fails

When an issue occurs inside a fixture (e.g. servers fail to start/stop),
the test result won't be detected as failed, but rather an error will be
thrown.

To ensure the tempdir is kept even if the test itself passes but the
system_test() fixture throws an error, a different mechanism is needed.
At the start of the critical test setup section, note that the fixture
hasn't finished yet. When this is detected in the system_test_dir()
fixture, it is recognized as error in test setup/teardown and the temp
directory is kept.

This may seem cumbersome, because it is. It's basically a workaround for
the way pytest handles fixtures and test errors in general.

3 years agoEnsure tempdir is kept for failed system tests
Tom Krizek [Thu, 12 Jan 2023 16:41:35 +0000 (17:41 +0100)] 
Ensure tempdir is kept for failed system tests

The temporary directory contains artifacts for the pytest module. That
module may contain multiple individual tests which were executed
sequentially. The artifacts should be kept if even one of these tests
failed.

Since pytest doesn't have any facility to expose test results to
fixtures, customize the pytest_runtest_makereport() hook to enable that.
It stores the test results into a session scope variable which is
available in all fixtures.

When deciding whether to remove the temporary directory, find the
relevant test results for this module and don't remove the tmpdir if any
one the tests failed.

3 years agoAdd --noclean option to pytest runner
Tom Krizek [Thu, 12 Jan 2023 16:38:06 +0000 (17:38 +0100)] 
Add --noclean option to pytest runner

Support the --noclean option to allow the user to keep the artifacts
from any test run.

3 years agoRun system tests inside temporary directories
Tom Krizek [Thu, 12 Jan 2023 16:30:22 +0000 (17:30 +0100)] 
Run system tests inside temporary directories

For every pytest module, create a copy of its system test directory and
run the test from that directory. This makes it easier to clean up
afterwards and makes it less error-prone when re-running (failed) tests.

Configure the logger to capture the module's log output into a separate
file available from the temporary directory. This is quite convenient
for exploring failures.

Cases where temporary directory should be kept are handled in a
follow-up commits.

3 years agoExecute the system test workflow in pytest runner
Tom Krizek [Thu, 12 Jan 2023 16:27:07 +0000 (17:27 +0100)] 
Execute the system test workflow in pytest runner

This is basically the pytest re-implementation of the run.sh script.

The fixture is applied to every module and ensures complete test
setup/teardown, such as starting/stopping servers, detecting coredumps
etc.

Note that the fixture system_test_dir is not defined yet. It is omitted
now for review readability and it's added in follow-up commits.

3 years agoUtility fixtures for pytest runner
Tom Krizek [Thu, 12 Jan 2023 16:01:36 +0000 (17:01 +0100)] 
Utility fixtures for pytest runner

Add fixtures for deriving system test name from the directory name and
for a module-specific logger.

Add fixtures to execute shell and perl scripts. Similar to how run.sh
calls commands, this functionality is also needed in pytest. The
fixtures take care of switching to a proper directory, logging
everything and handling errors.

Note that the fixture system_test_dir is not defined yet. It is omitted
now for review readability and it's added in follow-up commits.

3 years agoAssign unique ports to pytest modules
Tom Krizek [Thu, 12 Jan 2023 15:52:49 +0000 (16:52 +0100)] 
Assign unique ports to pytest modules

This is basically a pytest re-implementation of the get_ports.sh script.
The main difference is that ports are assigned on a module basis, rather
than a directory basis. Module is the new atomic unit for parallel
execution, therefore it needs to have unique ports to avoid collisions.

Each module gets its ports through the env fixture which is updated with
ports and other module-specific variables.

3 years agoEnsure system test programs and deps are compiled
Tom Krizek [Thu, 12 Jan 2023 15:47:55 +0000 (16:47 +0100)] 
Ensure system test programs and deps are compiled

Some system tests require extra programs and/or dependencies to be
compiled first. This is done via `make check` with the automake
framework when using check_* variables such as check_PROGRAMS.

To avoid running any tests via the automake framework, set the TESTS
env variable to empty string and utilize `make -e check` to override
default Makefile variables with environment ones. This ensures automake
will only compile the needed dependencies without running any tests.

Additional consideration needs to be taken for xdist. The compilation
command should be called just once before any tests are executed. To
achieve that, use the pytest_configure() hook and check that the
PYTEST_XDIST_WORKER env variable isn't set -- if it is, it indicates
we're in the spawned xdist worker and the compilation was already done
by the main pytest process that spawned the workers.

This is mostly done to have on-par functionality with legacy test
framework. In the future, we should get rid of the need to run "empty"
make -e check and perhaps compile test-stuff by default.

3 years agoObtain env vars from conf.sh in pytest runner
Tom Krizek [Thu, 12 Jan 2023 15:41:41 +0000 (16:41 +0100)] 
Obtain env vars from conf.sh in pytest runner

The commands executed by pytest during a system test need to have the
same environment variables set as if they were executed by the run.sh
shell script.

It was decided that for the moment, legacy way of executing system tests
with run.sh should be kept, which complicates things a bit. In order to
avoid duplicating the required variables in both conf.sh and pytest, it
was decided to use the existing conf.sh as the only authoritative
place for the variables.

It is necessary to process the environment variables from conf.sh right
when conftest.py is loaded, since they might be needed right away (e.g.
to test for feature support during test collection).

This solution is a bit hacky and is only meant to be used during the
transitory phase when both pytest and the legacy run.sh are both
supported. In the future, a superior pytest-only solution should be
used.

For discussion of other options, refer to
https://gitlab.isc.org/isc-projects/bind9/-/merge_requests/6809#note_318889

3 years agoCollect existing tests in pytest runner
Tom Krizek [Thu, 12 Jan 2023 15:26:25 +0000 (16:26 +0100)] 
Collect existing tests in pytest runner

Ensure pytest picks up our python test modules, since we're using
tests_*.py convention, which is different from the default.

Configure pytest logging to display the output from all tests (even the
ones that passed). This ensures we have sufficient amount of information
to debug test post-mortem just from the artifacts.

3 years agoSupport both pytest and legacy system test runner
Tom Krizek [Thu, 12 Jan 2023 14:48:55 +0000 (15:48 +0100)] 
Support both pytest and legacy system test runner

The legacy system test framework uses pytest to execute some tests.
Since it'd be quite difficult to convince pytest to decide whether to
include conftest.py (or which ones to include when launching from
subdir), it makes more sense to have a shared conftest.py which is used
by both the legacy test runner invocations of pytest and the new pytest
system test runner. It is ugly, but once we drop support for the legacy
runner, we'll get rid of it.

Properly scope the *port fixtures in order to ensure they'll work as
expected with the new pytest runner. Instead of using "session" (which
means the fixture is only evaluated once for the entire execution of
pytest), use "module" scope, which is evaluated separately for each
module. The legacy runner invoked pytest for each system test
separately, while the new pytest runner is invoked once for all system
tests -- therefore it requires the more fine-grained "module" scope to
for the fixtures to work properly.

Remove python shebang, as conftest.py isn't supposed to be an executable
script.

3 years agoMerge branch '4070-tsan-qpmulti-destroy' into 'main'
Tony Finch [Sat, 20 May 2023 07:27:44 +0000 (07:27 +0000)] 
Merge branch '4070-tsan-qpmulti-destroy' into 'main'

Acquire qpmulti->mutex during destruction

Closes #4070 and #4073

See merge request isc-projects/bind9!7938

3 years agoAcquire qpmulti->mutex during destruction
Tony Finch [Wed, 17 May 2023 09:57:16 +0000 (10:57 +0100)] 
Acquire qpmulti->mutex during destruction

Thread sanitizer warns that parts of the qp-trie are accessed
both with and without the mutex; the unlocked accesses happen during
destruction, so they should be benign, but there's no harm locking
anyway to convince tsan it is clean.

Also, ensure .tsan-suppress and .tsan-suppress-extra are in sync.

3 years agoMerge branch 'mnowak/danger-test-pairwise-hint' into 'main'
Michal Nowak [Fri, 19 May 2023 12:31:28 +0000 (12:31 +0000)] 
Merge branch 'mnowak/danger-test-pairwise-hint' into 'main'

Add a friendly Danger plea to run the pairwise CI job

See merge request isc-projects/bind9!7876

3 years agoAdd a friendly Danger plea to run the pairwise CI job
Michal Nowak [Fri, 28 Apr 2023 08:24:17 +0000 (10:24 +0200)] 
Add a friendly Danger plea to run the pairwise CI job

Sometimes a pairwise definition for a new ./configure switch is added
but not tested in the CI.

3 years agoMerge branch 'mnowak/fedora-38' into 'main'
Michal Nowak [Fri, 19 May 2023 11:53:40 +0000 (11:53 +0000)] 
Merge branch 'mnowak/fedora-38' into 'main'

Add Fedora 38

See merge request isc-projects/bind9!7936

3 years agoAdd Fedora 38
Michal Nowak [Mon, 17 Apr 2023 17:15:17 +0000 (19:15 +0200)] 
Add Fedora 38

3 years agoMerge branch '4077-add-RUNTIME_CHECK-around-wrap' into 'main'
Michal Nowak [Fri, 19 May 2023 09:07:18 +0000 (09:07 +0000)] 
Merge branch '4077-add-RUNTIME_CHECK-around-wrap' into 'main'

Ensure "wrap" variable is non-NULL

Closes #4077

See merge request isc-projects/bind9!7948

3 years agoEnsure "wrap" variable is non-NULL
Michal Nowak [Thu, 18 May 2023 15:57:14 +0000 (17:57 +0200)] 
Ensure "wrap" variable is non-NULL

RUNTIME_CHECK on the "wrap" variable avoids possible NULL dereference:

    thread.c: In function 'thread_wrap':
    thread.c:60:15: error: dereference of possibly-NULL 'wrap' [CWE-690] [-Werror=analyzer-possible-null-dereference]
       60 |         *wrap = (struct thread_wrap){

The RUNTIME_CHECK was there before
7d1ceaf35dbc25dfbca32deffa7f6ff8f452e75f.

3 years agoMerge branch 'mnowak/get_core_dumps-fix-misplaced-tsan-line' into 'main'
Michal Nowak [Fri, 19 May 2023 07:18:11 +0000 (07:18 +0000)] 
Merge branch 'mnowak/get_core_dumps-fix-misplaced-tsan-line' into 'main'

TSAN summarising line was misplaced in get_core_dumps.sh

See merge request isc-projects/bind9!7870

3 years agoTSAN summarising line was misplaced in get_core_dumps.sh
Michal Nowak [Wed, 26 Apr 2023 10:48:40 +0000 (12:48 +0200)] 
TSAN summarising line was misplaced in get_core_dumps.sh

The line summarising TSAN reports was misplaced in the ASAN territory
and thus never used.

I also made core dumps, assertion failures, and TSAN reports detection
independent of each other.

3 years agoMerge branch 'michal/cmocka-future-proofing' into 'main'
Michał Kępień [Thu, 18 May 2023 13:30:48 +0000 (13:30 +0000)] 
Merge branch 'michal/cmocka-future-proofing' into 'main'

cmocka future-proofing

See merge request isc-projects/bind9!7939

3 years agoRemove <isc/cmocka.h>
Michał Kępień [Thu, 18 May 2023 13:12:23 +0000 (15:12 +0200)] 
Remove <isc/cmocka.h>

The last use of the cmocka_add_test_byname() helper macro was removed in
commit 63fe9312ff8f54bc79e399bdbd5aaa15cd3e5459.  Remove the
<isc/cmocka.h> header that defines it.

3 years agoFix cmocka-related compiler warnings in ht_test
Michał Kępień [Thu, 18 May 2023 13:12:23 +0000 (15:12 +0200)] 
Fix cmocka-related compiler warnings in ht_test

tests/isc/ht_test.c triggers the following compiler warnings when built
against development versions of cmocka:

    In file included from ht_test.c:24:
    ht_test.c: In function ‘test_ht_full’:
    ht_test.c:68:45: warning: passing argument 2 of ‘_assert_ptr_equal’ makes pointer from integer without a cast [-Wint-conversion]
       68 |                 assert_ptr_equal((void *)i, (uintptr_t)f);
    /usr/include/cmocka.h:1513:56: note: in definition of macro ‘assert_ptr_equal’
     1513 | #define assert_ptr_equal(a, b) _assert_ptr_equal((a), (b), __FILE__, __LINE__)
          |                                                        ^
    /usr/include/cmocka.h:2907:36: note: expected ‘const void *’ but argument is of type ‘long unsigned int’
     2907 |                        const void *b,
          |                        ~~~~~~~~~~~~^
    ht_test.c:163:45: warning: passing argument 2 of ‘_assert_ptr_equal’ makes pointer from integer without a cast [-Wint-conversion]
      163 |                 assert_ptr_equal((void *)i, (uintptr_t)f);
    /usr/include/cmocka.h:1513:56: note: in definition of macro ‘assert_ptr_equal’
     1513 | #define assert_ptr_equal(a, b) _assert_ptr_equal((a), (b), __FILE__, __LINE__)
          |                                                        ^
    /usr/include/cmocka.h:2907:36: note: expected ‘const void *’ but argument is of type ‘long unsigned int’
     2907 |                        const void *b,
          |                        ~~~~~~~~~~~~^

These are caused by a change to the definitions of pointer assert
functions in cmocka's development branch [1].  Fix by casting the
affected variables to (void *) instead of (uintptr_t).

[1] https://git.cryptomilk.org/projects/cmocka.git/commit/?id=09621179af67535788a67957a910d9f17c975b45

3 years agoInclude <inttypes.h> whenever including <cmocka.h>
Michał Kępień [Thu, 18 May 2023 13:12:23 +0000 (15:12 +0200)] 
Include <inttypes.h> whenever including <cmocka.h>

Development versions of cmocka require the intmax_t and uintmax_t types
to be defined by the time the test code includes the <cmocka.h> header.
These types are defined in the <stdint.h> header, which is included by
the <inttypes.h> header, which in turn is already explicitly included by
some of the programs in the tests/ directory.  Ensure all programs in
that directory that include the <cmocka.h> header also include the
<inttypes.h> header to future-proof the code while keeping the change
set minimal and the resulting code consistent.  Also prevent explicitly
including the <stdint.h> header in those programs as it is included by
the <inttypes.h> header.

3 years agoMerge tag 'v9.19.13'
Michał Kępień [Thu, 18 May 2023 12:06:04 +0000 (14:06 +0200)] 
Merge tag 'v9.19.13'

BIND 9.19.13

3 years agoMerge branch '4022-three-dnssec-failures-on-fedora-38' into 'main'
Mark Andrews [Thu, 18 May 2023 00:42:17 +0000 (00:42 +0000)] 
Merge branch '4022-three-dnssec-failures-on-fedora-38' into 'main'

Resolve "Three "dnssec" failures on Fedora 38"

Closes #4022

See merge request isc-projects/bind9!7932

3 years agoLet RSASHA1 signing keys be ignored in FIPS mode
Mark Andrews [Tue, 16 May 2023 00:15:00 +0000 (10:15 +1000)] 
Let RSASHA1 signing keys be ignored in FIPS mode

When the FIPS provider is available, RSASHA1 signing keys for zone
"example.com." are ignored if the zone is attempted to be signed with
the dnssec-signzone "-F" (FIPS mode) option:

    "fatal: No signing keys specified or found"

3 years agoMerge branch '4071-placeholder' into 'main'
Michał Kępień [Wed, 17 May 2023 14:28:22 +0000 (14:28 +0000)] 
Merge branch '4071-placeholder' into 'main'

Add placeholder for GL #4071

Closes #4071

See merge request isc-projects/bind9!7941

3 years agoAdd placeholder for GL #4071
Michał Kępień [Wed, 17 May 2023 14:26:39 +0000 (16:26 +0200)] 
Add placeholder for GL #4071

3 years agoMerge branch '4069-upforwd-wait' into 'main'
Tony Finch [Tue, 16 May 2023 15:29:29 +0000 (15:29 +0000)] 
Merge branch '4069-upforwd-wait' into 'main'

Fix the `upforwd` system test

Closes #4069

See merge request isc-projects/bind9!7931

3 years agoCHANGES for [GL #4069]
Tony Finch [Tue, 16 May 2023 12:38:05 +0000 (13:38 +0100)] 
CHANGES for [GL #4069]

[test] Fix the `upforwd` system test to be more reliable,
especially when using thread sanitizer.

3 years agoMatch UQ and UR stats to domain name
Evan Hunt [Mon, 15 May 2023 20:22:24 +0000 (13:22 -0700)] 
Match UQ and UR stats to domain name

The upforwd test for forwarding updates to a dead primary can continue
running a little bit past its end, causing update replies to be
recorded during a subsequent test case. Correct this by only looking
for update requests and replies for the specific domain name being
tested at any given time.

3 years agoFix the `upforwd` system test
Tony Finch [Mon, 15 May 2023 19:04:14 +0000 (20:04 +0100)] 
Fix the `upforwd` system test

After the RCU changes were merged, the `upforwd` test started
consistenly failing when run under thread sanitizer. After some
investigation, it turned out that retry attempts were continuing after
the "update forwarding to dead primary" test. This caused mismatches
in the DNSTAP message counts for the subsequent tests, because they
were also counting retries.

Fix this problem by `wait`ing for the `nsupdate` processes to exit.

While investigating the bug, I replaced several fixed 15 second delays
with `wait_for_log`, so the test runs faster.

3 years agoMerge branch '4066-resolv-conf-parsing-eats-lines-if-more-than-3-nameservers-set...
Mark Andrews [Tue, 16 May 2023 03:25:34 +0000 (03:25 +0000)] 
Merge branch '4066-resolv-conf-parsing-eats-lines-if-more-than-3-nameservers-set' into 'main'

Resolve "resolv.conf parsing eats lines if more than 3 nameservers set"

Closes #4066

See merge request isc-projects/bind9!7922

3 years agoAdd CHANGES for [GL #4066]
Mark Andrews [Mon, 15 May 2023 00:39:50 +0000 (10:39 +1000)] 
Add CHANGES for [GL #4066]

3 years agoProperly process extra nameserver lines in resolv.conf
Mark Andrews [Mon, 15 May 2023 00:34:16 +0000 (10:34 +1000)] 
Properly process extra nameserver lines in resolv.conf

The whole line needs to be read rather than just the token "nameserver"
otherwise the next line in resolv.conf is not properly processed.

3 years agoMerge branch 'fanf-urcu-qsbr-build' into 'main'
Tony Finch [Mon, 15 May 2023 20:49:47 +0000 (20:49 +0000)] 
Merge branch 'fanf-urcu-qsbr-build' into 'main'

Fixes for liburcu-qsbr

Closes #4067

See merge request isc-projects/bind9!7925

3 years agoFixes for liburcu-qsbr
Tony Finch [Mon, 15 May 2023 10:42:33 +0000 (11:42 +0100)] 
Fixes for liburcu-qsbr

Move registration and deregistration of the main thread from
`isc_loopmgr_run()` into `isc__initialize()` / `isc__shutdown()`:
liburcu-qsbr fails an assertion if we try to use it from an
unregistered thread, and we need to be able to use it when the
event loops are not running.

Use `rcu_assign_pointer()` and `rcu_dereference()` in qp-trie
transactions so that they properly mark threads as online. The
RCU-protected pointer is no longer declared atomic because
liburcu does not (yet) use standard C atomics.

Fix the definition of `isc_qsbr_rcu_dereference()` to return
the referenced value, and to call the right function inside
liburcu.

Change the thread sanitizer suppressions to match any variant of
`rcu_*_barrier()`

3 years agoMerge branch '4068-coverity-uv_async_send' into 'main'
Tony Finch [Mon, 15 May 2023 20:49:23 +0000 (20:49 +0000)] 
Merge branch '4068-coverity-uv_async_send' into 'main'

Check the return value from uv_async_send()

Closes #4068

See merge request isc-projects/bind9!7926

3 years agoCheck the return value from uv_async_send()
Tony Finch [Mon, 15 May 2023 14:35:57 +0000 (15:35 +0100)] 
Check the return value from uv_async_send()

An omission pointed out by the following report from Coverity:

    /lib/isc/loop.c: 483 in isc_loopmgr_pause()
    >>>     CID 455002:  Error handling issues  (CHECKED_RETURN)
    >>>     Calling "uv_async_send" without checking return value (as is done elsewhere 5 out of 6 times).
    483      uv_async_send(&loop->pause_trigger);

3 years agoMerge branch 'mnowak/openbsd-7.3' into 'main'
Michal Nowak [Mon, 15 May 2023 17:46:44 +0000 (17:46 +0000)] 
Merge branch 'mnowak/openbsd-7.3' into 'main'

Add OpenBSD 7.3

See merge request isc-projects/bind9!7847

3 years agoAdd OpenBSD 7.3
Michal Nowak [Mon, 17 Apr 2023 16:50:55 +0000 (18:50 +0200)] 
Add OpenBSD 7.3

3 years agoMerge branch 'mnowak/freebsd-13.2' into 'main'
Michal Nowak [Mon, 15 May 2023 16:31:38 +0000 (16:31 +0000)] 
Merge branch 'mnowak/freebsd-13.2' into 'main'

Add FreeBSD 13.2

See merge request isc-projects/bind9!7846

3 years agoAdd FreeBSD 13.2
Michal Nowak [Mon, 17 Apr 2023 16:46:43 +0000 (18:46 +0200)] 
Add FreeBSD 13.2

3 years agoMerge branch '4064-read-timeout-failure' into 'main'
Evan Hunt [Mon, 15 May 2023 16:25:45 +0000 (16:25 +0000)] 
Merge branch '4064-read-timeout-failure' into 'main'

allow streamdns read to resume after timeout

Closes #4064

See merge request isc-projects/bind9!7921

3 years agoallow streamdns read to resume after timeout
Evan Hunt [Sun, 14 May 2023 06:31:45 +0000 (23:31 -0700)] 
allow streamdns read to resume after timeout

when reading on a streamdns socket failed due to timeout, but
the dispatch was still waiting for other responses, it would
resume reading by calling isc_nm_read() again. this caused
an assertion because the socket was already reading.

we now check that either the socket is reading, or that it was
already reading on the same handle.

3 years agoMerge branch 'fanf-urcu-qp' into 'main'
Tony Finch [Fri, 12 May 2023 20:43:30 +0000 (20:43 +0000)] 
Merge branch 'fanf-urcu-qp' into 'main'

Replace isc_qsbr with liburcu-qsbr

Closes #3936 and #4019

See merge request isc-projects/bind9!7668

3 years agoCHANGES note for [GL #3936]
Tony Finch [Thu, 9 Mar 2023 11:11:41 +0000 (11:11 +0000)] 
CHANGES note for [GL #3936]

[cleanup] Refactor the loop manager and qp-trie code to remove
isc_qsbr and use liburcu instead. [GL #3936]

3 years agoRemove the now-unused ISC_STACK
Tony Finch [Fri, 12 May 2023 11:20:42 +0000 (12:20 +0100)] 
Remove the now-unused ISC_STACK

We are using the liburcu concurrent data structures instead.

3 years agoUse per-CPU RCU helper threads
Tony Finch [Fri, 5 May 2023 07:12:35 +0000 (08:12 +0100)] 
Use per-CPU RCU helper threads

Create and free per-CPU helper threads from the main thread and tell
thread sanitizer to suppress leaking threads. (We are not leaking
threads ourselves and we can safely ignore the Userspace-RCU thread
leaks.)

3 years agoHelp thread sanitizer to cope with liburcu
Tony Finch [Thu, 4 May 2023 14:26:13 +0000 (15:26 +0100)] 
Help thread sanitizer to cope with liburcu

All the places the qp-trie code was using `call_rcu()` needed
`__tsan_release()` and `__tsan_acquire()` annotations, so
add a couple of wrappers to encapsulate this pattern.

With these wrappers, the tests run almost clean under thread
sanitizer. The remaining problems are due to `rcu_barrier()`
which can be suppressed using `.tsan-suppress`. It does not
suppress the whole of `liburcu`, because we would like thread
sanitizer to detect problems in `call_rcu()` callbacks, which
are called from `liburcu`.

The CI jobs have been updated to use `.tsan-suppress` by
default, except for a special-case job that needs the
additional suppressions in `.tsan-suppress-extra`.

We might be able to get rid of some of this after liburcu gains
support for thread sanitizer.

Note: the `rcu_barrier()` suppression is not entirely effective:
tsan sometimes reports races that originate inside `rcu_barrier()`
but tsan has discarded the stack so it does not have the
information required to suppress the report. These "races" can
be made much easier to reproduce by adding `atexit_sleep_ms=1000`
to `TSAN_OPTIONS`. The problem with tsan's short memory can be
addressed by increasing `history_size`: when it is large enough
(6 or 7) the `rcu_barrier()` stack usually survives long enough
for suppression to work.

3 years agoAvoid using the zone timer after its loop has gone
Tony Finch [Wed, 3 May 2023 14:29:43 +0000 (15:29 +0100)] 
Avoid using the zone timer after its loop has gone

Shutdown and cleanup of zones is more asynchronous with the qp-trie
zone table. As a result it's possible that some activity is delayed
until after a zone has been released from its zonemanager.

Previously, the dns_zone code was not very strict in the way it
refers to the loop it is running on: The loop pointer was stashed when
dns_zonemgr_managezone() was called and never cleared. Now, zones
properly attach to and detach from their loops.

The zone timer depends on its loop. The shutdown crashes occurred
when asynchronous calls tried to modify the zone timer after
dns_zonemgr_releasezone() has been called and the loop was
invalidated. In these cases the attempt to set the timer is now
ignored, with a debug log message.

3 years agoGet the tests working with liburcu
Tony Finch [Wed, 8 Mar 2023 14:52:30 +0000 (14:52 +0000)] 
Get the tests working with liburcu

Mostly a few qp-trie details to adjust.

3 years agoThe zone table no longer depends on the loop manager
Tony Finch [Thu, 27 Apr 2023 11:47:03 +0000 (12:47 +0100)] 
The zone table no longer depends on the loop manager

This reverts some of the changes in commit b171cacf4f0123ba
because now it isn't necessary to pass the loopmgr around.

3 years agoRefactor the core qp-trie code to use liburcu
Tony Finch [Wed, 8 Mar 2023 14:28:06 +0000 (14:28 +0000)] 
Refactor the core qp-trie code to use liburcu

A `dns_qmpulti_t` no longer needs to know about its loopmgr. We no
longer keep a linked list of `dns_qpmulti_t` that have reclamation
work, and we no longer mark chunks with the phase in which they are to
be reclaimed. Instead, empty chunks are listed in an array in a
`qp_rcu_t`, which is passed to call_rcu().

3 years agoRemove isc_qsbr (we are using liburcu instead)
Tony Finch [Wed, 8 Mar 2023 10:20:16 +0000 (10:20 +0000)] 
Remove isc_qsbr (we are using liburcu instead)

This commit breaks the qp-trie code.

3 years agoSlightly more sanitary thread dispatch
Tony Finch [Wed, 3 May 2023 14:44:36 +0000 (15:44 +0100)] 
Slightly more sanitary thread dispatch

Tell thread sanitizer that the thread wrapper is released before
passing it to a new thread.

3 years agoWait for RCU to finish before destroying a memory context
Tony Finch [Fri, 28 Apr 2023 13:10:03 +0000 (14:10 +0100)] 
Wait for RCU to finish before destroying a memory context

Memory reclamation by `call_rcu()` is asynchronous, so during shutdown
it can lose a race with the destruction of its memory context. When we
defer memory reclamation, we need to attach to the memory context to
indicate that it is still in use, but that is not enough to delay its
destruction. So, call `rcu_barrier()` in `isc_mem_destroy()` to wait
for pending RCU work to finish before proceeding to destroy the memory
context.

3 years agoA macro for the size of a struct with a flexible array member
Tony Finch [Thu, 9 Mar 2023 10:43:53 +0000 (10:43 +0000)] 
A macro for the size of a struct with a flexible array member

It can be fairly long-winded to allocate space for a struct with a
flexible array member: in general we need the size of the struct, the
size of the member, and the number of elements. Wrap them all up in a
STRUCT_FLEX_SIZE() macro, and use the new macro for the flexible
arrays in isc_ht and dns_qp.

3 years agoMerge branch '4046-rndc-t-option' into 'main'
Evan Hunt [Fri, 12 May 2023 19:37:36 +0000 (19:37 +0000)] 
Merge branch '4046-rndc-t-option' into 'main'

add 'rndc -t' option to set timeout

Closes #4046

See merge request isc-projects/bind9!7889

3 years agoCHANGES and release note for part 2 of [GL #4046]
Evan Hunt [Wed, 3 May 2023 21:34:39 +0000 (14:34 -0700)] 
CHANGES and release note for part 2 of [GL #4046]

3 years agoadd 'rndc -t' option to set timeout
Evan Hunt [Wed, 3 May 2023 21:28:37 +0000 (14:28 -0700)] 
add 'rndc -t' option to set timeout

Allow an arbitrary TCP timeout value to be specified when running
rndc, so that commands that take a long time to execute (for example,
reloading a very large configuration) can be given time to do so.

3 years agoMerge branch '4054-zone_resigninc-bugfix' into 'main'
Arаm Sаrgsyаn [Fri, 12 May 2023 13:37:46 +0000 (13:37 +0000)] 
Merge branch '4054-zone_resigninc-bugfix' into 'main'

zone_resigninc(): check whether zone->db is a valid pointer before attaching

Closes #4054

See merge request isc-projects/bind9!7914

3 years agoAdd a CHANGES note for [GL #4054]
Aram Sargsyan [Thu, 11 May 2023 12:20:58 +0000 (12:20 +0000)] 
Add a CHANGES note for [GL #4054]

3 years agoCheck whether zone->db is a valid pointer before attaching
Aram Sargsyan [Thu, 11 May 2023 12:08:13 +0000 (12:08 +0000)] 
Check whether zone->db is a valid pointer before attaching

The zone_resigninc() function does not check the validity of
'zone->db', which can crash named if the zone was unloaded earlier,
for example with "rndc delete".

Check that 'zone->db' is not 'NULL' before attaching to it, like
it is done in zone_sign() and zone_nsec3chain() functions, which
can similarly be called by zone maintenance.

3 years agoMerge branch 'ondrej/convert-isc_async-to-use-urcu-wfcqueue' into 'main'
Ondřej Surý [Fri, 12 May 2023 13:24:27 +0000 (13:24 +0000)] 
Merge branch 'ondrej/convert-isc_async-to-use-urcu-wfcqueue' into 'main'

Change the isc_async and isc_quota API to use cds_wfcqueue internally

See merge request isc-projects/bind9!7894

3 years agoAdd Userspace-RCU to global CFLAGS and LIBS
Ondřej Surý [Tue, 9 May 2023 11:38:37 +0000 (13:38 +0200)] 
Add Userspace-RCU to global CFLAGS and LIBS

The Userspace-RCU headers are now needed for more parts of the libisc
and libdns, thus we need to add it globally to prevent compilation
failures on systems with non-standard Userspace-RCU installation path.

3 years agoChange the isc_quota API to use cds_wfcqueue internally
Ondřej Surý [Mon, 8 May 2023 21:31:54 +0000 (23:31 +0200)] 
Change the isc_quota API to use cds_wfcqueue internally

The isc_quota API was using locked list of isc_job_t objects to keep the
waiting TCP accepts.  Change the isc_quota implementation to use
cds_wfcqueue internally - the enqueue is wait-free and only dequeue
needs to be locked.

3 years agoAdjust the udp_shutdown_connect to delay the check
Ondřej Surý [Tue, 9 May 2023 08:24:37 +0000 (10:24 +0200)] 
Adjust the udp_shutdown_connect to delay the check

The teardown jobs are not executed immediately, so we need to delay the
check for ISC_R_SHUTTINGDOWN even more (as the UDP connect is
synchronous, it makes it harder to test it).

3 years agoChange the isc_async API to use cds_wfcqueue internally
Ondřej Surý [Mon, 8 May 2023 21:31:54 +0000 (23:31 +0200)] 
Change the isc_async API to use cds_wfcqueue internally

The isc_async API was using lock-free stack (where enqueue operation was
not wait-free).  Change the isc_async to use cds_wfcqueue internally -
enqueue and splice (move the queue members from one list to another) is
nonblocking and wait-free.

3 years agoMerge branch '4045-refactor-rbtdb-glue_cache' into 'main'
Ondřej Surý [Fri, 12 May 2023 11:26:58 +0000 (11:26 +0000)] 
Merge branch '4045-refactor-rbtdb-glue_cache' into 'main'

Replace glue_cache hashtable with direct link in rdatasetheader

Closes #4045

See merge request isc-projects/bind9!7895

3 years agoAdd CHANGES and release note for [GL #4045]
Ondřej Surý [Tue, 9 May 2023 12:53:28 +0000 (14:53 +0200)] 
Add CHANGES and release note for [GL #4045]

3 years agoReplace glue_cache hashtable with direct link in rdatasetheader
Ondřej Surý [Wed, 3 May 2023 17:38:05 +0000 (19:38 +0200)] 
Replace glue_cache hashtable with direct link in rdatasetheader

Instead of having a global hashtable with a global rwlock for the GLUE
cache, move the glue_list directly into rdatasetheader and use
Userspace-RCU to update the pointer when the glue_list is empty.

Additionally, the cached glue_lists needs to be stored in the RBTDB
version for early cleaning, otherwise the circular dependencies between
nodes and glue_lists will prevent nodes to be ever cleaned up.

3 years agoMerge branch 'mnowak/coverity-scan-2022.12' into 'main'
Michal Nowak [Fri, 12 May 2023 08:13:42 +0000 (08:13 +0000)] 
Merge branch 'mnowak/coverity-scan-2022.12' into 'main'

Use the latest Coverity Scan

See merge request isc-projects/bind9!7881

3 years agoUse the latest Coverity Scan
Michal Nowak [Wed, 3 May 2023 09:55:57 +0000 (11:55 +0200)] 
Use the latest Coverity Scan

3 years agoMerge branch '4050-cdnskey-no' into 'main'
Matthijs Mekking [Fri, 12 May 2023 07:46:17 +0000 (07:46 +0000)] 
Merge branch '4050-cdnskey-no' into 'main'

Add option to not generate CDNSKEY record

Closes #4050

See merge request isc-projects/bind9!7917

3 years agoAdd release note and CHANGES for cdnskey option
Matthijs Mekking [Thu, 11 May 2023 14:20:47 +0000 (16:20 +0200)] 
Add release note and CHANGES for cdnskey option

3 years agoRead from kasp whether to publish CDNSKEY
Matthijs Mekking [Thu, 11 May 2023 14:15:57 +0000 (16:15 +0200)] 
Read from kasp whether to publish CDNSKEY

Check the policy and feed 'dns_dnssec_syncupdate() the right value
to enable/disable CDSNKEY publication.

3 years agoAdd test case for cdnskey no;
Matthijs Mekking [Thu, 11 May 2023 13:13:03 +0000 (15:13 +0200)] 
Add test case for cdnskey no;

Change one of the test cases to disable publication of CDNSKEY.

3 years agoAdd configuration option 'cdnskey'
Matthijs Mekking [Thu, 11 May 2023 12:11:45 +0000 (14:11 +0200)] 
Add configuration option 'cdnskey'

Add the 'cdnskey' configuration option to 'dnssec-policy'.

3 years agoAdd functions to set CDNSKEY publication
Matthijs Mekking [Thu, 11 May 2023 12:00:58 +0000 (14:00 +0200)] 
Add functions to set CDNSKEY publication

Add kasp API functions to enable/disable publication of CDNSKEY records.

3 years agoMerge branch 'mnowak/pytest_rewrite_ttl' into 'main'
Michal Nowak [Thu, 11 May 2023 14:09:42 +0000 (14:09 +0000)] 
Merge branch 'mnowak/pytest_rewrite_ttl' into 'main'

Rewrite the ttl system test to pytest

See merge request isc-projects/bind9!7896

3 years agoRewrite the ttl system test to pytest
Michal Nowak [Thu, 4 May 2023 18:05:30 +0000 (20:05 +0200)] 
Rewrite the ttl system test to pytest