]> git.ipfire.org Git - thirdparty/bind9.git/log
thirdparty/bind9.git
4 years agoAdd missing .clang-format in the named headers directory
Ondřej Surý [Tue, 5 Oct 2021 15:10:08 +0000 (17:10 +0200)] 
Add missing .clang-format in the named headers directory

The .clang-format was missing in bin/named/include/named, add the
symlink to .clang-format.headers to match the rest of the source tree.

4 years agoUse #pragma once as header guards
Ondřej Surý [Tue, 5 Oct 2021 14:49:47 +0000 (16:49 +0200)] 
Use #pragma once as header guards

Unify the header guard style and replace the inconsistent include guards
with #pragma once.

The #pragma once is widely and very well supported in all compilers that
BIND 9 supports, and #pragma once was already in use in several new or
refactored headers.

Using simpler method will also allow us to automate header guard checks
as this is simpler to programatically check.

For reference, here are the reasons for the change taken from
Wikipedia[1]:

> In the C and C++ programming languages, #pragma once is a non-standard
> but widely supported preprocessor directive designed to cause the
> current source file to be included only once in a single compilation.
>
> Thus, #pragma once serves the same purpose as include guards, but with
> several advantages, including: less code, avoidance of name clashes,
> and sometimes improvement in compilation speed. On the other hand,
> #pragma once is not necessarily available in all compilers and its
> implementation is tricky and might not always be reliable.

1. https://en.wikipedia.org/wiki/Pragma_once

4 years agoMerge branch '1432-dns_name_dup-post-cleanup' into 'main'
Ondřej Surý [Wed, 13 Oct 2021 04:19:46 +0000 (04:19 +0000)] 
Merge branch '1432-dns_name_dup-post-cleanup' into 'main'

Return void when ISC_R_SUCCESS is only returned value

Closes #1432

See merge request isc-projects/bind9!5471

4 years agodns/resolver.c: Return void when ISC_R_SUCCESS is only returned value
Ondřej Surý [Wed, 6 Oct 2021 11:41:21 +0000 (13:41 +0200)] 
dns/resolver.c: Return void when ISC_R_SUCCESS is only returned value

With isc_mem_get() and dns_name_dup() no longer being able to fail, some
functions can now only return ISC_R_SUCCESS.  Change the return type to
void for the following function(s):

 * dns_zone_setprimaries()
 * dns_zone_setparentals()
 * dns_zone_setparentals()
 * dns_zone_setalsonotify()

4 years agodns/view.c: Return void when ISC_R_SUCCESS is only returned value
Ondřej Surý [Wed, 6 Oct 2021 11:40:32 +0000 (13:40 +0200)] 
dns/view.c: Return void when ISC_R_SUCCESS is only returned value

With isc_mem_get() and dns_name_dup() no longer being able to fail, some
functions can now only return ISC_R_SUCCESS.  Change the return type to
void for the following function(s):

 * dns_view_adddelegationonly()
 * dns_view_excludedelegationonly()

4 years agodns/ssu.c: Return void when ISC_R_SUCCESS is only returned value
Ondřej Surý [Wed, 6 Oct 2021 11:18:16 +0000 (13:18 +0200)] 
dns/ssu.c: Return void when ISC_R_SUCCESS is only returned value

With isc_mem_get() and dns_name_dup() no longer being able to fail, some
functions can now only return ISC_R_SUCCESS.  Change the return type to
void for the following function(s):

 * dns_ssutable_addrule()
 * dns_ssutable_create()
 * dns_ssutable_createdlz()

4 years agodns/resolver.c: Return void when ISC_R_SUCCESS is only returned value
Ondřej Surý [Wed, 6 Oct 2021 10:59:45 +0000 (12:59 +0200)] 
dns/resolver.c: Return void when ISC_R_SUCCESS is only returned value

With isc_mem_get() and dns_name_dup() no longer being able to fail, some
functions can now only return ISC_R_SUCCESS.  Change the return type to
void for the following function(s):

 * dns_resolver_addalternate()

4 years agodns/rdata.c: Return void when ISC_R_SUCCESS is only returned value
Ondřej Surý [Wed, 6 Oct 2021 10:57:24 +0000 (12:57 +0200)] 
dns/rdata.c: Return void when ISC_R_SUCCESS is only returned value

With isc_mem_get() and dns_name_dup() no longer being able to fail, some
functions can now only return ISC_R_SUCCESS.  Change the return type to
void for the following function(s):

 * name_duporclone()

4 years agodns/lookup.c: Return void when ISC_R_SUCCESS is only returned value
Ondřej Surý [Wed, 6 Oct 2021 10:46:45 +0000 (12:46 +0200)] 
dns/lookup.c: Return void when ISC_R_SUCCESS is only returned value

With isc_mem_get() and dns_name_dup() no longer being able to fail, some
functions can now only return ISC_R_SUCCESS.  Change the return type to
void for the following function(s):

 * build_event()

4 years agodns/catz.c: Return void when ISC_R_SUCCESS is only returned value
Ondřej Surý [Wed, 6 Oct 2021 10:43:35 +0000 (12:43 +0200)] 
dns/catz.c: Return void when ISC_R_SUCCESS is only returned value

With isc_mem_get() and dns_name_dup() no longer being able to fail, some
functions can now only return ISC_R_SUCCESS.  Change the return type to
void for the following function(s):

 * dns_catz_options_copy()
 * dns_catz_options_setdefault()
 * dns_catz_entry_new()
 * dns_catz_entry_copy()

4 years agoMerge branch '2905-autoconf-check-for-struct-stat-pulls-in-fcntl-h-not-stat-h' into...
Mark Andrews [Wed, 13 Oct 2021 00:21:40 +0000 (00:21 +0000)] 
Merge branch '2905-autoconf-check-for-struct-stat-pulls-in-fcntl-h-not-stat-h' into 'main'

Resolve "autoconf check for struct stat pulls in fcntl.h not stat.h"

Closes #2905

See merge request isc-projects/bind9!5426

4 years agoUse '#include <sys/stat.h>' for the stat structure definition
Mark Andrews [Mon, 20 Sep 2021 07:33:56 +0000 (17:33 +1000)] 
Use '#include <sys/stat.h>' for the stat structure definition

