]> git.ipfire.org Git - thirdparty/bind9.git/log
thirdparty/bind9.git
3 years agoMerge branch '3745-delzone-catz' into 'main'
Tony Finch [Wed, 4 Jan 2023 17:04:48 +0000 (17:04 +0000)] 
Merge branch '3745-delzone-catz' into 'main'

Don't crash when rndc delzone encounters a catz member

Closes #3745

See merge request isc-projects/bind9!7232

3 years agoDon't crash when rndc delzone encounters a catz member
Tony Finch [Wed, 14 Dec 2022 16:24:19 +0000 (16:24 +0000)] 
Don't crash when rndc delzone encounters a catz member

This bug was masked in the tests because the `catz` test script did an
`rndc addzone` before an `rndc delzone`. The `addzone` autovivified
the NZF config, so `delzone` worked OK.

This commit swaps the order of two sections of the `catz` test script
so that it uses `delzone` before `addzone`, which provokes a crash
when `delzone` requires a non-NULL NZF config.

To fix the crash, we now try to remove the zone from the NZF config
only if it was dynamically added but not by a catalog zone.

3 years agoMerge branch '3760-cid-432259-sizeof-not-portable-in-lib-dns-remote' into 'main'
Matthijs Mekking [Wed, 4 Jan 2023 07:58:12 +0000 (07:58 +0000)] 
Merge branch '3760-cid-432259-sizeof-not-portable-in-lib-dns-remote' into 'main'

Fix CID 432259: Sizeof not portable (remote.c)

Closes #3760

See merge request isc-projects/bind9!7288

3 years agoFix CID 432259: Sizeof not portable (remote.c)
Matthijs Mekking [Tue, 3 Jan 2023 10:14:26 +0000 (11:14 +0100)] 
Fix CID 432259: Sizeof not portable (remote.c)

The following report suggests that the 'size' parameter in the two
calls to 'isc_mem_get()' should be set to the
'count * sizeof(*tlsnames)' and 'count * sizeof(*keynames)'
respectively.

