Commit graph

9413 commits

Author SHA1 Message Date
Ondřej Surý
4a3d589403 Refactor the dns_dt API to use ISC_THREAD_LOCAL
Previously, the dns_dt API used isc_thread_key API for TLS, which is
fairly complicated and requires initialization of memory contexts, etc.
This part of code was refactored to use a ISC_THREAD_LOCAL pointer which
greatly simplifies the whole code related to storing TLS variables.
2019-12-03 16:27:30 +01:00
Ondřej Surý
1a66aabd22 Refactor the dns_name API to use ISC_THREAD_LOCAL
Previously, the dns_name API used isc_thread_key API for TLS, which is
fairly complicated and requires initialization of memory contexts, etc.
This part of code was refactored to use a ISC_THREAD_LOCAL pointer which
greatly simplifies the whole code related to storing TLS variables.
2019-12-03 16:27:24 +01:00
Michał Kępień
b425b5d56e Move xmlInitThreads()/xmlCleanupThreads() calls
xmlInitThreads() and xmlCleanupThreads() are called from within
named_statschannels_configure() and named_statschannels_shutdown(),
respectively.  Both of these functions are executed by worker threads,
not the main named thread.  This causes ASAN to report memory leaks like
the following one upon shutdown (as long as named is asked to produce
any XML output over its configured statistics channels during its
lifetime):

    Direct leak of 968 byte(s) in 1 object(s) allocated from:
        #0 0x7f677c249cd8 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:153
        #1 0x7f677bc1838f in xmlGetGlobalState (/usr/lib/libxml2.so.2+0xa838f)

The data mentioned in the above report is a libxml2 state structure
stored as thread-specific data.  Such chunks of memory are automatically
released (by a destructor passed to pthread_key_create() by libxml2)
whenever a thread that allocated a given chunk exits.  However, if
xmlCleanupThreads() is called by a given thread before it exits, the
destructor will not be invoked (due to xmlCleanupThreads() calling
pthread_key_delete()) and ASAN will report a memory leak.  Thus,
xmlInitThreads() and xmlCleanupThreads() must not be called from worker
threads.  Since xmlInitThreads() must be called on Windows in order for
libxml2 to work at all, move xmlInitThreads() and xmlCleanupThreads()
calls to the main named thread (which does not produce any XML output
itself) in order to prevent the memory leak from being reported by ASAN.
2019-12-02 16:03:23 +01:00
Michał Kępień
670afbe84a Fix GeoIP2 memory leak upon reconfiguration
Loaded GeoIP2 databases are only released when named is shut down, but
not during server reconfiguration.  This causes memory to be leaked
every time "rndc reconfig" or "rndc reload" is used, as long as any
GeoIP2 database is in use.  Fix by releasing any loaded GeoIP2 databases
before reloading them.  Do not call dns_geoip_shutdown() until server
shutdown as that function releases the memory context used for caching
GeoIP2 lookup results.
2019-12-02 15:15:06 +01:00
Ondřej Surý
edd97cddc1 Refactor dns_name_dup() usage using the semantic patch 2019-11-29 14:00:37 +01:00
Michał Kępień
009df30f3a Fix logging long named command lines
The saved_command_line buffer in bin/named/main.c is 8192 bytes long.
The size of libisc's internal logging buffer (defined by the value of
the LOG_BUFFER_SIZE constant in lib/isc/log.c) is also 8192 bytes.
Since the buffer containing the ellipsis is passed as the last argument
to isc_log_write() and the buffer containing the potentially trimmed
named command line (saved_command_line) is passed as the second argument
in the same isc_log_write() call, it may happen that saved_command_line
will exhaust all available space in libisc's internal logging buffer, in
which case the ellipsis will be elided from the output.

Make saved_command_line 4096 bytes long as that value is arguably also
large enough for any reasonable use case and at the same time it ensures
ellipsis will always be printed for excessively long named command
lines.
2019-11-29 09:06:41 +01:00
Michał Kępień
58121f5f6d Improve portability of the "runtime" system test
The "runtime" system test currently fails on Windows because it waits
for named to log a message indicating successful startup ("running"),
but that never happens since named on Windows fails to open the
configuration file as its path includes control characters.

Instead of putting control characters in directory names, put them in
the value of the -D command line switch passed to named, which is used
for identifying an instance of named in a process listing and whose
value is completely ignored by named, but still logged.

