2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-05 17:15:31 +00:00
Commit Graph

3624 Commits

Author SHA1 Message Date
Evan Hunt
bd9f5c3c19 fix netmgr setup/teardown issues; setup and teardown only once in timer_test
- the netmgr was not correctly being specified when creating the task
  manager, and was cleaned up in the wrong order when shutting down.
- on freebsd, timer_test appears to be prone to failure if the
  netmgr is set up and torn down before and after ever test case, but
  less so if it's only set up once at the beginning and once at the
  end.
2019-11-13 14:47:47 +01:00
Ondřej Surý
aca0f88750 Remove the assertions from subthreads and use global errcnt to record errors 2019-11-13 14:47:47 +01:00
Ondřej Surý
2c3589e22a Lock the lasttime variable that's concurrently accessed between threads 2019-11-13 14:47:47 +01:00
Ondřej Surý
b9cb4c94fa Directly embed ../timer.c in timer_test.c for better assertion testing 2019-11-13 14:47:47 +01:00
Ondřej Surý
8de64964a3 Refactor the way we use memory context from isctest.c
This commit renames isctest {mctx,lctx} to test_{mctx,lctx} and cleans
up their usage in the individual unit tests.  This allows embedding
library .c files directly into the unit tests.
2019-11-13 14:47:47 +01:00
Witold Kręcicki
5ce4b04b50 If a task is running and we call isc_task_pause it can
be implicitly unpaused when we switch from 'running' to
'idle' state. Fix it by not switching to 'idle' when paused.
2019-11-13 12:32:17 +00:00
Michał Kępień
d8768bd143 Fix libuv.dll handling
Make sure libuv.dll gets copied to the proper directory in the Release
build configuration and that the BIND installer on Windows installs
libuv.dll.
2019-11-12 09:14:59 +00:00
Ondřej Surý
bd80969b11 Cleanup the {PATH,NAME}_MAX stray #ifdefs 2019-11-12 09:36:08 +01:00
Samuel Thibault
d10fbdec84 hurd: Fix build
Move PATH_MAX, NAME_MAX, IOV_MAX default definitions to the common
<isc/platform.h>.
2019-11-10 20:14:17 +00:00
Evan Hunt
b9a5508e52 remove ISC_QUEUE as it is no longer used 2019-11-07 11:55:37 -08:00
Witold Kręcicki
33bf90331b use clock_gettime() instead of gettimeofday() for isc_itme functions 2019-11-07 11:55:37 -08:00
Witold Kręcicki
a85a65f96e add atomic_exchange operations to mutexatomic.h and win32 stdatomic.h 2019-11-07 11:55:37 -08:00
Evan Hunt
59c64fa4bd add isc_task_pause() and isc_task_unpause() functions
This allows a task to be temporary disabled so that objects won't be
processed simultaneously by libuv events and isc_task events. When a
task is paused, currently running events may complete, but no further
event will added to the run queue will be executed until the task is
unpaused.
2019-11-07 11:55:37 -08:00
Evan Hunt
36ee430327 optionally associate a netmgr with a task manager when creating
When a task manager is created, we can now specify an `isc_nm`
object to associate with it; thereafter when the task manager is
placed into exclusive mode, the network manager will be paused.
2019-11-07 11:55:37 -08:00
Evan Hunt
48d003edf7 use netmgr in libisc unit tests 2019-11-07 11:55:37 -08:00
Witold Kręcicki
70397f9d92 netmgr: libuv-based network manager
This is a replacement for the existing isc_socket and isc_socketmgr
implementation. It uses libuv for asynchronous network communication;
"networker" objects will be distributed across worker threads reading
incoming packets and sending them for processing.

UDP listener sockets automatically create an array of "child" sockets
so each worker can listen separately.

TCP sockets are shared amongst worker threads.

A TCPDNS socket is a wrapper around a TCP socket, which handles the
the two-byte length field at the beginning of DNS messages over TCP.

(Other wrapper socket types can be implemented in the future to handle
DNS over TLS, DNS over HTTPS, etc.)
2019-11-07 11:55:37 -08:00
Evan Hunt
a8c814cb2f implement fixed-size array stack data structure 2019-11-07 11:55:37 -08:00
Witold Kręcicki
402969bf95 implement fetch-and-add array queue data structure
this is a lockless queue based on hazard pointers.
2019-11-07 11:55:37 -08:00
Evan Hunt
64e1a4a398 temporarily move ISC_QUEUE to list.h
The double-locked queue implementation is still currently in use
in ns_client, but will be replaced by a fetch-and-add array queue.
This commit moves it from queue.h to list.h so that queue.h can be
used for the new data structure, and clean up dependencies between
list.h and types.h. Later, when the ISC_QUEUE is no longer is use,
it will be removed completely.
2019-11-07 11:55:37 -08:00
Witold Kręcicki
aa57fa7090 implement hazard pointer data structure
this is a mechanism to allow safe lock-free data structures.
2019-11-07 11:55:37 -08:00
Witold Kręcicki
a5f8374400 add isc_sockaddr_fromsockaddr function
This converts from struct sockaddr to isc_sockaddr_t
2019-11-07 11:55:37 -08:00
Michał Kępień
65a8b53bd0 Do not use <sys/sysctl.h> on Linux
glibc 2.30 deprecated the <sys/sysctl.h> header [1].  However, that
header is still used on other Unix-like systems, so only prevent it from
being used on Linux, in order to prevent compiler warnings from being
triggered.

