Commit graph

33522 commits

Author SHA1 Message Date
Patrick McLean
ebced74b19 Add isc_time_now_hires function to get current time with high resolution
The current isc_time_now uses CLOCK_REALTIME_COARSE which only updates
on a timer tick. This clock is generally fine for millisecond accuracy,
but on servers with 100hz clocks, this clock is nowhere near accurate
enough for microsecond accuracy.

This commit adds a new isc_time_now_hires function that uses
CLOCK_REALTIME, which gives the current time, though it is somewhat
expensive to call. When microsecond accuracy is required, it may be
required to use extra resources for higher accuracy.
2021-03-20 11:25:55 -07:00
Ondřej Surý
bee4ee931f Merge branch '2416-improve-netmgr-unit-tests-reliability' into 'main'
Improve reliability of the netmgr unit tests

Closes #2455 and #2416

See merge request isc-projects/bind9!4628
2021-03-19 16:22:22 +00:00
Ondřej Surý
d96c94d754 Require CMocka >= 1.1.3 to run the unit tests
In CMocka versions << 1.1.3, the skip() function would cause the whole
unit test to abort when CMOCKA_TEST_ABORT is set.  As this is problem
only in Debian 9 Stretch and Ubuntu 16.04 Xenial, we just require the
CMocka >= 1.1.3 and disable the unit testing on Debian 9 Stretch until
we can pull the libcmocka-dev from stretch-backports and remove the
Ubuntu 16.04 Xenial from the CI as it is reaching End of Standard
Support at the end of April 2021.
2021-03-19 16:25:28 +01:00
Ondřej Surý
d016ea745f Fix compilation with NETMGR_TRACE(_VERBOSE) enabled on non-Linux
When NETMGR_TRACE(_VERBOSE) is enabled, the build would fail on some
non-Linux non-glibc platforms because:

  * Use <stdint.h> print macros because uint_fast32_t is not always
    unsigned long

  * The header <execinfo.h> is not available on non-glibc, thus commit
    adds dummy backtrace() and backtrace_symbols_fd() functions for
    platforms without HAVE_BACKTRACE
2021-03-19 16:25:28 +01:00
Ondřej Surý
42e4e3b843 Improve reliability of the netmgr unit tests
The netmgr unit tests were designed to push the system limits to maximum
by sending as many queries as possible in the busy loop from multiple
threads.  This mostly works with UDP, but in the stateful protocol where
establishing the connection takes more time, it failed quite often in
the CI.  On FreeBSD, this happened more often, because the socket() call
would fail spuriosly making the problem even worse.

This commit does several things to improve reliability:

* return value of isc_nm_<proto>connect() is always checked and retried
  when scheduling the connection fails

* The busy while loop has been slowed down with usleep(1000); so the
  netmgr threads could schedule the work and get executed.

* The isc_thread_yield() was replaced with usleep(1000); also to allow
  the other threads to do any work.

* Instead of waiting on just one variable, we wait for multiple
  variables to reach the final value

* We are wrapping the netmgr operations (connects, reads, writes,
  accepts) with reference counting and waiting for all the callbacks to
  be accounted for.

  This has two effects:

  a) the isc_nm_t is always clean of active sockets and handles when
     destroyed, so it will prevent the spurious INSIST(references == 1)
     from isc_nm_destroy()

  b) the unit test now ensures that all the callbacks are always called
     when they should be called, so any stuck test means that there was
     a missing callback call and it is always a real bug

These changes allows us to remove the workaround that would not run
certain tests on systems without port load-balancing.
2021-03-19 16:25:28 +01:00
Ondřej Surý
e8cd3d3cf7 Merge branch 'ondrej/call-failed_read-from-tls_error' into 'main'
Call isc__nm_tlsdns_failed_read on tls_error to cleanup the socket