While a similar check using special characters appears to be working
fine on Windows for the time being, modify it in the same way to avoid
potential future problems on other platforms and make the test cleaner.
2019-11-29 08:47:33 +01:00
Mark Andrews
36ce99d8a4 replace grep -r with 'find -type f | xargs' 2019-11-29 10:58:28 +11:00
Ondřej Surý
7489e6e6f9 Don't clean the system test temporary files if sanitizer reports were found inside 2019-11-28 21:39:20 +00:00
Ondřej Surý
51b05189f7 Use retry() and nextpart*() to simplify catz test 2019-11-28 08:02:33 +00:00
Witold Kręcicki
9b43e65c01 Fix timing issues in catz test
Make the log checks more precise and use the retry() function for
repeating the checks.
2019-11-28 08:02:33 +00:00
Michal Nowak
e00d650328 Fix the UID switch test to work with PKCS#11 build
Forward port of 32fe9a0051fc76be4657fc2742e71d2be6193011 by Ondřej Surý.
2019-11-27 17:19:10 +00:00
Ondřej Surý
cd804158b4 Fix multiple issues in named setuid check 2019-11-27 11:50:29 +01:00
Evan Hunt
7a8269207d fixed a test failure, some other shell cleanup 2019-11-27 11:50:29 +01:00
Ondřej Surý
f020199925 Instead of sleeping for a fixed time, wait for named to log specific message in a loop 2019-11-27 11:50:29 +01:00
Ondřej Surý
d9b3909a21 Use pre-prepared long command line for better portability 2019-11-27 11:50:29 +01:00
Ondřej Surý
340b1d2b6b Make runtime/tests.sh shellcheck and set -e clean
This mostly comprises of:

* using $(...) instead of `...`
* changing the directories in subshell and not ignoring `cd` return code
* handling every error gracefully instead of ignoring the return code
2019-11-27 11:50:29 +01:00
Ondřej Surý
8f539a8886 Further improve the runtime tests to look for a specific instead of generic error 2019-11-27 11:50:29 +01:00
Ondřej Surý
c48d8e0d42 The PATH_MAX on macOS is 1024, we can't override conffile path to test for ellipsis 2019-11-27 11:50:29 +01:00
Ondřej Surý
b5a18ac439 Fix couple of no-op tests to actually test something (configuration files were missing) 2019-11-27 11:50:29 +01:00
Ondřej Surý
00114e07ef Skip the runtime ellipsis test 2019-11-27 11:50:29 +01:00
Ondřej Surý
ce86721bc3 runtime test: make the pidfiles match the names of configuration files 2019-11-27 11:50:29 +01:00
Ondřej Surý
e9fa7b831b runtime test: use helper function that kills named and waits for the finish 2019-11-27 11:50:29 +01:00
Evan Hunt
715afa9c57 add a stats counter for clients dropped due to recursive-clients limit 2019-11-26 17:55:06 +00:00
Mark Andrews
9936462f31 dns_master_indent and dns_master_indentstr must not be global
The indentation for dumping the master zone was driven by two
global variables dns_master_indent and dns_master_indentstr.  In
threaded mode, this becomes prone to data access races, so this commit
converts the global variables into a local per-context tuple that
consist of count and string.
2019-11-26 13:52:18 +01:00
Ondřej Surý
d4163e2e97 kasp: Employ awk to make CDS checks stricter 2019-11-26 12:54:27 +01:00
Ondřej Surý
952d7fde63 Request exclusive access when crashing via fatal()
When loading the configuration fails, there might be already other tasks
running and calling OpenSSL library functions.  The OpenSSL on_exit
handler is called when exiting the main process and there's a timing
race between the on_exit function that destroys OpenSSL allocated
resources (threads, locks, ...) and other tasks accessing the very same
resources leading to a crash in the system threading library. Therefore,
the fatal() function needs to request exlusive access to the task
manager to finish the already running tasks and exit only when no other
tasks are running.
2019-11-26 12:47:01 +01:00
Ondřej Surý
38277ddb0b Detect cores on FreeBSD 2019-11-26 12:42:16 +01:00
Ondřej Surý
4b2911a45a Reduce the minimal numbers of days in jitter test to 5 2019-11-26 12:07:01 +01:00
Ondřej Surý
76eac9a691 Tune the performance of CDS/CDNSKEY deletion test 2019-11-26 12:07:01 +01:00
Ondřej Surý
519b047362 Tune the performance of oldsigs test
The oldsigs test was checking only for the validity of the A
a.oldsigs.example. resource record and associated DNSSEC signature while
the zone might not have been fully signed yet leading to validation
failures because of bogus signatures on the validation path.