[1] https://sourceware.org/ml/libc-alpha/2019-08/msg00029.html
2019-11-06 15:32:04 +01:00
Ondřej Surý
b4df5a6ecb Avoid an extra atomic_load() call 2019-11-06 11:30:36 +01:00
Diego Fronza
66fe8627de Added TCP high-water statistics variable
This variable will report the maximum number of simultaneous tcp clients
that BIND has served while running.

It can be verified by running rndc status, then inspect "tcp high-water:
count", or by generating statistics file, rndc stats, then inspect the
line with "TCP connection high-water" text.

The tcp-highwater variable is atomically updated based on an existing
tcp-quota system handled in ns/client.c.
2019-11-06 09:18:27 +01:00
Diego Fronza
a544e2e300 Add functions for collecting high-water counters
Add {isc,ns}_stats_{update_if_greater,get_counter}() functions that
are used to set and collect high-water type of statistics.
2019-11-06 09:11:20 +01:00
Diego Fronza
eb5611a770 Change the isc_stat_t type to isc__atomic_statcounter_t
The isc_stat_t type was too similar to isc_stats_t type, so the name was
changed to something more distinguishable.
2019-11-06 09:09:45 +01:00
Diego Fronza
0fc98ef2d5 Change the isc_statscounter_t type from int to C99 int_fast64_t type
For TCP high-water work, we need to keep the used integer types widths
in sync.