See merge request isc-projects/bind9!4824
2021-03-19 14:57:53 +00:00
Ondřej Surý
e4e0e9e3c1 Call isc__nm_tlsdns_failed_read on tls_error to cleanup the socket
In tls_error(), we now call isc__nm_tlsdns_failed_read() instead of just
stopping timer and reading from the socket.  This allows us to properly
cleanup any pending operation on the socket.
2021-03-19 15:28:52 +01:00
Matthijs Mekking
085c2e3249 Merge branch 'treysis-filter-a' into 'main'
filter-a plugin

Closes #2585

See merge request isc-projects/bind9!4816
2021-03-19 09:41:02 +00:00
Matthijs Mekking
9a256347ab Add changes for filter-a plugin 2021-03-19 08:06:55 +01:00
treysis
6b2ea00621 Add filter-a plugin for IPv6-dominant environments
(cherry picked from commit 78f6cd57e1cc166823415438fe2d19a324cf7a67)
2021-03-19 08:06:55 +01:00
Ondřej Surý
6ae0a90583 Merge branch '2581-oldsize-assertion' into 'main'
Fix memory accounting bug in TLSDNS

Closes #2581

See merge request isc-projects/bind9!4809
2021-03-18 22:03:25 +00:00
Ondřej Surý
e4b0730387 Call the isc__nm_failed_connect_cb() early when shutting down
When shutting down, calling the isc__nm_failed_connect_cb() was delayed
until the connect callback would be called.  It turned out that the
connect callback might not get called at all when the socket is being
shut down.  Call the failed_connect_cb() directly in the
tlsdns_shutdown() instead of waiting for the connect callback to call it.
2021-03-18 14:31:15 -07:00
Ondřej Surý
73c574e553 Fix typo in processbuffer() - tcpdns vs tlsdns
The processbuffer() would call isc__nm_tcpdns_processbuffer() instead of
isc__nm_tlsdns_processbuffer() for the isc_nm_tlsdnssocket type of
socket.
2021-03-18 21:35:13 +01:00
Ondřej Surý
1d64d4cde8 Fix memory accounting bug in TLSDNS
After a partial write the tls.senddata buffer would be rearranged to
contain only the data tha wasn't sent and the len part would be made
shorter, which would lead to attempt to free only part of a socket's
tls.senddata buffer.
2021-03-18 18:14:38 +01:00
Ondřej Surý
15f676f111 Merge branch 'ondrej/fix-dangling-uvreq-in-tlsdns' into 'main'
Fix dangling uvreq when data is sent from tlsdns_cycle()

See merge request isc-projects/bind9!4820
2021-03-18 17:02:18 +00:00
Ondřej Surý
5cc406a920 Fix dangling uvreq when data is sent from tlsdns_cycle()
The tlsdns_cycle() might call uv_write() to write data to the socket,
when this happens and the socket is shutdown before the callback
completes, the uvreq structure was not freed because the callback would
be called with non-zero status code.
2021-03-18 17:58:56 +01:00
Ondřej Surý
06913d3d74 Merge branch '2573-dont-timeout-when-sending-data' into 'main'
Resolve "Fix TCPDNS and TLSDNS timers"

Closes #2583 and #2573

See merge request isc-projects/bind9!4807
2021-03-18 16:01:01 +00:00
Michal Nowak
2edba8777f Merge branch 'v9_17_11-release' into 'main'
Merge 9.17.11 release branch

See merge request isc-projects/bind9!4818
2021-03-18 15:38:54 +00:00
Ondřej Surý
98f7495426 Add CHANGES and release note for GL #2573 2021-03-18 16:37:57 +01:00
Ondřej Surý
36ddefacb4 Change the isc_nm_(get|set)timeouts() to work with milliseconds
The RFC7828 specifies the keepalive interval to be 16-bit, specified in
units of 100 milliseconds and the configuration options tcp-*-timeouts
are following the suit.  The units of 100 milliseconds are very
unintuitive and while we can't change the configuration and presentation
format, we should not follow this weird unit in the API.