POSIX.1-2008 changed the st_atim, st_mtim, and st_ctime members of the
struct stat from time_t to struct timespec and because not all operating
systems already implemented this version of the standard or historically
deviated to include own nanosecond precision in the structure.

The autoconf script used to include <sys/fcntl.h> which contradicts
POSIX.1 as it mandates <sys/stat.h> inclusion.  Change the autoconf
check to include <sys/stat.h>.

Also fix the missing AC_MSG_RESULT([yes/no]) in the check.

4 years agoMerge branch 'each-cleanup-ancient' into 'main'
Evan Hunt [Tue, 12 Oct 2021 21:43:34 +0000 (21:43 +0000)] 
Merge branch 'each-cleanup-ancient' into 'main'

cleanup references to ancient named.conf options

Closes #357

See merge request isc-projects/bind9!5407

4 years agocleanup references to ancient named.conf options
Evan Hunt [Wed, 15 Sep 2021 15:55:32 +0000 (08:55 -0700)] 
cleanup references to ancient named.conf options

some removed options were still referenced in config.c or the ARM.

4 years agoMerge branch '2929-remove-master-slave-keywords' into 'main'
Evan Hunt [Tue, 12 Oct 2021 20:55:53 +0000 (20:55 +0000)] 
Merge branch '2929-remove-master-slave-keywords' into 'main'

Replace "master/slave" terminology

Closes #2929

See merge request isc-projects/bind9!5466

4 years agoRemove unused bin/tests/named.conf
Matthijs Mekking [Tue, 12 Oct 2021 07:28:17 +0000 (09:28 +0200)] 
Remove unused bin/tests/named.conf

This file serves no useful purpose anymore and can thus be removed.

4 years agoReplace "master/slave" terms in code
Matthijs Mekking [Tue, 5 Oct 2021 09:28:24 +0000 (11:28 +0200)] 
Replace "master/slave" terms in code

Replace some "master/slave" terminology in the code with the preferred
"primary/secondary" keywords. This also changes user output such as
log messages, and fixes a typo ("seconary") in cfg_test.c.

There are still some references to "master" and "slave" for various
reasons:

- The old syntax can still be used as a synonym.
- The master syntax is kept when it refers to master files and formats.
- This commit replaces mainly keywords that are local. If "master" or
  "slave" is used in for example a structure that is all over the
  place, it is considered out of scope for the moment.

4 years agoReplace "master/slave" terms in documentation
Matthijs Mekking [Tue, 5 Oct 2021 09:15:06 +0000 (11:15 +0200)] 
Replace "master/slave" terms in documentation

Replace those terms with the preferred "primary/secondary" keywords.

4 years agoReplace "master/slave" terms in code comments
Matthijs Mekking [Tue, 5 Oct 2021 09:07:44 +0000 (11:07 +0200)] 
Replace "master/slave" terms in code comments

Replace those terms with the preferred "primary/secondary" keywords.

4 years agoReplace "master/slave" terminology in tests
Matthijs Mekking [Tue, 5 Oct 2021 08:41:27 +0000 (10:41 +0200)] 
Replace "master/slave" terminology in tests

Replace most "master/slave" terminology in tests with the preferred
"primary/secondary", with the following exceptions:

- When testing the old syntax
- When master is used in master file and master file format terms
- When master is used in hostmaster or postmaster terms
- When master used in legacy domain names (for example in dig.batch)
- When there is no replacement (for example default-masters)

4 years agoMerge branch '2941-implement-incremental-hashing-resize' into 'main'
Ondřej Surý [Tue, 12 Oct 2021 14:35:37 +0000 (14:35 +0000)] 
Merge branch '2941-implement-incremental-hashing-resize' into 'main'

Implement incremental hash table resizing

Closes #2941

See merge request isc-projects/bind9!5476

