]> git.ipfire.org Git - thirdparty/bind9.git/log
thirdparty/bind9.git
5 years agoTest handling of non-apex RRSIG(SOA) RRsets
Michał Kępień [Fri, 23 Apr 2021 12:26:48 +0000 (14:26 +0200)] 
Test handling of non-apex RRSIG(SOA) RRsets

Add a check to the "dnssec" system test which ensures that RRSIG(SOA)
RRsets present anywhere else than at the zone apex are automatically
removed after a zone containing such RRsets is loaded.

5 years agoBe more precise with the stopping conditions in zone_resigninc
Mark Andrews [Thu, 8 Apr 2021 00:49:28 +0000 (10:49 +1000)] 
Be more precise with the stopping conditions in zone_resigninc

If there happens to be a RRSIG(SOA) that is not at the zone apex
for any reason it should not be considered as a stopping condition
for incremental zone signing.

5 years agoadd HTTP timeout recovery test
Evan Hunt [Wed, 21 Apr 2021 18:55:40 +0000 (11:55 -0700)] 
add HTTP timeout recovery test

NOTE: this test currently fails

5 years agofix TLS timeout recovery
Evan Hunt [Wed, 21 Apr 2021 17:28:26 +0000 (10:28 -0700)] 
fix TLS timeout recovery

the destruction of the socket in tls_failed_read_cb() needs to be
conditional; if reached due to a timeout on a timer that has
subsequently been reset, the socket must not be destroyed.

5 years agofix TCP timeout recovery
Evan Hunt [Wed, 21 Apr 2021 17:27:46 +0000 (10:27 -0700)] 
fix TCP timeout recovery

removed an unnecessary assert in the failed_read_cb() function.
also renamed to isc__nm_tcp_failed_read_cb() to match the practice
in other modules.

5 years agoadd TCP and TLS timeout recovery tests
Evan Hunt [Wed, 21 Apr 2021 17:27:09 +0000 (10:27 -0700)] 
add TCP and TLS timeout recovery tests

NOTE: currently these tests fail

5 years agoadd TCPDNS and TLSDNS timeout recovery tests
Evan Hunt [Wed, 21 Apr 2021 08:09:30 +0000 (01:09 -0700)] 
add TCPDNS and TLSDNS timeout recovery tests

this is similar in structure to the UDP timeout recovery test.

this commit adds a new mechanism to the netmgr test allowing the
listen socket to accept incoming TCP connections but never send
a response. this forces the client to time out on read.

5 years agorun read callbacks synchronously on timeout
Evan Hunt [Wed, 21 Apr 2021 06:27:51 +0000 (23:27 -0700)] 
run read callbacks synchronously on timeout

when running read callbacks, if the event result is not ISC_R_SUCCESS,
the callback is always run asynchronously. this is a problem on timeout,
because there's no chance to reset the timer before the socket has
already been destroyed. this commit allows read callbacks to run
synchronously for both ISC_R_SUCCESS and ISC_R_TIMEDOUT result codes.

5 years agoadd a UDP timeout recovery test
Evan Hunt [Wed, 21 Apr 2021 04:08:10 +0000 (21:08 -0700)] 
add a UDP timeout recovery test

this test sets up a server socket that listens for UDP connections
but never responds. the client will always time out; it should retry
five times before giving up.

5 years agoallow client read callback to be assignable
Evan Hunt [Wed, 21 Apr 2021 00:13:15 +0000 (17:13 -0700)] 
allow client read callback to be assignable

allow netmgr client tests to choose the function that will be
used as a read callback, without having to write a different
connect callback handler.

5 years agoMerge branch '2626-deadlock-with-concurrent-rndc-addzone-rndc-delzone-commands' into...
Diego dos Santos Fronza [Thu, 22 Apr 2021 15:47:16 +0000 (15:47 +0000)] 
Merge branch '2626-deadlock-with-concurrent-rndc-addzone-rndc-delzone-commands' into 'main'

Resolve "Deadlock with concurrent `rndc addzone`/`rndc delzone` commands"

Closes #2626

See merge request isc-projects/bind9!4904

5 years agoAdd CHANGES note for GL #2626
Diego Fronza [Fri, 16 Apr 2021 16:28:08 +0000 (13:28 -0300)] 
Add CHANGES note for GL #2626

5 years agoAdd system test for the deadlock fix
Diego Fronza [Mon, 19 Apr 2021 17:23:31 +0000 (14:23 -0300)] 
Add system test for the deadlock fix

The test spawns 4 parallel workers that keep adding, modifying and
deleting zones, the main thread repeatedly checks wheter rndc
status responds within a reasonable period.

While environment and timing issues may affect the test, in most
test cases the deadlock that was taking place before the fix used to
trigger in less than 7 seconds in a machine with at least 2 cores.

5 years agoFix deadlock between rndc addzone/delzone/modzone
Diego Fronza [Fri, 16 Apr 2021 15:21:31 +0000 (12:21 -0300)] 
Fix deadlock between rndc addzone/delzone/modzone

It follows a description of the steps that were leading to the deadlock:

1. `do_addzone` calls `isc_task_beginexclusive`.

2. `isc_task_beginexclusive` waits for (N_WORKERS - 1) halted tasks,
   this blocks waiting for those (no. workers -1) workers to halt.