This commit changes the isc_nm_(get|set)timeouts() functions to work
with milliseconds and convert the values to milliseconds before passing
them to the function, not just internally.
2021-03-18 16:37:57 +01:00
Ondřej Surý
1ef232f93d Merge the common parts between udp, tcpdns and tlsdns protocol
The udp, tcpdns and tlsdns contained lot of cut&paste code or code that
was very similar making the stack harder to maintain as any change to
one would have to be copied to the the other protocols.

In this commit, we merge the common parts into the common functions
under isc__nm_<foo> namespace and just keep the little differences based
on the socket type.
2021-03-18 16:37:57 +01:00
Ondřej Surý
caa5b6548a Fix TCPDNS and TLSDNS timers
After the TCPDNS refactoring the initial and idle timers were broken and
only the tcp-initial-timeout was always applied on the whole TCP
connection.

This broke any TCP connection that took longer than tcp-initial-timeout,
most often this would affect large zone AXFRs.

This commit changes the timeout logic in this way:

  * On TCP connection accept the tcp-initial-timeout is applied
    and the timer is started
  * When we are processing and/or sending any DNS message the timer is
    stopped
  * When we stop processing all DNS messages, the tcp-idle-timeout
    is applied and the timer is started again
2021-03-18 16:37:57 +01:00
Ondřej Surý
64cff61c02 Add TCP timeouts system test
The system tests were missing a test that would test tcp-initial-timeout
and tcp-idle-timeout.

This commit adds new "timeouts" system test that adds:

  * Test that waits longer than tcp-initial-timeout and then checks
    whether the socket was closed

  * Test that sends and receives DNS message then waits longer than
    tcp-initial-timeout but shorter time than tcp-idle-timeout than
    sends DNS message again than waits longer than tcp-idle-timeout
    and checks whether the socket was closed

  * Similar test, but bursting 25 DNS messages than waiting longer than
    tcp-initial-timeout and shorter than tcp-idle-timeout than do second
    25 DNS message burst

  * Check whether transfer longer than tcp-initial-timeout succeeds
2021-03-18 16:37:57 +01:00
Michal Nowak
3265dfa929
Set up release notes for BIND 9.17.12 2021-03-18 15:58:15 +01:00
Michal Nowak
8853ec09a5
Update BIND version to 9.17.11 2021-03-18 15:55:36 +01:00
Michal Nowak
9d4da23850
Add a CHANGES marker 2021-03-18 15:55:32 +01:00
Michal Nowak
a8b525290f
Merge branch 'mnowak/prepare-documentation-for-bind-9.17.11' into 'v9_17_11-release'
Prepare documentation for BIND 9.17.11

See merge request isc-private/bind9!252
2021-03-18 15:55:11 +01:00
Michal Nowak
924f8ceb06
Prepare release notes for BIND 9.17.11 2021-03-18 15:55:11 +01:00
Michal Nowak
e6ca82b2c4
Add release notes for GL #2472 2021-03-18 15:55:10 +01:00
Michal Nowak
566b8ab85e
Add release note for GL #2504 2021-03-18 15:55:10 +01:00
Michal Nowak
baf79279f0
Add release note for GL #2041 2021-03-18 15:55:10 +01:00
Michal Nowak
70076fb7c8
Reorder release notes 2021-03-18 15:55:10 +01:00
Michal Nowak
b66bb0c89e
Tweak and reword release notes 2021-03-18 15:54:41 +01:00
Michal Nowak
188d605c2a
Tweak and reword recent CHANGES entries 2021-03-18 15:53:30 +01:00
Michal Nowak
68128f2092
Release template: update the -S edition delivery tickets
Change requested by the Support team.
2021-03-18 15:53:30 +01:00
Mark Andrews
ffea605679 Merge branch '2580-does-not-compile-without-deprecated-openssl-apis' into 'main'
Resolve "Does not compile without deprecated OpenSSL APIs"

Closes #2580

