]> git.ipfire.org Git - thirdparty/bind9.git/log
thirdparty/bind9.git
3 years agoMerge branch '3724-update-dig-tcp-documentation' into 'main'
Mark Andrews [Wed, 7 Dec 2022 21:59:25 +0000 (21:59 +0000)] 
Merge branch '3724-update-dig-tcp-documentation' into 'main'

Resolve "Update dig +tcp documentation"

Closes #3724

See merge request isc-projects/bind9!7172

3 years agoAdd reference to +tcp for +ignore
Mark Andrews [Wed, 7 Dec 2022 04:51:34 +0000 (15:51 +1100)] 
Add reference to +tcp for +ignore

3 years agoMerge branch '3676-remove-operating-system-resource-limits' into 'main'
Ondřej Surý [Wed, 7 Dec 2022 18:50:30 +0000 (18:50 +0000)] 
Merge branch '3676-remove-operating-system-resource-limits' into 'main'

Mark setting operating system limits from named.conf as ancient

Closes #3676

See merge request isc-projects/bind9!7079

3 years agoAdd CHANGES and release note for [GL #3676]
Ondřej Surý [Sun, 13 Nov 2022 10:21:45 +0000 (11:21 +0100)] 
Add CHANGES and release note for [GL #3676]

3 years agoRemove isc_resource API and set limits directly in named_os unit
Ondřej Surý [Sun, 13 Nov 2022 10:04:30 +0000 (11:04 +0100)] 
Remove isc_resource API and set limits directly in named_os unit

The only function left in the isc_resource API was setting the file
limit.  Replace the whole unit with a simple getrlimit to check the
maximum value of RLIMIT_NOFILE and set the maximum back to rlimit_cur.

This is more compatible than trying to set RLIMIT_UNLIMITED on the
RLIMIT_NOFILE as it doesn't work on Linux (see man 5 proc on
/proc/sys/fs/nr_open), neither it does on Darwin kernel (see man 2
getrlimit).

The only place where the maximum value could be raised under privileged
user would be BSDs, but the `named_os_adjustnofile()` were not called
there before.  We would apply the increased limits only on Linux and Sun
platforms.

3 years agoMark setting operating system limits from named.conf as ancient
Ondřej Surý [Sun, 13 Nov 2022 09:28:17 +0000 (10:28 +0100)] 
Mark setting operating system limits from named.conf as ancient

After deprecating the operating system limits settings (coresize,
datasize, files and stacksize), mark them as ancient and remove the code
that sets the values from config.

3 years agoMerge branch 'ondrej-fix-missing-zone_check-in-checkds-system-test' into 'main'
Ondřej Surý [Wed, 7 Dec 2022 18:14:34 +0000 (18:14 +0000)] 
Merge branch 'ondrej-fix-missing-zone_check-in-checkds-system-test' into 'main'

Fix missing zone_check() call in checkds test

See merge request isc-projects/bind9!7161

3 years agoFix missing zone_check() call in checkds test
Ondřej Surý [Sun, 4 Dec 2022 13:50:54 +0000 (14:50 +0100)] 
Fix missing zone_check() call in checkds test

The bad2-dswithdrawn.checkds tests were missing call to the
zone_checks() contributing to intermittent timing failures of the
checkds system test.

3 years agoMerge branch '3708-remove-dead-code-from-dns_cache-unit' into 'main'
Ondřej Surý [Wed, 7 Dec 2022 18:11:32 +0000 (18:11 +0000)] 
Merge branch '3708-remove-dead-code-from-dns_cache-unit' into 'main'

Remove dead code from dns_cache_flush()

Closes #3708

See merge request isc-projects/bind9!7141

3 years agoRemove dead code from dns_cache_flush()
Ondřej Surý [Wed, 30 Nov 2022 10:33:33 +0000 (11:33 +0100)] 
Remove dead code from dns_cache_flush()

After removing the cache cleaning mechanism, we don't need to db
iterator in dns_cache_flush() anymore.

3 years agoMerge branch '3183-send-shutdown-to-ns_client-on-shutdown' into 'main'
Ondřej Surý [Wed, 7 Dec 2022 17:08:24 +0000 (17:08 +0000)] 
Merge branch '3183-send-shutdown-to-ns_client-on-shutdown' into 'main'

Propagate the shutdown event to the recursing ns_client(s)

Closes #3183

See merge request isc-projects/bind9!7027

3 years agoAdd CHANGES and release notes for [GL #3183]
Ondřej Surý [Thu, 3 Nov 2022 17:01:22 +0000 (18:01 +0100)] 
Add CHANGES and release notes for [GL #3183]

3 years agoPropagate the shutdown event to the recursing ns_client(s)
Ondřej Surý [Thu, 3 Nov 2022 16:42:12 +0000 (17:42 +0100)] 
Propagate the shutdown event to the recursing ns_client(s)

Send the ns_query_cancel() on the recursing clients when we initiate the
named shutdown for faster shutdown.

When we are shutting down the resolver, we cancel all the outstanding
fetches, and the ISC_R_CANCEL events doesn't propagate to the ns_client
callback.

In the future, the better solution how to fix this would be to look at
the shutdown paths and let them all propagate from bottom (loopmgr) to
top (f.e. ns_client).

3 years agoMerge branch '3712-fix-reference-counting-in-dns_adb-get_attached_entry' into 'main'
Ondřej Surý [Wed, 7 Dec 2022 15:16:50 +0000 (15:16 +0000)] 
Merge branch '3712-fix-reference-counting-in-dns_adb-get_attached_entry' into 'main'

Fix reference counting in get_attached_entry

Closes #3712

See merge request isc-projects/bind9!7168

3 years agoFix reference counting in get_attached_entry
Ondřej Surý [Tue, 6 Dec 2022 14:59:35 +0000 (15:59 +0100)] 
Fix reference counting in get_attached_entry

When get_attached_entry() encounters entry that would be expired, it
needs to get reference to the entry before calling maybe_expire_entry(),
so the ADB entry doesn't get destroyed inside the its own lock.

3 years agoMerge branch 'matthijs-document-ns-minimal-responses' into 'main'
Matthijs Mekking [Wed, 7 Dec 2022 11:19:20 +0000 (11:19 +0000)] 
Merge branch 'matthijs-document-ns-minimal-responses' into 'main'

Document NS queries are excempt from minimal-responses

See merge request isc-projects/bind9!7072

3 years agoDocument NS queries are excempt from minimal-responses
Matthijs Mekking [Fri, 11 Nov 2022 09:23:04 +0000 (10:23 +0100)] 
Document NS queries are excempt from minimal-responses

Also document that DNSKEY, DS, CDNSKEY, and CDS never do additional
section processing.

3 years agoMerge branch 'mnowak/asan-tsan-respdiff-jobs' into 'main'
Michal Nowak [Wed, 7 Dec 2022 07:26:21 +0000 (07:26 +0000)] 
Merge branch 'mnowak/asan-tsan-respdiff-jobs' into 'main'

Add ASAN- and TSAN-enabled respdiff jobs

See merge request isc-projects/bind9!7115

3 years agoAdd ASAN- and TSAN-enabled respdiff jobs
Michal Nowak [Tue, 22 Nov 2022 09:27:17 +0000 (10:27 +0100)] 
Add ASAN- and TSAN-enabled respdiff jobs

Neither of the new CI jobs can reliably pass at the moment; hence they
are defined with "allow_failure: true" until issues in the code base are
resolved.

3 years agoExtract TSAN parsing code
Michal Nowak [Tue, 22 Nov 2022 10:51:23 +0000 (11:51 +0100)] 
Extract TSAN parsing code

3 years agoMerge branch '3683-use-after-free-in-catalog-zone-processing' into 'main'
Mark Andrews [Tue, 6 Dec 2022 22:29:46 +0000 (22:29 +0000)] 
Merge branch '3683-use-after-free-in-catalog-zone-processing' into 'main'

Resolve "use after free in catalog zone processing"

Closes #3683

See merge request isc-projects/bind9!7137

3 years agoAdd release note for [GL #3683]
Mark Andrews [Wed, 30 Nov 2022 07:56:53 +0000 (18:56 +1100)] 
Add release note for [GL #3683]

3 years agoAdd CHANGES note for [GL #3683]
Mark Andrews [Wed, 30 Nov 2022 07:54:18 +0000 (18:54 +1100)] 
Add CHANGES note for [GL #3683]

3 years agoCheck that restored catalog zone works
Mark Andrews [Wed, 30 Nov 2022 08:32:11 +0000 (19:32 +1100)] 
Check that restored catalog zone works

Using a restored catalog zone excercised a use-after-free bug.
The test checks that the use-after-free bug is gone and is just
a reasonable behaviour check in its own right.

3 years agoAdd missing DbC magic checks
Mark Andrews [Thu, 1 Dec 2022 01:51:30 +0000 (12:51 +1100)] 
Add missing DbC magic checks

Checking for value != NULL is not sufficient to detect use after
free errors.

3 years agoCall dns_db_updatenotify_unregister earlier
Mark Andrews [Wed, 30 Nov 2022 07:44:37 +0000 (18:44 +1100)] 
Call dns_db_updatenotify_unregister earlier

dns_db_updatenotify_unregister needed to be called earlier to ensure
that listener->onupdate_arg always points to a valid object.  The
existing lazy cleanup in rbtdb_free did not ensure that.

3 years agoSuppress duplicate dns_db_updatenotify_register registrations
Mark Andrews [Wed, 30 Nov 2022 07:40:27 +0000 (18:40 +1100)] 
Suppress duplicate dns_db_updatenotify_register registrations

Duplicate dns_db_updatenotify_register registrations need to be
suppressed to ensure that dns_db_updatenotify_unregister is successful.

3 years agoMerge branch '3678-serve-stale-servfailing-unexpectedly' into 'main'
Arаm Sаrgsyаn [Tue, 6 Dec 2022 14:53:16 +0000 (14:53 +0000)] 
Merge branch '3678-serve-stale-servfailing-unexpectedly' into 'main'

Resolve "stale-serve and RPZ put in SERVFAIL cache unexpected record"

Closes #3678

See merge request isc-projects/bind9!7096

3 years agoAdd a CHANGES note for [GL #3678]
Aram Sargsyan [Thu, 17 Nov 2022 14:21:31 +0000 (14:21 +0000)] 
Add a CHANGES note for [GL #3678]

3 years agoConsider non-stale data when in serve-stale mode
Matthijs Mekking [Thu, 17 Nov 2022 13:52:26 +0000 (13:52 +0000)] 
Consider non-stale data when in serve-stale mode

With 'stale-answer-enable yes;' and 'stale-answer-client-timeout off;',
consider the following situation:

A CNAME record and its target record are in the cache, then the CNAME
record expires, but the target record is still valid.

When a new query for the CNAME record arrives, and the query fails,
the stale record is used, and then the query "restarts" to follow
the CNAME target. The problem is that the query's multiple stale
options (like DNS_DBFIND_STALEOK) are not reset, so 'query_lookup()'
treats the restarted query as a lookup following a failed lookup,
and returns a SERVFAIL answer when there is no stale data found in the
cache, even if there is valid non-stale data there available.

With this change, query_lookup() now considers non-stale data in the
cache in the first place, and returns it if it is available.

3 years agoAdd serve-stale CNAME check with stale-answer-client-timeout off
Aram Sargsyan [Thu, 17 Nov 2022 13:48:36 +0000 (13:48 +0000)] 
Add serve-stale CNAME check with stale-answer-client-timeout off

Prime the cache with the following records:

    shortttl.cname.example. 1 IN CNAME longttl.target.example.
    longttl.target.example. 600 IN A 10.53.0.2

Wait for the CNAME record to expire, disable the authoritative server,
and query 'shortttl.cname.example' again, expecting a stale answer.

3 years agoMerge branch '3697-reject-zones-with-ds-records-not-at-delegations' into 'main'
Mark Andrews [Tue, 6 Dec 2022 13:07:00 +0000 (13:07 +0000)] 
Merge branch '3697-reject-zones-with-ds-records-not-at-delegations' into 'main'

Resolve "Reject zones with DS records not at delegations"

Closes #3697

See merge request isc-projects/bind9!7116

3 years agoAdd CHANGES note for [GL #3697]
Mark Andrews [Thu, 24 Nov 2022 00:19:13 +0000 (11:19 +1100)] 
Add CHANGES note for [GL #3697]

3 years agoCheck that DS records are only present at delegations
Mark Andrews [Thu, 24 Nov 2022 00:10:58 +0000 (11:10 +1100)] 
Check that DS records are only present at delegations

This extends the integrity check to look for stray DS records
in the zone.

3 years agoMerge branch '3721-the-nslookup-command-does-not-obey-the-port-option-when-record...
Mark Andrews [Mon, 5 Dec 2022 22:19:23 +0000 (22:19 +0000)] 
Merge branch '3721-the-nslookup-command-does-not-obey-the-port-option-when-record-type-any-is-used' into 'main'

Resolve "The nslookup command does not obey the port option when record type ANY is used."

Closes #3721

See merge request isc-projects/bind9!7162

3 years agoAdd CHANGES note for [GL #3721]
Mark Andrews [Sun, 4 Dec 2022 22:27:13 +0000 (09:27 +1100)] 
Add CHANGES note for [GL #3721]

3 years agoRemember that the port was set in host and nslookup
Mark Andrews [Sun, 4 Dec 2022 22:21:35 +0000 (09:21 +1100)] 
Remember that the port was set in host and nslookup

Set 'port_set = true;' so that the TCP/DOT/DOH code doesn't reset
the port when making connections.

3 years agoAdd checks for 'host'
Mark Andrews [Sun, 4 Dec 2022 23:08:54 +0000 (10:08 +1100)] 
Add checks for 'host'

3 years agoCheck ANY lookup using nslookup
Mark Andrews [Sun, 4 Dec 2022 22:18:51 +0000 (09:18 +1100)] 
Check ANY lookup using nslookup

3 years agoMerge branch '3633-cid-361427-error-handling-issues-in-lib-dns-rdata-c' into 'main'
Mark Andrews [Sun, 4 Dec 2022 23:16:53 +0000 (23:16 +0000)] 
Merge branch '3633-cid-361427-error-handling-issues-in-lib-dns-rdata-c' into 'main'

Resolve "CID 361427: Error handling issues in lib/dns/rdata.c"

Closes #3633

See merge request isc-projects/bind9!7056

3 years agoAdd RUNTIME_CHECK for dns_rdata_tostruct
Mark Andrews [Tue, 8 Nov 2022 13:06:52 +0000 (13:06 +0000)] 
Add RUNTIME_CHECK for dns_rdata_tostruct

3 years agoMerge branch 'artem-tls-check-for-recv_cb' into 'main'
Artem Boldariev [Fri, 2 Dec 2022 12:11:41 +0000 (12:11 +0000)] 
Merge branch 'artem-tls-check-for-recv_cb' into 'main'

TLS: check for sock->recv_cb when handling received data

See merge request isc-projects/bind9!7158

3 years agoTLS: check for sock->recv_cb when handling received data
Artem Boldariev [Tue, 22 Nov 2022 13:11:57 +0000 (15:11 +0200)] 
TLS: check for sock->recv_cb when handling received data

This commit adds a check if 'sock->recv_cb' might have been nullified
during the call to 'sock->recv_cb'. That could happen, e.g. by an
indirect call to 'isc_nmhandle_close()' from within the callback when
wrapping up.

In this case, let's close the TLS connection.

3 years agoMerge branch 'artem-tls-doh-listeners-avoid-acessing-non-atomic-flags-on-handshake...
Artem Boldariev [Fri, 2 Dec 2022 11:18:56 +0000 (11:18 +0000)] 
Merge branch 'artem-tls-doh-listeners-avoid-acessing-non-atomic-flags-on-handshake-or-accept' into 'main'

TLS and DoH: Avoid accessing non-atomic listener socket flags during HS/when accepting a caonnection

See merge request isc-projects/bind9!7155

3 years agoDoH: Avoid accessing non-atomic listener socket flags when accepting
Artem Boldariev [Fri, 2 Dec 2022 08:41:28 +0000 (10:41 +0200)] 
DoH: Avoid accessing non-atomic listener socket flags when accepting

This commit ensures that the non-atomic flags inside a DoH listener
socket object (and associated worker) are accessed when doing accept
for a connection only from within the context of the dedicated thread,
but not other worker threads.

The purpose of this commit is to avoid TSAN errors during
isc__nmsocket_closing() calls. It is a continuation of
4b5559cd8f41e67bf03e92d9d0338dee9d549b48.

3 years agoTLS: Avoid accessing non-atomic listener socket flags during HS
Artem Boldariev [Thu, 1 Dec 2022 20:42:54 +0000 (22:42 +0200)] 
TLS: Avoid accessing non-atomic listener socket flags during HS

This commit ensures that the non-atomic flags inside a TLS listener
socket object (and associated worker) are accessed when doing
handshake for a connection only from within the context of the
dedicated thread, but not other worker threads.

The purpose of this commit is to avoid TSAN errors during
isc__nmsocket_closing() calls. It is a continuation of
4b5559cd8f41e67bf03e92d9d0338dee9d549b48.

3 years agoMerge branch 'tkrizek/system-tests-prereqs' into 'main'
Tom Krizek [Fri, 2 Dec 2022 09:44:29 +0000 (09:44 +0000)] 
Merge branch 'tkrizek/system-tests-prereqs' into 'main'

Unify system test feature detection and add missing prerequisites

See merge request isc-projects/bind9!7151

3 years agoAdd dnstap prerequisite for dnstap system test
Tom Krizek [Thu, 1 Dec 2022 09:52:56 +0000 (10:52 +0100)] 
Add dnstap prerequisite for dnstap system test

3 years agoAdd libnghttp2 prerequisite for doth system test
Tom Krizek [Wed, 30 Nov 2022 16:44:27 +0000 (17:44 +0100)] 
Add libnghttp2 prerequisite for doth system test

While some of these tests are for DoT which doesn't require nghttp2,
the server configs won't allow the server to start without nghttp2
support during compile time.

It might be possible to split these tests into DoT and DoH and only
require nghttp2 for DoH tests, but since almost all of our CI jobs are
compiled with nghttp2, we wouldn't gain a lot of coverage, so it's
probably not worth the effort.

3 years agoAdd lmdb prerequisite for nzd2nzf system test
Tom Krizek [Wed, 30 Nov 2022 16:43:56 +0000 (17:43 +0100)] 
Add lmdb prerequisite for nzd2nzf system test

3 years agoCheck for pkcs11-tool in keyfromlabel system test
Tom Krizek [Fri, 23 Sep 2022 13:25:31 +0000 (15:25 +0200)] 
Check for pkcs11-tool in keyfromlabel system test

pkcs11-tool which is typically part of the opensc package is required
for the keyfromlabel test.

3 years agoUse feature-test feature detection in pytests
Tom Krizek [Thu, 1 Dec 2022 14:21:22 +0000 (15:21 +0100)] 
Use feature-test feature detection in pytests

Avoid using the environment variables for feature detection and use the
feature-test utility instead.

Remove the obsolete environment variables from conf.sh, since they're no
longer used anywhere.

3 years agoUse feature-test to detect feature support in system tests
Tom Krizek [Thu, 1 Dec 2022 14:12:28 +0000 (15:12 +0100)] 
Use feature-test to detect feature support in system tests

Previously, there were two different ways to detect feature support.
Either through an environment variable set by configure in conf.sh, or
using the feature-test utility.

It is more simple and consistent to have only one way of detecting the
feature support. Using the feature-test utility seems superior the the
environment variables set by configure.

3 years agoAdd missing options to feature-test utility
Tom Krizek [Thu, 1 Dec 2022 14:08:36 +0000 (15:08 +0100)] 
Add missing options to feature-test utility

3 years agoMerge branch 'artem-tls-listener-avoid-acessing-flags-on-accept' into 'main'
Artem Boldariev [Thu, 1 Dec 2022 20:00:35 +0000 (20:00 +0000)] 
Merge branch 'artem-tls-listener-avoid-acessing-flags-on-accept' into 'main'

TLS: Avoid accessing listener socket flags from other threads when accepting a connection

See merge request isc-projects/bind9!7154

3 years agoTLS: Avoid accessing listener socket flags from other threads
Artem Boldariev [Wed, 30 Nov 2022 20:58:13 +0000 (22:58 +0200)] 
TLS: Avoid accessing listener socket flags from other threads

This commit ensures that the flags inside a TLS listener socket
object (and associated worker) are accessed when accepting a
connection only from within the context of the dedicated thread, but
not other worker threads.

3 years agoMerge branch 'ondrej-fix-single-read-tlsdns-client' into 'main'
Ondřej Surý [Thu, 1 Dec 2022 18:06:45 +0000 (18:06 +0000)] 
Merge branch 'ondrej-fix-single-read-tlsdns-client' into 'main'

Honour single read per client isc_nm_read() call in the TLSDNS

See merge request isc-projects/bind9!7152

3 years agoHonour single read per client isc_nm_read() call in the TLSDNS
Ondřej Surý [Thu, 1 Dec 2022 17:31:05 +0000 (18:31 +0100)] 
Honour single read per client isc_nm_read() call in the TLSDNS

The TLSDNS transport was not honouring the single read callback for
TLSDNS client.  It would call the read callbacks repeatedly in case the
single TLS read would result in multiple DNS messages in the decoded
buffer.

3 years agoMerge branch '3709-fix-dns_resolver-hash-tables' into 'main'
Ondřej Surý [Thu, 1 Dec 2022 13:35:08 +0000 (13:35 +0000)] 
Merge branch '3709-fix-dns_resolver-hash-tables' into 'main'

Refactor the dns_resolver fetch context hash tables and locking

Closes #3709

See merge request isc-projects/bind9!7142

3 years agoAdd CHANGES note for [GL #3709]
Ondřej Surý [Wed, 30 Nov 2022 10:43:20 +0000 (11:43 +0100)] 
Add CHANGES note for [GL #3709]

3 years agoRefactor the dns_resolver fetch context hash tables and locking
Ondřej Surý [Fri, 4 Nov 2022 14:04:29 +0000 (15:04 +0100)] 
Refactor the dns_resolver fetch context hash tables and locking

This is second in the series of fixing the usage of hashtables in the
dns_adb and the dns_resolver units.

Currently, the fetch buckets (used to hold the fetch context) and zone
buckets (used to hold per-domain counters) would never get cleaned from
the memory.  Combined with the fact that the hashtable now grows as
needed (instead of using hashtable as buckets), the memory usage in the
resolver can just grow and it never drops down.

In this commit, the usage of hashtables (hashmaps) has been completely
rewritten, so there are no "buckets" and all the matching conditions are
directly mapped into the hashtable key:

 1. For per-domain counter hashtable, this is simple as the lowercase
    domain name is used directly as a counter.

 2. For fetch context hashtable, this requires copying some extra flags
    back and forth in the key.

As we don't hold the "buckets" forever, the cleaning mechanism has been
rewritten as well:

 1. For per-domain counter hashtable, this is again much simpler, as we
    only need to check whether the usage counter is still zero under the
    lock and bail-out on cleaning if the counter is in use.

 2. For fetch context hashtable, this is more complicated as the fetch
    context cannot be reused after it has been finished.  The algorithm
    is different, the fetch context is always removed from the
    hashtable, but if we find the fetch context that has been marked
    as finished in the lookup function, we help with the cleaning from
    the hashtable and try again.

Couple of additional changes have been implemented in this refactoring
as those were needed for correct functionality and could not be split
into individual commits (or would not make sense as seperate commits):

 1. The dns_resolver_createfetch() has an option to create "unshared"
    fetch.  The "unshared" fetch will never get matched, so there's
    little point in storing the "unshared" fetch in the hashtable.
    Therefore the "unshared" fetches are now detached from the
    hashtable and live just on their own.

 2. Replace the custom reference counting with ISC_REFCOUNT_DECL/IMPL
    macros for better tracing.

 3. fctx_done_detach() is idempotent, it makes the "final" detach (the
    one matching the create function) only once.  But that also means
    that it has to be called before the detach that kept the fetch
    context alive in the callback.  A new macro fctx_done_unref() has
    been added to allow this code flow:

    fctx_done_unref(fctx, result);
    fctx_detach(&fctx);

    Doing this the other way around could cause fctx to get destroyed in
    the fctx_unref() first and fctx_done_detach() would cause UAF.

 4. The resume_qmin() and resume_dslookup() callbacks have been
    refactored for more readability and simpler code paths.  The
    validated() callback has also received some of the simplifications,
    but it should be refactored in the future as it is bit of spaghetti
    now.

3 years agoMerge branch 'each-cache-use-loops' into 'main' 7148/head
Evan Hunt [Wed, 30 Nov 2022 20:12:29 +0000 (20:12 +0000)] 
Merge branch 'each-cache-use-loops' into 'main'

change cache cleaning to use loops instead of tasks

See merge request isc-projects/bind9!7136

3 years agochange dns_db_settask() to _setloop()
Evan Hunt [Thu, 27 Oct 2022 05:36:04 +0000 (22:36 -0700)] 
change dns_db_settask() to _setloop()

The mechanism for associating a worker task to a database now
uses loops rather than tasks.

For this reason, the parameters to dns_cache_create() have been
updated to take a loop manager rather than a task manager.

3 years agoMerge branch 'artem-tls-tcp-compatibility-fixes' into 'main'
Artem Boldariev [Wed, 30 Nov 2022 16:30:03 +0000 (16:30 +0000)] 
Merge branch 'artem-tls-tcp-compatibility-fixes' into 'main'

TLS Stream: TCP transport compatibility fixes

See merge request isc-projects/bind9!7127

3 years agoTLS stream: always handle send callbacks asynchronously
Artem Boldariev [Fri, 28 Oct 2022 16:08:50 +0000 (19:08 +0300)] 
TLS stream: always handle send callbacks asynchronously

This commit ensures that send callbacks are always called from within
the context of its worker thread even in the case of
shuttigdown/inactive socket, just like TCP transport does and with
which TLS attempts to be as compatible as possible.

3 years agoTLS Stream: use ISC_R_CANCELLED error when shutting down
Artem Boldariev [Thu, 27 Oct 2022 18:16:36 +0000 (21:16 +0300)] 
TLS Stream: use ISC_R_CANCELLED error when shutting down

This commit changes ISC_R_NOTCONNECTED error code to ISC_R_CANCELLED
when attempting to start reading data on the shutting down socket in
order to make its behaviour compatible with that of TCP and not break
the common code in the unit tests.

3 years agoTLS Stream: fix isc_nm_read_stop() and reading flags handling
Artem Boldariev [Thu, 27 Oct 2022 17:13:06 +0000 (20:13 +0300)] 
TLS Stream: fix isc_nm_read_stop() and reading flags handling

It turned out that after the latest Network Manager refactoring
'sock->reading' flag was not processed correctly. Due to this
isc_nm_read_stop() might not work as expected because reading from the
underlying TCP socket could have been resume in 'tls_do_bio()'
regardless of the 'sock->reading' value.

This bug did not seem to cause problems with DoH, so it was not
noticed, but Stream DNS has more strict expectations regarding the
underlying transport.

Additionally to the above, the 'sock->recv_read' flag was completely
ignored and corresponding logic was completely unimplemented. That did
not allow to implement one fine detail compared to TCP: once reading
is started, it could be satisfied by one datum reading.

This commit fixes the issues above.

3 years agoMerge branch 'matthijs-deprecate-alt-transfer-source' into 'main'
Matthijs Mekking [Wed, 30 Nov 2022 15:50:26 +0000 (15:50 +0000)] 
Merge branch 'matthijs-deprecate-alt-transfer-source' into 'main'

Deprecate alt-transfer-source and companions

Closes #3694

See merge request isc-projects/bind9!7105

3 years agoMention deprecation of alternate transfer source
Matthijs Mekking [Wed, 23 Nov 2022 07:18:32 +0000 (08:18 +0100)] 
Mention deprecation of alternate transfer source

In the CHANGES and release notes.

3 years agoAdd missing deprecated tag to max-zone-ttl
Matthijs Mekking [Wed, 23 Nov 2022 07:16:38 +0000 (08:16 +0100)] 
Add missing deprecated tag to max-zone-ttl

This option was deprecated in commit 19352dd1877 but at that time
we didn't mark it deprecated in the ARM reference.

3 years agoDeprecate alt-transfer-source and companions
Matthijs Mekking [Wed, 23 Nov 2022 07:13:25 +0000 (08:13 +0100)] 
Deprecate alt-transfer-source and companions

Deprecate the alternate transfer sources from BIND 8.

3 years agoMerge branch 'marka/log-type-with-stale-answer-log-messages' into 'main'
Michał Kępień [Wed, 30 Nov 2022 14:00:20 +0000 (14:00 +0000)] 
Merge branch 'marka/log-type-with-stale-answer-log-messages' into 'main'

Log type with stale answer log messages

See merge request isc-projects/bind9!7145

3 years agoAdd CHANGES entry for GL !7145
Michał Kępień [Wed, 30 Nov 2022 13:32:58 +0000 (14:32 +0100)] 
Add CHANGES entry for GL !7145

3 years agoLog type with stale answer log messages
Mark Andrews [Thu, 27 Oct 2022 22:00:45 +0000 (09:00 +1100)] 
Log type with stale answer log messages

Add more information about which query type is dealing with serve-stale.
Update the expected log messages in the serve-stale system test.

3 years agoMerge branch 'matthijs/update-serve-stale-test-messages-to-include-rrtype' into ...
Michał Kępień [Wed, 30 Nov 2022 13:29:14 +0000 (13:29 +0000)] 
Merge branch 'matthijs/update-serve-stale-test-messages-to-include-rrtype' into 'main'

Update serve-stale test messages to include RRtype

See merge request isc-projects/bind9!7140

3 years agoUpdate serve-stale test messages to include RRtype
Matthijs Mekking [Tue, 8 Nov 2022 12:22:28 +0000 (13:22 +0100)] 
Update serve-stale test messages to include RRtype

3 years agoMerge branch '3706-compress-xfer' into 'main'
Tony Finch [Wed, 30 Nov 2022 13:11:13 +0000 (13:11 +0000)] 
Merge branch '3706-compress-xfer' into 'main'

Compress zone transfers properly

Closes #3706

See merge request isc-projects/bind9!7135

3 years agoCompress zone transfers properly
Tony Finch [Tue, 29 Nov 2022 20:23:31 +0000 (20:23 +0000)] 
Compress zone transfers properly

After change 5995, zone transfers were using a small
compression context that only had space for the first
few dozen names in each message. They now use a large
compression context with enough space for every name.

3 years agoMerge branch '3707-dont-log-final-reference-detached-on-LOG_INFO' into 'main'
Ondřej Surý [Wed, 30 Nov 2022 10:46:53 +0000 (10:46 +0000)] 
Merge branch '3707-dont-log-final-reference-detached-on-LOG_INFO' into 'main'

Don't log "final reference detached" on INFO level

Closes #3707

See merge request isc-projects/bind9!7139

3 years agoAdd CHANGES and release note for [GL #3707]
Ondřej Surý [Wed, 30 Nov 2022 09:56:52 +0000 (10:56 +0100)] 
Add CHANGES and release note for [GL #3707]

3 years agoDon't log "final reference detached" on INFO level
Ondřej Surý [Wed, 30 Nov 2022 09:46:40 +0000 (10:46 +0100)] 
Don't log "final reference detached" on INFO level

The "final reference detached" message was meant to be DEBUG(1), but was
instead kept at INFO level.  Move it to the DEBUG(1) logging level, so
it's not printed under normal operations.

3 years agoMerge branch '3239-fix-cleaning-of-adb-buckets' into 'main'
Ondřej Surý [Wed, 30 Nov 2022 09:35:18 +0000 (09:35 +0000)] 
Merge branch '3239-fix-cleaning-of-adb-buckets' into 'main'

Refactor the dns_adb unit

Closes #3239, #3238, #2615, #2078, #2437, #3312, and #2441

See merge request isc-projects/bind9!7138

3 years agoAdd CHANGES note for [GL #3239]
Ondřej Surý [Wed, 30 Nov 2022 09:13:29 +0000 (10:13 +0100)] 
Add CHANGES note for [GL #3239]

3 years agoKeep the unlink adb entries until expiration
Ondřej Surý [Wed, 23 Nov 2022 08:56:19 +0000 (09:56 +0100)] 
Keep the unlink adb entries until expiration

Currently, the ADB uses TTL of 0 for ADB names that the server is
authoritative for and TTL of 10 seconds for HINT and GLUE ADB names.

This requires the unlinked ADB entries to be kept around, because they
would disappear too quickly.  This especially affect the root zone as
the trust level is "ultimate" for the root zone nameservers.

This commit restores the ability to keep the unlinked ADB entries in the
database for later reuse, restores printing the unlinked entries and
adds some extra cleaning of the unlinked ADB entries on the tail of the
LRU list (similar to what we are doing for the ADB names).

3 years agoRefactor the dns_adb unit
Ondřej Surý [Thu, 13 Oct 2022 10:00:54 +0000 (12:00 +0200)] 
Refactor the dns_adb unit

The dns_adb unit has been refactored to be much simpler.  Following
changes have been made:

1. Simplify the ADB to always allow GLUE and hints

   There were only two places where dns_adb_createfind() was used - in
   the dns_resolver unit where hints and GLUE addresses were ok, and in
   the dns_zone where dns_adb_createfind() would be called without
   DNS_ADBFIND_HINTOK and DNS_ADBFIND_GLUEOK set.

   Simplify the logic by allowing hint and GLUE addresses when looking
   up the nameserver addresses to notify.  The difference is negligible
   and would cause a difference in the notified addresses only when
   there's mismatch between the parent and child addresses and we
   haven't cached the child addresses yet.

2. Drop the namebuckets and entrybuckets

   Formerly, the namebuckets and entrybuckets were used to reduced the
   lock contention when accessing the double-linked lists stored in each
   bucket.  In the previous refactoring, the custom hashtable for the
   buckets has been replaced with isc_ht/isc_hashmap, so only a single
   item (mostly, see below) would end up in each bucket.

   Removing the entrybuckets has been straightforward, the only matching
   was done on the isc_sockaddr_t member of the dns_adbentry.

   Removing the zonebuckets required GLUEOK and HINTOK bits to be
   removed because the find could match entries with-or-without the bits
   set, and creating a custom key that stores the
   DNS_ADBFIND_STARTATZONE in the first byte of the key, so we can do a
   straightforward lookup into the hashtable without traversing a list
   that contains items with different flags.

3. Remove unassociated entries from ADB database

   Previously, the adbentries could live in the ADB database even after
   unlinking them from dns_adbnames.  Such entries would show up as
   "Unassociated entries" in the ADB dump.  The benefit of keeping such
   entries is little - the chance that we link such entry to a adbname
   is small, and it's simpler to evict unlinked entries from the ADB
   cache (and the hashtable) than create second LRU cleaning mechanism.

   Unlinked ADB entries are now directly deleted from the hash
   table (hashmap) upon destruction.

4. Cleanup expired entries from the hash table

   When buckets were still in place, the code would keep the buckets
   always allocated and never shrink the hash table (hashmap).  With
   proper reference counting in place, we can delete the adbnames from
   the hash table and the LRU list.

5. Stop purging the names early when we hit the time limit

   Because the LRU list is now time ordered, we can stop purging the
   names when we find a first entry that doesn't fullfil our time-based
   eviction criteria because no further entry on the LRU list will meet
   the criteria.

Future work:

1. Lock contention

   In this commit, the focus was on correctness of the data structure,
   but in the future, the lock contention in the ADB database needs to
   be addressed.  Currently, we use simple mutex to lock the hash
   tables, because we almost always need to use a write lock for
   properly purging the hashtables.  The ADB database needs to be
   sharded (similar to the effect that buckets had in the past).  Each
   shard would contain own hashmap and own LRU list.

2. Time-based purging

   The ADB names and entries stay intact when there are no lookups.
   When we add separate shards, a timer needs to be added for time-based
   cleaning in case there's no traffic hashing to the inactive shard.

3. Revisit the 30 minutes limit

   The ADB cache is capped at 30 minutes.  This needs to be revisited,
   and at least the limit should be configurable (in both directions).

3 years agoCreate per-thread task for dns_adb resolver fetches
Ondřej Surý [Thu, 13 Oct 2022 06:11:30 +0000 (08:11 +0200)] 
Create per-thread task for dns_adb resolver fetches

The dns_adb would serialize all fetches on a single task.  Create a
per-thread task, so the fetches will stay local to the thread that
initiated the fetch.

3 years agoExpire namehooks when purging stale ADB names
Ondřej Surý [Mon, 1 Aug 2022 14:33:30 +0000 (16:33 +0200)] 
Expire namehooks when purging stale ADB names

Instead of trying to expire entries from adbentrybuckets, expire the
namehooks while purging the stale ADB names.

3 years agoPurge stale ADB names globaly, not per bucket
Ondřej Surý [Mon, 1 Aug 2022 07:07:38 +0000 (09:07 +0200)] 
Purge stale ADB names globaly, not per bucket

Before the refactoring, there was only few buckets with many names in
them, so cleaning up stale ADB names per-bucket made sense.  After the
refactoring, each bucket directly maps to ADB name, so purging has been
effectively disabled.

Create a global LRU list for ADB names (and ADB entries) and purge the
stale ADB names globally.

3 years agodns_adb: Remove deadnames and deadentries
Ondřej Surý [Wed, 27 Jul 2022 11:45:15 +0000 (13:45 +0200)] 
dns_adb: Remove deadnames and deadentries

Previously, the name and entry buckets were much larger, so the dead
names and entries were moved to a secondary list to be cleaned
later (f.e. after the already running fetch has been canceled).  After
the last refactoring, the bucket now contains only the name (entry)
itself and thus the extra list has a little use.  Remove the .deadnames
and .deadentries from dns_adbnamebucket_t and dns_adbentrybucket_t
structures.

3 years agoMerge branch 'ondrej-eliminitate-rpzs-irefs' into 'main'
Ondřej Surý [Wed, 30 Nov 2022 09:01:12 +0000 (09:01 +0000)] 
Merge branch 'ondrej-eliminitate-rpzs-irefs' into 'main'

Refactor dns_rpz unit to use single reference counting

See merge request isc-projects/bind9!6864

3 years agoRefactor dns_rpz unit to use single reference counting
Ondřej Surý [Wed, 5 Oct 2022 09:21:28 +0000 (11:21 +0200)] 
Refactor dns_rpz unit to use single reference counting

The dns_rpz_zones structure was using .refs and .irefs for strong and
weak reference counting.  Rewrite the unit to use just a single
reference counting + shutdown sequence (dns_rpz_destroy_rpzs) that must
be called by the creator of the dns_rpz_zones_t object.  Remove the
reference counting from the dns_rpz_zone structure as it is not needed
because the zone objects are fully embedded into the dns_rpz_zones
structure and dns_rpz_zones_t object must never be destroyed before all
dns_rpz_zone_t objects.

The dns_rps_zones_t reference counting uses the new ISC_REFCOUNT_TRACE
capability - enable by defining DNS_RPZ_TRACE in the dns/rpz.h header.

Additionally, add magic numbers to the dns_rpz_zone and dns_rpz_zones
structures.

3 years agoAdd extra set of ISC_REFCOUNT_TRACE_{IMPL,DECL} macros
Ondřej Surý [Wed, 5 Oct 2022 09:19:52 +0000 (11:19 +0200)] 
Add extra set of ISC_REFCOUNT_TRACE_{IMPL,DECL} macros

The new ISC_REFCOUNT_TRACE_{IMPL,DECL} macros can be used to add a
reference tracing capability to any unit using the reference counting.
It requires a little bit of extra work in each header as you can't have
a define from inside a define (see rpz.h), but it's fairly easy to add
tracing to any struct using reference counting with these macros.

3 years agoMerge branch '3639-remove-cache_cleaner-from-dns_cache-api' into 'main'
Ondřej Surý [Wed, 30 Nov 2022 06:15:46 +0000 (06:15 +0000)] 
Merge branch '3639-remove-cache_cleaner-from-dns_cache-api' into 'main'

Remove the unused cache cleaning mechanism from dns_cache API

Closes #3639

See merge request isc-projects/bind9!7011

3 years agoAdd CHANGES note for [GL #3639]
Ondřej Surý [Mon, 28 Nov 2022 14:43:31 +0000 (15:43 +0100)] 
Add CHANGES note for [GL #3639]

3 years agoRemove the unused cache cleaning mechanism from dns_cache API
Ondřej Surý [Wed, 2 Nov 2022 10:40:19 +0000 (11:40 +0100)] 
Remove the unused cache cleaning mechanism from dns_cache API

The dns_cache API contained a cache cleaning mechanism that would be
disabled for 'rbt' based cache.  As named doesn't have any other cache
implementations, remove the cache cleaning mechanism from dns_cache API.

3 years agoRemove the dead external cache cleaning mechanism from RBTDB
Ondřej Surý [Wed, 2 Nov 2022 10:40:19 +0000 (11:40 +0100)] 
Remove the dead external cache cleaning mechanism from RBTDB

The RBTDB has own cache cleaning mechanism and therefor the iterator
.cleaning member would never be set to true.  Remove the code that
checks for iterator->cleaning from the RBTDB.

3 years agoMerge branch 'artem-tcp-use-uv_try_write' into 'main'
Artem Boldariev [Tue, 29 Nov 2022 12:47:21 +0000 (12:47 +0000)] 
Merge branch 'artem-tcp-use-uv_try_write' into 'main'

TCP: use uv_try_write() to optimise sends

See merge request isc-projects/bind9!7129

3 years agoTCP: use uv_try_write() to optimise sends
Artem Boldariev [Thu, 10 Nov 2022 19:05:00 +0000 (21:05 +0200)] 
TCP: use uv_try_write() to optimise sends

This commit make TCP code use uv_try_write() on best effort basis,
just like TCP DNS and TLS DNS code does.

This optimisation was added in
'caa5b6548a11da6ca772d6f7e10db3a164a18f8d' but, similar change was
mistakenly omitted for generic TCP code. This commit fixes that.

3 years agoMerge branch 'mnowak/llvm-15' into 'main'
Michal Nowak [Tue, 29 Nov 2022 08:04:22 +0000 (08:04 +0000)] 
Merge branch 'mnowak/llvm-15' into 'main'

Update clang to version 15

See merge request isc-projects/bind9!6754

3 years agoUpdate sources to Clang 15 formatting
Michal Nowak [Wed, 2 Nov 2022 18:33:14 +0000 (19:33 +0100)] 
Update sources to Clang 15 formatting