/lib/dns/remote.c: 117 in dns_remote_init()
111 }
112 } else {
113 remote->keynames = NULL;
114 }
115
116 if (tlsnames != NULL) {

>>>     CID 432259:    (SIZEOF_MISMATCH)
>>>     Passing argument "count * 8UL /* sizeof (tlsnames) */" to
>>> function "isc__mem_get" and then casting the return value to
>>> "dns_name_t **" is suspicious.  In this particular case
>>> "sizeof (dns_name_t **)" happens to be equal to
>>> "sizeof (dns_name_t *)", but this is not a portable assumption.

117 remote->tlsnames = isc_mem_get(mctx, count * sizeof(tlsnames));
118 for (i = 0; i < count; i++) {
119 remote->tlsnames[i] = NULL;
120 }
121 for (i = 0; i < count; i++) {
122 if (tlsnames[i] != NULL) {

/lib/dns/remote.c: 99 in dns_remote_init()
93 memmove(remote->dscps, dscp, count * sizeof(isc_dscp_t));
94 } else {
95 remote->dscps = NULL;
96 }
97
98 if (keynames != NULL) {

>>>     CID 432259:    (SIZEOF_MISMATCH)
>>>     Passing argument "count * 8UL /* sizeof (keynames) */" to
>>> function "isc__mem_get" and then casting the return value to
>>> "dns_name_t **" is suspicious.  In this particular case
>>> "sizeof (dns_name_t **)" happens to be equal to "sizeof
>>> (dns_name_t *)", but this is not a portable assumption.

99  remote->keynames = isc_mem_get(mctx, count * sizeof(keynames));
100  for (i = 0; i < count; i++) {
101 remote->keynames[i] = NULL;
102  }
103  for (i = 0; i < count; i++) {
104 if (keynames[i] != NULL) {

3 years agoMerge branch '3735-fix-rpz-shutdown-bugs' into 'main'
Arаm Sаrgsyаn [Tue, 3 Jan 2023 15:11:08 +0000 (15:11 +0000)] 
Merge branch '3735-fix-rpz-shutdown-bugs' into 'main'

Fix shutdown and error path bugs in the rpz unit

Closes #3735

See merge request isc-projects/bind9!7289

3 years agoAdd a CHANGES note for [GL #3735]
Aram Sargsyan [Tue, 3 Jan 2023 13:27:00 +0000 (13:27 +0000)] 
Add a CHANGES note for [GL #3735]

3 years agoFix an error path bug in rpz.c:update_nodes()
Aram Sargsyan [Tue, 3 Jan 2023 13:34:58 +0000 (13:34 +0000)] 
Fix an error path bug in rpz.c:update_nodes()

When dns_db_createiterator() fails, 'updbit' should not be destroyed
for obvious reasons, i.e. it is NULL.

3 years agoFix a shutdown and error path bugs in rpz.c:update_nodes()
Aram Sargsyan [Tue, 3 Jan 2023 13:24:38 +0000 (13:24 +0000)] 
Fix a shutdown and error path bugs in rpz.c:update_nodes()

When shutting down, or when dns_dbiterator_current() fails, 'node'
shouldn't be detached, because it is NULL at that point.

3 years agoFix a shutdown bug in update_rpz_cb()
Aram Sargsyan [Tue, 3 Jan 2023 13:21:34 +0000 (13:21 +0000)] 
Fix a shutdown bug in update_rpz_cb()

When shutting down, the cleanup path should not try to destroy
'newnodes', because it is NULL at that point.

Introduce another label for the "shuttingdown" scenario.

3 years agoMerge branch '3754-adb-maybe_expire_entry-called-unlocked-bug' into 'main'
Arаm Sаrgsyаn [Tue, 3 Jan 2023 09:01:18 +0000 (09:01 +0000)] 
Merge branch '3754-adb-maybe_expire_entry-called-unlocked-bug' into 'main'

Don't expire an ADB entry without holding the entries lock

Closes #3754

See merge request isc-projects/bind9!7275

3 years agoAdd a CHANGES note for [GL #3754]
Aram Sargsyan [Fri, 23 Dec 2022 14:26:46 +0000 (14:26 +0000)] 
Add a CHANGES note for [GL #3754]

3 years agoDon't expire an ADB entry without holding the entries lock
Aram Sargsyan [Fri, 23 Dec 2022 14:21:03 +0000 (14:21 +0000)] 
Don't expire an ADB entry without holding the entries lock

The clean_namehooks() function does't hold the 'adb->entries_lock'
lock, so calling maybe_expire_entry() is not thread-safe.

Instead of adding a lock/unlock, leave the expiration to later,
e.g. by the get_attached_and_locked_entry() function.

Also fix a couple of comment typos.

3 years agoMerge branch '3761-ubsan-error-in-isc_buffer_reserve' into 'main'
Mark Andrews [Tue, 3 Jan 2023 07:30:21 +0000 (07:30 +0000)] 
Merge branch '3761-ubsan-error-in-isc_buffer_reserve' into 'main'

Resolve "UBSAN error in isc_buffer_reserve"

Closes #3761

See merge request isc-projects/bind9!7285

3 years agoDo not pass NULL pointer to memmove - undefined behaviour
Mark Andrews [Tue, 3 Jan 2023 03:28:11 +0000 (14:28 +1100)] 
Do not pass NULL pointer to memmove - undefined behaviour

Check if 'old_base' is NULL and if so skip calling memmove.

3 years agoMerge branch 'michal/update-copyright-year-to-2023' into 'main'
Michał Kępień [Mon, 2 Jan 2023 13:06:36 +0000 (13:06 +0000)] 
Merge branch 'michal/update-copyright-year-to-2023' into 'main'

Update copyright year to 2023

See merge request isc-projects/bind9!7282

3 years agoUpdate copyright year to 2023
Michał Kępień [Mon, 2 Jan 2023 12:58:00 +0000 (13:58 +0100)] 
Update copyright year to 2023

3 years agoMerge branch 'artem-tls-use-isc-buffer' into 'main'
Artem Boldariev [Fri, 30 Dec 2022 18:35:53 +0000 (18:35 +0000)] 
Merge branch 'artem-tls-use-isc-buffer' into 'main'

TLS: use isc_buffer_t for send requests, reuse isc_buffer_t during send requests

See merge request isc-projects/bind9!7281

3 years agoTLS: use isc_buffer_t for send requests
Artem Boldariev [Thu, 29 Dec 2022 18:03:26 +0000 (20:03 +0200)] 
TLS: use isc_buffer_t for send requests

This commit replaces ad-hoc code for send requests buffer management
within TLS with the one based on isc_buffer_t.

Previous version of the code was trying to use pre-allocated small
buffers to avoid extra allocations. The code would allocate a larger
dynamic buffer when needed. There is no need to have ad-hoc code for
this, as isc_buffer_t now provides this functionality internally.

Additionally to the above, the old version of the code lacked any
logic to reuse the dynamically allocated buffers. Now, as we do not
manage memory buffers, but isc_buffer_t objects, we can implement this
strategy. It can be in particular helpful for longer lasting
connections, as in this case the buffer will adjust itself to the size
of the messages being transferred. That is, it is in particular useful
for XoT, as Stream DNS happen to order send requests in such a way
that the send request will get reused.

3 years agoMerge branch 'aram/dns_dispatch_createtcp-bugfix' into 'main'
Arаm Sаrgsyаn [Wed, 28 Dec 2022 14:18:52 +0000 (14:18 +0000)] 
Merge branch 'aram/dns_dispatch_createtcp-bugfix' into 'main'

Don't pass a NULL pointer to isc_sockaddr_format()

See merge request isc-projects/bind9!7277

3 years agoDon't pass a NULL pointer to isc_sockaddr_format()
Aram Sargsyan [Wed, 28 Dec 2022 12:10:09 +0000 (12:10 +0000)] 
Don't pass a NULL pointer to isc_sockaddr_format()

The 'localaddr' pointer can be NULL, which causes an assertion failure.

Use '&disp->local' instead when printing a debug log message.

3 years agoMerge branch '3714-remove-alt-transfer-source' into 'main'
Matthijs Mekking [Fri, 23 Dec 2022 15:11:25 +0000 (15:11 +0000)] 
Merge branch '3714-remove-alt-transfer-source' into 'main'

Remove setting alternate transfer source

Closes #3714

See merge request isc-projects/bind9!7163

3 years agoAdd CHANGES and release notes for #3714
Matthijs Mekking [Mon, 5 Dec 2022 09:23:12 +0000 (10:23 +0100)] 
Add CHANGES and release notes for #3714

Update release notes, remove the deprecation entry and add a new
removed feature entry.

3 years agoRemove unused dns_remote_t functions
Matthijs Mekking [Mon, 5 Dec 2022 09:21:38 +0000 (10:21 +0100)] 
Remove unused dns_remote_t functions

Now that setting alternate transfer sources is removed, the functions
to check whether all addresses are considered good have become obsolete.

3 years agoRemove setting alternate transfer source from doc
Matthijs Mekking [Mon, 5 Dec 2022 09:18:33 +0000 (10:18 +0100)] 
Remove setting alternate transfer source from doc

Remove any reference to 'alt-transfer-source', 'alt-transfer-source-v6',
and 'use-alt-transfer-source' from the documentation and manual pages.

3 years agoRemove setting alternate transfer source
Matthijs Mekking [Fri, 2 Dec 2022 15:38:52 +0000 (16:38 +0100)] 
Remove setting alternate transfer source

Remove parsing the configuration options 'alt-transfer-source',
'alt-transfer-source-v6', and 'use-alt-transfer-source', and remove
the corresponding code that implements the feature.

3 years agoMerge branch 'matthijs-remote-server-refactor' into 'main'
Matthijs Mekking [Fri, 23 Dec 2022 13:37:14 +0000 (13:37 +0000)] 
Merge branch 'matthijs-remote-server-refactor' into 'main'

Refactor remote servers (primaries, parental agents) in zone.c

See merge request isc-projects/bind9!7110

3 years agoAdd release notes
Matthijs Mekking [Thu, 22 Dec 2022 09:11:20 +0000 (10:11 +0100)] 
Add release notes

The refactor introduces a new way to configure source addresses for
primaries and parental-agents, a new thingy that we should make people
aware of.

3 years agoAdd CHANGES
Matthijs Mekking [Wed, 23 Nov 2022 15:20:50 +0000 (16:20 +0100)] 
Add CHANGES

Mention the refactor of zone.c

3 years agoUse 'source[-v6]' for transfer, notify, checkds
Matthijs Mekking [Wed, 23 Nov 2022 15:15:16 +0000 (16:15 +0100)] 
Use 'source[-v6]' for transfer, notify, checkds

Use the configured 'source' and 'source-v6' when initiating a zone
transfer, sending a notify, or when checking for the DS. Remove the
special code for using alternate transfer sources.

Update some system tests to use the new configuration and make sure
the tests still work.

3 years agoSmall comment change in remote.h header file
Matthijs Mekking [Tue, 22 Nov 2022 15:30:19 +0000 (16:30 +0100)] 
Small comment change in remote.h header file

The documentation for 'dns_remote_addr()' was incorrect (copy paste
error).

3 years agoParse and store new 'source[-v6]' option
Matthijs Mekking [Tue, 22 Nov 2022 10:55:49 +0000 (11:55 +0100)] 
Parse and store new 'source[-v6]' option

Parse the new 'source' and 'source-v6' options and store them with
the corresponding remote servers (parental-agents, primaries, ...).

3 years agoAdd new 'source[-v6]' option for remote servers
Matthijs Mekking [Tue, 13 Dec 2022 16:28:19 +0000 (17:28 +0100)] 
Add new 'source[-v6]' option for remote servers

Add a new way to configure the preferred source address when talking to
remote servers such as primaries and parental-agents. This will
eventually deprecate options such as 'parental-source',
'parental-source-v6', 'transfer-source', etc.

Example of the new configuration:

    parental-agents "parents" port 5353 \
        source 10.10.10.10 port 5354 dscp 54 \
        source-v6 2001:db8::10 port 5355 dscp 55 {
10.10.10.11;
2001:db8::11;
    };

3 years agoRemove functions named_config_[get|put]iplist
Matthijs Mekking [Thu, 10 Nov 2022 10:21:50 +0000 (11:21 +0100)] 
Remove functions named_config_[get|put]iplist

They are unused.

3 years agoRefactor zone.c, use dns_remote_t structure
Matthijs Mekking [Wed, 26 Oct 2022 12:40:30 +0000 (14:40 +0200)] 
Refactor zone.c, use dns_remote_t structure

Use the new dns_remote_t structure for remote server communication to
primaries, parental agents, etc.

3 years agoAdd new files for remote server communication
Matthijs Mekking [Wed, 26 Oct 2022 12:38:19 +0000 (14:38 +0200)] 
Add new files for remote server communication

The dns_remote_t structure is intended to replace the variables in
the structure that deals with remote server communication to primaries,
parental agents, forwarders, etc.

3 years agoMerge branch 'tkrizek/gitignore-fixes' into 'main'
Tom Krizek [Fri, 23 Dec 2022 13:29:12 +0000 (13:29 +0000)] 
Merge branch 'tkrizek/gitignore-fixes' into 'main'

Don't track gitignored files in the repo

See merge request isc-projects/bind9!7264

3 years agoDetect "ignored yet tracked" files in GitLab CI
Michał Kępień [Fri, 23 Dec 2022 12:21:47 +0000 (13:21 +0100)] 
Detect "ignored yet tracked" files in GitLab CI

Ensure that no .gitignore file in the tree contains patterns matching
files tracked by Git by adding a simple script that detects such
situations and running that script as part of the "misc" job in the
"precheck" stage of every GitLab CI pipeline.

3 years agoRemove obsolete gitignore file in mysqldyn
Tom Krizek [Thu, 22 Dec 2022 13:54:32 +0000 (14:54 +0100)] 
Remove obsolete gitignore file in mysqldyn

The Makefile used to be autogenerated prior to
67f76b126900d313b343f563353f8237a6a264d2 which is the reason why the
.gitignore existed in the first place. Since then, a static Makefile is
used and is supposed to be tracked in the git repo.

3 years agoMake gitignore matching in rpzrecurse more precise
Tom Krizek [Thu, 22 Dec 2022 13:46:49 +0000 (14:46 +0100)] 
Make gitignore matching in rpzrecurse more precise

The pre-defined test cases use named.$TESTCASE.conf naming convention,
where TESTCASE is a human readable name contaning actual word(s). The
autogenerated test cases' names always start with a number from 1 to 6.

3 years agoRemove ans.pl system test files from gitignore
Tom Krizek [Thu, 22 Dec 2022 13:28:53 +0000 (14:28 +0100)] 
Remove ans.pl system test files from gitignore

The ans*.pl scripts are part of system tests and should be part of the
repository. The gitignore entires for these files have been removed.

3 years agoRename dig reference files in the rrsetorder test
Tom Krizek [Thu, 22 Dec 2022 13:26:03 +0000 (14:26 +0100)] 
Rename dig reference files in the rrsetorder test

bin/tests/system/rrsetorder/dig.out* files match a gitignore expression
present in bin/tests/system/.gitignore.  Since these are meant to be
reference files that are compared to the files generated when the
"rrsetorder" system test is run, rename them to avoid listing tracked
files in .gitignore files.

3 years agoMerge branch '3752-resolver-adb-quota-bug' into 'main'
Arаm Sаrgsyаn [Fri, 23 Dec 2022 10:23:29 +0000 (10:23 +0000)] 
Merge branch '3752-resolver-adb-quota-bug' into 'main'

Fix an ADB quota management bug in the resolver

Closes #3752

See merge request isc-projects/bind9!7266

3 years agoAdd CHANGES and release notes for [GL #3752]
Aram Sargsyan [Thu, 22 Dec 2022 14:01:47 +0000 (14:01 +0000)] 
Add CHANGES and release notes for [GL #3752]

3 years agoFix an ADB quota management error in the resolver
Aram Sargsyan [Thu, 22 Dec 2022 13:48:33 +0000 (13:48 +0000)] 
Fix an ADB quota management error in the resolver

Normally, when a 'resquery_t' object is created in fctx_query(),
we call dns_adb_beginudpfetch() (which increases the ADB quota)
only if it's a UDP query. Then, in fctx_cancelquery(), we call
dns_adb_endudpfetch() to decreases back the ADB quota, again only
if it's a UDP query.

The problem is that a UDP query can become a TCP query, preventing
the quota from adjusting back in fctx_cancelquery() later.

Call dns_adb_beginudpfetch() also when switching the query type
from UDP to TCP.

3 years agoINSIST that active quota is 0 in destroy_adbentry()
Aram Sargsyan [Thu, 22 Dec 2022 13:43:47 +0000 (13:43 +0000)] 
INSIST that active quota is 0 in destroy_adbentry()

This should catch ADB quota management errors in the resolver.

3 years agoMerge branch '3748-rename-tls-caches-creation-functions' into 'main'
Artem Boldariev [Fri, 23 Dec 2022 09:13:56 +0000 (09:13 +0000)] 
Merge branch '3748-rename-tls-caches-creation-functions' into 'main'

Rename isc_tlsctx_cache_new() to isc_tlsctx_cache_create(), tlsctx_client_session_cache_new() to tlsctx_client_session_create()

Closes #3748

See merge request isc-projects/bind9!7269

3 years agotlsctx_client_session_cache_new() -> tlsctx_client_session_create()
Artem Boldariev [Thu, 22 Dec 2022 18:04:22 +0000 (20:04 +0200)] 
tlsctx_client_session_cache_new() -> tlsctx_client_session_create()

Additionally to renaming, it changes the function definition so that
it accepts a pointer to pointer instead of returning a pointer to the
new object.

It is mostly done to make it in line with other functions in the
module.

3 years agoRename isc_tlsctx_cache_new() -> isc_tlsctx_cache_create()
Artem Boldariev [Thu, 22 Dec 2022 17:54:16 +0000 (19:54 +0200)] 
Rename isc_tlsctx_cache_new() -> isc_tlsctx_cache_create()

Additionally to renaming, it changes the function definition so that
it accepts a pointer to pointer instead of returning a pointer to the
new object.

It is mostly done to make it in line with other functions in the
module.

3 years agoMerge branch 'tkrizek/dangerfile-backport-tweaks' into 'main'
Tom Krizek [Fri, 23 Dec 2022 08:50:10 +0000 (08:50 +0000)] 
Merge branch 'tkrizek/dangerfile-backport-tweaks' into 'main'

danger CI: tweak backport check and add Affects label check

See merge request isc-projects/bind9!7253

3 years agodanger: check the Affects labels are set
Tom Krizek [Mon, 19 Dec 2022 14:14:48 +0000 (15:14 +0100)] 
danger: check the Affects labels are set

Unless the MR is a backport, the Affects labels should be used to
indicate which versions are affected by the issue that prompted the MR.

3 years agodanger: check version in MR title
Tom Krizek [Mon, 19 Dec 2022 13:43:16 +0000 (14:43 +0100)] 
danger: check version in MR title

Enforce the version indicator to be at the start of the MR title.

3 years agoMerge tag 'v9_19_8'
Tom Krizek [Thu, 22 Dec 2022 09:13:38 +0000 (10:13 +0100)] 
Merge tag 'v9_19_8'

BIND 9.19.8

3 years agoMerge branch '3750-legacy-system-test-dig-timed-out-fix' into 'main'
Arаm Sаrgsyаn [Wed, 21 Dec 2022 14:40:43 +0000 (14:40 +0000)] 
Merge branch '3750-legacy-system-test-dig-timed-out-fix' into 'main'

Fix DiG "timed out" message check in "legacy" system test

Closes #3750

See merge request isc-projects/bind9!7259

3 years agoFix DiG "timed out" message check in "legacy" system test
Aram Sargsyan [Wed, 21 Dec 2022 13:52:22 +0000 (13:52 +0000)] 
Fix DiG "timed out" message check in "legacy" system test

The test expects a "connection timed out" message from DiG when it
experiences a timeout, while the current version of DiG prints just
a "timed out" message, like below:

    ;; communications error to 10.53.0.1#11314: timed out
    ;; communications error to 10.53.0.1#11314: timed out
    ;; communications error to 10.53.0.1#11314: timed out

    ; <<>> DiG 9.19.9-dev <<>> -p 11314 +tries +time +tcp +tries +time @10.53.0.1 dropedns. TXT
    ; (1 server found)
    ;; global options: +cmd
    ;; no servers could be reached

Change the expected string to match the current DiG output.

Use the '-F' switch for "grep" for matching a fixed string.

3 years agoMerge branch 'tkrizek/system-tests-conventions' into 'main'
Tom Krizek [Wed, 21 Dec 2022 12:42:27 +0000 (12:42 +0000)] 
Merge branch 'tkrizek/system-tests-conventions' into 'main'

Unify system tests naming conventions

See merge request isc-projects/bind9!7150

3 years agoUpdate tests gitignore file
Tom Krizek [Wed, 21 Dec 2022 11:52:08 +0000 (12:52 +0100)] 
Update tests gitignore file

The .mypy_cache was added to the system test dir gitignore, since it
should be ignored.

3 years agoRename engine_pkcs11 system test
Tom Krizek [Fri, 2 Dec 2022 15:51:36 +0000 (16:51 +0100)] 
Rename engine_pkcs11 system test

In order to have a common naming convention for system tests, rename the
only outlier "engine_pkcs11" to "enginepkcs11", which was the only
system test using an underscore in its name.

The only allowed word separators for system test names are either dash
or no separator.

3 years agoUse common name convention for pytest files
Tom Krizek [Fri, 14 Oct 2022 09:12:53 +0000 (11:12 +0200)] 
Use common name convention for pytest files

It is better to use consistent file names to avoid issue with sorting
etc.

Using underscore in filenames as opposed to dash was chosen because it
seems more common in pytest/python to use underscore for filenames.

Also rename the bin/tests/system/timeouts/tests-tcp.py file to
bin/tests/system/timeouts/tests_tcp_timeouts.py to avoid pytest name
collision (there can't be two files named tests_tcp.py).

3 years agoMerge branch 'artem-add-missing-dnsstream-test-header-to-the-makefile-am' into 'main'
Artem Boldariev [Wed, 21 Dec 2022 12:18:36 +0000 (12:18 +0000)] 
Merge branch 'artem-add-missing-dnsstream-test-header-to-the-makefile-am' into 'main'

Add missing "dnsstream_utils_test_data.h" to the Makefile.am

See merge request isc-projects/bind9!7256

3 years agoAdd missing "dnsstream_utils_test_data.h" to the Makefile.am
Artem Boldariev [Wed, 21 Dec 2022 10:37:44 +0000 (12:37 +0200)] 
Add missing "dnsstream_utils_test_data.h" to the Makefile.am

This commit ensures that "dnsstream_utils_test_data.h" is referenced
by Makefile.am and, thus, is not missing from a created tarball.

3 years agoMerge branch '3178-dispatch-race-fix' into 'main'
Ondřej Surý [Wed, 21 Dec 2022 11:49:09 +0000 (11:49 +0000)] 
Merge branch '3178-dispatch-race-fix' into 'main'

Fix more issues in the dns_dispatch unit

Closes #3178

See merge request isc-projects/bind9!7252

3 years agoCall the connected dns_dispatch callback asynchronously
Ondřej Surý [Tue, 20 Dec 2022 07:39:36 +0000 (08:39 +0100)] 
Call the connected dns_dispatch callback asynchronously

The dns_request code is very sensitive about calling the connected and
deadlocks when the timing is "right" in several places.  Move the call
to the connected callback to the (udp|tcp)_connected() functions, so
they are called asynchronously instead of directly from
the (udp|tcp)_dispentry_cancel() functions.

3 years agoIgnore TCP dispatches that have zero references
Ondřej Surý [Tue, 20 Dec 2022 05:11:26 +0000 (06:11 +0100)] 
Ignore TCP dispatches that have zero references

The TCP dispatches are removed from the dispatchmgr->list in the
dispatch_destroy() and there's a brief period of time where
dns_dispatch_gettcp() can find a dispatch in connected state that's
being destroyed.

Set the dispatch state to DNS_DISPATCHSTATE_NONE in the TCP connection
callback if there are no responses waiting, and ignore TCP dispatches
with zero references in dns_dispatch_gettcp().

3 years agoFix assignment vs comparison typo in tcp_connected()
Ondřej Surý [Mon, 19 Dec 2022 17:17:46 +0000 (18:17 +0100)] 
Fix assignment vs comparison typo in tcp_connected()

In tcp_connected() a typo has turned a DbC check into an assignment
breaking the state machine and making the dns_dispatch_gettcp() try to
attach to dispatch in process of destruction.

3 years agoDon't remove dispatches in CANCELED state from the list
Ondřej Surý [Mon, 19 Dec 2022 16:28:39 +0000 (17:28 +0100)] 
Don't remove dispatches in CANCELED state from the list

In dns_dispatch_gettcp(), we can't remove canceled dispatches from the
mgr->list because ISC_LIST_NEXT() would fail in the next iteration.

3 years agoIgnore TCP dispatches in DNS_DISPATCHSTATE_NONE state
Ondřej Surý [Mon, 19 Dec 2022 13:26:31 +0000 (14:26 +0100)] 
Ignore TCP dispatches in DNS_DISPATCHSTATE_NONE state

The TCP dispatches in DNS_DISPATCHSTATE_NONE could be either very
fresh or those could be dispatches that failed connecting to the
destination.  Ignore them when trying to connect to an existing
TCP dispatch via dns_dispatch_gettcp().

3 years agoMerge branch 'tkrizek/default-alg-fixups' into 'main'
Tom Krizek [Wed, 21 Dec 2022 09:39:56 +0000 (09:39 +0000)] 
Merge branch 'tkrizek/default-alg-fixups' into 'main'

Fix minor issues with DEFAULT_ALGORITHM selection in system tests

Closes #3747

See merge request isc-projects/bind9!7059

3 years agoMake Python interpreter required for system tests
Tom Krizek [Tue, 8 Nov 2022 13:55:17 +0000 (14:55 +0100)] 
Make Python interpreter required for system tests

This introduces a Python dependency for running system tests. It is
needed in order to:
  - write new test control scripts in Python
  - gradually rewrite old Perl scripts into Python if needed
  - eventually introduce pytest as the new test runner framework

This commit is not intended to be backported to 9.16.

3 years agoMake Perl interpreter required for system tests
Tom Krizek [Tue, 8 Nov 2022 13:54:14 +0000 (14:54 +0100)] 
Make Perl interpreter required for system tests

This change has no practical impact, as Perl was already required for
all system tests, this check only makes it more explicit.

3 years agoEnsure test interpreters are defined before common config
Tom Krizek [Mon, 7 Nov 2022 15:38:49 +0000 (16:38 +0100)] 
Ensure test interpreters are defined before common config

Nothing from conf.sh.common is required to set these values. On the
contrary, a Python interpreter needs to be set in order to randomize the
algorithm set (which happens in conf.sh.common).

3 years agoForce quiet mode when using testcrypto.sh directly
Tom Krizek [Mon, 7 Nov 2022 14:58:40 +0000 (15:58 +0100)] 
Force quiet mode when using testcrypto.sh directly

When testcrypto.sh is used as a standalone script, always use quiet mode
to avoid using undefined commands (such as echo_i) which require
inclusion of the entire conf.sh machinery.

3 years agoMerge branch 'artem-stream-dns' into 'main'
Artem Boldariev [Tue, 20 Dec 2022 20:59:50 +0000 (20:59 +0000)] 
Merge branch 'artem-stream-dns' into 'main'

StreamDNS - unified transport for DNS over TLS and DNS over TCP (and possibly more)

Closes #3374

See merge request isc-projects/bind9!6707

3 years agoConvert Stream DNS to use isc_buffer API
Ondřej Surý [Fri, 16 Dec 2022 12:01:18 +0000 (13:01 +0100)] 
Convert Stream DNS to use isc_buffer API

Drop the whole isc_dnsbuffer API and use new improved isc_buffer API
that provides same functionality as the isc_dnsbuffer unit now.

3 years agoModify release notes [GL #3374]
Artem Boldariev [Wed, 23 Nov 2022 13:44:33 +0000 (15:44 +0200)] 
Modify release notes [GL #3374]

Mention that DNS over TCP and DNS over TLS transports are superseded.

3 years agoModify CHANGES [GL #3374]
Artem Boldariev [Wed, 23 Nov 2022 13:41:21 +0000 (15:41 +0200)] 
Modify CHANGES [GL #3374]

Mention that DNS over TCP and DNS over TLS transports are superseded.

3 years agoModify AUTHORS
Artem Boldariev [Tue, 29 Nov 2022 11:03:56 +0000 (13:03 +0200)] 
Modify AUTHORS

Add "Artem Boldariev" to the list of BIND9 authors.

3 years agoStreamDNS: Use isc__nm_senddns() to send DNS messages
Artem Boldariev [Wed, 7 Dec 2022 12:32:20 +0000 (14:32 +0200)] 
StreamDNS: Use isc__nm_senddns() to send DNS messages

This commit modifies the Stream DNS message so that it uses the
optimised code path (isc__nm_senddns()) for sending DNS messages over
the underlying transport. This way we avoid allocating any
intermediate memory buffers needed to render a DNS message with its
length pre-pended ahead of the contents (TCP DNS message format).

3 years agoTLS: isc__nm_senddns() support
Artem Boldariev [Wed, 7 Dec 2022 12:18:33 +0000 (14:18 +0200)] 
TLS: isc__nm_senddns() support

This commit adds support for isc_nm_senddns() to the generic TLS code.

3 years agoAdd isc__nm_senddns()
Artem Boldariev [Wed, 7 Dec 2022 11:33:52 +0000 (13:33 +0200)] 
Add isc__nm_senddns()

The new internal function works in the same way as isc_nm_send()
except that it sends a DNS message size ahead of the DNS message
data (the format used in DNS over TCP).

The intention is to provide a fast path for sending DNS messages over
streams protocols - that is, without allocating any intermediate
memory buffers.

3 years agoTLS: try to avoid allocating send request objects
Artem Boldariev [Mon, 5 Dec 2022 18:19:03 +0000 (20:19 +0200)] 
TLS: try to avoid allocating send request objects

This commit optimises TLS send request object allocation to enable
send request object reuse, somewhat reducing pressure on the memory
manager. It is especially helpful in the case when Stream DNS uses the
TLS implementation as the transport.

3 years agoRemove TLS DNS transport (and parts common with TCP DNS)
Artem Boldariev [Tue, 22 Nov 2022 19:03:02 +0000 (21:03 +0200)] 
Remove TLS DNS transport (and parts common with TCP DNS)

This commit removes TLS DNS transport superseded by Stream DNS.

3 years agoRemove TCP DNS transport
Artem Boldariev [Tue, 22 Nov 2022 18:43:05 +0000 (20:43 +0200)] 
Remove TCP DNS transport

This commit removes TCP DNS transport superseded by Stream DNS.

3 years agoMake dispatch unit tests use Stream DNS
Artem Boldariev [Fri, 7 Oct 2022 19:23:06 +0000 (22:23 +0300)] 
Make dispatch unit tests use Stream DNS

This commit replaces usage of TCP DNS and TLS DNS in the dispatch unit
tests with Stream DNS transport.

3 years agoMake isc_nm_tlssocket unit tests available in non DoH-enabled builds
Artem Boldariev [Tue, 23 Aug 2022 19:15:54 +0000 (22:15 +0300)] 
Make isc_nm_tlssocket unit tests available in non DoH-enabled builds

This commit ensures that generic TLS unit tests are available in non
DoH-enabled builds, as isc_nm_tlssocket is not tied exclusively to the
DoH implementation anymore.

3 years agoMake isc_nm_tlssocket non-optional
Artem Boldariev [Tue, 18 Oct 2022 12:36:00 +0000 (15:36 +0300)] 
Make isc_nm_tlssocket non-optional

This commit unties generic TLS code (isc_nm_tlssocket) from DoH, so
that it will be available regardless of the fact if BIND was built
with DNS over HTTP support or not.

3 years agoDoH: use isc_nmhandle_set_tcp_nodelay()
Artem Boldariev [Thu, 25 Aug 2022 19:44:59 +0000 (22:44 +0300)] 
DoH: use isc_nmhandle_set_tcp_nodelay()

This commit replaces ad-hoc code for disabling Nagle's algorithm with
a call to isc_nmhandle_set_tcp_nodelay().

3 years agoStreamDNS: opportunistically disable Nagle's algorithm
Artem Boldariev [Thu, 27 Oct 2022 18:14:35 +0000 (21:14 +0300)] 
StreamDNS: opportunistically disable Nagle's algorithm

This commit ensures that Stream DNS code attempts to disable Nagle's
algorithm regardless of underlying stream transport (TCP or TLS), as
we are not interested in trading latency for throughout when dealing
with DNS messages.

3 years agoDisable Nagle's algorithm for TLS connections by default
Artem Boldariev [Thu, 25 Aug 2022 19:37:26 +0000 (22:37 +0300)] 
Disable Nagle's algorithm for TLS connections by default

This commit ensures that Nagle's algorithm is disabled by default for
TLS connections on best effort basis, just like other networking
software (e.g. NGINX) does, as, in the case of TLS, we are not
interested in trading latency for throughput, rather vice versa.

We attempt to disable it as early as we can, right after TCP
connections establishment, as an attempt to speed up handshake
handling.

3 years agoTCP: make it possible to set Nagle's algorithms state via handle
Artem Boldariev [Thu, 25 Aug 2022 19:18:15 +0000 (22:18 +0300)] 
TCP: make it possible to set Nagle's algorithms state via handle

This commit adds ability to turn the Nagle's algorithm on or off via
connections handle. It adds the isc_nmhandle_set_tcp_nodelay()
function as the public interface for this functionality.

3 years agoExtend isc__nm_socket_tcp_nodelay() to accept value
Artem Boldariev [Thu, 25 Aug 2022 18:59:23 +0000 (21:59 +0300)] 
Extend isc__nm_socket_tcp_nodelay() to accept value

This makes it possible to both enable and disable Nagle's algorithm
for a TCP socket descriptor, before the change it was possible only to
disable it.

3 years agoBIND: use Stream DNS for DNS over TCP connections
Artem Boldariev [Fri, 5 Aug 2022 16:43:34 +0000 (19:43 +0300)] 
BIND: use Stream DNS for DNS over TCP connections

This commit makes BIND use the new Stream DNS transport for DNS over
TCP.

3 years agoBIND: use Stream DNS for DNS over TLS connections
Artem Boldariev [Tue, 29 Nov 2022 16:15:54 +0000 (18:15 +0200)] 
BIND: use Stream DNS for DNS over TLS connections

This commit makes BIND use the new Stream DNS transport for DNS over
TLS.

3 years agoUse Stream DNS in dig for DNS over TCP
Artem Boldariev [Tue, 23 Aug 2022 16:18:31 +0000 (19:18 +0300)] 
Use Stream DNS in dig for DNS over TCP

This commit makes dig use the new Stream DNS transport for DNS over
TCP.

3 years agoUse Stream DNS in dig for DNS over TLS
Artem Boldariev [Tue, 12 Jul 2022 20:08:07 +0000 (23:08 +0300)] 
Use Stream DNS in dig for DNS over TLS

This commit makes dig use the new Stream DNS transport for DNS over
TLS.

3 years agoRe-purpose TLS DNS and TCP DNS unit tests for Stream DNS
Artem Boldariev [Tue, 8 Nov 2022 14:43:01 +0000 (16:43 +0200)] 
Re-purpose TLS DNS and TCP DNS unit tests for Stream DNS

This commit modifies the existing unit tests for TLS DNS and TCP DNS
in such a way that the new Stream DNS transport is used as it is
intended to be a drop-in replacement for these two transports.

3 years agoAdd isc_nm_streamdnssocket (aka Stream DNS)
Artem Boldariev [Mon, 20 Jun 2022 17:30:12 +0000 (20:30 +0300)] 
Add isc_nm_streamdnssocket (aka Stream DNS)

This commit adds an initial implementation of isc_nm_streamdnssocket
transport: a unified transport for DNS over stream protocols messages,
which is capable of replacing both TCP DNS and TLS DNS
transports. Currently, the interface it provides is a unified set of
interfaces provided by both of the transports it attempts to replace.

The transport is built around "isc_dnsbuffer_t" and
"isc_dnsstream_assembler_t" objects and attempts to minimise both the
number of memory allocations during network transfers as well as
memory usage.

3 years agoAdd a set of unit tests for dnsbuffer_t and dnsstream_assembler_t
Artem Boldariev [Thu, 2 Jun 2022 11:19:12 +0000 (14:19 +0300)] 
Add a set of unit tests for dnsbuffer_t and dnsstream_assembler_t

This commit adds a set of unit tests for isc_dnsbuffer_t and
isc_dnsstream_assembler_t which help to verify that they work as
expected.

3 years agoAdd isc_dnsstream_assembler_t implementation
Artem Boldariev [Mon, 13 Jun 2022 16:20:08 +0000 (19:20 +0300)] 
Add isc_dnsstream_assembler_t implementation

This commit adds the implementation for an "isc_dnsstream_assembler_t"
object. The object is built on top of "isc_dnsbuffer_t" and is
intended to encapsulate the state machine used for handling DNS
messages received in the format used for messages transmitted over
TCP.

The idea is that the object accepts the input data received from a
socket, tries to assemble DNS messages from the incoming data and
calls the callback which contains the status of the incoming data as
well as a pointer to the memory region referencing the data of the
assembled message. It is capable of assembling DNS messages no matter
how torn apart they are when sent over network.

The following statuses might be passed to the callback:

* ISC_R_SUCCESS - a message has been successfully assembled;
* ISC_R_NOMORE  - not enough data has been processed to assemble a
message;
* ISC_R_RANGE - there was an attempt to process a zero-sized DNS
message (someone attempts to send us junk data).

One could say that the object replaces the implementation of
"isc__nm_*_processbuffer()" functions used by the old TCP DNS and TLS
DNS transports with a better defined state machine completely
decoupled from the networking code itself.

Such a design makes it trivial to write unit tests for it, leading to
better verification of its correctness.

Another important difference is directly related to the fact that it
is built on top of "isc_dnsbuffer_t", which tries to manage memory in
a smart way. In particular:

* It tries to use a static buffer for smaller messages, reducing
pressure on the memory manager (hot path);
* When allocating dynamic memory for larger messages, it tries to
allocate memory conservatively (generic path).

These characteristics is a significant upgrade over the older logic
where a 64KB(+2 bytes) buffer was allocated from dynamic memory
regardless of the fact if we need a buffer this large or not. That is,
lesser memory usage is expected in a generic case for DNS transports
built on top of "isc_dnsstream_assembler_t."

3 years agoAdd isc_dnsbuffer_t implementation
Artem Boldariev [Tue, 7 Jun 2022 10:14:29 +0000 (13:14 +0300)] 
Add isc_dnsbuffer_t implementation

This commit adds "isc_dnsbuffer_t" object implementation, a thin
wrapper on top of "isc_buffer_t" which has the following
characteristics:

* provides interface specifically atuned for handling/generating DNS
messages, especially in the format used for DNS messages over TCP;
* avoids allocating dynamic memory when handling small DNS messages,
while transparently switching to using dynamic memory when handling
larger messages. This approach significantly reduces pressure on the
memory allocator, as most of the DNS messages are small.

3 years agoTLS: add an internal function isc__nmhandle_get_selected_alpn()
Artem Boldariev [Wed, 3 Aug 2022 11:46:33 +0000 (14:46 +0300)] 
TLS: add an internal function isc__nmhandle_get_selected_alpn()

The added function provides the interface for getting an ALPN tag
negotiated during TLS connection establishment.

The new function can be used by higher level transports.