See merge request isc-projects/bind9!4806
2021-03-17 20:10:11 +00:00
Mark Andrews
a9f883cbc2 Stop using deprecated calls in lib/isc/tls.c
from Rosen Penev @neheb
2021-03-17 20:05:47 +00:00
Matthijs Mekking
8d8373c21c Merge branch '2523-thaw-dnssec-policy-zone' into 'main'
Resolve "Unable to thaw a frozen dynamic zone when KASP is configured."

Closes #2523

See merge request isc-projects/bind9!4777
2021-03-17 10:11:13 +00:00
Matthijs Mekking
0cae3249e3 Add test for thaw dynamic kasp zone
Add a test for freezing, manually updating, and then thawing a dynamic
zone with "dnssec-policy". In the kasp system test we add parameters
to the "update_is_signed" check to signal the indicated IP addresses
for the labels "a" and "d". If set to '-', the test is skipped.

After nsupdating the dynamic.kasp zone, we revert the update (with
nsupdate) and update the zone again, but now with the freeze/thaw
approach.
2021-03-17 08:24:17 +01:00
Matthijs Mekking
b90846f222 Fully sign a thawed zone
When thawing a zone, we don't know what changes have been made. If we
do DNSSEC maintenance on this zone, schedule a full sign.
2021-03-17 08:24:17 +01:00
Matthijs Mekking
b518ed9f46 Fix "unable to thaw dynamic kasp zone"
Dynamic zones with dnssec-policy could not be thawed because KASP
zones were considered always dynamic. But a dynamic KASP zone should
also check whether updates are disabled.
2021-03-17 08:24:15 +01:00
Matthijs Mekking
0eb0dabdcc Merge branch '2561-dnssec-guide-signing-type' into 'main'
Fix typo in DNSSEC Guide

Closes #2561

See merge request isc-projects/bind9!4791
2021-03-16 13:37:32 +00:00
Matthijs Mekking
d45af8877a Fix typo in DNSSEC Guide
The "dnssec-policy" example should say "keys" instead of "key".
2021-03-16 13:37:16 +00:00
Artem Boldariev
50eaa0f38f Merge branch '2514-tls-cert-chain' into 'main'
Load full certificate chain from a certificate chain file

Closes #2514

See merge request isc-projects/bind9!4792
2021-03-16 10:33:35 +00:00
Matthijs Mekking
c69fafdd65 Add change entry for [#2514] 2021-03-16 11:50:32 +02:00
Artem Boldariev
75363dcb7c Load full certificate chain from a certificate chain file
This commit fixes loading the certificate chain files so that the full
chain could be sent to the clients which require that for
verification. Before that fix only the top most certificate would be
loaded from the chain and sent to clients preventing some of them to
perform certificate validation (e.g. Windows 10 DoH client).
2021-03-16 11:49:04 +02:00
Matthijs Mekking
6dee5c1b28 Merge branch '2562-xot-crash' into 'main'
Fix a XoT crash

Closes #2562

See merge request isc-projects/bind9!4803
2021-03-16 09:42:18 +00:00
Matthijs Mekking
ee0835d977 Fix a XoT crash
The transport should also be detached when we skip a master, otherwise
named will crash when sending a SOA query to the next master over TLS,
because the transport must be NULL when we enter
'dns_view_gettransport'.
2021-03-16 10:11:12 +01:00
Mark Andrews
24c796942f Merge branch '2569-nsupdate-on-solaris-produces-different-failure-text-than-expected' into 'main'
Resolve "nsupdate on Solaris produces different failure text than expected"

Closes #2569

See merge request isc-projects/bind9!4804
2021-03-16 00:11:02 +00:00
Mark Andrews
25d1276170 Ignore the actual error code returned by getaddrinfo
when testing if interactive mode continues or not on
invalid hostname.  We only need to detect that getaddrinfo
failed and that we continued or not.
2021-03-16 10:20:28 +11:00