]> git.ipfire.org Git - thirdparty/bind9.git/log
thirdparty/bind9.git
5 years agoAdd CHANGES note for [GL !4835]
Evan Hunt [Tue, 23 Mar 2021 01:56:06 +0000 (18:56 -0700)] 
Add CHANGES note for [GL !4835]

5 years agomove samples/resolve.c to bin/tests/system
Evan Hunt [Tue, 23 Mar 2021 01:40:21 +0000 (18:40 -0700)] 
move samples/resolve.c to bin/tests/system

"resolve" is used by the resolver system tests, and I'm not
certain whether delv exercises the same code, so rather than
remove it, I moved it to bin/tests/system.

5 years agoremove sample-async
Evan Hunt [Tue, 23 Mar 2021 01:25:15 +0000 (18:25 -0700)] 
remove sample-async

sample code for export libraries is no longer needed and
this code is not used for any internal tests. also, sample-gai.c
had already been removed but there were some dangling references.

5 years agorename dns_client_createx() to dns_client_create()
Evan Hunt [Tue, 23 Mar 2021 01:16:28 +0000 (18:16 -0700)] 
rename dns_client_createx() to dns_client_create()

there's no longer a need to use an alternate name.

5 years agoremove dns_client_request() and related code
Evan Hunt [Tue, 23 Mar 2021 01:14:37 +0000 (18:14 -0700)] 
remove dns_client_request() and related code

continues the cleanup of dns_client started in the previous commit.

5 years agoremove dns_client_update() and related code
Evan Hunt [Tue, 23 Mar 2021 01:04:23 +0000 (18:04 -0700)] 
remove dns_client_update() and related code

the libdns client API is no longer being maintained for
external use, we can remove the code that isn't being used
internally, as well as the related tests.

5 years agoMerge branch '2634-placeholder' into 'main'
Michał Kępień [Fri, 16 Apr 2021 12:20:37 +0000 (12:20 +0000)] 
Merge branch '2634-placeholder' into 'main'

Add placeholder for GL #2634

See merge request isc-projects/bind9!4901

5 years agoAdd placeholder for GL #2634
Michał Kępień [Fri, 16 Apr 2021 12:16:57 +0000 (14:16 +0200)] 
Add placeholder for GL #2634

5 years agoMerge branch '2623-9-16-13-overwrites-master-files-if-old-format-jnl-files-are-presen...
Ondřej Surý [Fri, 16 Apr 2021 11:12:19 +0000 (11:12 +0000)] 
Merge branch '2623-9-16-13-overwrites-master-files-if-old-format-jnl-files-are-present' into 'main'

Resolve "9.16.13 overwrites master files if old format .jnl files are present"

Closes #2623

See merge request isc-projects/bind9!4880