Note: int_fast32_t is used on WIN32 platform
2019-11-06 08:43:46 +01:00
Tinderbox User
8c573fc3fd Merge branch 'security-master' 2019-10-19 23:30:23 +00:00
Michał Kępień
abfde3d543 Fix cppcheck 1.89 warnings
cppcheck 1.89 enabled certain value flow analysis mechanisms [1] which
trigger null pointer dereference false positives in lib/dns/rpz.c:

    lib/dns/rpz.c:582:7: warning: Possible null pointer dereference: tgt_ip [nullPointer]
      if (KEY_IS_IPV4(tgt_prefix, tgt_ip)) {
          ^
    lib/dns/rpz.c:1419:44: note: Calling function 'adj_trigger_cnt', 4th argument 'NULL' value is 0
      adj_trigger_cnt(rpzs, rpz_num, rpz_type, NULL, 0, true);
                                               ^
    lib/dns/rpz.c:582:7: note: Null pointer dereference
      if (KEY_IS_IPV4(tgt_prefix, tgt_ip)) {
          ^
    lib/dns/rpz.c:596:7: warning: Possible null pointer dereference: tgt_ip [nullPointer]
      if (KEY_IS_IPV4(tgt_prefix, tgt_ip)) {
          ^
    lib/dns/rpz.c:1419:44: note: Calling function 'adj_trigger_cnt', 4th argument 'NULL' value is 0
      adj_trigger_cnt(rpzs, rpz_num, rpz_type, NULL, 0, true);
                                               ^
    lib/dns/rpz.c:596:7: note: Null pointer dereference
      if (KEY_IS_IPV4(tgt_prefix, tgt_ip)) {
          ^
    lib/dns/rpz.c:610:7: warning: Possible null pointer dereference: tgt_ip [nullPointer]
      if (KEY_IS_IPV4(tgt_prefix, tgt_ip)) {
          ^
    lib/dns/rpz.c:1419:44: note: Calling function 'adj_trigger_cnt', 4th argument 'NULL' value is 0
      adj_trigger_cnt(rpzs, rpz_num, rpz_type, NULL, 0, true);
                                               ^
    lib/dns/rpz.c:610:7: note: Null pointer dereference
      if (KEY_IS_IPV4(tgt_prefix, tgt_ip)) {
          ^

It seems that cppcheck no longer treats at least some REQUIRE()
assertion failures as fatal, so add extra assertion macro definitions to
lib/isc/include/isc/util.h that are only used when the CPPCHECK
preprocessor macro is defined; these definitions make cppcheck 1.89
behave as expected.

There is an important requirement for these custom definitions to work:
cppcheck must properly treat abort() as a function which does not
return.  In order for that to happen, the __GNUC__ macro must be set to
a high enough number (because system include directories are used and
system headers compile attributes away if __GNUC__ is not high enough).
__GNUC__ is thus set to the major version number of the GCC compiler
used, which is what that latter does itself during compilation.

[1] aaeec462e6
2019-10-16 22:23:36 +02:00
Mark Andrews
fb87e669fb Detect partial prefixes / incomplete IPv4 address in acls. 2019-10-14 00:28:07 +11:00
Ondřej Surý
635e5293b2 Remove unused RSA Security copyrighted cryptoki.h header 2019-10-04 08:35:45 +02:00
Ondřej Surý
a0d3614a60 Remove randomly scattered additional style check suppressions that caused unmatchedSuppression 2019-10-03 09:04:27 +02:00
Ondřej Surý
026cf2ff4f lib/isc/unix/socket.c: Suppress preprocessorErrorDirective error from Cppcheck 2019-10-03 09:04:27 +02:00
Ondřej Surý
c662969da1 lib/isc/task.c: Fix invalid order of DbC checks that could cause dereference before NULL check 2019-10-03 09:04:27 +02:00
Ondřej Surý
e8948fd9b4 lib/isc/pkc11.c: Fix possible NULL pointer dereference in push_attribute() 2019-10-03 09:04:27 +02:00
Ondřej Surý
e9f30fc211 lib/isc/buffer.c: Fix invalid order of DbC checks that could cause dereference before NULL check 2019-10-03 09:04:27 +02:00
Ondřej Surý
2230b9d55d Disable benchmark tests when Thread Sanitizer is enabled 2019-10-02 14:09:33 +02:00
Ondřej Surý
8828a41077 Declare __SANITIZE_THREAD__ in isc/util.h when clang ThreadSanitizer is used 2019-10-02 14:09:33 +02:00
Ondřej Surý
e06a34674a Convert all variables accessed between multiple threads to atomic 2019-10-02 13:41:45 +02:00
Ondřej Surý
07879f354c Properly initialize atomic variables 2019-10-02 13:09:33 +02:00
Ondřej Surý
76e954124a lib/isc/tests/task_test.c: Convert all variables accessed between multiple threads to atomic 2019-10-02 13:09:28 +02:00
Tinderbox User
0729d194c9 prep 9.15.5 2019-10-02 06:08:59 +00:00
Ondřej Surý
288f5a4b52 Various little fixes found by coccinelle
The coccinellery repository provides many little semantic patches to fix common
problems in the code.  The number of semantic patches in the coccinellery
repository is high and most of the semantic patches apply only for Linux, so it
doesn't make sense to run them on regular basis as the processing takes a lot of
time.

The list of issue found in BIND 9, by no means complete, includes:

- double assignment to a variable
- `continue` at the end of the loop
- double checks for `NULL`
- useless checks for `NULL` (cannot be `NULL`, because of earlier return)
- using `0` instead of `NULL`
- useless extra condition (`if (foo) return; if (!foo) { ...; }`)
- removing & in front of static functions passed as arguments
2019-10-01 16:48:55 +02:00
Michał Kępień
0476e8f1ac Make VS solution upgrading unnecessary
Until now, the build process for BIND on Windows involved upgrading the
solution file to the version of Visual Studio used on the build host.
Unfortunately, the executable used for that (devenv.exe) is not part of
Visual Studio Build Tools and thus there is no clean way to make that
executable part of a Windows Server container.

Luckily, the solution upgrade process boils down to just adding XML tags
to Visual Studio project files and modifying certain XML attributes - in
files which we pregenerate anyway using win32utils/Configure.  Thus,
extend win32utils/Configure with three new command line parameters that
enable it to mimic what "devenv.exe bind9.sln /upgrade" does.  This
makes the devenv.exe build step redundant and thus facilitates building
BIND in Windows Server containers.
2019-09-26 15:11:15 +02:00
Ondřej Surý
9ff02c8170 Silence false positive warning from Clang 10 in random_test.c 2019-09-26 14:58:18 +02:00
Ondřej Surý
5a788adb1c Add ATOMIC_VAR_INIT initializer to mutexatomics.h 2019-09-26 11:37:35 +02:00
Ondřej Surý
728fc0ca25 Add atomic_fetch_add and atomic_fetch_or convenience macros and unix and win32 shims 2019-09-26 11:37:35 +02:00
Ondřej Surý
52064809b4 Fix the wrong function for the atomic_fetch_add_explicit64 shim on non-WIN64 build 2019-09-26 11:36:48 +02:00
Ondřej Surý
718a317dc7 Fix unprotected access to thread->epoll_events[fd] in unwatch_fd() 2019-09-24 08:11:50 -04:00
Ondřej Surý
9808d7360e Move the lock from internal_{accept,connect,recv,send} to global level to protect more socket variables 2019-09-24 08:11:50 -04:00