]> git.ipfire.org Git - thirdparty/bind9.git/log
thirdparty/bind9.git
5 years agoVarious text edits and fixes to the documentation
Suzanne Goldlust [Mon, 8 Jun 2020 15:33:45 +0000 (15:33 +0000)] 
Various text edits and fixes to the documentation

(cherry picked from commit 5aa5ad5abcb61bef7f2da8f619cab57485255441)

5 years agoMerge branch '1948-primaries-synonym-v9_16' into 'v9_16'
Michał Kępień [Tue, 12 Jan 2021 14:24:06 +0000 (14:24 +0000)] 
Merge branch '1948-primaries-synonym-v9_16' into 'v9_16'

[v9_16] Resolve "add synonym for "masters""

See merge request isc-projects/bind9!4554

5 years agoCHANGES, release note
Evan Hunt [Wed, 17 Jun 2020 09:39:58 +0000 (02:39 -0700)] 
CHANGES, release note

(cherry picked from commit 565f99f9e565671d7370a3309cbe156b173cd4ac)

5 years agofurther tidying of primary/secondary terminology in system tests
Evan Hunt [Tue, 30 Jun 2020 20:10:59 +0000 (13:10 -0700)] 
further tidying of primary/secondary terminology in system tests

this changes most visble uses of master/slave terminology in tests.sh
and most uses of 'type master' or 'type slave' in named.conf files.
files in the checkconf test were not updated in order to confirm that
the old syntax still works. rpzrecurse was also left mostly unchanged
to avoid interference with DNSRPS.

(cherry picked from commit e43b3c1fa1f3f5fc8a9a93303cc87a2d7dc7da03)

5 years agouse primary/secondary terminology in 'rndc zonestatus'
Evan Hunt [Tue, 30 Jun 2020 20:03:11 +0000 (13:03 -0700)] 
use primary/secondary terminology in 'rndc zonestatus'

(cherry picked from commit 68c384e11822c2ca7f742d63bac9ce757c6296d2)

5 years agoprevent "primaries" lists from having duplicate names
Evan Hunt [Fri, 26 Jun 2020 04:59:56 +0000 (21:59 -0700)] 
prevent "primaries" lists from having duplicate names

it is now an error to have two primaries lists with the same
name. this is true regardless of whether the "primaries" or
"masters" keywords were used to define them.

(cherry picked from commit f619708bbfed238a2f12028bfc71c7ed3b35a4a8)

5 years agoadd "primary-only" as a synonym for "master-only"
Evan Hunt [Wed, 17 Jun 2020 09:45:07 +0000 (02:45 -0700)] 
add "primary-only" as a synonym for "master-only"

update the "notify" option to use RFC 8499 terminology as well.

(cherry picked from commit 424a3cf3ccb0c3b4aaf2f8e9af57432acadf2112)

5 years agoadd "primaries" as a synonym for "masters" in named.conf
Evan Hunt [Wed, 17 Jun 2020 09:02:27 +0000 (02:02 -0700)] 
add "primaries" as a synonym for "masters" in named.conf

as "type primary" is preferred over "type master" now, it makes
sense to make "primaries" available as a synonym too.

added a correctness check to ensure "primaries" and "masters"
cannot both be used in the same zone.

(cherry picked from commit 16e14353b1755111645024d06fa4225e019ba9a2)

5 years agoMerge branch '2383-kasp-sig-validity-dnskey-bug-v9_16' into 'v9_16'
Matthijs Mekking [Tue, 12 Jan 2021 12:40:47 +0000 (12:40 +0000)] 
Merge branch '2383-kasp-sig-validity-dnskey-bug-v9_16' into 'v9_16'

Fix signatures-validity config option (9.16)

See merge request isc-projects/bind9!4551

5 years agoFix signatures-validity config option
Matthijs Mekking [Thu, 7 Jan 2021 16:41:38 +0000 (17:41 +0100)] 
Fix signatures-validity config option

KASP was using 'signatures-validity-dnskey' instead of
'signatures-validity'.

(cherry picked from commit ad63e9e4f84a126fb076fdc16aff7ebf7f21db44)

5 years agoMerge branch 'mnowak/fix-copyright-date-in-man-pages-v9_16' into 'v9_16'
Michal Nowak [Mon, 11 Jan 2021 12:06:46 +0000 (12:06 +0000)] 
Merge branch 'mnowak/fix-copyright-date-in-man-pages-v9_16' into 'v9_16'

[v9_16] Update copyright date in man pages

See merge request isc-projects/bind9!4550

5 years agoUpdate copyright date in man pages
Michal Nowak [Mon, 11 Jan 2021 11:54:46 +0000 (12:54 +0100)] 
Update copyright date in man pages

(cherry picked from commit 358c133ee20e64b64569429df196d7c7767a624a)

5 years agoMerge branch '606-add-the-isc-dnssec-guide-as-a-bind-9-arm-appendix-v9_16' into ...
Michał Kępień [Fri, 8 Jan 2021 12:58:02 +0000 (12:58 +0000)] 
Merge branch '606-add-the-isc-dnssec-guide-as-a-bind-9-arm-appendix-v9_16' into 'v9_16'

[v9_16] Add the ISC DNSSEC Guide as a BIND 9 ARM appendix

See merge request isc-projects/bind9!4547

5 years agoAdd the ISC DNSSEC Guide as a BIND 9 ARM appendix
Michał Kępień [Fri, 8 Jan 2021 12:12:20 +0000 (13:12 +0100)] 
Add the ISC DNSSEC Guide as a BIND 9 ARM appendix

Add the ISC DNSSEC Guide to the BIND 9 ARM in order to include the
former in every BIND release.

(cherry picked from commit f96e6a1e1df4c6ab8480d1ceb77bf0f0e99b3033)

5 years agoMerge branch '2366-add-CHANGES-entry-v9_16' into 'v9_16'
Michał Kępień [Fri, 8 Jan 2021 11:53:20 +0000 (11:53 +0000)] 
Merge branch '2366-add-CHANGES-entry-v9_16' into 'v9_16'

[v9_16] Add CHANGES entry for GL #2366

See merge request isc-projects/bind9!4545

5 years agoAdd CHANGES entry for GL #2366
Michał Kępień [Fri, 8 Jan 2021 11:42:03 +0000 (12:42 +0100)] 
Add CHANGES entry for GL #2366

(cherry picked from commit 995b72d2b753e6b519ca5055eaa773bd0fd98450)

5 years agoMerge branch '2366-bind-9-16-10-build-fails-with-libmaxminddb-1-4-3' into 'v9_16'
Mark Andrews [Wed, 6 Jan 2021 08:04:25 +0000 (08:04 +0000)] 
Merge branch '2366-bind-9-16-10-build-fails-with-libmaxminddb-1-4-3' into 'v9_16'