5 years agoAdd CHANGES and release note for [GL #2623]
Mark Andrews [Mon, 12 Apr 2021 00:43:56 +0000 (10:43 +1000)] 
Add CHANGES and release note for [GL #2623]

5 years agoRefactor dns_journal_rollforward() to work over opened journal
Ondřej Surý [Tue, 13 Apr 2021 11:26:09 +0000 (13:26 +0200)] 
Refactor dns_journal_rollforward() to work over opened journal

Too much logic was cramped inside the dns_journal_rollforward() that
made it harder to follow.  The dns_journal_rollforward() was refactored
to work over already opened journal and some of the previous logic was
moved to new static zone_journal_rollforward() that separates the
journal "rollforward" logic from the "zone" logic.

5 years agoFixing a recoverable journal should not result in the zone being written
Mark Andrews [Sun, 11 Apr 2021 23:36:18 +0000 (09:36 +1000)] 
Fixing a recoverable journal should not result in the zone being written

when dns_journal_rollforward returned ISC_R_RECOVERABLE the distintion
between 'up to date' and 'success' was lost, as a consequence
zone_needdump() was called writing out the zone file when it shouldn't
have been.   This change restores that distintion.  Adjust system
test to reflect visible changes.

5 years agoMerge branch 'artem/move-tls-tests-into-netmgr-tests' into 'main'
Artem Boldariev [Thu, 15 Apr 2021 14:03:14 +0000 (14:03 +0000)] 
Merge branch 'artem/move-tls-tests-into-netmgr-tests' into 'main'

Merge the tls_test.c into netmgr_test.c and extend the tests suite

See merge request isc-projects/bind9!4893

5 years agoHandle a situation when SSL shutdown messages were sent and received
Artem Boldariev [Wed, 14 Apr 2021 16:02:50 +0000 (19:02 +0300)] 
Handle a situation when SSL shutdown messages were sent and received

It fixes a corner case which was causing dig to print annoying
messages like:

14-Apr-2021 18:48:37.099 SSL error in BIO: 1 TLS error (errno:
0). Arguments: received_data: (nil), send_data: (nil), finish: false

even when all the data was properly processed.

5 years agoTLS: try to close TCP socket descriptor earlier when possible
Artem Boldariev [Tue, 13 Apr 2021 15:45:10 +0000 (18:45 +0300)] 
TLS: try to close TCP socket descriptor earlier when possible

Before this fix underlying TCP sockets could remain opened for longer
than it is actually required, causing unit tests to fail with lots of
ISC_R_TOOMANYOPENFILES errors.

The change also enables graceful SSL shutdown (before that it  would
happen only in the case when isc_nm_cancelread() were called).

5 years agoMerge the tls_test.c into netmgr_test.c and extend the tests suite
Ondřej Surý [Thu, 1 Apr 2021 07:15:43 +0000 (09:15 +0200)] 
Merge the tls_test.c into netmgr_test.c and extend the tests suite

This commit merges TLS tests into the common Network Manager unit
tests suite and extends the unit test framework to include support for
additional "ping-pong" style tests where all data could be sent via
lesser number of connections (the behaviour of the old test
suite). The tests for TCP and TLS were extended to make use of the new
mode, as this mode better translates to how the code is used in DoH.

Both TLS and TCP tests now share most of the unit tests' code, as they
are expected to function similarly from a users's perspective anyway.

Additionally to the above, the TLS test suite was extended to include
TLS tests using the connections quota facility.

5 years agoMerge branch 'matthijs-keymgr2kasp-rework' into 'main'
Matthijs Mekking [Thu, 15 Apr 2021 12:45:25 +0000 (12:45 +0000)] 
Merge branch 'matthijs-keymgr2kasp-rework' into 'main'

Update keymgr2kasp system test

Closes #2631

See merge request isc-projects/bind9!4894

5 years agoFix view-related issues in the "keymgr2kasp" test
Matthijs Mekking [Wed, 14 Apr 2021 13:23:41 +0000 (15:23 +0200)] 
Fix view-related issues in the "keymgr2kasp" test

Due to the lack of "match-clients" clauses in ns4/named2.conf.in, the
same view is incorrectly chosen for all queries received by ns4 in the
"keymgr2kasp" system test.  This causes only one version of the
"view-rsasha256.kasp" zone to actually be checked.  Add "match-clients"
clauses to ns4/named2.conf.in to ensure the test really checks what it
claims to.

Use identical view names ("ext", "int") in ns4/named.conf.in and
ns4/named2.conf.in so that it is easier to quickly identify the
differences between these two files.

Update tests.sh to account for the above changes.  Also fix a copy-paste
error in a comment to prevent confusion.

5 years agoMerge branch '1100-inline-signing-include' into 'main'
Matthijs Mekking [Wed, 14 Apr 2021 09:35:35 +0000 (09:35 +0000)] 
Merge branch '1100-inline-signing-include' into 'main'

Resolve "Test inline-signing with $INCLUDE"

Closes #1100

See merge request isc-projects/bind9!4825

5 years agoDocument relative path of $INCLUDE
Matthijs Mekking [Fri, 19 Mar 2021 14:39:20 +0000 (15:39 +0100)] 
Document relative path of $INCLUDE

Add to the ARM from where relative paths are searched.

5 years agoFix inline test with missing $INCLUDE
Matthijs Mekking [Fri, 19 Mar 2021 14:23:01 +0000 (15:23 +0100)] 
Fix inline test with missing $INCLUDE

The test case for a zone with a missing include file was wrong for two
reasons:
1. It was loading the wrong file (master5 instead of master6)
2. It did actually not set the $ret variable to 1 if the test failed
   (it should default to ret=1 and clear the variable if the
   appropriate log is found).

5 years agoAdd inline-signing with $INCLUDE test
Matthijs Mekking [Fri, 19 Mar 2021 14:21:17 +0000 (15:21 +0100)] 
Add inline-signing with $INCLUDE test

Add a test case for inline-signing for a zone with an $INCLUDE
statement. There is already a test for a missing include file, this
one adds a test for a zone with an include file that does exist.

Test if the record in the included file is loaded.

5 years agoMerge branch '2347-draft-vandijk-dnsop-nsec-ttl' into 'main'
Matthijs Mekking [Tue, 13 Apr 2021 12:14:53 +0000 (12:14 +0000)] 
Merge branch '2347-draft-vandijk-dnsop-nsec-ttl' into 'main'

Implement draft-vandijk-dnsop-nsec-ttl

Closes #2347

See merge request isc-projects/bind9!4506

5 years agoSmall refactor lib/dns/zone.c
Matthijs Mekking [Tue, 23 Mar 2021 08:57:43 +0000 (09:57 +0100)] 
Small refactor lib/dns/zone.c

Introduce some macros that can be reused in 'zone_load_soa_rr()' and
'zone_get_from_db()' to make those functions more readable.

5 years agoUse designated initializer in dns_zone_create
Matthijs Mekking [Tue, 23 Mar 2021 08:20:50 +0000 (09:20 +0100)] 
Use designated initializer in dns_zone_create

Shorten the code and make it less prone to initialisation errors
(it is still easy to forget adding an initializer, but it now defaults
to 0).

5 years agoAdd change entry and release note for [#2347]
Matthijs Mekking [Mon, 22 Mar 2021 14:53:47 +0000 (15:53 +0100)] 
Add change entry and release note for [#2347]

5 years agoImplement draft-vandijk-dnsop-nsec-ttl
Matthijs Mekking [Fri, 18 Dec 2020 13:19:36 +0000 (14:19 +0100)] 
Implement draft-vandijk-dnsop-nsec-ttl

The draft says that the NSEC(3) TTL must have the same TTL value
as the minimum of the SOA MINIMUM field and the SOA TTL. This was
always the intended behaviour.

Update the zone structure to also track the SOA TTL. Whenever we
use the MINIMUM value to determine the NSEC(3) TTL, use the minimum
of MINIMUM and SOA TTL instead.

There is no specific test for this, however two tests need adjusting
because otherwise they failed: They were testing for NSEC3 records
including the TTL. Update these checks to use 600 (the SOA TTL),
rather than 3600 (the SOA MINIMUM).

5 years agoMerge branch '2289-cache-dump-stale-ttl-weird-values' into 'main'
Matthijs Mekking [Tue, 13 Apr 2021 08:54:49 +0000 (08:54 +0000)] 
Merge branch '2289-cache-dump-stale-ttl-weird-values' into 'main'

Fix nonsensical stale TTL values in cache dump

Closes #2289

See merge request isc-projects/bind9!4799

5 years agoUse stale TTL as RRset TTL in dumpdb
Matthijs Mekking [Fri, 12 Mar 2021 15:27:45 +0000 (16:27 +0100)] 
Use stale TTL as RRset TTL in dumpdb

It is more intuitive to have the countdown 'max-stale-ttl' as the
RRset TTL, instead of 0 TTL. This information was already available
in a comment "; stale (will be retained for x more seconds", but
Support suggested to put it in the TTL field instead.

5 years agoCheck staleness in bind_rdataset
Matthijs Mekking [Fri, 12 Mar 2021 14:12:27 +0000 (15:12 +0100)] 
Check staleness in bind_rdataset

Before binding an RRset, check the time and see if this record is
stale (or perhaps even ancient). Marking a header stale or ancient
happens only when looking up an RRset in cache, but binding an RRset
can also happen on other occasions (for example when dumping the
database).

Check the time and compare it to the header. If according to the
time the entry is stale, but not ancient, set the STALE attribute.
If according to the time is ancient, set the ANCIENT attribute.

We could mark the header stale or ancient here, but that requires
locking, so that's why we only compare the current time against
the rdh_ttl.

Adjust the test to check the dump-db before querying for data. In the
dumped file the entry should be marked as stale, despite no cache
lookup happened since the initial query.

5 years agoFix nonsensical stale TTL values in cache dump
Matthijs Mekking [Wed, 10 Mar 2021 11:09:16 +0000 (12:09 +0100)] 
Fix nonsensical stale TTL values in cache dump

When introducing change 5149, "rndc dumpdb" started to print a line
above a stale RRset, indicating how long the data will be retained.

At that time, I thought it should also be possible to load
a cache from file. But if a TTL has a value of 0 (because it is stale),
stale entries wouldn't be loaded from file. So, I added the
'max-stale-ttl' to TTL values, and adjusted the $DATE accordingly.

Since we actually don't have a "load cache from file" feature, this
is premature and is causing confusion at operators. This commit
changes the 'max-stale-ttl' adjustments.

A check in the serve-stale system test is added for a non-stale
RRset (longttl.example) to make sure the TTL in cache is sensible.

Also, the comment above stale RRsets could have nonsensical
values. A possible reason why this may happen is when the RRset was
marked a stale but the 'max-stale-ttl' has passed (and is actually an
RRset awaiting cleanup). This would lead to the "will be retained"
value to be negative (but since it is stored in an uint32_t, you would
get a nonsensical value (e.g. 4294362497).

To mitigate against this, we now also check if the header is not
ancient. In addition we check if the stale_ttl would be negative, and
if so we set it to 0. Most likely this will not happen because the
header would already have been marked ancient, but there is a possible
race condition where the 'rdh_ttl + serve_stale_ttl' has passed,
but the header has not been checked for staleness.

5 years agoMerge branch '2622-command-line-option-l-not-shown-with-usage-message' into 'main'
Mark Andrews [Tue, 13 Apr 2021 01:33:28 +0000 (01:33 +0000)] 
Merge branch '2622-command-line-option-l-not-shown-with-usage-message' into 'main'

Resolve "Command-line option -L not shown with usage message"

Closes #2622

See merge request isc-projects/bind9!4881

5 years agoUpdate named's usage description
Mark Andrews [Mon, 12 Apr 2021 02:06:54 +0000 (12:06 +1000)] 
Update named's usage description

5 years agoMerge branch 'michal/add-placeholder-entries-to-CHANGES' into 'main'
Michał Kępień [Thu, 8 Apr 2021 11:10:54 +0000 (11:10 +0000)] 
Merge branch 'michal/add-placeholder-entries-to-CHANGES' into 'main'

Add placeholders for GL #2467, GL #2540, GL #2604

See merge request isc-projects/bind9!4878

5 years agoAdd placeholders for GL #2467, GL #2540, GL #2604
Michał Kępień [Thu, 8 Apr 2021 11:06:57 +0000 (13:06 +0200)] 
Add placeholders for GL #2467, GL #2540, GL #2604

5 years agoMerge branch '2578-rework-get_ports.sh-to-make-it-not-use-a-lock-file' into 'main'
Michał Kępień [Thu, 8 Apr 2021 09:37:51 +0000 (09:37 +0000)] 
Merge branch '2578-rework-get_ports.sh-to-make-it-not-use-a-lock-file' into 'main'

Rework get_ports.sh to make it not use a lock file

Closes #2578

See merge request isc-projects/bind9!4801

5 years agoUse the same port selection method on all systems
Michał Kępień [Thu, 8 Apr 2021 09:12:37 +0000 (11:12 +0200)] 
Use the same port selection method on all systems

When system tests are run on Windows, they are assigned port ranges that
are 100 ports wide and start from port number 5000.  This is a different
port assignment method than the one used on Unix systems.  Drop the "-p"
command line option from bin/tests/system/run.sh invocations used for
starting system tests on Windows to unify the port assignment method
used across all operating systems.

5 years agoRework get_ports.sh to make it not use a lock file
Michał Kępień [Thu, 8 Apr 2021 09:12:37 +0000 (11:12 +0200)] 
Rework get_ports.sh to make it not use a lock file

The get_ports.sh script is used for determining the range of ports a
given system test should use.  It first determines the start of the port
range to return (the base port); it can either be specified explicitly
by the caller or chosen randomly.  Subsequent ports are picked
sequentially, starting from the base port.  To ensure no single port is
used by multiple tests, a state file (get_ports.state) containing the
last assigned port is maintained by the script.  Concurrent access to
the state file is protected by a lock file (get_ports.lock); if one
instance of the script holds the lock file while another instance tries
to acquire it, the latter retries its attempt to acquire the lock file
after sleeping for 1 second; this retry process can be repeated up to 10
times before the script returns an error.

There are some problems with this approach:

  - the sleep period in case of failure to acquire the lock file is
    fixed, which leads to a "thundering herd" type of problem, where
    (depending on how processes are scheduled by the operating system)
    multiple system tests try to acquire the lock file at the same time
    and subsequently sleep for 1 second, only for the same situation to
    likely happen the next time around,

  - the lock file is being locked and then unlocked for every single
    port assignment made, not just once for the entire range of ports a
    system test should use; in other words, the lock file is currently
    locked and unlocked 13 times per system test; this increases the
    odds of the "thundering herd" problem described above preventing a
    system test from getting one or more ports assigned before the
    maximum retry count is reached (assuming multiple system tests are
    run in parallel); it also enables the range of ports used by a given
    system test to be non-sequential (which is a rather cosmetic issue,
    but one that can make log interpretation harder than necessary when
    test failures are diagnosed),

  - both issues described above cause unnecessary delays when multiple
    system tests are started in parallel (due to high lock file
    contention among the system tests being started),

  - maintaining a state file requires ensuring proper locking, which
    complicates the script's source code.

Rework the get_ports.sh script so that it assigns non-overlapping port
ranges to its callers without using a state file or a lock file:

  - add a new command line switch, "-t", which takes the name of the
    system test to assign ports for,

  - ensure every instance of get_ports.sh knows how many ports all
    system tests which form the test suite are going to need in total
    (based on the number of subdirectories found in bin/tests/system/),

  - in order to ensure all instances of get_ports.sh work on the same
    global port range (so that no port range collisions happen), a
    stable (throughout the expected run time of a single system test
    suite) base port selection method is used instead of the random one;
    specifically, the base port, unless specified explicitly using the
    "-p" command line switch, is derived from the number of hours which
    passed since the Unix Epoch time,

  - use the name of the system test to assign ports for (passed via the
    new "-t" command line switch) as a unique index into the global
    system test range, to ensure all system tests use disjoint port
    ranges.

5 years agoMerge branch 'mnowak/fix-missing-fromhex.pl-in-out-of-tree' into 'main'
Michal Nowak [Thu, 8 Apr 2021 09:07:07 +0000 (09:07 +0000)] 
Merge branch 'mnowak/fix-missing-fromhex.pl-in-out-of-tree' into 'main'

Move fromhex.pl script to bin/tests/system/

See merge request isc-projects/bind9!4875

5 years agoMove fromhex.pl script to bin/tests/system/
Michal Nowak [Thu, 8 Apr 2021 07:20:34 +0000 (09:20 +0200)] 
Move fromhex.pl script to bin/tests/system/

The fromhex.pl script needs to be copied from the source directory to
the build directory before any test is run, otherwise the out-of-tree
fails to find it. Given that the script is used only in system test,
move it to bin/tests/system/.

5 years agoMerge branch '2620-free-resources-when-gss_accept_sec_context-fails' into 'main'
Michał Kępień [Thu, 8 Apr 2021 08:40:27 +0000 (08:40 +0000)] 
Merge branch '2620-free-resources-when-gss_accept_sec_context-fails' into 'main'

Free resources when gss_accept_sec_context() fails

Closes #2620

See merge request isc-projects/bind9!4873

5 years agoAdd CHANGES entry
Michał Kępień [Thu, 8 Apr 2021 08:33:44 +0000 (10:33 +0200)] 
Add CHANGES entry

5 years agoFree resources when gss_accept_sec_context() fails
Michał Kępień [Thu, 8 Apr 2021 08:33:44 +0000 (10:33 +0200)] 
Free resources when gss_accept_sec_context() fails

Even if a call to gss_accept_sec_context() fails, it might still cause a
GSS-API response token to be allocated and left for the caller to
release.  Make sure the token is released before an early return from
dst_gssapi_acceptctx().

5 years agoMerge branch '2600-general-error-managed-keys-zone-dns_journal_compact-failed-no...
Ondřej Surý [Wed, 7 Apr 2021 19:28:39 +0000 (19:28 +0000)] 
Merge branch '2600-general-error-managed-keys-zone-dns_journal_compact-failed-no-more' into 'main'

Resolve "general: error: managed-keys-zone: dns_journal_compact failed: no more"

Closes #2600

See merge request isc-projects/bind9!4849

5 years agoAdd CHANGES and release note for [GL #2600]
Mark Andrews [Wed, 31 Mar 2021 04:15:19 +0000 (15:15 +1100)] 
Add CHANGES and release note for [GL #2600]

5 years agoCheck that upgrade of managed-keys.bind.jnl succeeded
Mark Andrews [Wed, 31 Mar 2021 15:43:37 +0000 (02:43 +1100)] 
Check that upgrade of managed-keys.bind.jnl succeeded

Update the system to include a recoverable managed.keys journal created
with <size,serial0,serial1,0> transactions and test that it has been
updated as part of the start up process.

5 years agoRewrite managed-key journal immediately
Mark Andrews [Thu, 1 Apr 2021 04:22:55 +0000 (15:22 +1100)] 
Rewrite managed-key journal immediately

Both managed keys and regular zone journals need to be updated
immediately when a recoverable error is discovered.

5 years agoUpdate dns_journal_compact() to handle bad transaction headers
Mark Andrews [Wed, 31 Mar 2021 04:03:33 +0000 (15:03 +1100)] 
Update dns_journal_compact() to handle bad transaction headers

Previously, dns_journal_begin_transaction() could reserve the wrong
amount of space.  We now check that the transaction is internally
consistent when upgrading / downgrading a journal and we also handle the
bad transaction headers.

5 years agoCompute transaction size based on journal/transaction type
Mark Andrews [Thu, 1 Apr 2021 04:30:42 +0000 (15:30 +1100)] 
Compute transaction size based on journal/transaction type

previously the code assumed that it was a new transaction.

5 years agoUse journal_write_xhdr() to write the dummy transaction header
Mark Andrews [Wed, 31 Mar 2021 02:29:13 +0000 (13:29 +1100)] 
Use journal_write_xhdr() to write the dummy transaction header

Instead of journal_write(), use correct format call journal_write_xhdr()
to write the dummy transaction header which looks at j->header_ver1 to
determine which transaction header to write instead of always writing a
zero filled journal_rawxhdr_t header.

5 years agoMerge branch '2401-ISC_R_TIMEDOUT-is-recoverable' into 'main'
Ondřej Surý [Wed, 7 Apr 2021 14:34:46 +0000 (14:34 +0000)] 
Merge branch '2401-ISC_R_TIMEDOUT-is-recoverable' into 'main'

netmgr: Make it possible to recover from ISC_R_TIMEDOUT

Closes #2401

See merge request isc-projects/bind9!4845

5 years agoAdd CHANGES note for GL #2401
Evan Hunt [Wed, 7 Apr 2021 00:50:45 +0000 (17:50 -0700)] 
Add CHANGES note for GL #2401

5 years agoUse T_CONNECT timeout constant for TCP tests (instead of 1 ms)
Artem Boldariev [Wed, 7 Apr 2021 13:11:40 +0000 (16:11 +0300)] 
Use T_CONNECT timeout constant for TCP tests (instead of 1 ms)

The netmgr_test would be failing on heavily loaded systems because the
connection timeout was set to 1 ms.  Use the global constant instead.

5 years agoEnsure dig lookup is detached on UDP connect failure
Evan Hunt [Tue, 6 Apr 2021 23:49:14 +0000 (16:49 -0700)] 
Ensure dig lookup is detached on UDP connect failure

dig could hang when UDP connect failed due to a dangling lookup object.

5 years agoRefactor async callbacks and fix the double tlsdnsconnect callback
Ondřej Surý [Tue, 6 Apr 2021 16:27:38 +0000 (18:27 +0200)] 
Refactor async callbacks and fix the double tlsdnsconnect callback

The isc_nm_tlsdnsconnect() call could end up with two connect callbacks
called when the timeout fired and the TCP connection was aborted,
but the TLS handshake was not complete yet.  isc__nm_connecttimeout_cb()
forgot to clean up sock->tls.pending_req when the connect callback was
called with ISC_R_TIMEDOUT, leading to a second callback running later.

A new argument has been added to the isc__nm_*_failed_connect_cb and
isc__nm_*_failed_read_cb functions, to indicate whether the callback
needs to run asynchronously or not.

5 years agoSkip long tls_tests in the CI
Ondřej Surý [Tue, 6 Apr 2021 18:49:52 +0000 (20:49 +0200)] 
Skip long tls_tests in the CI

We already skip most of the recv_send tests in CI because they are
too timing-related to be run in overloaded environment.  This commit
adds a similar change to tls_test before we merge tls_test into
netmgr_test.

5 years agoPrevent short TLS tests from hanging in case of errors
Artem Boldariev [Tue, 6 Apr 2021 12:18:44 +0000 (15:18 +0300)] 
Prevent short TLS tests from hanging in case of errors

The tests in tls_test.c could hang in the event of a connect
error.  This commit allows the tests to bail out when such an
error occurs.

5 years agorearrange nm_teardown() to check correctness after shutting down
Evan Hunt [Sat, 3 Apr 2021 05:34:18 +0000 (22:34 -0700)] 
rearrange nm_teardown() to check correctness after shutting down

if a test failed at the beginning of nm_teardown(), the function
would abort before isc_nm_destroy() or isc_tlsctx_free() were reached;
we would then abort when nm_setup() was run for the next test case.
rearranging the teardown function prevents this problem.

5 years agoisc_nm_*connect() always return via callback
Ondřej Surý [Wed, 31 Mar 2021 16:32:32 +0000 (18:32 +0200)] 
isc_nm_*connect() always return via callback

The isc_nm_*connect() functions were refactored to always return the
connection status via the connect callback instead of sometimes returning
the hard failure directly (for example, when the socket could not be
created, or when the network manager was shutting down).

This commit changes the connect functions in all the network manager
modules, and also makes the necessary refactoring changes in places
where the connect functions are called.

5 years agomove UDP connect retries from dig into isc_nm_udpconnect()
Evan Hunt [Thu, 1 Apr 2021 21:02:03 +0000 (14:02 -0700)] 
move UDP connect retries from dig into isc_nm_udpconnect()

dig previously ran isc_nm_udpconnect() three times before giving
up, to work around a freebsd bug that caused connect() to return
a spurious transient EADDRINUSE. this commit moves the retry code
into the network manager itself, so that isc_nm_udpconnect() no
longer needs to return a result code.

5 years agoUse generic functions for reading and timers in TCP
Ondřej Surý [Wed, 31 Mar 2021 10:14:54 +0000 (12:14 +0200)] 
Use generic functions for reading and timers in TCP

The TCP module has been updated to use the generic functions from
netmgr.c instead of its own local copies.  This brings the module
mostly up to par with the TCPDNS and TLSDNS modules.

5 years agoFix and clean up handling of connect callbacks
Ondřej Surý [Wed, 31 Mar 2021 09:48:41 +0000 (11:48 +0200)] 
Fix and clean up handling of connect callbacks

Serveral problems were discovered and fixed after the change in
the connection timeout in the previous commits:

  * In TLSDNS, the connection callback was not called at all under some
    circumstances when the TCP connection had been established, but the
    TLS handshake hadn't been completed yet.  Additional checks have
    been put in place so that tls_cycle() will end early when the
    nmsocket is invalidated by the isc__nm_tlsdns_shutdown() call.

  * In TCP, TCPDNS and TLSDNS, new connections would be established
    even when the network manager was shutting down.  The new
    call isc__nm_closing() has been added and is used to bail out
    early even before uv_tcp_connect() is attempted.

5 years agoMake it possible to recover from connect timeouts
Ondřej Surý [Tue, 30 Mar 2021 07:25:09 +0000 (09:25 +0200)] 
Make it possible to recover from connect timeouts

Similarly to the read timeout, it's now possible to recover from
ISC_R_TIMEDOUT event by restarting the timer from the connect callback.

The change here also fixes platforms that missing the socket() options
to set the TCP connection timeout, by moving the timeout code into user
space.  On platforms that support setting the connect timeout via a
socket option, the timeout has been hardcoded to 2 minutes (the maximum
value of tcp-initial-timeout).

5 years agoMake it possible to recover from read timeouts
Ondřej Surý [Mon, 29 Mar 2021 08:52:05 +0000 (10:52 +0200)] 
Make it possible to recover from read timeouts

Previously, when the client timed out on read, the client socket would
be automatically closed and destroyed when the nmhandle was detached.
This commit changes the logic so that it's possible for the callback to
recover from the ISC_R_TIMEDOUT event by restarting the timer. This is
done by calling isc_nmhandle_settimeout(), which prevents the timeout
handling code from destroying the socket; instead, it continues to wait
for data.

One specific use case for multiple timeouts is serve-stale - the client
socket could be created with shorter timeout (as specified with
stale-answer-client-timeout), so we can serve the requestor with stale
answer, but keep the original query running for a longer time.

5 years agoDisable netmgr tests only when running under CI
Ondřej Surý [Wed, 31 Mar 2021 06:59:03 +0000 (08:59 +0200)] 
Disable netmgr tests only when running under CI

The full netmgr test suite is unstable when run in CI due to various
timing issues.  Previously, we enabled the full test suite only when
CI_ENABLE_ALL_TESTS environment variable was set, but that went against
original intent of running the full suite when an individual developer
would run it locally.

This change disables the full test suite only when running in the CI and
the CI_ENABLE_ALL_TESTS is not set.

5 years agoMerge branch '2608-stale-answer-client-timeout-default-off' into 'main'
Matthijs Mekking [Wed, 7 Apr 2021 12:45:48 +0000 (12:45 +0000)] 
Merge branch '2608-stale-answer-client-timeout-default-off' into 'main'

Change default stale-answer-client-timeout to off

Closes #2608

See merge request isc-projects/bind9!4862

5 years agoChange default stale-answer-client-timeout to off
Matthijs Mekking [Fri, 2 Apr 2021 12:33:54 +0000 (14:33 +0200)] 
Change default stale-answer-client-timeout to off

Using "stale-answer-client-timeout" turns out to have unforeseen
negative consequences, and thus it is better to disable the feature
by default for the time being.

5 years agoMerge branch '2582-threadsanitizer-data-race-lib-dns-zone-c-10272-7-in-zone_maintenan...
Diego dos Santos Fronza [Wed, 7 Apr 2021 12:05:05 +0000 (12:05 +0000)] 
Merge branch '2582-threadsanitizer-data-race-lib-dns-zone-c-10272-7-in-zone_maintenance' into 'main'

Resolve "ThreadSanitizer: data race lib/dns/zone.c:10272:7 in zone_maintenance"

Closes #2582

See merge request isc-projects/bind9!4864

5 years agoResolve TSAN data race in zone_maintenance
Diego Fronza [Tue, 6 Apr 2021 19:29:25 +0000 (16:29 -0300)] 
Resolve TSAN data race in zone_maintenance

Fix race between zone_maintenance and dns_zone_notifyreceive functions,
zone_maintenance was attempting to read a zone flag calling
DNS_ZONE_FLAG(zone, flag) while dns_zone_notifyreceive was updating
a flag in the same zone calling DNS_ZONE_SETFLAG(zone, ...).

The code reading the flag in zone_maintenance was not protected by the
zone's lock, to avoid a race the zone's lock is now being acquired
before an attempt to read the zone flag is made.

5 years agoMerge branch '2579-enforce-a-run-time-limit-on-unit-test-binaries' into 'main'
Michał Kępień [Wed, 7 Apr 2021 09:46:40 +0000 (09:46 +0000)] 
Merge branch '2579-enforce-a-run-time-limit-on-unit-test-binaries' into 'main'

Enforce a run time limit on unit test binaries

Closes #2579

See merge request isc-projects/bind9!4802

5 years agoEnforce a run time limit on unit test binaries
Michał Kępień [Wed, 7 Apr 2021 09:41:45 +0000 (11:41 +0200)] 
Enforce a run time limit on unit test binaries

When a unit test binary hangs, the GitLab CI job in which it is run is
stuck until its run time limit is exceeded.  Furthermore, it is not
trivial to determine which test(s) hung in a given GitLab CI job based
on its log.  To prevent these issues, enforce a run time limit on every
binary executed by the lib/unit-test-driver.sh script.  Use a timeout of
5 minutes for consistency with older BIND 9 branches, which employed
Kyua for running unit tests.  Report an exit code of 124 when the run
time limit is exceeded for a unit test binary, for consistency with the
"timeout" tool included in GNU coreutils.

5 years agoMerge branch '2611-doth-failure' into 'main'
Artem Boldariev [Wed, 7 Apr 2021 08:44:38 +0000 (08:44 +0000)] 
Merge branch '2611-doth-failure' into 'main'

Fix "doth" system test failure with SSL_ERROR_SYSCALL (5)

See merge request isc-projects/bind9!4863

5 years agoRemove dead code which was supposed to handle TLS shutdowns nicely
Artem Boldariev [Tue, 6 Apr 2021 20:44:37 +0000 (23:44 +0300)] 
Remove dead code which was supposed to handle TLS shutdowns nicely

Fixes Coverity issue CID 330954 (See #2612).

5 years agoHandle buggy situations with SSL_ERROR_SYSCALL
Artem Boldariev [Tue, 6 Apr 2021 17:57:45 +0000 (20:57 +0300)] 
Handle buggy situations with SSL_ERROR_SYSCALL

See "BUGS" section at:

https://www.openssl.org/docs/man1.1.1/man3/SSL_get_error.html

It is mentioned there that when TLS status equals SSL_ERROR_SYSCALL
AND errno == 0 it means that underlying transport layer returned EOF
prematurely.  However, we are managing the transport ourselves, so we
should just resume reading from the TCP socket.

It seems that this case has been handled properly on modern versions
of OpenSSL. That being said, the situation goes in line with the
manual: it is briefly mentioned there that SSL_ERROR_SYSCALL might be
returned not only in a case of low-level errors (like system call
failures).

5 years agoMerge branch '2613-lib-dns-gen-is-not-deleted-on-make-clean' into 'main'
Mark Andrews [Wed, 7 Apr 2021 07:18:53 +0000 (07:18 +0000)] 
Merge branch '2613-lib-dns-gen-is-not-deleted-on-make-clean' into 'main'

Resolve "lib/dns/gen is not deleted on make clean"

Closes #2613

See merge request isc-projects/bind9!4865

5 years agoremove lib/dns/gen when running 'make clean'
Mark Andrews [Tue, 6 Apr 2021 22:06:49 +0000 (08:06 +1000)] 
remove lib/dns/gen when running 'make clean'

5 years agoMerge branch '2594-servestale-staleonly-recursion-race' into 'main'
Matthijs Mekking [Fri, 2 Apr 2021 11:26:57 +0000 (11:26 +0000)] 
Merge branch '2594-servestale-staleonly-recursion-race' into 'main'

Serve-stale "staleonly" recursion race condition

See merge request isc-projects/bind9!4859

5 years agoIf RPZ config'd, bail stale-answer-client-timeout
Matthijs Mekking [Tue, 30 Mar 2021 14:05:51 +0000 (16:05 +0200)] 
If RPZ config'd, bail stale-answer-client-timeout

When we are recursing, RPZ processing is not allowed. But when we are
performing a lookup due to "stale-answer-client-timeout", we are still
recursing. This effectively means that RPZ processing is disabled on
such a lookup.

In this case, bail the "stale-answer-client-timeout" lookup and wait
for recursion to complete, as we we can't perform the RPZ rewrite
rules reliably.

5 years agoRename "staleonly"
Matthijs Mekking [Mon, 29 Mar 2021 07:46:08 +0000 (09:46 +0200)] 
Rename "staleonly"

The dboption DNS_DBFIND_STALEONLY caused confusion because it implies
we are looking for stale data **only** and ignore any active RRsets in
the cache. Rename it to DNS_DBFIND_STALETIMEOUT as it is more clear
the option is related to a lookup due to "stale-answer-client-timeout".

Rename other usages of "staleonly", instead use "lookup due to...".
Also rename related function and variable names.

5 years agoRestore the RECURSIONOK attribute after staleonly
Matthijs Mekking [Fri, 26 Mar 2021 14:18:01 +0000 (15:18 +0100)] 
Restore the RECURSIONOK attribute after staleonly

When doing a staleonly lookup we don't want to fallback to recursion.
After all, there are obviously problems with recursion, otherwise we
wouldn't do a staleonly lookup.

When resuming from recursion however, we should restore the
RECURSIONOK flag, allowing future required lookups for this client
to recurse.

5 years agoRemove result exception on staleonly lookup
Matthijs Mekking [Fri, 26 Mar 2021 13:43:07 +0000 (14:43 +0100)] 
Remove result exception on staleonly lookup

When implementing "stale-answer-client-timeout", we decided that
we should only return positive answers prematurely to clients. A
negative response is not useful, and in that case it is better to
wait for the recursion to complete.

To do so, we check the result and if it is not ISC_R_SUCCESS, we
decide that it is not good enough. However, there are more return
codes that could lead to a positive answer (e.g. CNAME chains).

This commit removes the exception and now uses the same logic that
other stale lookups use to determine if we found a useful stale
answer (stale_found == true).

This means we can simplify two test cases in the serve-stale system
test: nodata.example is no longer treated differently than data.example.

5 years agoAdd notes and changes for [#2594]
Matthijs Mekking [Fri, 26 Mar 2021 11:25:20 +0000 (12:25 +0100)] 
Add notes and changes for [#2594]

Pretty newsworthy.

5 years agoRemove INSIST on NS_QUERYATTR_ANSWERED
Matthijs Mekking [Fri, 26 Mar 2021 10:58:12 +0000 (11:58 +0100)] 
Remove INSIST on NS_QUERYATTR_ANSWERED

The NS_QUERYATTR_ANSWERED attribute is to prevent sending a response
twice. Without the attribute, this may happen if a staleonly lookup
found a useful answer and sends a response to the client, and later
recursion ends and also tries to send a response.

The attribute was also used to mask adding a duplicate RRset. This is
considered harmful. When we created a response to the client with a
stale only lookup (regardless if we actually have send the response),
we should clear the rdatasets that were added during that lookup.

Mark such rdatasets with the a new attribute,
DNS_RDATASETATTR_STALE_ADDED. Set a query attribute
NS_QUERYATTR_STALEOK if we may have added rdatasets during a stale
only lookup. Before creating a response on a normal lookup, check if
we can expect rdatasets to have been added during a staleonly lookup.
If so, clear the rdatasets from the message with the attribute
DNS_RDATASETATTR_STALE_ADDED set.

5 years agoSimplify when to detach the client
Matthijs Mekking [Thu, 25 Mar 2021 17:12:38 +0000 (18:12 +0100)] 
Simplify when to detach the client

With stale-answer-client-timeout, we may send a response to the client,
but we may want to hold on to the network manager handle, because
recursion is going on in the background, or we need to refresh a
stale RRset.

Simplify the setting of 'nodetach':
* During a staleonly lookup we should not detach the nmhandle, so just
  set it prior to 'query_lookup()'.
* During a staleonly "stalefirst" lookup set the 'nodetach' to true
  if we are going to refresh the RRset.

Now there is no longer the need to clear the 'nodetach' if we go
through the "dbfind_stale", "stale_refresh_window", or "stale_only"
paths.

5 years agoRefactor stale lookups, ignore active RRsets
Matthijs Mekking [Thu, 25 Mar 2021 16:25:32 +0000 (17:25 +0100)] 
Refactor stale lookups, ignore active RRsets

When doing a staleonly lookup, ignore active RRsets from cache. If we
don't, we may add a duplicate RRset to the message, and hit an
assertion failure in query.c because adding the duplicate RRset to the
ANSWER section failed.

This can happen on a race condition. When a client query is received,
the recursion is started. When 'stale-answer-client-timeout' triggers
around the same time the recursion completes, the following sequence
of events may happen:
1. Queue the "try stale" fetch_callback() event to the client task.
2. Add the RRsets from the authoritative response to the cache.
3. Queue the "fetch complete" fetch_callback() event to the client task.
4. Execute the "try stale" fetch_callback(), which retrieves the
   just-inserted RRset from the database.
5. In "ns_query_done()" we are still recursing, but the "staleonly"
   query attribute has already been cleared. In other words, the
   query will resume when recursion ends (it already has ended but is
   still on the task queue).
6. Execute the "fetch complete" fetch_callback(). It finds the answer
   from recursion in the cache again and tries to add the duplicate to
   the answer section.

This commit changes the logic for finding stale answers in the cache,
such that on "stale_only" lookups actually only stale RRsets are
considered. It refactors the code so that code paths for "dbfind_stale",
"stale_refresh_window", and "stale_only" are more clear.

First we call some generic code that applies in all three cases,
formatting the domain name for logging purposes, increment the
trystale stats, and check if we actually found stale data that we can
use.

The "dbfind_stale" lookup will return SERVFAIL if we didn't found a
usable answer, otherwise we will continue with the lookup
(query_gotanswer()). This is no different as before the introduction of
"stale-answer-client-timeout" and "stale-refresh-time".

The "stale_refresh_window" lookup is similar to the "dbfind_stale"
lookup: return SERVFAIL if we didn't found a usable answer, otherwise
continue with the lookup (query_gotanswer()).

Finally the "stale_only" lookup.

If the "stale_only" lookup was triggered because of an actual client
timeout (stale-answer-client-timeout > 0), and if database lookup
returned a stale usable RRset, trigger a response to the client.
Otherwise return and wait until the recursion completes (or the
resolver query times out).

If the "stale_only" lookup is a "stale-anwer-client-timeout 0" lookup,
preferring stale data over a lookup. In this case if there was no stale
data, or the data was not a positive answer, retry the lookup with the
stale options cleared, a.k.a. a normal lookup. Otherwise, continue
with the lookup (query_gotanswer()) and refresh the stale RRset. This
will trigger a response to the client, but will not detach the handle
because a fetch will be created to refresh the RRset.

5 years agoKeep track of allow client detach
Matthijs Mekking [Thu, 25 Mar 2021 13:13:35 +0000 (14:13 +0100)] 
Keep track of allow client detach

The stale-answer-client-timeout feature introduced a dependancy on
when a client may be detached from the handle. The dboption
DNS_DBFIND_STALEONLY was reused to track this attribute. This overloads
the meaning of this database option, and actually introduced a bug
because the option was checked in other places. In particular, in
'ns_query_done()' there is a check for 'RECURSING(qctx->client) &&
(!QUERY_STALEONLY(&qctx->client->query) || ...' and the condition is
satisfied because recursion has not completed yet and
DNS_DBFIND_STALEONLY is already cleared by that time (in
query_lookup()), because we found a useful answer and we should detach
the client from the handle after sending the response.

Add a new boolean to the client structure to keep track of client
detach from handle is allowed or not. It is only disallowed if we are
in a staleonly lookup and we didn't found a useful answer.

5 years agoMerge branch 'artem/tls-tests-and-fixes' into 'main'
Artem Boldariev [Thu, 1 Apr 2021 15:41:52 +0000 (15:41 +0000)] 
Merge branch 'artem/tls-tests-and-fixes' into 'main'

TLS transport code refactoring and unit tests

See merge request isc-projects/bind9!4851

5 years agoFix crash (regression) in DIG when handling non-DoH responses
Artem Boldariev [Wed, 31 Mar 2021 10:23:59 +0000 (13:23 +0300)] 
Fix crash (regression) in DIG when handling non-DoH responses

This commit fixes crash in dig when it encounters non-expected header
value. The bug was introduced at some point late in the last DoH
development cycle. Also, refactors the relevant code a little bit to
ensure better incoming data validation for client-side DoH
connections.

5 years agoTLS code refactoring, fixes and unit-tests
Artem Boldariev [Wed, 10 Mar 2021 12:30:16 +0000 (14:30 +0200)] 
TLS code refactoring, fixes and unit-tests

This commit fixes numerous stability issues with TLS transport code as
well as adds unit tests for it.

5 years agoMerge branch '2607-remove-custom-spnego' into 'main'
Ondřej Surý [Thu, 1 Apr 2021 14:14:00 +0000 (14:14 +0000)] 
Merge branch '2607-remove-custom-spnego' into 'main'

Remove custom ISC SPNEGO implementation

Closes #2607

See merge request isc-projects/bind9!4856

5 years agoAdd CHANGES and release note for GL #2607
Ondřej Surý [Thu, 1 Apr 2021 08:28:06 +0000 (10:28 +0200)] 
Add CHANGES and release note for GL #2607

5 years agoMerge branch '2538-bind-9-17-build-process-leaving-files-in-unexpected-locations...
Mark Andrews [Thu, 1 Apr 2021 09:34:17 +0000 (09:34 +0000)] 
Merge branch '2538-bind-9-17-build-process-leaving-files-in-unexpected-locations' into 'main'

Resolve "BIND 9.17 build process leaving files in unexpected locations?"

Closes #2538

See merge request isc-projects/bind9!4757

5 years agoTest dynamic libraries should not be installed
Mark Andrews [Mon, 1 Mar 2021 02:58:06 +0000 (13:58 +1100)] 
Test dynamic libraries should not be installed

Tag the libraries with check_ to prevent them being installed
by "make install".  Additionally make check requires .so to be
create which requires .lai files to be constructed which, in
turn, requires -rpath <dir> as part of "linking" the .la file.

5 years agoMerge branch 'mnowak/web-run-gcc-tarball-ci-job' into 'main'
Michal Nowak [Wed, 31 Mar 2021 14:37:15 +0000 (14:37 +0000)] 
Merge branch 'mnowak/web-run-gcc-tarball-ci-job' into 'main'

Run gcc:tarball CI job in web-triggered pipelines

See merge request isc-projects/bind9!4850

5 years agoRun gcc:tarball CI job in web-triggered pipelines
Michal Nowak [Wed, 31 Mar 2021 08:20:35 +0000 (10:20 +0200)] 
Run gcc:tarball CI job in web-triggered pipelines

The gcc:tarball CI job may identify problems with tarballs created by
"make dist" of the tarball-create CI job. Enabling the gcc:tarball CI
job in web-triggered pipelines provides developers with a test vector.

5 years agoMerge branch 'michal/include-all-pre-generated-man-pages-in-make-dist' into 'main'
Michał Kępień [Mon, 29 Mar 2021 11:08:00 +0000 (11:08 +0000)] 
Merge branch 'michal/include-all-pre-generated-man-pages-in-make-dist' into 'main'

Include all pre-generated man pages in "make dist"

See merge request isc-projects/bind9!4838

5 years agoInclude all pre-generated man pages in "make dist"
Michał Kępień [Mon, 29 Mar 2021 11:06:39 +0000 (13:06 +0200)] 
Include all pre-generated man pages in "make dist"

Some man pages (e.g. dnstap-read.1, named-nzd2nzf.1) should only be
installed conditionally (when the relevant features are enabled in a
given BIND 9 build).  This is achieved using Automake conditionals.
However, while all source reStructuredText files are included in
tarballs produced by "make dist" (distribution tarballs) as they should
be, the list of pre-generated man pages included in distribution
tarballs incorrectly depends on the ./configure switches used for the
build for which "make dist" is run.  Meanwhile, distribution tarballs
should always contain all the files necessary to build any flavor of
BIND 9.

Here is an example scenario which fails to work as intended:

    autoreconf -i
    ./configure --disable-maintainer-mode
    make dist
    tar --extract --file bind-9.17.11.tar.xz
    cd bind-9.17.11
    ./configure --disable-maintainer-mode --enable-dnstap
    make

Fix by always including pre-generated versions of all conditionally
installed man pages in EXTRA_DIST.  While this may cause some of them to
appear in EXTRA_DIST more than once (depending on the ./configure
switches used for the build for which "make dist" is run), it seems to
not be a problem for Automake.

5 years agoMerge branch '2597-make-calling-generic-rdata-methods-consistent' into 'main'
Mark Andrews [Fri, 26 Mar 2021 22:27:51 +0000 (22:27 +0000)] 
Merge branch '2597-make-calling-generic-rdata-methods-consistent' into 'main'

Resolve "Make calling generic rdata methods consistent"

Closes #2597

See merge request isc-projects/bind9!4834

5 years agoMake calling generic rdata methods consistent
Mark Andrews [Fri, 17 Jul 2020 02:23:19 +0000 (12:23 +1000)] 
Make calling generic rdata methods consistent

add matching macros to pass arguments from called methods
to generic methods.  This will reduce the amount of work
required when extending methods.

Also cleanup unnecessary UNUSED declarations.

5 years agoMerge branch 'bind-dyndb-ldap-v9.16.13' into 'main'
Ondřej Surý [Fri, 26 Mar 2021 18:43:18 +0000 (18:43 +0000)] 
Merge branch 'bind-dyndb-ldap-v9.16.13' into 'main'

Do not require config.h to use isc/util.h

See merge request isc-projects/bind9!4840