...
isc_task_beginexclusive(isc_task_t *task0) {
    ...
while (manager->halted + 1 < manager->workers) {
wake_all_queues(manager);
WAIT(&manager->halt_cond, &manager->halt_lock);
}
```

3. It is possible that in `task.c / dispatch()` a worker is running a
   task event, if that event blocks it will not allow this worker to
   halt.

4. `do_addzone` acquires `LOCK(&view->new_zone_lock);`,

5. `rmzone` event is called from some worker's `dispatch()`, `rmzone`
   blocks waiting for the same lock.

6. `do_addzone` calls `isc_task_beginexclusive`.

7. Deadlock triggered, since:
- `rmzone` is wating for the lock.
- `isc_task_beginexclusive` is waiting for (no. workers - 1) to
   be halted
- since `rmzone` event is blocked it won't allow the worker to halt.

To fix this, we updated do_addzone code to call isc_task_beginexclusive
before the lock is acquired, we postpone locking to the nearest required
place, same for isc_task_beginexclusive.

The same could happen with rndc modzone, so that was addressed as well.

5 years agoMerge branch '2634-test-tkey-gssapi-credential' into 'main'
Petr Špaček [Thu, 22 Apr 2021 15:25:36 +0000 (15:25 +0000)] 
Merge branch '2634-test-tkey-gssapi-credential' into 'main'

Add tests for the "tkey-gssapi-credential" option

See merge request isc-projects/bind9!4905

5 years agoAdd tests for the "tkey-gssapi-credential" option
Petr Špaček [Fri, 16 Apr 2021 16:05:43 +0000 (18:05 +0200)] 
Add tests for the "tkey-gssapi-credential" option

Four named instances in the "nsupdate" system test have GSS-TSIG support
enabled.  All of them currently use "tkey-gssapi-keytab".  Configure two
of them with "tkey-gssapi-credential" to test that option.

As "tkey-gssapi-keytab" and "tkey-gssapi-credential" both provide the
same functionality, no test modifications are required.  The difference
between the two options is that the value of "tkey-gssapi-keytab" is an
explicit path to the keytab file to acquire credentials from, while the
value of "tkey-gssapi-credential" is the name of the principal whose
credentials should be used; those credentials are looked up in the
keytab file expected by the Kerberos library, i.e. /etc/krb5.keytab by
default.  The path to the default keytab file can be overridden using by
setting the KRB5_KTNAME environment variable.  Utilize that variable to
use existing keytab files with the "tkey-gssapi-credential" option.

The KRB5_KTNAME environment variable should not interfere with the
"tkey-gssapi-keytab" option.  Nevertheless, rename one of the keytab
files used with "tkey-gssapi-keytab" to something else than the contents
of the KRB5_KTNAME environment variable in order to make sure that both
"tkey-gssapi-keytab" and "tkey-gssapi-credential" are actually tested.

5 years agoMerge branch 'ondrej/autoconf-2.71-fixes' into 'main'
Ondřej Surý [Thu, 22 Apr 2021 12:41:11 +0000 (12:41 +0000)] 
Merge branch 'ondrej/autoconf-2.71-fixes' into 'main'

Update the configure.ac for autoconf >= 2.71 compatibility

See merge request isc-projects/bind9!4899

5 years agoUpdate the configure.ac for autoconf >= 2.71 compatibility
Ondřej Surý [Fri, 16 Apr 2021 10:25:35 +0000 (12:25 +0200)] 
Update the configure.ac for autoconf >= 2.71 compatibility

This mostly removes stuff that's either deprecated, obsolete or not used
at all:

* Update the minimal autoconf version to 2.69
* AC_PROG_CC_C99 is deprecated, just use AC_PROG_CC as we require C11
  anyway
* AC_HEADER_TIME is deprecated, both <sys/time.h> and <time.h> can be
  included at the same time, and we don't use the macros that
  AC_HEADER_TIME defines anywhere
* AC_HEADER_STDC checks for ISO C90 and we require at least C11
* Replace AC_TRY_*([]) with AC_*_IFELSE([AC_LANG_PROGRAM()])
* Update m4/ax_check_openssl.m4 from serial 10 to serial 11
* Update m4/ax_gcc_func_attribute.m4 from serial 10 to serial 13
* Update m4/ax_pthread.m4 from serial 24 to serial 30
* Add early AC_CANONICAL_TARGET call to prevent warning from AX_PTHREAD

5 years agoMerge branch '2625-the-shutdown-system-test-is-not-capturing-enough' into 'main'
Mark Andrews [Thu, 22 Apr 2021 06:47:21 +0000 (06:47 +0000)] 
Merge branch '2625-the-shutdown-system-test-is-not-capturing-enough' into 'main'

Resolve "The shutdown system test is not capturing enough"

Closes #2625

See merge request isc-projects/bind9!4883

5 years agoAbort named if 'rndc stop' or 'kill TERM' has failed to shutdown
Mark Andrews [Mon, 12 Apr 2021 08:00:07 +0000 (18:00 +1000)] 
Abort named if 'rndc stop' or 'kill TERM' has failed to shutdown

5 years agoMerge branch '2638-run-internal-tasks-on-top-of-network-manager-worker-loops' into...
Ondřej Surý [Tue, 20 Apr 2021 22:16:42 +0000 (22:16 +0000)] 
Merge branch '2638-run-internal-tasks-on-top-of-network-manager-worker-loops' into 'main'

Refactor taskmgr to run on top of netmgr

Closes #2638

See merge request isc-projects/bind9!4918

5 years agoAdd CHANGES and release note for [GL #2638]
Ondřej Surý [Mon, 19 Apr 2021 14:24:26 +0000 (16:24 +0200)] 
Add CHANGES and release note for [GL #2638]

5 years agoRefactor taskmgr to run on top of netmgr
Ondřej Surý [Fri, 9 Apr 2021 09:31:19 +0000 (11:31 +0200)] 
Refactor taskmgr to run on top of netmgr

This commit changes the taskmgr to run the individual tasks on the
netmgr internal workers.  While an effort has been put into keeping the
taskmgr interface intact, couple of changes have been made:

 * The taskmgr has no concept of universal privileged mode - rather the
   tasks are either privileged or unprivileged (normal).  The privileged
   tasks are run as a first thing when the netmgr is unpaused.  There
   are now four different queues in in the netmgr:

   1. priority queue - netievent on the priority queue are run even when
      the taskmgr enter exclusive mode and netmgr is paused.  This is
      needed to properly start listening on the interfaces, free
      resources and resume.

   2. privileged task queue - only privileged tasks are queued here and
      this is the first queue that gets processed when network manager
      is unpaused using isc_nm_resume().  All netmgr workers need to
      clean the privileged task queue before they all proceed normal
      operation.  Both task queues are processed when the workers are
      finished.

   3. task queue - only (traditional) task are scheduled here and this
      queue along with privileged task queues are process when the
      netmgr workers are finishing.  This is needed to process the task
      shutdown events.

   4. normal queue - this is the queue with netmgr events, e.g. reading,
      sending, callbacks and pretty much everything is processed here.

 * The isc_taskmgr_create() now requires initialized netmgr (isc_nm_t)
   object.

 * The isc_nm_destroy() function now waits for indefinite time, but it
   will print out the active objects when in tracing mode
   (-DNETMGR_TRACE=1 and -DNETMGR_TRACE_VERBOSE=1), the netmgr has been
   made a little bit more asynchronous and it might take longer time to
   shutdown all the active networking connections.

 * Previously, the isc_nm_stoplistening() was a synchronous operation.
   This has been changed and the isc_nm_stoplistening() just schedules
   the child sockets to stop listening and exits.  This was needed to
   prevent a deadlock as the the (traditional) tasks are now executed on
   the netmgr threads.

 * The socket selection logic in isc__nm_udp_send() was flawed, but
   fortunatelly, it was broken, so we never hit the problem where we
   created uvreq_t on a socket from nmhandle_t, but then a different
   socket could be picked up and then we were trying to run the send
   callback on a socket that had different threadid than currently
   running.

5 years agoMerge branch '2630-tsan-error-in-xfrin-c' into 'main'
Ondřej Surý [Tue, 20 Apr 2021 12:13:35 +0000 (12:13 +0000)] 
Merge branch '2630-tsan-error-in-xfrin-c' into 'main'

Prevent the double xfrin_fail() call

Closes #2630

See merge request isc-projects/bind9!4898

5 years agoAdd CHANGES note for [GL #2630]
Ondřej Surý [Fri, 16 Apr 2021 14:10:55 +0000 (16:10 +0200)] 
Add CHANGES note for [GL #2630]

5 years agoPrevent the double xfrin_fail() call
Ondřej Surý [Fri, 16 Apr 2021 09:08:05 +0000 (11:08 +0200)] 
Prevent the double xfrin_fail() call

When we are reading from the xfrin socket, and the transfer would be
shutdown, the shutdown function would call `xfrin_fail()` which in turns
calls `xfrin_cancelio()` that causes the read callback to be invoked
with `ISC_R_CANCELED` status code and that caused yet another
`xfrin_fail()` call.

The fix here is to ensure the `xfrin_fail()` would be run only once
properly using better synchronization on xfr->shuttingdown flag.

5 years agoMerge branch '2637-threadsanitizer-lock-order-inversion-potential-deadlock-in-zone_re...
Ondřej Surý [Mon, 19 Apr 2021 20:29:56 +0000 (20:29 +0000)] 
Merge branch '2637-threadsanitizer-lock-order-inversion-potential-deadlock-in-zone_refreshkeys' into 'main'

Fix lock-order-inversion (potential deadlock) in dns_resolver_createfetch

Closes #2637

See merge request isc-projects/bind9!4909

5 years agoFix lock-order-inversion (potential deadlock) in dns_resolver_createfetch
Ondřej Surý [Mon, 19 Apr 2021 08:01:32 +0000 (10:01 +0200)] 
Fix lock-order-inversion (potential deadlock) in dns_resolver_createfetch

There's a lock-order-inversion when running `zone_maintenance()` from
the timer while shutting down the server `shutdown_server()`.  This only
happens when the taskmgr scheduling is more relaxed and paralellized,
but the issue is real nevertheless.

The associated ThreadSanitizer warning:

    WARNING: ThreadSanitizer: lock-order-inversion (potential deadlock)
      Cycle in lock order graph: M1 (0x000000000001) => M2 (0x000000000000) => M1

      Mutex M2 acquired here while holding mutex M1 in thread T1:
#0 pthread_mutex_lock <null>
#1 dns_view_findzonecut lib/dns/view.c:1326:2
#2 fctx_create lib/dns/resolver.c:5144:13
#3 dns_resolver_createfetch lib/dns/resolver.c:10977:12
#4 zone_refreshkeys lib/dns/zone.c:10830:13
#5 zone_maintenance lib/dns/zone.c:11065:5
#6 zone_timer lib/dns/zone.c:14652:2
#7 task_run lib/isc/task.c:857:5
#8 isc_task_run lib/isc/task.c:944:10
#9 isc__nm_async_task lib/isc/netmgr/netmgr.c:730:24
#10 process_netievent lib/isc/netmgr/netmgr.c
#11 process_queue lib/isc/netmgr/netmgr.c:885:8
#12 process_tasks_queue lib/isc/netmgr/netmgr.c:756:10
#13 process_queues lib/isc/netmgr/netmgr.c:772:7
#14 async_cb lib/isc/netmgr/netmgr.c:671:2
#15 uv__async_io /home/ondrej/Projects/tsan/libuv/src/unix/async.c:163:5
#16 uv__io_poll /home/ondrej/Projects/tsan/libuv/src/unix/linux-core.c:462:11
#17 uv_run /home/ondrej/Projects/tsan/libuv/src/unix/core.c:392:5
#18 nm_thread lib/isc/netmgr/netmgr.c:597:11
#19 isc__trampoline_run lib/isc/trampoline.c:184:11

      Mutex M1 previously acquired by the same thread here:
#0 pthread_mutex_lock <null>
#1 zone_refreshkeys lib/dns/zone.c:10717:2
#2 zone_maintenance lib/dns/zone.c:11065:5
#3 zone_timer lib/dns/zone.c:14652:2
#4 task_run lib/isc/task.c:857:5
#5 isc_task_run lib/isc/task.c:944:10
#6 isc__nm_async_task lib/isc/netmgr/netmgr.c:730:24
#7 process_netievent lib/isc/netmgr/netmgr.c
#8 process_queue lib/isc/netmgr/netmgr.c:885:8
#9 process_tasks_queue lib/isc/netmgr/netmgr.c:756:10
#10 process_queues lib/isc/netmgr/netmgr.c:772:7
#11 async_cb lib/isc/netmgr/netmgr.c:671:2
#12 uv__async_io /home/ondrej/Projects/tsan/libuv/src/unix/async.c:163:5
#13 uv__io_poll /home/ondrej/Projects/tsan/libuv/src/unix/linux-core.c:462:11
#14 uv_run /home/ondrej/Projects/tsan/libuv/src/unix/core.c:392:5
#15 nm_thread lib/isc/netmgr/netmgr.c:597:11
#16 isc__trampoline_run lib/isc/trampoline.c:184:11

      Mutex M1 acquired here while holding mutex M2 in thread T2:
#0 pthread_mutex_lock <null>
#1 dns_zone_flush lib/dns/zone.c:11443:2
#2 view_flushanddetach lib/dns/view.c:657:5
#3 dns_view_flushanddetach lib/dns/view.c:690:2
#4 shutdown_server bin/named/server.c:10056:4
#5 task_run lib/isc/task.c:857:5
#6 isc_task_run lib/isc/task.c:944:10
#7 isc__nm_async_task lib/isc/netmgr/netmgr.c:730:24
#8 process_netievent lib/isc/netmgr/netmgr.c
#9 process_queue lib/isc/netmgr/netmgr.c:885:8
#10 process_tasks_queue lib/isc/netmgr/netmgr.c:756:10
#11 process_queues lib/isc/netmgr/netmgr.c:772:7
#12 async_cb lib/isc/netmgr/netmgr.c:671:2
#13 uv__async_io /home/ondrej/Projects/tsan/libuv/src/unix/async.c:163:5
#14 uv__io_poll /home/ondrej/Projects/tsan/libuv/src/unix/linux-core.c:462:11
#15 uv_run /home/ondrej/Projects/tsan/libuv/src/unix/core.c:392:5
#16 nm_thread lib/isc/netmgr/netmgr.c:597:11
#17 isc__trampoline_run lib/isc/trampoline.c:184:11

      Mutex M2 previously acquired by the same thread here:
#0 pthread_mutex_lock <null>
#1 view_flushanddetach lib/dns/view.c:645:3
#2 dns_view_flushanddetach lib/dns/view.c:690:2
#3 shutdown_server bin/named/server.c:10056:4
#4 task_run lib/isc/task.c:857:5
#5 isc_task_run lib/isc/task.c:944:10
#6 isc__nm_async_task lib/isc/netmgr/netmgr.c:730:24
#7 process_netievent lib/isc/netmgr/netmgr.c
#8 process_queue lib/isc/netmgr/netmgr.c:885:8
#9 process_tasks_queue lib/isc/netmgr/netmgr.c:756:10
#10 process_queues lib/isc/netmgr/netmgr.c:772:7
#11 async_cb lib/isc/netmgr/netmgr.c:671:2
#12 uv__async_io /home/ondrej/Projects/tsan/libuv/src/unix/async.c:163:5
#13 uv__io_poll /home/ondrej/Projects/tsan/libuv/src/unix/linux-core.c:462:11
#14 uv_run /home/ondrej/Projects/tsan/libuv/src/unix/core.c:392:5
#15 nm_thread lib/isc/netmgr/netmgr.c:597:11
#16 isc__trampoline_run lib/isc/trampoline.c:184:11

      Thread T2 (running) created by main thread at:
#0 pthread_create <null>
#1 isc_thread_create lib/isc/pthreads/thread.c:79:8
#2 isc_nm_start lib/isc/netmgr/netmgr.c:303:3
#3 create_managers bin/named/main.c:957:15
#4 setup bin/named/main.c:1267:11
#5 main bin/named/main.c:1558:2

      Thread T2 (running) created by main thread at:
#0 pthread_create <null>
#1 isc_thread_create lib/isc/pthreads/thread.c:79:8
#2 isc_nm_start lib/isc/netmgr/netmgr.c:303:3
#3 create_managers bin/named/main.c:957:15
#4 setup bin/named/main.c:1267:11
#5 main bin/named/main.c:1558:2

    SUMMARY: ThreadSanitizer: lock-order-inversion (potential deadlock) in __interceptor_pthread_mutex_lock

5 years agoMerge branch 'ondrej/cleanup-ISCAPI-remnants' into 'main'
Ondřej Surý [Mon, 19 Apr 2021 11:48:14 +0000 (11:48 +0000)] 
Merge branch 'ondrej/cleanup-ISCAPI-remnants' into 'main'

Cleanup the public vs private ISCAPI remnants

See merge request isc-projects/bind9!4911

5 years agoCleanup the public vs private ISCAPI remnants
Ondřej Surý [Mon, 19 Apr 2021 09:12:58 +0000 (11:12 +0200)] 
Cleanup the public vs private ISCAPI remnants

Since all the libraries are internal now, just cleanup the ISCAPI remnants
in isc_socket, isc_task and isc_timer APIs.  This means, there's one less
layer as following changes have been done:

 * struct isc_socket and struct isc_socketmgr have been removed
 * struct isc__socket and struct isc__socketmgr have been renamed
   to struct isc_socket and struct isc_socketmgr
 * struct isc_task and struct isc_taskmgr have been removed
 * struct isc__task and struct isc__taskmgr have been renamed
   to struct isc_task and struct isc_taskmgr
 * struct isc_timer and struct isc_timermgr have been removed
 * struct isc__timer and struct isc__timermgr have been renamed
   to struct isc_timer and struct isc_timermgr
 * All the associated code that dealt with typing isc_<foo>
   to isc__<foo> and back has been removed.

5 years agoMerge branch 'ondrej/fixup-bin/tests/system/resolve-win32-directories' into 'main'
Ondřej Surý [Mon, 19 Apr 2021 11:15:12 +0000 (11:15 +0000)] 
Merge branch 'ondrej/fixup-bin/tests/system/resolve-win32-directories' into 'main'

Fixup win32 paths for moved bin/tests/system/resolve

See merge request isc-projects/bind9!4916

5 years agoFixup win32 paths for moved bin/tests/system/resolve
Ondřej Surý [Mon, 19 Apr 2021 10:17:45 +0000 (12:17 +0200)] 
Fixup win32 paths for moved bin/tests/system/resolve

When resolve.c was moved from lib/samples to bin/tests/system, the
resolve.vcxproj.in would still contain old paths to the directory
root. This commit adds one more ..\ to match the directory depth.

Additionally, fixup the path in BINDInstall.vcxproj.in to be
bin/tests/system and not bin/tests/samples.

5 years agoMerge branch '2636-timing-race-in-setnsec3param-task' into 'main'
Ondřej Surý [Mon, 19 Apr 2021 09:22:31 +0000 (09:22 +0000)] 
Merge branch '2636-timing-race-in-setnsec3param-task' into 'main'

Fix task timing race in setnsec3param()

Closes #2636

See merge request isc-projects/bind9!4908

5 years agoFix task timing race in setnsec3param()
Ondřej Surý [Mon, 19 Apr 2021 07:25:14 +0000 (09:25 +0200)] 
Fix task timing race in setnsec3param()

When setnsec3param() is schedule from zone_postload() there's no
guarantee that `zone->db` is not `NULL` yet.  Thus when the
setnsec3param() is called, we need to check for `zone->db` existence and
reschedule the task, because calling `rss_post()` on a zone with empty
`.db` ends up with no-op (the function just returns).

5 years agoMerge branch 'ondrej/cleanup-double-createinctx-constructors' into 'main'
Ondřej Surý [Mon, 19 Apr 2021 08:26:32 +0000 (08:26 +0000)] 
Merge branch 'ondrej/cleanup-double-createinctx-constructors' into 'main'

Cleanup the isc_<*>mgr_createinc() constructors

See merge request isc-projects/bind9!4910

5 years agoCleanup the isc_<*>mgr_createinc() constructors
Ondřej Surý [Mon, 19 Apr 2021 08:20:43 +0000 (10:20 +0200)] 
Cleanup the isc_<*>mgr_createinc() constructors

Previously, the taskmgr, timermgr and socketmgr had a constructor
variant, that would create the mgr on top of existing appctx.  This was
no longer true and isc_<*>mgr was just calling isc_<*>mgr_create()
directly without any extra code.

This commit just cleans up the extra function.

5 years agoMerge branch 'marka-initialise-resarg-lock' into 'main'
Mark Andrews [Mon, 19 Apr 2021 04:59:39 +0000 (04:59 +0000)] 
Merge branch 'marka-initialise-resarg-lock' into 'main'

properly initialise resarg->lock

See merge request isc-projects/bind9!4907

5 years agoproperly initialise resarg->lock
Mark Andrews [Mon, 19 Apr 2021 04:32:40 +0000 (14:32 +1000)] 
properly initialise resarg->lock

5 years agoMerge branch 'each-cleanup-dns_client' into 'main'
Ondřej Surý [Fri, 16 Apr 2021 13:35:44 +0000 (13:35 +0000)] 
Merge branch 'each-cleanup-dns_client' into 'main'

clean up dns_client and related samples

See merge request isc-projects/bind9!4835

5 years agoAdd CHANGES note for [GL !4835]
Evan Hunt [Tue, 23 Mar 2021 01:56:06 +0000 (18:56 -0700)] 
Add CHANGES note for [GL !4835]

5 years agomove samples/resolve.c to bin/tests/system
Evan Hunt [Tue, 23 Mar 2021 01:40:21 +0000 (18:40 -0700)] 
move samples/resolve.c to bin/tests/system

"resolve" is used by the resolver system tests, and I'm not
certain whether delv exercises the same code, so rather than
remove it, I moved it to bin/tests/system.

5 years agoremove sample-async
Evan Hunt [Tue, 23 Mar 2021 01:25:15 +0000 (18:25 -0700)] 
remove sample-async

sample code for export libraries is no longer needed and
this code is not used for any internal tests. also, sample-gai.c
had already been removed but there were some dangling references.

5 years agorename dns_client_createx() to dns_client_create()
Evan Hunt [Tue, 23 Mar 2021 01:16:28 +0000 (18:16 -0700)] 
rename dns_client_createx() to dns_client_create()

there's no longer a need to use an alternate name.

5 years agoremove dns_client_request() and related code
Evan Hunt [Tue, 23 Mar 2021 01:14:37 +0000 (18:14 -0700)] 
remove dns_client_request() and related code

continues the cleanup of dns_client started in the previous commit.

5 years agoremove dns_client_update() and related code
Evan Hunt [Tue, 23 Mar 2021 01:04:23 +0000 (18:04 -0700)] 
remove dns_client_update() and related code

the libdns client API is no longer being maintained for
external use, we can remove the code that isn't being used
internally, as well as the related tests.

5 years agoMerge branch '2634-placeholder' into 'main'
Michał Kępień [Fri, 16 Apr 2021 12:20:37 +0000 (12:20 +0000)] 
Merge branch '2634-placeholder' into 'main'

Add placeholder for GL #2634

See merge request isc-projects/bind9!4901

5 years agoAdd placeholder for GL #2634
Michał Kępień [Fri, 16 Apr 2021 12:16:57 +0000 (14:16 +0200)] 
Add placeholder for GL #2634

5 years agoMerge branch '2623-9-16-13-overwrites-master-files-if-old-format-jnl-files-are-presen...
Ondřej Surý [Fri, 16 Apr 2021 11:12:19 +0000 (11:12 +0000)] 
Merge branch '2623-9-16-13-overwrites-master-files-if-old-format-jnl-files-are-present' into 'main'

Resolve "9.16.13 overwrites master files if old format .jnl files are present"

Closes #2623

See merge request isc-projects/bind9!4880

5 years agoAdd CHANGES and release note for [GL #2623]
Mark Andrews [Mon, 12 Apr 2021 00:43:56 +0000 (10:43 +1000)] 
Add CHANGES and release note for [GL #2623]

5 years agoRefactor dns_journal_rollforward() to work over opened journal
Ondřej Surý [Tue, 13 Apr 2021 11:26:09 +0000 (13:26 +0200)] 
Refactor dns_journal_rollforward() to work over opened journal

Too much logic was cramped inside the dns_journal_rollforward() that
made it harder to follow.  The dns_journal_rollforward() was refactored
to work over already opened journal and some of the previous logic was
moved to new static zone_journal_rollforward() that separates the
journal "rollforward" logic from the "zone" logic.

5 years agoFixing a recoverable journal should not result in the zone being written
Mark Andrews [Sun, 11 Apr 2021 23:36:18 +0000 (09:36 +1000)] 
Fixing a recoverable journal should not result in the zone being written

when dns_journal_rollforward returned ISC_R_RECOVERABLE the distintion
between 'up to date' and 'success' was lost, as a consequence
zone_needdump() was called writing out the zone file when it shouldn't
have been.   This change restores that distintion.  Adjust system
test to reflect visible changes.

5 years agoMerge branch 'artem/move-tls-tests-into-netmgr-tests' into 'main'
Artem Boldariev [Thu, 15 Apr 2021 14:03:14 +0000 (14:03 +0000)] 
Merge branch 'artem/move-tls-tests-into-netmgr-tests' into 'main'

Merge the tls_test.c into netmgr_test.c and extend the tests suite

See merge request isc-projects/bind9!4893

5 years agoHandle a situation when SSL shutdown messages were sent and received
Artem Boldariev [Wed, 14 Apr 2021 16:02:50 +0000 (19:02 +0300)] 
Handle a situation when SSL shutdown messages were sent and received

It fixes a corner case which was causing dig to print annoying
messages like:

14-Apr-2021 18:48:37.099 SSL error in BIO: 1 TLS error (errno:
0). Arguments: received_data: (nil), send_data: (nil), finish: false

even when all the data was properly processed.

5 years agoTLS: try to close TCP socket descriptor earlier when possible
Artem Boldariev [Tue, 13 Apr 2021 15:45:10 +0000 (18:45 +0300)] 
TLS: try to close TCP socket descriptor earlier when possible

Before this fix underlying TCP sockets could remain opened for longer
than it is actually required, causing unit tests to fail with lots of
ISC_R_TOOMANYOPENFILES errors.

The change also enables graceful SSL shutdown (before that it  would
happen only in the case when isc_nm_cancelread() were called).

5 years agoMerge the tls_test.c into netmgr_test.c and extend the tests suite
Ondřej Surý [Thu, 1 Apr 2021 07:15:43 +0000 (09:15 +0200)] 
Merge the tls_test.c into netmgr_test.c and extend the tests suite

This commit merges TLS tests into the common Network Manager unit
tests suite and extends the unit test framework to include support for
additional "ping-pong" style tests where all data could be sent via
lesser number of connections (the behaviour of the old test
suite). The tests for TCP and TLS were extended to make use of the new
mode, as this mode better translates to how the code is used in DoH.

Both TLS and TCP tests now share most of the unit tests' code, as they
are expected to function similarly from a users's perspective anyway.

Additionally to the above, the TLS test suite was extended to include
TLS tests using the connections quota facility.

5 years agoMerge branch 'matthijs-keymgr2kasp-rework' into 'main'
Matthijs Mekking [Thu, 15 Apr 2021 12:45:25 +0000 (12:45 +0000)] 
Merge branch 'matthijs-keymgr2kasp-rework' into 'main'

Update keymgr2kasp system test

Closes #2631

See merge request isc-projects/bind9!4894

5 years agoFix view-related issues in the "keymgr2kasp" test
Matthijs Mekking [Wed, 14 Apr 2021 13:23:41 +0000 (15:23 +0200)] 
Fix view-related issues in the "keymgr2kasp" test

Due to the lack of "match-clients" clauses in ns4/named2.conf.in, the
same view is incorrectly chosen for all queries received by ns4 in the
"keymgr2kasp" system test.  This causes only one version of the
"view-rsasha256.kasp" zone to actually be checked.  Add "match-clients"
clauses to ns4/named2.conf.in to ensure the test really checks what it
claims to.

Use identical view names ("ext", "int") in ns4/named.conf.in and
ns4/named2.conf.in so that it is easier to quickly identify the
differences between these two files.

Update tests.sh to account for the above changes.  Also fix a copy-paste
error in a comment to prevent confusion.

5 years agoMerge branch '1100-inline-signing-include' into 'main'
Matthijs Mekking [Wed, 14 Apr 2021 09:35:35 +0000 (09:35 +0000)] 
Merge branch '1100-inline-signing-include' into 'main'

Resolve "Test inline-signing with $INCLUDE"

Closes #1100

See merge request isc-projects/bind9!4825

5 years agoDocument relative path of $INCLUDE
Matthijs Mekking [Fri, 19 Mar 2021 14:39:20 +0000 (15:39 +0100)] 
Document relative path of $INCLUDE

Add to the ARM from where relative paths are searched.

5 years agoFix inline test with missing $INCLUDE
Matthijs Mekking [Fri, 19 Mar 2021 14:23:01 +0000 (15:23 +0100)] 
Fix inline test with missing $INCLUDE

The test case for a zone with a missing include file was wrong for two
reasons:
1. It was loading the wrong file (master5 instead of master6)
2. It did actually not set the $ret variable to 1 if the test failed
   (it should default to ret=1 and clear the variable if the
   appropriate log is found).

5 years agoAdd inline-signing with $INCLUDE test
Matthijs Mekking [Fri, 19 Mar 2021 14:21:17 +0000 (15:21 +0100)] 
Add inline-signing with $INCLUDE test

Add a test case for inline-signing for a zone with an $INCLUDE
statement. There is already a test for a missing include file, this
one adds a test for a zone with an include file that does exist.

Test if the record in the included file is loaded.

5 years agoMerge branch '2347-draft-vandijk-dnsop-nsec-ttl' into 'main'
Matthijs Mekking [Tue, 13 Apr 2021 12:14:53 +0000 (12:14 +0000)] 
Merge branch '2347-draft-vandijk-dnsop-nsec-ttl' into 'main'

Implement draft-vandijk-dnsop-nsec-ttl

Closes #2347

See merge request isc-projects/bind9!4506

5 years agoSmall refactor lib/dns/zone.c
Matthijs Mekking [Tue, 23 Mar 2021 08:57:43 +0000 (09:57 +0100)] 
Small refactor lib/dns/zone.c

Introduce some macros that can be reused in 'zone_load_soa_rr()' and
'zone_get_from_db()' to make those functions more readable.

5 years agoUse designated initializer in dns_zone_create
Matthijs Mekking [Tue, 23 Mar 2021 08:20:50 +0000 (09:20 +0100)] 
Use designated initializer in dns_zone_create

Shorten the code and make it less prone to initialisation errors
(it is still easy to forget adding an initializer, but it now defaults
to 0).

5 years agoAdd change entry and release note for [#2347]
Matthijs Mekking [Mon, 22 Mar 2021 14:53:47 +0000 (15:53 +0100)] 
Add change entry and release note for [#2347]

5 years agoImplement draft-vandijk-dnsop-nsec-ttl
Matthijs Mekking [Fri, 18 Dec 2020 13:19:36 +0000 (14:19 +0100)] 
Implement draft-vandijk-dnsop-nsec-ttl

The draft says that the NSEC(3) TTL must have the same TTL value
as the minimum of the SOA MINIMUM field and the SOA TTL. This was
always the intended behaviour.

Update the zone structure to also track the SOA TTL. Whenever we
use the MINIMUM value to determine the NSEC(3) TTL, use the minimum
of MINIMUM and SOA TTL instead.

There is no specific test for this, however two tests need adjusting
because otherwise they failed: They were testing for NSEC3 records
including the TTL. Update these checks to use 600 (the SOA TTL),
rather than 3600 (the SOA MINIMUM).

5 years agoMerge branch '2289-cache-dump-stale-ttl-weird-values' into 'main'
Matthijs Mekking [Tue, 13 Apr 2021 08:54:49 +0000 (08:54 +0000)] 
Merge branch '2289-cache-dump-stale-ttl-weird-values' into 'main'

Fix nonsensical stale TTL values in cache dump

Closes #2289

See merge request isc-projects/bind9!4799

5 years agoUse stale TTL as RRset TTL in dumpdb
Matthijs Mekking [Fri, 12 Mar 2021 15:27:45 +0000 (16:27 +0100)] 
Use stale TTL as RRset TTL in dumpdb

It is more intuitive to have the countdown 'max-stale-ttl' as the
RRset TTL, instead of 0 TTL. This information was already available
in a comment "; stale (will be retained for x more seconds", but
Support suggested to put it in the TTL field instead.

5 years agoCheck staleness in bind_rdataset
Matthijs Mekking [Fri, 12 Mar 2021 14:12:27 +0000 (15:12 +0100)] 
Check staleness in bind_rdataset

Before binding an RRset, check the time and see if this record is
stale (or perhaps even ancient). Marking a header stale or ancient
happens only when looking up an RRset in cache, but binding an RRset
can also happen on other occasions (for example when dumping the
database).

Check the time and compare it to the header. If according to the
time the entry is stale, but not ancient, set the STALE attribute.
If according to the time is ancient, set the ANCIENT attribute.

We could mark the header stale or ancient here, but that requires
locking, so that's why we only compare the current time against
the rdh_ttl.

Adjust the test to check the dump-db before querying for data. In the
dumped file the entry should be marked as stale, despite no cache
lookup happened since the initial query.

5 years agoFix nonsensical stale TTL values in cache dump
Matthijs Mekking [Wed, 10 Mar 2021 11:09:16 +0000 (12:09 +0100)] 
Fix nonsensical stale TTL values in cache dump

When introducing change 5149, "rndc dumpdb" started to print a line
above a stale RRset, indicating how long the data will be retained.

At that time, I thought it should also be possible to load
a cache from file. But if a TTL has a value of 0 (because it is stale),
stale entries wouldn't be loaded from file. So, I added the
'max-stale-ttl' to TTL values, and adjusted the $DATE accordingly.

Since we actually don't have a "load cache from file" feature, this
is premature and is causing confusion at operators. This commit
changes the 'max-stale-ttl' adjustments.

A check in the serve-stale system test is added for a non-stale
RRset (longttl.example) to make sure the TTL in cache is sensible.

Also, the comment above stale RRsets could have nonsensical
values. A possible reason why this may happen is when the RRset was
marked a stale but the 'max-stale-ttl' has passed (and is actually an
RRset awaiting cleanup). This would lead to the "will be retained"
value to be negative (but since it is stored in an uint32_t, you would
get a nonsensical value (e.g. 4294362497).

To mitigate against this, we now also check if the header is not
ancient. In addition we check if the stale_ttl would be negative, and
if so we set it to 0. Most likely this will not happen because the
header would already have been marked ancient, but there is a possible
race condition where the 'rdh_ttl + serve_stale_ttl' has passed,
but the header has not been checked for staleness.

5 years agoMerge branch '2622-command-line-option-l-not-shown-with-usage-message' into 'main'
Mark Andrews [Tue, 13 Apr 2021 01:33:28 +0000 (01:33 +0000)] 
Merge branch '2622-command-line-option-l-not-shown-with-usage-message' into 'main'

Resolve "Command-line option -L not shown with usage message"

Closes #2622

See merge request isc-projects/bind9!4881

5 years agoUpdate named's usage description
Mark Andrews [Mon, 12 Apr 2021 02:06:54 +0000 (12:06 +1000)] 
Update named's usage description

5 years agoMerge branch 'michal/add-placeholder-entries-to-CHANGES' into 'main'
Michał Kępień [Thu, 8 Apr 2021 11:10:54 +0000 (11:10 +0000)] 
Merge branch 'michal/add-placeholder-entries-to-CHANGES' into 'main'

Add placeholders for GL #2467, GL #2540, GL #2604

See merge request isc-projects/bind9!4878

5 years agoAdd placeholders for GL #2467, GL #2540, GL #2604
Michał Kępień [Thu, 8 Apr 2021 11:06:57 +0000 (13:06 +0200)] 
Add placeholders for GL #2467, GL #2540, GL #2604

5 years agoMerge branch '2578-rework-get_ports.sh-to-make-it-not-use-a-lock-file' into 'main'
Michał Kępień [Thu, 8 Apr 2021 09:37:51 +0000 (09:37 +0000)] 
Merge branch '2578-rework-get_ports.sh-to-make-it-not-use-a-lock-file' into 'main'

Rework get_ports.sh to make it not use a lock file

Closes #2578

See merge request isc-projects/bind9!4801

5 years agoUse the same port selection method on all systems
Michał Kępień [Thu, 8 Apr 2021 09:12:37 +0000 (11:12 +0200)] 
Use the same port selection method on all systems

When system tests are run on Windows, they are assigned port ranges that
are 100 ports wide and start from port number 5000.  This is a different
port assignment method than the one used on Unix systems.  Drop the "-p"
command line option from bin/tests/system/run.sh invocations used for
starting system tests on Windows to unify the port assignment method
used across all operating systems.

5 years agoRework get_ports.sh to make it not use a lock file
Michał Kępień [Thu, 8 Apr 2021 09:12:37 +0000 (11:12 +0200)] 
Rework get_ports.sh to make it not use a lock file

The get_ports.sh script is used for determining the range of ports a
given system test should use.  It first determines the start of the port
range to return (the base port); it can either be specified explicitly
by the caller or chosen randomly.  Subsequent ports are picked
sequentially, starting from the base port.  To ensure no single port is
used by multiple tests, a state file (get_ports.state) containing the
last assigned port is maintained by the script.  Concurrent access to
the state file is protected by a lock file (get_ports.lock); if one
instance of the script holds the lock file while another instance tries
to acquire it, the latter retries its attempt to acquire the lock file
after sleeping for 1 second; this retry process can be repeated up to 10
times before the script returns an error.

There are some problems with this approach:

  - the sleep period in case of failure to acquire the lock file is
    fixed, which leads to a "thundering herd" type of problem, where
    (depending on how processes are scheduled by the operating system)
    multiple system tests try to acquire the lock file at the same time
    and subsequently sleep for 1 second, only for the same situation to
    likely happen the next time around,

  - the lock file is being locked and then unlocked for every single
    port assignment made, not just once for the entire range of ports a
    system test should use; in other words, the lock file is currently
    locked and unlocked 13 times per system test; this increases the
    odds of the "thundering herd" problem described above preventing a
    system test from getting one or more ports assigned before the
    maximum retry count is reached (assuming multiple system tests are
    run in parallel); it also enables the range of ports used by a given
    system test to be non-sequential (which is a rather cosmetic issue,
    but one that can make log interpretation harder than necessary when
    test failures are diagnosed),

  - both issues described above cause unnecessary delays when multiple
    system tests are started in parallel (due to high lock file
    contention among the system tests being started),

  - maintaining a state file requires ensuring proper locking, which
    complicates the script's source code.

Rework the get_ports.sh script so that it assigns non-overlapping port
ranges to its callers without using a state file or a lock file:

  - add a new command line switch, "-t", which takes the name of the
    system test to assign ports for,

  - ensure every instance of get_ports.sh knows how many ports all
    system tests which form the test suite are going to need in total
    (based on the number of subdirectories found in bin/tests/system/),

  - in order to ensure all instances of get_ports.sh work on the same
    global port range (so that no port range collisions happen), a
    stable (throughout the expected run time of a single system test
    suite) base port selection method is used instead of the random one;
    specifically, the base port, unless specified explicitly using the
    "-p" command line switch, is derived from the number of hours which
    passed since the Unix Epoch time,

  - use the name of the system test to assign ports for (passed via the
    new "-t" command line switch) as a unique index into the global
    system test range, to ensure all system tests use disjoint port
    ranges.

5 years agoMerge branch 'mnowak/fix-missing-fromhex.pl-in-out-of-tree' into 'main'
Michal Nowak [Thu, 8 Apr 2021 09:07:07 +0000 (09:07 +0000)] 
Merge branch 'mnowak/fix-missing-fromhex.pl-in-out-of-tree' into 'main'

Move fromhex.pl script to bin/tests/system/

See merge request isc-projects/bind9!4875

5 years agoMove fromhex.pl script to bin/tests/system/
Michal Nowak [Thu, 8 Apr 2021 07:20:34 +0000 (09:20 +0200)] 
Move fromhex.pl script to bin/tests/system/

The fromhex.pl script needs to be copied from the source directory to
the build directory before any test is run, otherwise the out-of-tree
fails to find it. Given that the script is used only in system test,
move it to bin/tests/system/.

5 years agoMerge branch '2620-free-resources-when-gss_accept_sec_context-fails' into 'main'
Michał Kępień [Thu, 8 Apr 2021 08:40:27 +0000 (08:40 +0000)] 
Merge branch '2620-free-resources-when-gss_accept_sec_context-fails' into 'main'

Free resources when gss_accept_sec_context() fails

Closes #2620

See merge request isc-projects/bind9!4873

5 years agoAdd CHANGES entry
Michał Kępień [Thu, 8 Apr 2021 08:33:44 +0000 (10:33 +0200)] 
Add CHANGES entry

5 years agoFree resources when gss_accept_sec_context() fails
Michał Kępień [Thu, 8 Apr 2021 08:33:44 +0000 (10:33 +0200)] 
Free resources when gss_accept_sec_context() fails

Even if a call to gss_accept_sec_context() fails, it might still cause a
GSS-API response token to be allocated and left for the caller to
release.  Make sure the token is released before an early return from
dst_gssapi_acceptctx().

5 years agoMerge branch '2600-general-error-managed-keys-zone-dns_journal_compact-failed-no...
Ondřej Surý [Wed, 7 Apr 2021 19:28:39 +0000 (19:28 +0000)] 
Merge branch '2600-general-error-managed-keys-zone-dns_journal_compact-failed-no-more' into 'main'

Resolve "general: error: managed-keys-zone: dns_journal_compact failed: no more"

Closes #2600

See merge request isc-projects/bind9!4849

5 years agoAdd CHANGES and release note for [GL #2600]
Mark Andrews [Wed, 31 Mar 2021 04:15:19 +0000 (15:15 +1100)] 
Add CHANGES and release note for [GL #2600]

5 years agoCheck that upgrade of managed-keys.bind.jnl succeeded
Mark Andrews [Wed, 31 Mar 2021 15:43:37 +0000 (02:43 +1100)] 
Check that upgrade of managed-keys.bind.jnl succeeded

Update the system to include a recoverable managed.keys journal created
with <size,serial0,serial1,0> transactions and test that it has been
updated as part of the start up process.

5 years agoRewrite managed-key journal immediately
Mark Andrews [Thu, 1 Apr 2021 04:22:55 +0000 (15:22 +1100)] 
Rewrite managed-key journal immediately

Both managed keys and regular zone journals need to be updated
immediately when a recoverable error is discovered.

5 years agoUpdate dns_journal_compact() to handle bad transaction headers
Mark Andrews [Wed, 31 Mar 2021 04:03:33 +0000 (15:03 +1100)] 
Update dns_journal_compact() to handle bad transaction headers

Previously, dns_journal_begin_transaction() could reserve the wrong
amount of space.  We now check that the transaction is internally
consistent when upgrading / downgrading a journal and we also handle the
bad transaction headers.

5 years agoCompute transaction size based on journal/transaction type
Mark Andrews [Thu, 1 Apr 2021 04:30:42 +0000 (15:30 +1100)] 
Compute transaction size based on journal/transaction type

previously the code assumed that it was a new transaction.

5 years agoUse journal_write_xhdr() to write the dummy transaction header
Mark Andrews [Wed, 31 Mar 2021 02:29:13 +0000 (13:29 +1100)] 
Use journal_write_xhdr() to write the dummy transaction header

Instead of journal_write(), use correct format call journal_write_xhdr()
to write the dummy transaction header which looks at j->header_ver1 to
determine which transaction header to write instead of always writing a
zero filled journal_rawxhdr_t header.

5 years agoMerge branch '2401-ISC_R_TIMEDOUT-is-recoverable' into 'main'
Ondřej Surý [Wed, 7 Apr 2021 14:34:46 +0000 (14:34 +0000)] 
Merge branch '2401-ISC_R_TIMEDOUT-is-recoverable' into 'main'

netmgr: Make it possible to recover from ISC_R_TIMEDOUT

Closes #2401

See merge request isc-projects/bind9!4845

5 years agoAdd CHANGES note for GL #2401
Evan Hunt [Wed, 7 Apr 2021 00:50:45 +0000 (17:50 -0700)] 
Add CHANGES note for GL #2401

5 years agoUse T_CONNECT timeout constant for TCP tests (instead of 1 ms)
Artem Boldariev [Wed, 7 Apr 2021 13:11:40 +0000 (16:11 +0300)] 
Use T_CONNECT timeout constant for TCP tests (instead of 1 ms)

The netmgr_test would be failing on heavily loaded systems because the
connection timeout was set to 1 ms.  Use the global constant instead.

5 years agoEnsure dig lookup is detached on UDP connect failure
Evan Hunt [Tue, 6 Apr 2021 23:49:14 +0000 (16:49 -0700)] 
Ensure dig lookup is detached on UDP connect failure

dig could hang when UDP connect failed due to a dangling lookup object.

5 years agoRefactor async callbacks and fix the double tlsdnsconnect callback
Ondřej Surý [Tue, 6 Apr 2021 16:27:38 +0000 (18:27 +0200)] 
Refactor async callbacks and fix the double tlsdnsconnect callback

The isc_nm_tlsdnsconnect() call could end up with two connect callbacks
called when the timeout fired and the TCP connection was aborted,
but the TLS handshake was not complete yet.  isc__nm_connecttimeout_cb()
forgot to clean up sock->tls.pending_req when the connect callback was
called with ISC_R_TIMEDOUT, leading to a second callback running later.

A new argument has been added to the isc__nm_*_failed_connect_cb and
isc__nm_*_failed_read_cb functions, to indicate whether the callback
needs to run asynchronously or not.

5 years agoSkip long tls_tests in the CI
Ondřej Surý [Tue, 6 Apr 2021 18:49:52 +0000 (20:49 +0200)] 
Skip long tls_tests in the CI

We already skip most of the recv_send tests in CI because they are
too timing-related to be run in overloaded environment.  This commit
adds a similar change to tls_test before we merge tls_test into
netmgr_test.

5 years agoPrevent short TLS tests from hanging in case of errors
Artem Boldariev [Tue, 6 Apr 2021 12:18:44 +0000 (15:18 +0300)] 
Prevent short TLS tests from hanging in case of errors

The tests in tls_test.c could hang in the event of a connect
error.  This commit allows the tests to bail out when such an
error occurs.

5 years agorearrange nm_teardown() to check correctness after shutting down
Evan Hunt [Sat, 3 Apr 2021 05:34:18 +0000 (22:34 -0700)] 
rearrange nm_teardown() to check correctness after shutting down

if a test failed at the beginning of nm_teardown(), the function
would abort before isc_nm_destroy() or isc_tlsctx_free() were reached;
we would then abort when nm_setup() was run for the next test case.
rearranging the teardown function prevents this problem.

5 years agoisc_nm_*connect() always return via callback
Ondřej Surý [Wed, 31 Mar 2021 16:32:32 +0000 (18:32 +0200)] 
isc_nm_*connect() always return via callback

The isc_nm_*connect() functions were refactored to always return the
connection status via the connect callback instead of sometimes returning
the hard failure directly (for example, when the socket could not be
created, or when the network manager was shutting down).

This commit changes the connect functions in all the network manager
modules, and also makes the necessary refactoring changes in places
where the connect functions are called.

5 years agomove UDP connect retries from dig into isc_nm_udpconnect()
Evan Hunt [Thu, 1 Apr 2021 21:02:03 +0000 (14:02 -0700)] 
move UDP connect retries from dig into isc_nm_udpconnect()

dig previously ran isc_nm_udpconnect() three times before giving
up, to work around a freebsd bug that caused connect() to return
a spurious transient EADDRINUSE. this commit moves the retry code
into the network manager itself, so that isc_nm_udpconnect() no
longer needs to return a result code.

5 years agoUse generic functions for reading and timers in TCP
Ondřej Surý [Wed, 31 Mar 2021 10:14:54 +0000 (12:14 +0200)] 
Use generic functions for reading and timers in TCP

The TCP module has been updated to use the generic functions from
netmgr.c instead of its own local copies.  This brings the module
mostly up to par with the TCPDNS and TLSDNS modules.