Resolve "BIND 9.16.10 build fails with libmaxminddb-1.4.3"

See merge request isc-projects/bind9!4531

5 years agoFix 'configure --with-maxminddb=<path>'
Mark Andrews [Wed, 6 Jan 2021 06:53:10 +0000 (17:53 +1100)] 
Fix 'configure --with-maxminddb=<path>'

5 years agoMerge branch '2355-incorrect-increment-of-inactive-in-rbtdb-c-maybe_free_rbtdb-v9_16...
Mark Andrews [Wed, 6 Jan 2021 05:51:10 +0000 (05:51 +0000)] 
Merge branch '2355-incorrect-increment-of-inactive-in-rbtdb-c-maybe_free_rbtdb-v9_16' into 'v9_16'

Resolve "Incorrect increment of inactive in rbtdb.c:maybe_free_rbtdb()"

See merge request isc-projects/bind9!4530

5 years agoAdd release note
Mark Andrews [Fri, 18 Dec 2020 02:43:11 +0000 (13:43 +1100)] 
Add release note

(cherry picked from commit 584e589d844968362fda7d52f6d0cee7ba36b7ea)

5 years agoAdd CHANGES
Mark Andrews [Fri, 18 Dec 2020 02:40:23 +0000 (13:40 +1100)] 
Add CHANGES

(cherry picked from commit 65702896bd1c9efaee85cb2ffbb7c64c18702ae7)

5 years agoInactive incorrectly incremented
Mark Andrews [Fri, 18 Dec 2020 02:31:07 +0000 (13:31 +1100)] 
Inactive incorrectly incremented

It is possible to have two threads destroying an rbtdb at the same
time when detachnode() executes and removes the last reference to
a node between exiting being set to true for the node and testing
if the references are zero in maybe_free_rbtdb().  Move NODE_UNLOCK()
to after checking if references is zero to prevent detachnode()
changing the reference count too early.

(cherry picked from commit 859d2fdad6d1c6ff20083a4c463a929cbeb26438)

5 years agoMerge branch '2359-too-many-newlines-dnssec-signzone-verify-v9_16' into 'v9_16'
Matthijs Mekking [Tue, 5 Jan 2021 13:00:25 +0000 (13:00 +0000)] 
Merge branch '2359-too-many-newlines-dnssec-signzone-verify-v9_16' into 'v9_16'

Fix dnssec-signzone and -verify logging (again)

See merge request isc-projects/bind9!4525

5 years agoFix dnssec-signzone and -verify logging (again)
Matthijs Mekking [Tue, 5 Jan 2021 11:06:23 +0000 (12:06 +0100)] 
Fix dnssec-signzone and -verify logging (again)

While fixing #2359, 'report()' was changed so that it would print the
newline.

Newlines were missing from the output of 'dnssec-signzone'
and 'dnssec-verify' because change
664b8f04f5f2322086138f5eda5899a62bcc019b moved the printing from
newlines to the library.

This had to be reverted because this also would print redundant
newlines in logfiles.

While doing the revert, some newlines in 'lib/dns/zoneverify.c'
were left in place, now making 'dnssec-signzone' and 'dnssec-verify'
print too many newlines.

This commit removes those newlines, so that the output looks nice
again.

(cherry picked from commit 18c62a077ec0f7f1c56564dc2bd45b0c80e5b2f7)

5 years agoMerge branch '2359-missing-newlines-in-log-messages-dnssec-signzone-dnssec-verify...
Mark Andrews [Tue, 5 Jan 2021 01:47:26 +0000 (01:47 +0000)] 
Merge branch '2359-missing-newlines-in-log-messages-dnssec-signzone-dnssec-verify-c-v9_16' into 'v9_16'

Resolve "missing newlines in log messages dnssec-signzone/dnssec-verify"

See merge request isc-projects/bind9!4522

5 years agoAdd CHANGES
Mark Andrews [Wed, 23 Dec 2020 02:20:57 +0000 (13:20 +1100)] 
Add CHANGES

(cherry picked from commit 244525a303be6fcce4ef9a33a58c3978b11ce545)

5 years agoFix dnssec-signzone and dnssec-verify logging
Mark Andrews [Wed, 23 Dec 2020 01:21:24 +0000 (12:21 +1100)] 
Fix dnssec-signzone and dnssec-verify logging

The newlines need to be appended to the messages generated by report
in a atomic manner.

(cherry picked from commit c36bd83822582fcd0084a36d2eebc555f5e1c2d9)

5 years agoMerge branch '2361-the-additional-system-test-fails-on-system-gcc-mutexatomics' into...
Mark Andrews [Tue, 5 Jan 2021 00:32:03 +0000 (00:32 +0000)] 
Merge branch '2361-the-additional-system-test-fails-on-system-gcc-mutexatomics' into 'v9_16'

Resolve "The additional system test fails on system:gcc:mutexatomics"

See merge request isc-projects/bind9!4520

5 years agoadd CHANGES
Mark Andrews [Mon, 4 Jan 2021 05:15:21 +0000 (16:15 +1100)] 
add CHANGES

5 years agoUse atomic_init when initalising server->reload_status
Mark Andrews [Mon, 4 Jan 2021 05:03:08 +0000 (16:03 +1100)] 
Use atomic_init when initalising server->reload_status

5 years agoMerge branch 'marka-copyrights' into 'v9_16'
Mark Andrews [Mon, 4 Jan 2021 04:35:20 +0000 (04:35 +0000)] 
Merge branch 'marka-copyrights' into 'v9_16'

update for 2021

See merge request isc-projects/bind9!4519

5 years agoupdate for 2021
Mark Andrews [Mon, 4 Jan 2021 04:14:44 +0000 (15:14 +1100)] 
update for 2021

5 years agoMerge branch '1750-dnssec-policy-none-v9_16' into 'v9_16'
Matthijs Mekking [Wed, 23 Dec 2020 12:25:06 +0000 (12:25 +0000)] 
Merge branch '1750-dnssec-policy-none-v9_16' into 'v9_16'

Resolve "dnssec-policy graceful transition to insecure"

See merge request isc-projects/bind9!4513