4 years agoAdd CHANGES and release note for [GL #2941]
Ondřej Surý [Thu, 7 Oct 2021 19:55:18 +0000 (21:55 +0200)] 
Add CHANGES and release note for [GL #2941]

4 years agodns/rbt.c: Implement incremental hash table resizing
Ondřej Surý [Thu, 7 Oct 2021 16:41:02 +0000 (18:41 +0200)] 
dns/rbt.c: Implement incremental hash table resizing

Originally, the hash table used in RBT database would be resized when it
reached certain number of elements (defined by overcommit).  This was
causing resolution brownouts for busy resolvers, because the rehashing
could take several seconds to complete.  This was mitigated by
pre-allocating the hash table in the RBT database used for caching to be
large-enough as determined by max-cache-size.  The downside of this
solution was that the pre-allocated hash table could take a significant
chunk of the memory even when the resolver cache would be otherwise
empty because the default value for max-cache-size is 90% of available
memory.

Implement incremental resizing[1] to perform the rehashing gradually:

 1. During the resize, allocate the new hash table, but keep the old
    table unchanged.
 2. In each lookup or delete operation, check both tables.
 3. Perform insertion operations only in the new table.
 4. At each insertion also move r elements from the old table to the new
    table.
 5. When all elements are removed from the old table, deallocate it.

To ensure that the old table is completely copied over before the new
table itself needs to be enlarged, it is necessary to increase the
size of the table by a factor of at least (r + 1)/r during resizing.

In our implementation r is equal to 1.

The downside of this approach is that the old table and the new table
could stay in memory for longer when there are no new insertions into
the hash table for prolonged periods of time as the incremental
rehashing happens only during the insertions.

The upside of this approach is that it's no longer necessary to
pre-allocate large hash table, because the RBT hash table rehashing
doesn't cause resolution brownouts anymore and thus we can use the
memory as needed.

1. https://en.m.wikipedia.org/wiki/Hash_table#Dynamic_resizing

4 years agoMerge branch '1316-toggle-the-default-of-dnssec-dnskey-kskonly-to-yes' into 'main'
Matthijs Mekking [Tue, 12 Oct 2021 12:38:16 +0000 (12:38 +0000)] 
Merge branch '1316-toggle-the-default-of-dnssec-dnskey-kskonly-to-yes' into 'main'

Change default of dnssec-dnskey-kskonly to yes

Closes #1316

See merge request isc-projects/bind9!5472

4 years agoAdd CHANGES and release note for [GL #1316]
Matthijs Mekking [Wed, 6 Oct 2021 14:15:36 +0000 (16:15 +0200)] 
Add CHANGES and release note for [GL #1316]

4 years agoChange default of dnssec-dnskey-kskonly to yes
Matthijs Mekking [Wed, 6 Oct 2021 14:05:12 +0000 (16:05 +0200)] 
Change default of dnssec-dnskey-kskonly to yes

The extra RRSIG on DNSKEY, CDS and CDNSKEY RRsets add to the payload,
without having added value.

4 years agoMerge branch '1610-enable-UseSTD3ASCIIRules-in-idn2' into 'main'
Ondřej Surý [Tue, 12 Oct 2021 11:05:19 +0000 (11:05 +0000)] 
Merge branch '1610-enable-UseSTD3ASCIIRules-in-idn2' into 'main'

Enable IDN2_USE_STD3_ASCII_RULES to idn2 conversion functions

Closes #1610

See merge request isc-projects/bind9!5464

4 years agoAdd CHANGES and release note for [GL #1610]
Ondřej Surý [Tue, 5 Oct 2021 09:50:18 +0000 (11:50 +0200)] 
Add CHANGES and release note for [GL #1610]

4 years agoCorrect --with-idn references to --with-libidn2
Matthijs Mekking [Thu, 7 Oct 2021 09:55:29 +0000 (11:55 +0200)] 
Correct --with-idn references to --with-libidn2

The documentation and feature-test were using '--with-idn' but the
configure script doesn't recognize this option. The correct option to
enable IDN support is '--with-libidn2'.

4 years agoAdd idna test for UseSTD3ASCIIRules=true
Ondřej Surý [Wed, 6 Oct 2021 17:19:33 +0000 (19:19 +0200)] 
Add idna test for UseSTD3ASCIIRules=true

Add test to encode unicode sequence that encodes differently with
UseSTD3ASCIIRules=false which is default with idn2 >= 2.0.3 and
UseSTD3ASCIIRules=true which is what should be used to encode hostnames
and domains.

4 years agoEnable IDN2_USE_STD3_ASCII_RULES to idn2 conversion functions
Ondřej Surý [Tue, 5 Oct 2021 09:35:59 +0000 (11:35 +0200)] 
Enable IDN2_USE_STD3_ASCII_RULES to idn2 conversion functions

libidn2 defaults to UseSTD3ASCIIRules=false. That allows arbitrary ASCII
characters to show up in the toASCII output, including space and
underscore.  Enable IDN2_USE_STD3_ASCII_RULES to the libidn2 conversion
to disallow additional characters from the conversion (see Validity
Criteria[1]).

4 years agoMerge branch '2933-bump-the-default-clang-version-to-13' into 'main'
Ondřej Surý [Tue, 12 Oct 2021 09:29:13 +0000 (09:29 +0000)] 
Merge branch '2933-bump-the-default-clang-version-to-13' into 'main'

Change the LLVM tools version to 13

Closes #2933

See merge request isc-projects/bind9!5484

4 years agoUpdate the source code formatting using clang-format-13
Ondřej Surý [Tue, 12 Oct 2021 06:57:47 +0000 (08:57 +0200)] 
Update the source code formatting using clang-format-13

clang-format-13 fixed some of the formatting that clang-format-12 got
wrong.  Update the formatting.

4 years agoChange the LLVM tools version to 13
Ondřej Surý [Tue, 12 Oct 2021 06:55:57 +0000 (08:55 +0200)] 
Change the LLVM tools version to 13

LLVM 13.0.0 was released on 4. October 2021, change the default version
to the current stable.

4 years agoMerge branch 'michal/properly-handle-jemalloc-autoconf-variables' into 'main'
Michał Kępień [Tue, 12 Oct 2021 09:09:06 +0000 (09:09 +0000)] 
Merge branch 'michal/properly-handle-jemalloc-autoconf-variables' into 'main'

Properly handle JEMALLOC_* Autoconf variables

See merge request isc-projects/bind9!5486

4 years agoProperly handle JEMALLOC_* Autoconf variables
Michał Kępień [Tue, 12 Oct 2021 08:44:30 +0000 (10:44 +0200)] 
Properly handle JEMALLOC_* Autoconf variables

The AX_CHECK_JEMALLOC() m4 macro sets the JEMALLOC_CFLAGS variable, not
JEMALLOC_CPPFLAGS.  Furthermore, the JEMALLOC_CFLAGS and JEMALLOC_LIBS
variables should only be included in the build flags if jemalloc was
successfully configured.  Tweak lib/isc/Makefile.am accordingly.

4 years agoMerge branch '2935-cid-339035-1-of-1-explicit-null-dereferenced-forward_null' into...
Mark Andrews [Mon, 11 Oct 2021 23:16:22 +0000 (23:16 +0000)] 
Merge branch '2935-cid-339035-1-of-1-explicit-null-dereferenced-forward_null' into 'main'

Resolve "CID 339035 (#1 of 1): Explicit null dereferenced (FORWARD_NULL)"

Closes #2935

See merge request isc-projects/bind9!5470

4 years agoAdd CHANGES for [GL #2935]
Mark Andrews [Wed, 6 Oct 2021 08:18:31 +0000 (19:18 +1100)] 
Add CHANGES for [GL #2935]

4 years agoFix cleanup of signature buffer in dns_dnssec_signmessage
Mark Andrews [Wed, 6 Oct 2021 08:10:36 +0000 (19:10 +1100)] 
Fix cleanup of signature buffer in dns_dnssec_signmessage

A NULL pointer could be freed if error handling occured.

4 years agoMerge branch '2899-placeholder' into 'main'
Michał Kępień [Fri, 8 Oct 2021 10:07:46 +0000 (10:07 +0000)] 
Merge branch '2899-placeholder' into 'main'

Add placeholder for GL #2899

See merge request isc-projects/bind9!5479

4 years agoAdd placeholder for GL #2899
Michał Kępień [Fri, 8 Oct 2021 10:04:04 +0000 (12:04 +0200)] 
Add placeholder for GL #2899

4 years agoMerge branch '719-make-isc_result-static-CHANGES' into 'main'
Ondřej Surý [Thu, 7 Oct 2021 06:48:02 +0000 (06:48 +0000)] 
Merge branch '719-make-isc_result-static-CHANGES' into 'main'

Update isc_result_t developer documentation and CHANGES

Closes #719

See merge request isc-projects/bind9!5475

4 years agoAdd CHANGES notes for [GL #719]
Ondřej Surý [Thu, 7 Oct 2021 06:06:54 +0000 (08:06 +0200)] 
Add CHANGES notes for [GL #719]

4 years agoUpdate isc_result_t developer documentation
Ondřej Surý [Thu, 7 Oct 2021 06:05:16 +0000 (08:05 +0200)] 
Update isc_result_t developer documentation

There's no multiple result.{c,h} location to defining result codes,
update the documentation accordingly.

4 years agoMerge branch '2934-cid-339111-memory-corruptions-use_after_free' into 'main'
Ondřej Surý [Wed, 6 Oct 2021 15:45:58 +0000 (15:45 +0000)] 
Merge branch '2934-cid-339111-memory-corruptions-use_after_free' into 'main'

Resolve "CID 339111:  Memory - corruptions  (USE_AFTER_FREE)"

Closes #2934

See merge request isc-projects/bind9!5469

4 years agoCorrectly call dns_dispatch_done() in dns_dispatch_cancel()
Mark Andrews [Wed, 6 Oct 2021 07:32:19 +0000 (18:32 +1100)] 
Correctly call dns_dispatch_done() in dns_dispatch_cancel()

Pass '&resp' rather than 'respp' as we have already cleared '*respp'
when we took ownership of 'resp'.

4 years agoMerge branch '719-make-isc_result-static' into 'main'
Ondřej Surý [Wed, 6 Oct 2021 09:40:47 +0000 (09:40 +0000)] 
Merge branch '719-make-isc_result-static' into 'main'

Make isc_result a static enum

Closes #719

See merge request isc-projects/bind9!5458

4 years agoMake isc_result a static enum
Ondřej Surý [Mon, 4 Oct 2021 15:14:53 +0000 (17:14 +0200)] 
Make isc_result a static enum

Remove the dynamic registration of result codes.  Convert isc_result_t
from unsigned + #defines into 32-bit enum type in grand unified
<isc/result.h> header.  Keep the existing values of the result codes
even at the expense of the description and identifier tables being
unnecessary large.

Additionally, add couple of:

    switch (result) {
    [...]
    default:
        break;
    }

statements where compiler now complains about missing enum values in the
switch statement.

4 years agoImprove STATIC_ASSERT macro for older compilers
Ondřej Surý [Mon, 4 Oct 2021 15:14:53 +0000 (17:14 +0200)] 
Improve STATIC_ASSERT macro for older compilers

Previously, when using compiler without support for static assertions,
the STATIC_ASSERT() macro would be replaced with runtime assertion.
Change the STATIC_ASSERT() macro to a version that's compile time
assertion even when using pre-C11 compilers.

Courtesy of Joseph Quinsey: https://godbolt.org/z/K9RvWS

4 years agoRemove duplicate DE_CONST macro
Ondřej Surý [Tue, 5 Oct 2021 14:08:24 +0000 (16:08 +0200)] 
Remove duplicate DE_CONST macro

Both <isccc/util.h> and <isc/util.h> defined DE_CONST() macro.  As
<isccc/util.h> header includes <isc/util.h>, remove the macro from
<isccc/util.h> header.

4 years agoChange the ISC_R_SUCCESS to DNS_RRL_RESULT_OK in dns_rrl()
Ondřej Surý [Mon, 4 Oct 2021 15:14:53 +0000 (17:14 +0200)] 
Change the ISC_R_SUCCESS to DNS_RRL_RESULT_OK in dns_rrl()

There's value mismatch between the return type of dns_rrl() that's
dns_rrl_result_t and ISC_R_SUCCESS which belongs to isc_result_t.  This
works incidentally, because DNS_RRL_RESULT_OK == ISC_R_SUCCESS.

This would break when we change isc_result_t to be static enum in
consecutive commit.  Change the value to match the type.

4 years agoMerge branch '2928-coverity-fixes' into 'main'
Evan Hunt [Tue, 5 Oct 2021 19:30:55 +0000 (19:30 +0000)] 
Merge branch '2928-coverity-fixes' into 'main'

address coverity and sanitizer reports

Closes #2928

See merge request isc-projects/bind9!5456

4 years agoincrement fctx references while waiting for validator
Evan Hunt [Tue, 5 Oct 2021 00:07:22 +0000 (17:07 -0700)] 
increment fctx references while waiting for validator

We need to ensure the fctx isn't freed while the validator
is pending.

4 years agorefactor dispatch cancellation
Evan Hunt [Sun, 3 Oct 2021 22:15:50 +0000 (15:15 -0700)] 
refactor dispatch cancellation

Renamed some functions for clarity and readability:

- dns_dispatch_addresponse() -> dns_dispatch_add()
- dns_dispatch_removeresponse() -> dns_dispatch_done()

The dns_dispatch_cancel() function now calls dns_dispatch_done()
directly, so it is no longer ever necessary to call both functions.

dns_dispatch_cancel() is used to terminate dispatch connections
that are still pending, while dns_dispatch_done() is used when they
are complete.

4 years agosimplify sending request events
Evan Hunt [Mon, 4 Oct 2021 00:24:35 +0000 (17:24 -0700)] 
simplify sending request events

The function send_if_done() was just a front-end for req_sendevents().

4 years agoclarify fctx_cancelquery() behavior
Evan Hunt [Sun, 3 Oct 2021 20:58:41 +0000 (13:58 -0700)] 
clarify fctx_cancelquery() behavior

Cleaned up dereferencing of query objects, and added a comment
explaining it better.

4 years agoMerge branch 'ondrej/fix-missing-OPENSSL_CFLAGS-in-bind9' into 'main'
Ondřej Surý [Tue, 5 Oct 2021 13:15:57 +0000 (13:15 +0000)] 
Merge branch 'ondrej/fix-missing-OPENSSL_CFLAGS-in-bind9' into 'main'

Add OPENSSL_CFLAGS to libbind9 Makefile.am

See merge request isc-projects/bind9!5465

4 years agoAdd OPENSSL_CFLAGS to libbind9 Makefile.am
Ondřej Surý [Tue, 5 Oct 2021 12:21:21 +0000 (14:21 +0200)] 
Add OPENSSL_CFLAGS to libbind9 Makefile.am

The build would fail if the OpenSSL libraries were not in default
include path because we include <openssl/opensslv.h> header in
lib/bind9/check.c.  Add $(OPENSSL_CFLAGS) to lib/bind9/Makefile.am.

4 years agoMerge branch '2794-dot-alpn-for-xfrs' into 'main'
Artem Boldariev [Tue, 5 Oct 2021 08:49:27 +0000 (08:49 +0000)] 
Merge branch '2794-dot-alpn-for-xfrs' into 'main'

Resolve #2794, #2884: make "dot" ALPN token negotiation to be required for XoT

Closes #2884 and #2794

See merge request isc-projects/bind9!5391

4 years agoAdd an entry to the release notes file [GL #2794]
Artem Boldariev [Fri, 10 Sep 2021 08:25:12 +0000 (11:25 +0300)] 
Add an entry to the release notes file [GL #2794]

Mention that "dot" ALPN tag is now required for XoT.

4 years agoAdd an entry to the CHANGES [GL #2884]
Artem Boldariev [Fri, 10 Sep 2021 08:17:47 +0000 (11:17 +0300)] 
Add an entry to the CHANGES [GL #2884]

Mention that the bug making dig abort during zone transfers sometimes
is resolved.

4 years agoDoT: do not attempt to call read callback if it is not avaialble
Artem Boldariev [Thu, 9 Sep 2021 13:52:55 +0000 (16:52 +0300)] 
DoT: do not attempt to call read callback if it is not avaialble

This commit fixes a crash in DoT code when it was attempting to call a
read callback on the later stages of the connection when it is not
available.

It also fixes [GL #2884] (back-trace provided in the bug report is
exactly the same as was seen when fixing this problem).

4 years agoAdd an entry to the CHANGES file [GL #2794]
Artem Boldariev [Wed, 8 Sep 2021 09:15:13 +0000 (12:15 +0300)] 
Add an entry to the CHANGES file [GL #2794]

Mention in the CHANGES file that "dot" ALPN token is required to be
negotiated for XoT.

4 years agoDo not allow zone transfers in dig over TLS without ALPN
Artem Boldariev [Thu, 2 Sep 2021 12:39:50 +0000 (15:39 +0300)] 
Do not allow zone transfers in dig over TLS without ALPN

This commit makes dig fail with error in case a zone transfer is
attempted over a connections where ALPN was not negotiated. All other
request types will work fine.

4 years agoAdd ALPN negotiation tests to TLS DNS test set
Artem Boldariev [Tue, 31 Aug 2021 13:41:59 +0000 (16:41 +0300)] 
Add ALPN negotiation tests to TLS DNS test set

This commits adds a set of unit tests to ensure that ALPN happens over
the connections and that the result of the negotiation can be checked.

4 years agoRequire "dot" ALPN token for incoming xfrs over XoT
Artem Boldariev [Mon, 30 Aug 2021 14:13:00 +0000 (17:13 +0300)] 
Require "dot" ALPN token for incoming xfrs over XoT

This commit make the code handling incoming zone transfers to verify
if they are allowed to be done over the underlying connections. As a
result the check ensures that the "dot" ALPN token has been negotiated
over the underlying connection.

4 years agoMake dig advertise the "dot" ALPN token for DoT connections
Artem Boldariev [Thu, 26 Aug 2021 13:36:36 +0000 (16:36 +0300)] 
Make dig advertise the "dot" ALPN token for DoT connections

This commit makes dig advertise the "dot" ALPN token to make it
possible for ALPN to happen.

4 years agoRequire "dot" ALPN token for zone transfer requests over DoT (XoT)
Artem Boldariev [Thu, 26 Aug 2021 13:06:42 +0000 (16:06 +0300)] 
Require "dot" ALPN token for zone transfer requests over DoT (XoT)

This commit makes BIND verify that zone transfers are allowed to be
done over the underlying connection. Currently, it makes sense only
for DoT, but the code is deliberately made to be protocol-agnostic.

4 years agoAdd isc_nm_xfr_allowed() function
Artem Boldariev [Thu, 26 Aug 2021 12:07:20 +0000 (15:07 +0300)] 
Add isc_nm_xfr_allowed() function

The intention of having this function is to have a predicate to check
if a zone transfer could be performed over the given handle. In most
cases we can assume that we can do zone transfers over any stream
transport except DoH, but this assumption will not work for zone
transfers over DoT (XoT), as the RFC9103 requires ALPN to happen,
which might not be the case for all deployments of DoT.

4 years agoLow level code to support ALPN in DoT
Artem Boldariev [Wed, 25 Aug 2021 12:31:20 +0000 (15:31 +0300)] 
Low level code to support ALPN in DoT

This commit adds low-level code necessary to support ALPN in DoT as
XoT requires "dot" ALPN token to be negotiated on a connection for
zone transfers.

4 years agoMerge branch '2900-listenlist_test-notify_test-and-query_test-failing' into 'main'
Mark Andrews [Tue, 5 Oct 2021 06:44:43 +0000 (06:44 +0000)] 
Merge branch '2900-listenlist_test-notify_test-and-query_test-failing' into 'main'

Resolve "listenlist_test, notify_test, and query_test failing."

Closes #2900

See merge request isc-projects/bind9!5461

4 years agoIncrease the number of file descriptors available
Mark Andrews [Tue, 5 Oct 2021 05:01:56 +0000 (16:01 +1100)] 
Increase the number of file descriptors available

The 'listenlist_test', 'notify_test', and 'query_test' tests failed
when the descriptor limit was 256 on MacOS 11.6 with 8 cpus. On the
test platform the limit needed to be increased to ~400.  Increase
the limit to at least 1024 to give some head room.

4 years agoMerge branch '88-make-libs-private' into 'main'
Evan Hunt [Mon, 4 Oct 2021 21:16:34 +0000 (21:16 +0000)] 
Merge branch '88-make-libs-private' into 'main'

remove libdns init/shutdown functions

Closes #88

See merge request isc-projects/bind9!5405

4 years agoCHANGES for [GL #88]
Evan Hunt [Wed, 15 Sep 2021 08:48:04 +0000 (01:48 -0700)] 
CHANGES for [GL #88]

4 years agoRemove libns init/shutdown functions
Evan Hunt [Wed, 15 Sep 2021 08:42:14 +0000 (01:42 -0700)] 
Remove libns init/shutdown functions

as libraries are no longer exported, these functions served
no useful purpose.

4 years agoRemove libdns init/shutdown functions
Evan Hunt [Wed, 15 Sep 2021 08:40:31 +0000 (01:40 -0700)] 
Remove libdns init/shutdown functions

as libdns is no longer exported, it's not necessary to have
init and shutdown functions. the only purpose they served
was to create a private mctx and run dst_lib_init(), which
can be called directly instead.

4 years agoMerge branch '2925-do-not-allow-default-http' into 'main'
Artem Boldariev [Mon, 4 Oct 2021 15:04:07 +0000 (15:04 +0000)] 
Merge branch '2925-do-not-allow-default-http' into 'main'

Do not allow defining "http" clauses named "default"

Closes #2925

See merge request isc-projects/bind9!5453

4 years agoModify CHANGES [GL #2925]
Artem Boldariev [Thu, 30 Sep 2021 09:42:11 +0000 (12:42 +0300)] 
Modify CHANGES [GL #2925]

Mention that it is not allowed defining "http" clauses named "default"

4 years agoDo not allow defining "http" clauses named "default"
Artem Boldariev [Thu, 30 Sep 2021 09:40:03 +0000 (12:40 +0300)] 
Do not allow defining "http" clauses named "default"

This name is reserved for being used in 'listen-on' statements only.

4 years agoMerge branch '2401-use-netmgr-for-dispatch' into 'main' 728/merge
Evan Hunt [Sat, 2 Oct 2021 19:04:03 +0000 (19:04 +0000)] 
Merge branch '2401-use-netmgr-for-dispatch' into 'main'

Resolve "use netmgr for dispatch"

Closes #2401

See merge request isc-projects/bind9!4601

4 years agoAdd CHANGES and release note for [GL #2401]
Evan Hunt [Tue, 28 Sep 2021 00:51:44 +0000 (17:51 -0700)] 
Add CHANGES and release note for [GL #2401]

4 years agoCorrected several system test issues
Evan Hunt [Fri, 24 Sep 2021 22:45:57 +0000 (15:45 -0700)] 
Corrected several system test issues

- serve-stale: dig wasn't always running in background when it should.
  some of the serve-stale test cases are based on groups of dig calls
  running simultaneously in the background: the test pauses and resumes
  running after 'wait'. in some cases the final call to dig in a group
  wasn't in the background, and this sometimes caused delays that
  affected later test results.  in another case, a test was simplified
  and made more reliable by running dig in the foreground removing a
  sleep.

- serve-stale: The extension of the dig timeout period from 10 to 11
  seconds in commit 5307bf64ce80 was left undone in a few places and has
  now been completed.

- serve-stale: Resolver-query-timeout was set incorrectly.  a comment
  above a test case in serve-stale/tests.sh says: "We configured a long
  value of 30 seconds for resolver-query-timeout," but
  resolver-query-timeout was actually set to 10, not 30. this is now
  fixed.

- rpz: Force retransfer of the fast-expire zone, to ensure it's fully
  loaded in ns3; previously it could have been left unloaded if ns5
  wasn't up yet when ns3 attempted the zone transfer.

- statistics: The TCP4SendErr counter is incremented when a TCP dispatch
  is canceled while sending. depending on test timing, this may have
  happened by the time the statistics are dumped. worked around by
  ignoring that stat couunter when checking for errors.

- hooks: Add a prereq.sh script to prevent running under TSAN.

- zero: Disabled the servfail cache so that SERVFAIL is reported only
  when there actually is a failure, not repeatedly every time the same
  query is sent.

4 years agoresolver: Fixed shutdown processing
Evan Hunt [Thu, 5 Aug 2021 16:33:53 +0000 (09:33 -0700)] 
resolver: Fixed shutdown processing

- Prevent shutdown races: attach/detach to dns_resolver in dns_fetch_t
  and fctx_t; delay destruction of fctx when finds are still active;
  reference the fctx while canceling; reverse the order of
  fctx_destroy() and empty_bucket().

- Don't resend queries if fetches have been canceled.

- It's possible for fctx_doshutdown() to run before a TCP connection has
  completed. if the query is not on the queries list, then it is not
  canceled, but the adbaddrinfo is freed. when tcp_connected() runs
  later, the query is in an inconstent state. to fix this, we add the
  query to queries before running dns_dispatch_connect(), instead of in
  the connect callback.

- Combined the five fctx_cleanup* functions into a single one.

- Added comments and changed some names to make this code easier to
  understand.

4 years agodispatch: Enforce original timeout when calling _getnext()
Evan Hunt [Fri, 1 Oct 2021 19:53:31 +0000 (12:53 -0700)] 
dispatch: Enforce original timeout when calling _getnext()

udp_recv() will call dispatch_getnext() if the message received is
invalid or doesn't match; we need to reduce the timeout each time this
happens so we can't be starved forever by someone sending garbage
packets.

4 years agodispatch: Clean up connect and recv callbacks
Evan Hunt [Wed, 4 Aug 2021 20:14:11 +0000 (13:14 -0700)] 
dispatch: Clean up connect and recv callbacks

- disp_connected() has been split into two functions,
  udp_connected() (which takes 'resp' as an argument) and
  tcp_connected() (which takes 'disp', and calls the connect callbacks
  for all pending resps).

- In dns_dispatch_connect(), if a connection is already open, we need to
  detach the dispentry immediately because we won't be running
  tcp_connected().

- dns_disptach_cancel() also now calls the connect callbacks for pending
  TCP responses, and the response callbacks for open TCP connections
  waiting on read.

- If udp_connected() runs after dns_dispatch_cancel() has been called,
  ensure that the caller's connect callback is run.

- If a UDP connection fails with EADDRINUSE, we try again up to five
  times with a different local port number before giving up.

- If a TCP connection is canceled while still pending connection, the
  connect timeout may still fire. we attach the dispatch before
  connecting to ensure that it won't be detached too soon in this case.

- The dispentry is no longer removed from the pending list when
  deactivating, so that the connect callback can still be run if
  dns_dispatch_removeresponse() was run while the connecting was
  pending.

- Rewrote dns_dispatch_gettcp() to avoid a data race.

- startrecv() and dispatch_getnext() can be called with a NULL resp when
  using TCP.

- Refactored udp_recv() and tcp_recv() and added result logging.

- EOF is now treated the same as CANCELED in response callbacks.

- ISC_R_SHUTTINGDOWN is sent to the reponse callbacks for all resps if
  tcp_recv() is triggered by a netmgr shutdown.  (response callbacks
  are *not* sent by udp_recv() in this case.)

4 years agodispatch: Fix several connect-related issues
Evan Hunt [Wed, 4 Aug 2021 01:24:27 +0000 (18:24 -0700)] 
dispatch: Fix several connect-related issues

- startrecv() and getnext() have been rewritten.

- Don't set TCP flag when connecting a UDP dispatch.

- Prevent TCP connections from trying to connect twice.

- dns_dispatch_gettcp() can now find a matching TCP dispatch that has
  not yet fully connected, and attach to it.  when the connection is
  completed, the connect callbacks are run for all of the pending
  entries.

- An atomic 'state' variable is now used for connection state instead of
  attributes.

- When dns_dispatch_cancel() is called on a TCP dispatch entry, only
  that one entry is canceled. the dispatch itself should not be shut
  down until there are no dispatch entries left associated with it.

- Other incidental cleanup, including removing DNS_DISPATCHATTR_IPV4 and
  _IPV6 (they were being set in the dispatch attributes but never used),
  cleaning up dns_requestmgr_create(), and renaming dns_dispatch_read()
  to the more descriptive dns_dispatch_resume().

4 years agodispatch: Remove 'timeout' callback
Ondřej Surý [Tue, 3 Aug 2021 13:27:06 +0000 (15:27 +0200)] 
dispatch: Remove 'timeout' callback

- It is no longer necessary to pass a 'timeout' callback to
  dns_dispatch_addresponse(); timeouts are handled directly by the
  'response' callback instead.

- The netmgr handle is no longer passed to dispatch callbacks, since
  they don't (and can't) use it. instead, dispatch_cb_t now takes a
  result code, region, and argument.

- Cleaned up timeout-related tests in dispatch_test.c

4 years agodispatch: Refactor to eliminate dns_dispatchevent
Evan Hunt [Tue, 27 Jul 2021 03:23:18 +0000 (20:23 -0700)] 
dispatch: Refactor to eliminate dns_dispatchevent

- Responses received by the dispatch are no longer sent to the caller
  via a task event, but via a netmgr-style recv callback.  the 'action'
  parameter to dns_dispatch_addresponse() is now called 'response' and
  is called directly from udp_recv() or tcp_recv() when a valid response
  has been received.

- All references to isc_task and isc_taskmgr have been removed from
  dispatch functions.

- All references to dns_dispatchevent_t have been removed and the type
  has been deleted.

- Added a task to the resolver response context, to be used for fctx
  events.

- When the caller cancels an operation, the response handler will be
  called with ISC_R_CANCELED; it can abort immediately since the caller
  will presumably have taken care of cleanup already.

- Cleaned up attach/detach in resquery and request.

4 years agoRemove DISPATH_TRACE, RESOLVER_TRACE and REQ_TRACE logging
Evan Hunt [Thu, 9 Sep 2021 22:25:08 +0000 (15:25 -0700)] 
Remove DISPATH_TRACE, RESOLVER_TRACE and REQ_TRACE logging

Remove the debugging printfs. (leaving this as a separate commit rather
than squashing it so we can restore it in the future if we ever need it
again.)

4 years agoRefactor dispatch, resolver and request
Evan Hunt [Wed, 26 May 2021 05:54:17 +0000 (22:54 -0700)] 
Refactor dispatch, resolver and request

Since every dispsock was associated with a dispentry anyway (though not
always vice versa), the members of dispsock have been combined into
dispentry, which is now reference-counted.  dispentry objects are now
attached before connecting and detached afterward to prevent races
between the connect callback and dns_dispatch_removeresponse().

Dispatch and dispatchmgr objects are now reference counted as well, and
the shutdown process has been simplified.  reference counting of
resquery and request objects has also been cleaned up significantly.

dns_dispatch_cancel() now flags a dispentry as having been canceled, so
that if the connect callback runs after cancellation, it will not
initiate a read.

The isblackholed() function has been simplified.

4 years agoRewrite dns_resolver and dns_request to use netmgr timeouts
Evan Hunt [Fri, 23 Apr 2021 01:58:01 +0000 (18:58 -0700)] 
Rewrite dns_resolver and dns_request to use netmgr timeouts

- The `timeout_action` parameter to dns_dispatch_addresponse() been
  replaced with a netmgr callback that is called when a dispatch read
  times out.  this callback may optionally reset the read timer and
  resume reading.

- Added a function to convert isc_interval to milliseconds; this is used
  to translate fctx->interval into a value that can be passed to
  dns_dispatch_addresponse() as the timeout.

- Note that netmgr timeouts are accurate to the millisecond, so code to
  check whether a timeout has been reached cannot rely on microsecond
  accuracy.

- If serve-stale is configured, then a timeout received by the resolver
  may trigger it to return stale data, and then resume waiting for the
  read timeout. this is no longer based on a separate stale timer.

- The code for canceling requests in request.c has been altered so that
  it can run asynchronously.

- TCP timeout events apply to the dispatch, which may be shared by
  multiple queries.  since in the event of a timeout we have no query ID
  to use to identify the resp we wanted, we now just send the timeout to
  the oldest query that was pending.

- There was some additional refactoring in the resolver: combining
  fctx_join() and fctx_try_events() into one function to reduce code
  duplication, and using fixednames in fetchctx and fetchevent.

- Incidental fix: new_adbaddrinfo() can't return NULL anymore, so the
  code can be simplified.

4 years agoConvert dispatch to netmgr
Evan Hunt [Thu, 14 Jan 2021 21:02:57 +0000 (13:02 -0800)] 
Convert dispatch to netmgr

The flow of operations in dispatch is changing and will now be similar
for both UDP and TCP queries:

1) Call dns_dispatch_addresponse() to assign a query ID and register
   that we'll be listening for a response with that ID soon. the
   parameters for this function include callback functions to inform the
   caller when the socket is connected and when the message has been
   sent, as well as a task action that will be sent when the response
   arrives. (later this could become a netmgr callback, but at this
   stage to minimize disruption to the calling code, we continue to use
   isc_task for the response event.) on successful completion of this
   function, a dispatch entry object will be instantiated.

2) Call dns_dispatch_connect() on the dispatch entry. this runs
   isc_nm_udpconnect() or isc_nm_tcpdnsconnect(), as needed, and begins
   listening for responses. the caller is informed via a callback
   function when the connection is established.

3) Call dns_dispatch_send() on the dispatch entry. this runs
   isc_nm_send() to send a request.

4) Call dns_dispatch_removeresponse() to terminate listening and close
   the connection.

Implementation comments below:

- As we will be using netmgr buffers now.  code to send the length in
  TCP queries has also been removed as that is handled by the netmgr.

- TCP dispatches can be used by multiple simultaneous queries, so
  dns_dispatch_connect() now checks whether the dispatch is already
  connected before calling isc_nm_tcpdnsconnect() again.

- Running dns_dispatch_getnext() from a non-network thread caused a
  crash due to assertions in the netmgr read functions that appear to be
  unnecessary now. the assertions have been removed.

- fctx->nqueries was formerly incremented when the connection was
  successful, but is now incremented when the query is started and
  decremented if the connection fails.

- It's no longer necessary for each dispatch to have a pool of tasks, so
  there's now a single task per dispatch.

- Dispatch code to avoid UDP ports already in use has been removed.

- dns_resolver and dns_request have been modified to use netmgr callback
  functions instead of task events. some additional changes were needed
  to handle shutdown processing correctly.

- Timeout processing is not yet fully converted to use netmgr timeouts.

- Fixed a lock order cycle reported by TSAN (view -> zone-> adb -> view)
  by by calling dns_zt functions without holding the view lock.

4 years agonetmgr fixes needed for dispatch
Ondřej Surý [Mon, 26 Jul 2021 11:14:41 +0000 (13:14 +0200)] 
netmgr fixes needed for dispatch

- The read timer must always be stopped when reading stops.

- Read callbacks can now call isc_nm_read() again in TCP, TCPDNS and
  TLSDNS; previously this caused an assertion.

- The wrong failure code could be sent after a UDP recv failure because
  the if statements were in the wrong order. the check for a NULL
  address needs to be after the check for an error code, otherwise the
  result will always be set to ISC_R_EOF.

- When aborting a read or connect because the netmgr is shutting down,
  use ISC_R_SHUTTINGDOWN. (ISC_R_CANCELED is now reserved for when the
  read has been canceled by the caller.)

- A new function isc_nmhandle_timer_running() has been added enabling a
  callback to check whether the timer has been reset after processing a
  timeout.

- Incidental netmgr fix: always use isc__nm_closing() instead of
  referencing sock->mgr->closing directly

- Corrected a few comments that used outdated function names.

4 years agoRemove reference count REQUIRE in isc_nm_read()
Evan Hunt [Mon, 25 Jan 2021 21:14:14 +0000 (13:14 -0800)] 
Remove reference count REQUIRE in isc_nm_read()

Previously isc_nm_read() required references on the handle to be at
least 2, under the assumption that it would only ever be called from a
connect or accept callback. however, it can also be called from a read
callback, in which case the reference count might be only 1.

4 years agoMove isc_socket_cancel() calls into dispatch
Evan Hunt [Tue, 5 Jan 2021 07:51:07 +0000 (23:51 -0800)] 
Move isc_socket_cancel() calls into dispatch

We now use dns_dispatch_cancel() for this purpose. NOTE: The caller
still has to track whether there are pending send or connect events in
the dispatch or dispatch entry; later this should be moved into the
dispatch module as well.

Also removed some public dns_dispatch_*() API calls that are no longer
used outside dispatch itself.

4 years agoMove isc_socket_sendto2() calls into dispatch
Evan Hunt [Tue, 5 Jan 2021 07:03:50 +0000 (23:03 -0800)] 
Move isc_socket_sendto2() calls into dispatch

We now use dns_dispatch_send() for this purpose.

4 years agoMove isc_socket_getsockname() calls into dispatch
Evan Hunt [Mon, 4 Jan 2021 22:38:35 +0000 (14:38 -0800)] 
Move isc_socket_getsockname() calls into dispatch

We now use dns_dispentry_getlocaladdress(). (this API is likely to be
cleaned up further later.)

4 years agoMove isc_socket_connect() calls into dispatch
Evan Hunt [Sat, 19 Dec 2020 09:34:41 +0000 (01:34 -0800)] 
Move isc_socket_connect() calls into dispatch

dns_dispatch_connect() connects a dispatch socket (for TCP) or a
dispatch entry socket (for UDP). This is the next step in moving all
uses of the isc_socket code into the dispatch module.

This API is temporary; it needs to be cleaned up further so that it can
be called the same way for both TCP and UDP.

4 years agoTemporarily move dns_tcpmsg functionality into dispatch
Evan Hunt [Sat, 19 Dec 2020 01:21:00 +0000 (17:21 -0800)] 
Temporarily move dns_tcpmsg functionality into dispatch

Continuing the effort to move all uses of the isc_socket API into
dispatch.c, this commit removes the dns_tcpmsg module entirely, as
dispatch was its only caller, and moves the parts of its functionality
that were being used into the dispatch module.

This code will be removed when we switch to using netmgr TCPDNS.

4 years agoCreating TCP dispatch now creates/binds the socket
Evan Hunt [Fri, 18 Dec 2020 22:59:50 +0000 (14:59 -0800)] 
Creating TCP dispatch now creates/binds the socket

Previously, creation of TCP dispatches differed from UDP in that a TCP
dispatch was created to attach to an existing socket, whereas a UDP
dispatch would be created in a vacuum and sockets would be opened on
demand when a transaction was initiated.

We are moving as much socket code as possible into the dispatch module,
so that it can be replaced with a netmgr version as easily as
possible. (This will also have the side effect of making TCP and UDP
dispatches more similar.)

As a step in that direction, this commit changes
dns_dispatch_createtcp() so that it creates the TCP socket.