This commit changes the test to test that all old signatures in the
oldsigs.example. zone were replaced and the zone is fully resigned
before running the main check.
2019-11-26 12:07:01 +01:00
Ondřej Surý
ffb7ae8beb Tune the performance of the jitter test 2019-11-26 12:07:01 +01:00
Ondřej Surý
31264a7e00 Add retry_quiet() function to retry quietly for an event to occur 2019-11-26 09:17:32 +01:00
Evan Hunt
d484b66ae1 improve system tests
- increase prefetch test timing tolerance.
- remove five-second pause and explicit connection closing in tcp test
  as they are no longer necessary.
2019-11-22 16:46:32 -08:00
Evan Hunt
00333a5c97 netmgr: add shutdown function
- new function isc_nm_shutdown() shuts down all active TCP connections,
  but does not destroy the netmgr.
2019-11-22 16:46:32 -08:00
Witold Kręcicki
37354ee225 netmgr: fix TCP backlog and client quota count
- add support for TCP backlog, using the value provided by config.
 - don't attach to TCP client quota for listening sockets, only
   connected sockets.
2019-11-22 16:46:32 -08:00
Evan Hunt
199bd6b623 netmgr: make TCP timeouts configurable
- restore support for tcp-initial-timeout, tcp-idle-timeout,
  tcp-keepalive-timeout and tcp-advertised-timeout configuration
  options, which were ineffective previously.
2019-11-22 16:46:31 -08:00
Mark Andrews
e98157b7fe add +[no]yaml to usage() 2019-11-23 00:02:52 +11:00
Mark Andrews
78685ed173 alphabetise delv's usage. 2019-11-22 12:38:20 +00:00
Evan Hunt
7bd3205c61 BIND 9.15.6
-----BEGIN PGP SIGNATURE-----
 
 iEYEABECAAYFAl3SCY8ACgkQw1ppSAjxOtJBiwCgpRCA6Q0+8YXb0ycV2G2hJO6V
 AyUAn2acZBqCFJqOZgCdtyh2banWMbmT
 =43ra
 -----END PGP SIGNATURE-----

Merge tag 'v9_15_6' into merge-v9_15_6
2019-11-20 13:34:25 -08:00
Ondřej Surý
512dadc8d1 Dump the backtrace to stdout when core is found in systest directory 2019-11-21 02:05:47 +08:00
Michal Nowak
b00360537e
Verifying that named switches UID
This test runs only under root, which is required for the user-switch
`-u` option to work.

Closes #537.
2019-11-20 10:56:21 +01:00
Michał Kępień
b50ced528d Fail the "tcp" system test when ans6 fails
Make the "tcp" system test fail if the Python tool used for establishing
TCP connections (ans6) logs a result different than "OK" after
processing a command sent to it (as that means the tool was unable to
successfully perform the requested action), with the exception of
cleanup errors at the end of the test which can be safely ignored.  Note
that the tool not returning any result at all in 10 seconds is still a
fatal error in all cases.
2019-11-19 15:26:56 +01:00
Mark Andrews
ca83a66618 alphabetize command line switch 2019-11-19 08:21:26 +00:00
Tinderbox User
767a2aef43 prep 9.15.6 2019-11-17 18:59:41 -08:00
Evan Hunt
0f9d8eb7b5 add support for DS trust anchors in mirror zone verification 2019-11-17 17:44:17 -08:00
Ondřej Surý
e95af30b23 Make lib/ns Thread Sanitizer clean 2019-11-17 17:42:41 -08:00
Evan Hunt
c29ccae2a6 Document initial-ds and static-ds keywords 2019-11-15 15:47:57 -08:00
Evan Hunt
54a682ea50 use DS style trust anchors in all system tests
this adds functions in conf.sh.common to create DS-style trust anchor
files. those functions are then used to create nearly all of the trust
anchors in the system tests.

there are a few exceptions:
 - some tests in dnssec and mkeys rely on detection of unsupported
   algorithms, which only works with key-style trust anchors, so those
   are used for those tests in particular.
 - the mirror test had a problem with the use of a CSK without a
   SEP bit, which still needs addressing

in the future, some of these tests should be changed back to using
traditional trust anchors, so that both types will be exercised going
forward.
2019-11-15 15:47:57 -08:00
Evan Hunt
342cc9b168 add support for DS trust anchors in delv 2019-11-15 15:47:57 -08:00