5 years agoAdd notes for [#2341]
Matthijs Mekking [Tue, 8 Dec 2020 08:55:36 +0000 (09:55 +0100)] 
Add notes for [#2341]

Mention the bugfix in the release.

(cherry picked from commit 08b6e8c2c9218928537a6b6a4f72cccc5e1faea6)

5 years agoAdd documentation and notes for [#1750]
Matthijs Mekking [Tue, 8 Dec 2020 08:42:51 +0000 (09:42 +0100)] 
Add documentation and notes for [#1750]

(cherry picked from commit 7825d8f916bcfb0e725f0db5402035fd5c48a432)

5 years agoFix a quirky mkeys test failure
Matthijs Mekking [Mon, 7 Dec 2020 13:37:23 +0000 (14:37 +0100)] 
Fix a quirky mkeys test failure

The mkeys system test started to fail after introducing support for
zones transitioning to unsigned without going bogus. This is because
there was actually a bug in the code: if you reconfigure a zone and
remove the "auto-dnssec" option, the zone is actually still DNSSEC
maintained. This is because in zoneconf.c there is no call
to 'dns_zone_setkeyopt()' if the configuration option is not used
(cfg_map_get(zoptions, "auto-dnssec", &obj) will return an error).

The mkeys system test implicitly relied on this bug: initially the
root zone is being DNSSEC maintained, then at some point it needs to
reset the root zone in order to prepare for some tests with bad
signatures. Because it needs to inject a bad signature, 'auto-dnssec'
is removed from the configuration.

The test pass but for the wrong reasons:

I:mkeys:reset the root server
I:mkeys:reinitialize trust anchors
I:mkeys:check positive validation (18)

The 'check positive validation' test works because the zone is still
DNSSEC maintained: The DNSSEC records in the signed root zone file on
disk are being ignored.

After fixing the bug/introducing graceful transition to insecure,
the root zone is no longer DNSSEC maintained after the reconfig.

The zone now explicitly needs to be reloaded because otherwise the
'check positive validation' test works against an old version of the
zone (the one with all the revoked keys), and the test will obviously
fail.

(cherry picked from commit 2fc42b598b954f8cbd8a5fc99cc990b15b235b40)

5 years agoUpdate keymgr to allow transition to insecure mode
Matthijs Mekking [Thu, 3 Dec 2020 15:04:28 +0000 (16:04 +0100)] 
Update keymgr to allow transition to insecure mode

The keymgr prevented zones from going to insecure mode. If we
have a policy with an empty key list this is a signal that the zone
wants to go back to insecure mode. In this case allow one extra state
transition to be valid when checking for DNSSEC safety.

(cherry picked from commit 913410006912984b49f9e8efa74e7c1f274cbe4d)

5 years agoPublish CDS/CDNSKEY Delete Records
Matthijs Mekking [Thu, 3 Dec 2020 14:33:45 +0000 (15:33 +0100)] 
Publish CDS/CDNSKEY Delete Records

Check if zone is transitioning from secure to insecure. If so,
delete the CDS/CDNSKEY records, otherwise make sure they are not
part of the RRset.

(cherry picked from commit 68d715a229c586ba427fed9ec3af87770a647509)

5 years agoTreat dnssec-policy "none" as a builtin zone
Matthijs Mekking [Thu, 3 Dec 2020 14:01:42 +0000 (15:01 +0100)] 
Treat dnssec-policy "none" as a builtin zone

Configure "none" as a builtin policy. Change the 'cfg_kasp_fromconfig'
api so that the 'name' will determine what policy needs to be
configured.

When transitioning a zone from secure to insecure, there will be
cases when a zone with no DNSSEC policy (dnssec-policy none) should
be using KASP. When there are key state files available, this is an
indication that the zone once was DNSSEC signed but is reconfigured
to become insecure.

If we would not run the keymgr, named would abruptly remove the
DNSSEC records from the zone, making the zone bogus. Therefore,
change the code such that a zone will use kasp if there is a valid
dnssec-policy configured, or if there are state files available.

(cherry picked from commit cf420b2af0d45693d0f5f34d9113ea411b5f2225)

5 years agoAdd function to see if dst key uses kasp
Matthijs Mekking [Thu, 3 Dec 2020 09:19:38 +0000 (10:19 +0100)] 
Add function to see if dst key uses kasp

For purposes of zones transitioning back to insecure mode, it is
practical to see if related keys have a state file associated.

(cherry picked from commit 8f2c5e45da47394c812f5499b2766b13387c7bbc)

5 years agoSmall adjustments to kasp rndc_checkds function
Matthijs Mekking [Thu, 3 Dec 2020 08:03:21 +0000 (09:03 +0100)] 
Small adjustments to kasp rndc_checkds function

Slightly better test output, and only call 'load keys' if the
'rndc checkds' call succeeded.

(cherry picked from commit 756674f6d1e62e4f5eabbb71e80a25974a32783c)

5 years agoAdd tests for going from secure to insecure
Matthijs Mekking [Thu, 3 Dec 2020 07:53:34 +0000 (08:53 +0100)] 
Add tests for going from secure to insecure

Add two test zones that will be reconfigured to go insecure, by
setting the 'dnssec-policy' option to 'none'.

One zone was using inline-signing (implicitly through dnssec-policy),
the other is a dynamic zone.

Two tweaks to the kasp system test are required: we need to set
when to except the CDS/CDS Delete Records, and we need to know
when we are dealing with a dynamic zone (because the logs to look for
are slightly different, inline-signing prints "(signed)" after the
zone name, dynamic zones do not).

(cherry picked from commit fa2e4e66b04dfdc2fccfdacaa6ab7cbded035586)

5 years agoMerge branch '2245-bind-9-16-8-does-not-honor-cpu-affinity-v9_16' into 'v9_16'
Mark Andrews [Tue, 22 Dec 2020 23:13:49 +0000 (23:13 +0000)] 
Merge branch '2245-bind-9-16-8-does-not-honor-cpu-affinity-v9_16' into 'v9_16'

Resolve "bind 9.16.8 does not honor CPU affinity"

See merge request isc-projects/bind9!4510

5 years agoAdd CHANGES and release notes for [GL #2245]
Mark Andrews [Wed, 2 Dec 2020 05:08:39 +0000 (16:08 +1100)] 
Add CHANGES and release notes for [GL #2245]

(cherry picked from commit fc4af548e7d87cca7019a935f48d3165816c1860)

5 years agoAdd test for cpu affinity
Matthijs Mekking [Thu, 10 Dec 2020 10:57:23 +0000 (11:57 +0100)] 
Add test for cpu affinity

Add a test to check BIND 9 honors CPU affinity mask. This requires
some changes to the start script, to construct the named command.

(cherry picked from commit f1a097964c52b1d765248fd10fb98837174a5077)

5 years agoOnly pick CPUs that are part of the existing CPU affinity set when
Mark Andrews [Tue, 17 Nov 2020 03:59:01 +0000 (14:59 +1100)] 
Only pick CPUs that are part of the existing CPU affinity set when

assigning a thread to a CPU.

(cherry picked from commit 698d9285d40c3a7f26d81764bd9d5eaff7748fb2)

5 years agoMerge branch '2348-bin-tools-mdig-compile-link-failure-because-of-missing-isccfg...
Mark Andrews [Sun, 20 Dec 2020 21:54:45 +0000 (21:54 +0000)] 
Merge branch '2348-bin-tools-mdig-compile-link-failure-because-of-missing-isccfg-dependency' into 'v9_16'

Resolve "bin/tools/mdig: compile/link failure because of missing isccfg dependency"

See merge request isc-projects/bind9!4493

5 years agoHandle shared library platforms that don't support inter library dependancies
Mark Andrews [Tue, 15 Dec 2020 08:18:41 +0000 (19:18 +1100)] 
Handle shared library platforms that don't support inter library dependancies

5 years agoFixup library link lists
Mark Andrews [Tue, 15 Dec 2020 00:33:24 +0000 (11:33 +1100)] 
Fixup library link lists

5 years agoMerge branch 'v9_16_10-release' into 'v9_16'
Michał Kępień [Wed, 16 Dec 2020 21:29:31 +0000 (21:29 +0000)] 
Merge branch 'v9_16_10-release' into 'v9_16'

Merge 9.16.10 release branch

See merge request isc-projects/bind9!4501

5 years agoSet up release notes for BIND 9.16.11
Michał Kępień [Wed, 16 Dec 2020 21:21:19 +0000 (22:21 +0100)] 
Set up release notes for BIND 9.16.11

5 years agoBump BIND_BASELINE_VERSION for ABI checks
Michał Kępień [Wed, 16 Dec 2020 21:21:19 +0000 (22:21 +0100)] 
Bump BIND_BASELINE_VERSION for ABI checks

5 years agoMerge branch 'mnowak/fix-program-name-in-dnssec-keymgr-8' into 'v9_16'
Michal Nowak [Mon, 14 Dec 2020 12:21:06 +0000 (12:21 +0000)] 
Merge branch 'mnowak/fix-program-name-in-dnssec-keymgr-8' into 'v9_16'

[v9_16] Man page fixes (named.rst & dnssec-keymgr.rst)

See merge request isc-projects/bind9!4479

5 years agoFix program name reference in dnssec-keymgr(8)
Michal Nowak [Tue, 8 Dec 2020 15:37:28 +0000 (16:37 +0100)] 
Fix program name reference in dnssec-keymgr(8)

5 years agoFix a reference to rndc(8) in named(8) manual page
Michal Nowak [Tue, 8 Dec 2020 15:11:04 +0000 (16:11 +0100)] 
Fix a reference to rndc(8) in named(8) manual page

(cherry picked from commit befcbcac28986bc725454f7241c0cf145049a1cf)

5 years agoMerge branch '2058-print-warning-when-fallback-to-soaserial-increment-v9_16' into...
Ondřej Surý [Sat, 12 Dec 2020 07:37:24 +0000 (07:37 +0000)] 
Merge branch '2058-print-warning-when-fallback-to-soaserial-increment-v9_16' into 'v9_16'

Resolve "`dnssec-signzone -N unixtime` behaves like `increment`"

See merge request isc-projects/bind9!4492

5 years agoAdd CHANGES and release notes for GL #2058
Ondřej Surý [Thu, 10 Dec 2020 09:39:48 +0000 (10:39 +0100)] 
Add CHANGES and release notes for GL #2058

(cherry picked from commit ba887a688c03f1f67b03a735a49a8ad4439f9f57)

5 years agoUpdate dnssec-signzone -N soa-serial-format description
Mark Andrews [Fri, 11 Dec 2020 03:07:31 +0000 (14:07 +1100)] 
Update dnssec-signzone -N soa-serial-format description

document the autoincrement when the serial would go backwards.

(cherry picked from commit eb1b29b19ecf5b0bfb2e2b9dc56972d5f015859e)

5 years agoPrint warning when falling back to increment soa serial method
Ondřej Surý [Thu, 10 Dec 2020 09:31:31 +0000 (10:31 +0100)] 
Print warning when falling back to increment soa serial method

When using the `unixtime` or `date` method to update the SOA serial,
`named` and `dnssec-signzone` would silently fallback to `increment`
method to prevent the new serial number to be smaller than the old
serial number (using the serial number arithmetics).  Add a warning
message when such fallback happens.

(cherry picked from commit ef685bab5c0ce68e98328dd19dfb1fb8f9d0fdee)

5 years agoMerge branch '2321-netmgr-v2-v9_16' into 'v9_16'
Ondřej Surý [Wed, 9 Dec 2020 16:04:21 +0000 (16:04 +0000)] 
Merge branch '2321-netmgr-v2-v9_16' into 'v9_16'

Synchronize netmgr sub-library with main branch

See merge request isc-projects/bind9!4455

5 years agoMerge branch 'ondrej/release-notes-doesnt-need-copyright-v9_16' into 'v9_16'
Ondřej Surý [Wed, 9 Dec 2020 09:51:20 +0000 (09:51 +0000)] 
Merge branch 'ondrej/release-notes-doesnt-need-copyright-v9_16' into 'v9_16'

Remove the requirement for the release notes to have copyright

See merge request isc-projects/bind9!4484

5 years agoRemove the requirement for the release notes to have copyright
Ondřej Surý [Wed, 9 Dec 2020 09:35:13 +0000 (10:35 +0100)] 
Remove the requirement for the release notes to have copyright

The release notes doesn't have to have copyright header, it doesn't add
any value there as the release notes are useless outside the project.

(cherry picked from commit cb30d9892d45d23e19e15de6725bcd771ed5035f)

5 years agoAdd CHANGES and release notes
Ondřej Surý [Fri, 4 Dec 2020 14:04:17 +0000 (15:04 +0100)] 
Add CHANGES and release notes

5 years agoFix HAVE_SO_REUSEPORT_LB macro name definition
Ondřej Surý [Fri, 4 Dec 2020 12:19:44 +0000 (13:19 +0100)] 
Fix HAVE_SO_REUSEPORT_LB macro name definition

A typo in macro definition caused the load-balanced sockets to be
disabled even on platforms with existing support for load-balanced
sockets.

(cherry picked from commit 5caf33feda92617e18514633cadaae60e934101f)

5 years agoSync the func() -> func(void) in netmgr
Ondřej Surý [Thu, 3 Dec 2020 17:45:13 +0000 (18:45 +0100)] 
Sync the func() -> func(void) in netmgr

5 years agoUse sock->nchildren instead of mgr->nworkers when initializing NM
Ondřej Surý [Thu, 3 Dec 2020 16:58:10 +0000 (17:58 +0100)] 
Use sock->nchildren instead of mgr->nworkers when initializing NM

On Windows, we were limiting the number of listening children to just 1,
but we were then iterating on mgr->nworkers.  That lead to scheduling
more async_*listen() than actually allocated and out-of-bound read-write
operation on the heap.

(cherry picked from commit 87c5867202935c59dfe66321238275ba4a953b53)

5 years agoExplicitly link the netmgr tests with -luv
Ondřej Surý [Thu, 3 Dec 2020 15:35:25 +0000 (16:35 +0100)] 
Explicitly link the netmgr tests with -luv

5 years agoFix datarace when UDP/TCP connect fails and we are in nmthread
Ondřej Surý [Thu, 3 Dec 2020 12:00:33 +0000 (13:00 +0100)] 
Fix datarace when UDP/TCP connect fails and we are in nmthread

When we were in nmthread, the isc__nm_async_<proto>connect() function
executes in the same thread as the isc__nm_<proto>connect() and on a
failure, it would block indefinitely because the failure branch was
setting sock->active to false before the condition around the wait had a
chance to skip the WAIT().

This also fixes the zero system test being stuck on FreeBSD 11, so we
re-enable the test in the commit.

5 years agoAdd FreeBSD connection timeout socket option
Ondřej Surý [Wed, 2 Dec 2020 20:54:25 +0000 (21:54 +0100)] 
Add FreeBSD connection timeout socket option

On FreeBSD, the option to configure connection timeout is called
TCP_KEEPINIT, use it to configure the connection timeout there.

This also fixes the dangling socket problems in the unit test, so
re-enable them.

5 years agoDistribute queries among threads even on platforms without lb sockets
Ondřej Surý [Wed, 2 Dec 2020 14:37:18 +0000 (15:37 +0100)] 
Distribute queries among threads even on platforms without lb sockets

On platforms without load-balancing socket all the queries would be
handle by a single thread.  Currently, the support for load-balanced
sockets is present in Linux with SO_REUSEPORT and FreeBSD 12 with
SO_REUSEPORT_LB.

This commit adds workaround for such platforms that:

1. setups single shared listening socket for all listening nmthreads for
   UDP, TCP and TCPDNS netmgr transports

2. Calls uv_udp_bind/uv_tcp_bind on the underlying socket just once and
   for rest of the nmthreads only copy the internal libuv flags (should
   be just UV_HANDLE_BOUND and optionally UV_HANDLE_IPV6).

3. start reading on UDP socket or listening on TCP socket

The load distribution among the nmthreads is uneven, but it's still
better than utilizing just one thread for processing all the incoming
queries

5 years agoDon't use stack allocated buffer for uv_write()
Ondřej Surý [Thu, 3 Dec 2020 07:33:21 +0000 (08:33 +0100)] 
Don't use stack allocated buffer for uv_write()

On FreeBSD, the stack is destroyed more aggressively than on Linux and
that revealed a bug where we were allocating the 16-bit len for the
TCPDNS message on the stack and the buffer got garbled before the
uv_write() sendback was executed.  Now, the len is part of the uvreq, so
we can safely pass it to the uv_write() as the req gets destroyed after
the sendcb is executed.

(cherry picked from commit 94afea932567bf1eb6ee5b80a1c7b2d4071980bd)

5 years agoMake netmgr initialize and cleanup Winsock itself
Michał Kępień [Wed, 2 Dec 2020 21:36:23 +0000 (22:36 +0100)] 
Make netmgr initialize and cleanup Winsock itself

On Windows, WSAStartup() needs to be called to initialize Winsock before
any sockets are created or else socket() calls will return error code
10093 (WSANOTINITIALISED).  Since BIND's Network Manager is intended to
work as a reusable networking library, it should take care of calling
WSAStartup() - and its cleanup counterpart, WSACleanup() - itself rather
than relying on external code to do it.  Add the necessary WSAStartup()
and WSACleanup() calls to isc_nm_start() and isc_nm_destroy(),
respectively.

(cherry picked from commit 88f96faba872cfe7006c6de84759515bdf6e9c47)

5 years agoExtend log message for unexpected socket() errors
Michał Kępień [Wed, 2 Dec 2020 21:36:23 +0000 (22:36 +0100)] 
Extend log message for unexpected socket() errors

Make sure the error code is included in the message logged for
unexpected socket creation errors in order to facilitate troubleshooting
on Windows.

(cherry picked from commit dc2e1dea864b89f8dbf6365b395d6d0e292e9888)

5 years agoAdjust the nstests for isc_nmhandle_{attach,detach} name change
Ondřej Surý [Wed, 2 Dec 2020 11:34:35 +0000 (12:34 +0100)] 
Adjust the nstests for isc_nmhandle_{attach,detach} name change

Due to the added attach/detach tracing in the netmgr-v2 code, the
libns tests needs to be adjusted as the real function names have
changed from isc_nmhandle_* to isc__nmhandle_*.

5 years agoThe cmocka.h header MUST be included before isc/util.h gets included
Ondřej Surý [Tue, 1 Dec 2020 14:08:49 +0000 (15:08 +0100)] 
The cmocka.h header MUST be included before isc/util.h gets included

The isc/util.h header redefine the DbC checks (REQUIRE, INSIST, ...)  to
be cmocka "fake" assertions.  However that means that cmocka.h needs to
be included after UNIT_TESTING is defined but before isc/util.h is
included.  Because isc/util.h is included in most of the project headers
this means that the sequence MUST be:

    #define UNIT_TESTING
    #include <cmocka.h>

    #include <isc/_anything_.h>

See !2204 for other header requirements for including cmocka.h.

(cherry picked from commit 0ba697fe8c3a05fc7723529fa20ea9c7865e5b6c)

5 years agoautoconf: link with libssl
Witold Kręcicki [Wed, 13 May 2020 15:37:51 +0000 (17:37 +0200)] 
autoconf: link with libssl

This is prerequisite to adding DoT and DoH support to BIND 9.

5 years agoAdd libssl libraries to Windows build
Ondřej Surý [Sat, 10 Oct 2020 05:26:18 +0000 (07:26 +0200)] 
Add libssl libraries to Windows build

This commit extends the perl Configure script to also check for libssl
in addition to libcrypto and change the vcxproj source files to link
with both libcrypto and libssl.

5 years agoFix the data race in accessing the isc_nm_t timers
Ondřej Surý [Wed, 2 Dec 2020 08:52:39 +0000 (09:52 +0100)] 
Fix the data race in accessing the isc_nm_t timers

The following TSAN report about accessing the mgr timers (mgr->init,
mgr->idle, mgr->keepalive and mgr->advertised) has been fixed in this
commit:

    ==================
    WARNING: ThreadSanitizer: data race (pid=2746)
    Read of size 4 at 0x7b440008a948 by thread T18:
    #0 isc__nm_tcpdns_read /home/ondrej/Projects/bind9/lib/isc/netmgr/tcpdns.c:849:25 (libisc.so.1706+0x2ba0f)
    #1 isc_nm_read /home/ondrej/Projects/bind9/lib/isc/netmgr/netmgr.c:1679:3 (libisc.so.1706+0x22258)
    #2 tcpdns_connect_connect_cb /home/ondrej/Projects/bind9/lib/isc/tests/tcpdns_test.c:363:2 (tcpdns_test+0x4bc5fb)
    #3 isc__nm_async_connectcb /home/ondrej/Projects/bind9/lib/isc/netmgr/netmgr.c:1816:2 (libisc.so.1706+0x228c9)
    #4 isc__nm_connectcb /home/ondrej/Projects/bind9/lib/isc/netmgr/netmgr.c:1791:3 (libisc.so.1706+0x22713)
    #5 tcpdns_connect_cb /home/ondrej/Projects/bind9/lib/isc/netmgr/tcpdns.c:343:2 (libisc.so.1706+0x2d89d)
    #6 uv__stream_connect /home/ondrej/Projects/tsan/libuv/src/unix/stream.c:1381:5 (libuv.so.1+0x27c18)
    #7 uv__stream_io /home/ondrej/Projects/tsan/libuv/src/unix/stream.c:1298:5 (libuv.so.1+0x25977)
    #8 uv__io_poll /home/ondrej/Projects/tsan/libuv/src/unix/linux-core.c:462:11 (libuv.so.1+0x2e795)
    #9 uv_run /home/ondrej/Projects/tsan/libuv/src/unix/core.c:385:5 (libuv.so.1+0x158ec)
    #10 nm_thread /home/ondrej/Projects/bind9/lib/isc/netmgr/netmgr.c:530:11 (libisc.so.1706+0x1c94a)

    Previous write of size 4 at 0x7b440008a948 by main thread:
    #0 isc_nm_settimeouts /home/ondrej/Projects/bind9/lib/isc/netmgr/netmgr.c:490:12 (libisc.so.1706+0x1dda5)
    #1 tcpdns_recv_two /home/ondrej/Projects/bind9/lib/isc/tests/tcpdns_test.c:601:2 (tcpdns_test+0x4bad0e)
    #2 cmocka_run_one_test_or_fixture <null> (libcmocka.so.0+0x70be)
    #3 __libc_start_main /build/glibc-vjB4T1/glibc-2.28/csu/../csu/libc-start.c:308:16 (libc.so.6+0x2409a)

    Location is heap block of size 281 at 0x7b440008a840 allocated by main thread:
    #0 malloc <null> (tcpdns_test+0x42864b)
    #1 default_memalloc /home/ondrej/Projects/bind9/lib/isc/mem.c:713:8 (libisc.so.1706+0x6d261)
    #2 mem_get /home/ondrej/Projects/bind9/lib/isc/mem.c:622:8 (libisc.so.1706+0x69b9c)
    #3 isc___mem_get /home/ondrej/Projects/bind9/lib/isc/mem.c:1044:9 (libisc.so.1706+0x6d379)
    #4 isc__mem_get /home/ondrej/Projects/bind9/lib/isc/mem.c:2432:10 (libisc.so.1706+0x6889e)
    #5 isc_nm_start /home/ondrej/Projects/bind9/lib/isc/netmgr/netmgr.c:203:8 (libisc.so.1706+0x1c219)
    #6 nm_setup /home/ondrej/Projects/bind9/lib/isc/tests/tcpdns_test.c:244:11 (tcpdns_test+0x4baaa4)
    #7 cmocka_run_one_test_or_fixture <null> (libcmocka.so.0+0x70fd)
    #8 __libc_start_main /build/glibc-vjB4T1/glibc-2.28/csu/../csu/libc-start.c:308:16 (libc.so.6+0x2409a)

    Thread T18 'isc-net-0000' (tid=3513, running) created by main thread at:
    #0 pthread_create <null> (tcpdns_test+0x429e7b)
    #1 isc_thread_create /home/ondrej/Projects/bind9/lib/isc/pthreads/thread.c:73:8 (libisc.so.1706+0x8476a)
    #2 isc_nm_start /home/ondrej/Projects/bind9/lib/isc/netmgr/netmgr.c:271:3 (libisc.so.1706+0x1c66a)
    #3 nm_setup /home/ondrej/Projects/bind9/lib/isc/tests/tcpdns_test.c:244:11 (tcpdns_test+0x4baaa4)
    #4 cmocka_run_one_test_or_fixture <null> (libcmocka.so.0+0x70fd)
    #5 __libc_start_main /build/glibc-vjB4T1/glibc-2.28/csu/../csu/libc-start.c:308:16 (libc.so.6+0x2409a)

    SUMMARY: ThreadSanitizer: data race /home/ondrej/Projects/bind9/lib/isc/netmgr/tcpdns.c:849:25 in isc__nm_tcpdns_read
    ==================
    ThreadSanitizer: reported 1 warnings

(cherry picked from commit 2e1dd56d0ba70c6434a1afce0a5b785244cafd6a)

5 years agoAvoid netievent allocations when the callbacks can be called directly
Ondřej Surý [Wed, 2 Dec 2020 07:54:51 +0000 (08:54 +0100)] 
Avoid netievent allocations when the callbacks can be called directly

After turning the users callbacks to be asynchronous, there was a
visible performance drop.  This commit prevents the unnecessary
allocations while keeping the code paths same for both asynchronous and
synchronous calls.

The same change was done to the isc__nm_udp_{read,send} as those two
functions are in the hot path.

(cherry picked from commit d6d2fbe0e9ad3eb85bb823fc534330bde7d2df6a)

5 years agoRefactor netmgr and add more unit tests
Ondřej Surý [Thu, 12 Nov 2020 09:32:18 +0000 (10:32 +0100)] 
Refactor netmgr and add more unit tests

This is a part of the works that intends to make the netmgr stable,
testable, maintainable and tested.  It contains a numerous changes to
the netmgr code and unfortunately, it was not possible to split this
into smaller chunks as the work here needs to be committed as a complete
works.

NOTE: There's a quite a lot of duplicated code between udp.c, tcp.c and
tcpdns.c and it should be a subject to refactoring in the future.

The changes that are included in this commit are listed here
(extensively, but not exclusively):

* The netmgr_test unit test was split into individual tests (udp_test,
  tcp_test, tcpdns_test and newly added tcp_quota_test)

* The udp_test and tcp_test has been extended to allow programatic
  failures from the libuv API.  Unfortunately, we can't use cmocka
  mock() and will_return(), so we emulate the behaviour with #define and
  including the netmgr/{udp,tcp}.c source file directly.

* The netievents that we put on the nm queue have variable number of
  members, out of these the isc_nmsocket_t and isc_nmhandle_t always
  needs to be attached before enqueueing the netievent_<foo> and
  detached after we have called the isc_nm_async_<foo> to ensure that
  the socket (handle) doesn't disappear between scheduling the event and
  actually executing the event.

* Cancelling the in-flight TCP connection using libuv requires to call
  uv_close() on the original uv_tcp_t handle which just breaks too many
  assumptions we have in the netmgr code.  Instead of using uv_timer for
  TCP connection timeouts, we use platform specific socket option.

* Fix the synchronization between {nm,async}_{listentcp,tcpconnect}

  When isc_nm_listentcp() or isc_nm_tcpconnect() is called it was
  waiting for socket to either end up with error (that path was fine) or
  to be listening or connected using condition variable and mutex.

  Several things could happen:

    0. everything is ok

    1. the waiting thread would miss the SIGNAL() - because the enqueued
       event would be processed faster than we could start WAIT()ing.
       In case the operation would end up with error, it would be ok, as
       the error variable would be unchanged.

    2. the waiting thread miss the sock->{connected,listening} = `true`
       would be set to `false` in the tcp_{listen,connect}close_cb() as
       the connection would be so short lived that the socket would be
       closed before we could even start WAIT()ing

* The tcpdns has been converted to using libuv directly.  Previously,
  the tcpdns protocol used tcp protocol from netmgr, this proved to be
  very complicated to understand, fix and make changes to.  The new
  tcpdns protocol is modeled in a similar way how tcp netmgr protocol.
Closes: #2194, #2283, #2318, #2266, #2034, #1920
* The tcp and tcpdns is now not using isc_uv_import/isc_uv_export to
  pass accepted TCP sockets between netthreads, but instead (similar to
  UDP) uses per netthread uv_loop listener.  This greatly reduces the
  complexity as the socket is always run in the associated nm and uv
  loops, and we are also not touching the libuv internals.

  There's an unfortunate side effect though, the new code requires
  support for load-balanced sockets from the operating system for both
  UDP and TCP (see #2137).  If the operating system doesn't support the
  load balanced sockets (either SO_REUSEPORT on Linux or SO_REUSEPORT_LB
  on FreeBSD 12+), the number of netthreads is limited to 1.

* The netmgr has now two debugging #ifdefs:

  1. Already existing NETMGR_TRACE prints any dangling nmsockets and
     nmhandles before triggering assertion failure.  This options would
     reduce performance when enabled, but in theory, it could be enabled
     on low-performance systems.

  2. New NETMGR_TRACE_VERBOSE option has been added that enables
     extensive netmgr logging that allows the software engineer to
     precisely track any attach/detach operations on the nmsockets and
     nmhandles.  This is not suitable for any kind of production
     machine, only for debugging.

* The tlsdns netmgr protocol has been split from the tcpdns and it still
  uses the old method of stacking the netmgr boxes on top of each other.
  We will have to refactor the tlsdns netmgr protocol to use the same
  approach - build the stack using only libuv and openssl.

* Limit but not assert the tcp buffer size in tcp_alloc_cb
Closes: #2061
(cherry picked from commit 634bdfb16d8f91ba411f43d0e871ff45cebe125e)

5 years agoTurn all the callback to be always asynchronous
Ondřej Surý [Wed, 11 Nov 2020 09:46:33 +0000 (10:46 +0100)] 
Turn all the callback to be always asynchronous

When calling the high level netmgr functions, the callback would be
sometimes called synchronously if we catch the failure directly, or
asynchronously if it happens later.  The synchronous call to the
callback could create deadlocks as the caller would not expect the
failed callback to be executed directly.

(cherry picked from commit a49d88568fef290f1ad3ce5656d0e30d41d61606)

5 years agonetmgr: Add additional safeguards to netmgr/tls.c
Ondřej Surý [Tue, 10 Nov 2020 10:23:05 +0000 (11:23 +0100)] 
netmgr: Add additional safeguards to netmgr/tls.c

This commit adds couple of additional safeguards against running
sends/reads on inactive sockets.  The changes was modeled after the
changes we made to netmgr/tcpdns.c

(cherry picked from commit fa424225af76c9ce242fd4bc32f44b5783833cb1)

5 years agoisc_nm_tls_create_server_ctx can create ephemeral certs
Witold Kręcicki [Fri, 9 Oct 2020 18:57:51 +0000 (20:57 +0200)] 
isc_nm_tls_create_server_ctx can create ephemeral certs

In-memory ephemeral certs creation for easy DoT/DoH deployment.

(cherry picked from commit 3c00fb71db09e9d64f48f325cfad5973cf625f9f)

5 years agoAdd DoT support to bind
Witold Kręcicki [Thu, 1 Oct 2020 11:18:47 +0000 (13:18 +0200)] 
Add DoT support to bind

Parse the configuration of tls objects into SSL_CTX* objects.  Listen on
DoT if 'tls' option is setup in listen-on directive.  Use DoT/DoH ports
for DoT/DoH.

(cherry picked from commit 38b78f59a08b11dc7c551dfe279df58203f2e2da)

5 years agoreport peer address in TLS mode, and specify protocol
Evan Hunt [Fri, 18 Sep 2020 01:28:37 +0000 (18:28 -0700)] 
report peer address in TLS mode, and specify protocol

- peer address was not being reported correctly by "dig +tls"
- the protocol used is now reported in the dig output: UDP, TCP, or TLS.

(cherry picked from commit 8886569e9d11258f0c7f01bae1040435ffb61631)

5 years agonetmgr: server-side TLS support
Witold Kręcicki [Wed, 13 May 2020 15:37:51 +0000 (17:37 +0200)] 
netmgr: server-side TLS support

Add server-side TLS support to netmgr - that includes moving some of the
isc_nm_ functions from tcp.c to a wrapper in netmgr.c calling a proper
tcp or tls function, and a new isc_nm_listentls() function.

Add DoT support to tcpdns - isc_nm_listentlsdns().

(cherry picked from commit b2ee0e9dc31cbe87b799e3b796165ebdf8de5f85)

5 years agoaddress some possible shutdown races in xfrin
Evan Hunt [Mon, 9 Nov 2020 20:33:37 +0000 (12:33 -0800)] 
address some possible shutdown races in xfrin

there were two failures during observed in testing, both occurring
when 'rndc halt' was run rather than 'rndc stop' - the latter dumps
zone contents to disk and presumably introduced enough delay to
prevent the races:

- a failure when the zone was shut down and called dns_xfrin_detach()
  before the xfrin had finished connecting; the connect timeout
  terminated without detaching its handle
- a failure when the tcpdns socket timer fired after the outerhandle
  had already been cleared.

this commit incidentally addresses a failure observed in mutexatomic
due to a variable having been initialized incorrectly.

5 years agonetmgr: Don't crash if socket() returns an error in udpconnect
Ondřej Surý [Sat, 7 Nov 2020 19:48:37 +0000 (20:48 +0100)] 
netmgr: Don't crash if socket() returns an error in udpconnect

socket() call can return an error - e.g. EMFILE, so we need to handle
this nicely and not crash.

Additionally wrap the socket() call inside a platform independent helper
function as the Socket data type on Windows is unsigned integer:

> This means, for example, that checking for errors when the socket and
> accept functions return should not be done by comparing the return
> value with –1, or seeing if the value is negative (both common and
> legal approaches in UNIX). Instead, an application should use the
> manifest constant INVALID_SOCKET as defined in the Winsock2.h header
> file.

(cherry picked from commit 8af7f81d6c1f974ac3305186ae34b9ce423525d0)

5 years agonetmgr: Always load the result from async socket
Ondřej Surý [Fri, 6 Nov 2020 12:11:08 +0000 (13:11 +0100)] 
netmgr: Always load the result from async socket

Because we use result earlier for setting the loadbalancing on the
socket, we could be left with a ISC_R_NOTIMPLEMENTED value stored in the
variable and when the UDP connection would succeed, we would
errorneously return this value instead of ISC_R_SUCCESS.

(cherry picked from commit 050258bda4a45faf18baaf3879a9da160d2230fe)

5 years agodig: use new netmgr timeout mechanism
Evan Hunt [Tue, 3 Nov 2020 05:38:56 +0000 (21:38 -0800)] 
dig: use new netmgr timeout mechanism

use isc_nmhandle_settimeout() to set read/recv timeouts, and get rid
of connect_timeout() and related functions in dighost.c.

(cherry picked from commit ea2b04c361c29cdad80c92877184b063f23002d0)

5 years agoadd isc_nmhandle_settimeout() function
Evan Hunt [Tue, 3 Nov 2020 03:58:05 +0000 (19:58 -0800)] 
add isc_nmhandle_settimeout() function

this function sets the read timeout for the socket associated
with a netmgr handle and, if the timer is running, resets it.
for TCPDNS sockets it also sets the read timeout and resets the
timer on the outer TCP socket.

(cherry picked from commit 4be63c5b00700f83a96da67cc092bb3b87efaf15)

5 years agofix nmhandle attach/detach errors in tcpdnsconnect_cb()
Ondřej Surý [Wed, 4 Nov 2020 19:59:31 +0000 (20:59 +0100)] 
fix nmhandle attach/detach errors in tcpdnsconnect_cb()

we need to attach to the statichandle when connecting TCPDNS sockets,
same as with UDP.

(cherry picked from commit 2191d2bf444b3b699b995871d837e3baea4f5185)

5 years agoIncorrect result code passed to failed_connect_cb
Mark Andrews [Wed, 4 Nov 2020 04:20:13 +0000 (15:20 +1100)] 
Incorrect result code passed to failed_connect_cb

    *** CID 312970:  Incorrect expression  (COPY_PASTE_ERROR) /lib/isc/netmgr/tcp.c: 282 in tcp_connect_cb()
    276      }
    277
    278      isc__nm_incstats(sock->mgr, sock->statsindex[STATID_CONNECT]);
    279      r = uv_tcp_getpeername(&sock->uv_handle.tcp, (struct sockaddr *)&ss,
    280             &(int){ sizeof(ss) });
    281      if (r != 0) {
    >>>     CID 312970:  Incorrect expression  (COPY_PASTE_ERROR)
    >>>     "status" in "isc___nm_uverr2result(status, true, "netmgr/tcp.c", 282U)" looks like a copy-paste error.
    282      failed_connect_cb(sock, req, isc__nm_uverr2result(status));
    283      return;
    284      }
    285
    286      atomic_store(&sock->connecting, false);
    287

(cherry picked from commit 0073cb73562f9101be7e8430bcaf3e1a21c7f10f)

5 years agoPut up additional safe guards to not use inactive/closed tcpdns socket
Ondřej Surý [Mon, 2 Nov 2020 14:55:12 +0000 (15:55 +0100)] 
Put up additional safe guards to not use inactive/closed tcpdns socket

When we are operating on the tcpdns socket, we need to double check
whether the socket or its outerhandle or its listener or its mgr is
still active and when not, bail out early.

(cherry picked from commit c14c1fdd2c43c96a6b31affc719cdf18f0057667)

5 years agoFix improper closed connection handling in tcpdns.
Witold Kręcicki [Sat, 31 Oct 2020 20:08:53 +0000 (21:08 +0100)] 
Fix improper closed connection handling in tcpdns.

If dnslisten_readcb gets a read callback it needs to verify that the
outer socket wasn't closed in the meantime, and issue a CANCELED callback
if it was.

(cherry picked from commit 3ab3d90de039a3f086bba9c25792e42dd1b4a614)

5 years agocheck return value from uv_tcp_getpeername() when connecting
Evan Hunt [Thu, 29 Oct 2020 22:42:09 +0000 (15:42 -0700)] 
check return value from uv_tcp_getpeername() when connecting

if we can't determine the peer, the connect should fail.

(cherry picked from commit 8fcad58ea6b8a2b247e4c894ef3d49778dd07b54)

5 years agoset REUSEPORT and REUSEADDR on TCP sockets if needed
Evan Hunt [Thu, 29 Oct 2020 18:15:26 +0000 (11:15 -0700)] 
set REUSEPORT and REUSEADDR on TCP sockets if needed

When binding a TCP socket, if bind() fails with EADDRINUSE,
try again with REUSEPORT/REUSEADDR (or the equivalent options).

(cherry picked from commit 26a3a22895d634b44bd0a4a4ec3bff3a41290dab)

5 years agoFix more races between connect and shutdown
Ondřej Surý [Thu, 29 Oct 2020 11:04:00 +0000 (12:04 +0100)] 
Fix more races between connect and shutdown

There were more races that could happen while connecting to a
socket while closing or shutting down the same socket.  This
commit introduces a .closing flag to guard the socket from
being closed twice.

(cherry picked from commit ed3ab63f749cb5eefb3b4b0156b4afdbf9c22b35)

5 years agoFix a race between isc__nm_async_shutdown() and new sends/reads
Ondřej Surý [Tue, 27 Oct 2020 19:00:08 +0000 (20:00 +0100)] 
Fix a race between isc__nm_async_shutdown() and new sends/reads

There was a data race where a new event could be scheduled after
isc__nm_async_shutdown() had cleaned up all the dangling UDP/TCP
sockets from the loop.

(cherry picked from commit 6cfadf9db037efa57d84803601891a33a85a8d8e)

5 years agoRefactor udp_recv_cb()
Ondřej Surý [Mon, 26 Oct 2020 16:31:55 +0000 (17:31 +0100)] 
Refactor udp_recv_cb()

- more logical code flow.
- propagate errors back to the caller.
- add a 'reading' flag and call the callback from failed_read_cb()
  only when it the socket was actively reading.

(cherry picked from commit 5fcd52209a9eeb7c6575b77c3bd4070ad9ba1c2d)