Commit Graph
3531 Commits
Author SHA1 Message Date
Ondřej SurýandWitold Kręcicki 244ac0601f lib/isc/counter.c: use isc_refcount_t 2019-07-09 16:11:14 +02:00
Witold Kręcicki 92424e23fa Special, for-tests-only, mode with atomics emulated by a mutex-locked variable - useful for finding atomics congestions 2019-07-09 16:09:36 +02:00
Witold Kręcicki 5aeb99786e Properly initialize all atomic variables 2019-07-09 16:09:36 +02:00
Witold Kręcicki 420f84f3f5 isc/timer: use isc_refcount_t 2019-07-09 16:09:36 +02:00
Witold Kręcicki b56948743a lib/isc/task: use isc_refcount_t 2019-07-09 16:09:36 +02:00
Thomas JachandEvan Hunt 9ba3e3f1b5 convert geoip to geoip2 in win32utils/Configure 2019-07-04 08:58:26 -07:00
Michał Kępień df42771a54 Define ATOMIC_VAR_INIT() on Windows
Commit b104a9bc50 introduced unconditional
use of the ATOMIC_VAR_INIT() macro in bin/dnssec/dnssec-signzone.c even
though that macro is only defined on Unix platforms.  Define it on
Windows systems as well in order to prevent build failures.
2019-07-03 14:27:53 +02:00
Ondřej SurýandOndřej Surý 49462cf974 Make isc_rwlock.c thread-safe
The ThreadSanitizer found several possible data races in our rwlock
implementation.  This commit changes all the unprotected variables to atomic and
also changes the explicit memory ordering (atomic_<foo>_explicit(..., <order>)
functions to use our convenience macros (atomic_<foo>_<order>).
2019-07-03 00:05:34 -04:00
Mark AndrewsandOndřej Surý 7c95192691 Define ATOMIC_VAR_INIT in isc/stdatomic.h shim 2019-07-03 00:05:34 -04:00
Ondřej SurýandOndřej Surý 570f358252 Add atomic_compare_exchange_strong_relaxed convenience macro 2019-07-03 00:05:34 -04:00
Ondřej Surý 209b2e53d1 Remove SO_BSDCOMPAT usage, it's ignore since Linux 2.4
The SO_BSDCOMPAT socket option is no-op since Linux 2.4, see the manpage:

SO_BSDCOMPAT
	Enable BSD bug-to-bug compatibility.  This is used by the UDP protocol
	module in Linux 2.0 and 2.2.  If enabled, ICMP errors received for a UDP
	socket will not be passed to the user program.  In later kernel
	versions, support for this option has been phased out: Linux 2.4
	silently ignores it, and Linux 2.6 generates a kernel warning (printk())
	if a program uses this option.  Linux 2.0 also enabled BSD bug-to-bug
	compatibility options (random header changing, skipping of the broadcast
	flag) for raw sockets with this option, but that was removed in Linux
	2.2.
2019-07-01 16:16:40 +02:00
Ondřej Surý 5d1e7be582 Rename OPENSSL_INCLUDES to OPENSSL_CFLAGS in AX_CHECK_OPENSSL() macro
The ax_check_openssl m4 macro used OPENSSL_INCLUDES.  Rename the
subst variable to OPENSSL_CFLAGS and wrap AX_CHECK_OPENSSL() in
action-if-not-found part of PKG_CHECK_MODULE check for libcrypto.
2019-06-25 12:36:01 +02:00
Ondřej Surý e3e6888946 Make the usage of json-c objects opaque to the caller
The json-c have previously leaked into the global namespace leading
to forced -I<include_path> for every compilation unit using isc/xml.h
header.  This MR fixes the usage making the caller object opaque.
2019-06-25 12:04:20 +02:00
Ondřej Surý 0771dd3be8 Make the usage of libxml2 opaque to the caller
The libxml2 have previously leaked into the global namespace leading
to forced -I<include_path> for every compilation unit using isc/xml.h
header.  This MR fixes the usage making the caller object opaque.
2019-06-25 12:01:32 +02:00
Mark Andrews 134248531c silence unchecked return 2019-06-24 19:50:43 -04:00
Ondřej Surý 0f9f1ece14 Stop requiring same memory ordering in win32 atomic_compare_exchange functions 2019-06-20 18:52:27 +02:00
Ondřej Surý 28af0de764 isc_app_reload doesn't return value, don't use return() there 2019-06-20 18:52:27 +02:00
Ondřej Surý 5098c95452 Merge unix/app.c and win32/app.c
The differences between two files are very minimal and most of the
code is common.  Merge those two files and use #ifdef WIN32 to include
the right bits on Windows.
2019-06-20 18:52:27 +02:00
Michał KępieńandOndřej Surý e21103f2d3 Fix statistics for x86 Windows builds
Using atomic_int_fast64_t variables with atomic functions on x86 does
not cause Visual Studio to report build errors, but such operations
yield useless results.  Since the isc_stat_t type is unconditionally
typedef'd to atomic_int_fast64_t, any code performing atomic operations
on isc_stat_t variables is broken in x86 Windows builds.  Fix by using
the atomic_int_fast32_t type for isc_stat_t in x86 Windows builds.
2019-06-20 17:49:25 +02:00
Tinderbox UserandEvan Hunt 9bb0b30bc2 prep 9.15.1 2019-06-19 15:36:28 -07:00
Michał Kępień ce796ac1f4 Address GCC 9.1 -O3 compilation warnings
Compiling with -O3 triggers the following warnings with GCC 9.1:

    task.c: In function ‘isc_taskmgr_create’:
    task.c:1384:43: warning: ‘%04u’ directive output may be truncated writing between 4 and 10 bytes into a region of size 6 [-Wformat-truncation=]
     1384 |   snprintf(name, sizeof(name), "isc-worker%04u", i);
          |                                           ^~~~
    task.c:1384:32: note: directive argument in the range [0, 4294967294]
     1384 |   snprintf(name, sizeof(name), "isc-worker%04u", i);
          |                                ^~~~~~~~~~~~~~~~
    task.c:1384:3: note: ‘snprintf’ output between 15 and 21 bytes into a destination of size 16
     1384 |   snprintf(name, sizeof(name), "isc-worker%04u", i);
          |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    private_test.c: In function ‘private_nsec3_totext_test’:
    private_test.c:110:9: warning: array subscript 4 is outside array bounds of ‘uint32_t[1]’ {aka ‘unsigned int[1]’} [-Warray-bounds]
      110 |  while (*sp == '\0' && slen > 0) {
          |         ^~~
    private_test.c:103:11: note: while referencing ‘salt’
      103 |  uint32_t salt;
          |           ^~~~

Prevent these warnings from being triggered by increasing the size of
the relevant array (task.c) and reordering conditions (private_test.c).
2019-06-11 10:18:23 +02:00
Ondřej SurýandEvan Hunt ac3d9b97a3 Fix Windows build by moving #include <pthread.h> to correct #ifdef block 2019-06-05 11:17:19 -07:00
Ondřej SurýandEvan Hunt 1e2f40d01b Fixup the atomic code in pthread_rwlock branch of lib/isc/rwlock.c 2019-06-05 11:17:19 -07:00
Mark Andrews 5d5d751c7f teach cppcheck that _assert_int_equal and _assert_int_not_equal don't return on failure 2019-06-03 23:04:10 -04:00
Ondřej SurýandMichał Kępień 14ecd7d79e Revise the Windows section of <isc/endian.h>
Add a comment and remove redundant definitions.
2019-06-03 14:13:23 +02:00
Ondřej SurýandMichał Kępień 7e05848870 Revise the macOS section of <isc/endian.h>
Move the macOS section of <isc/endian.h> to a lower spot as it is
believed not to be the most popular platform for running BIND.  Add a
comment and remove redundant definitions.
2019-06-03 14:13:23 +02:00
Ondřej SurýandMichał Kępień 2e54b1be29 Make <isc/endian.h> detect GNU rather than Linux
Instead of only supporting Linux, try making <isc/endian.h> support
other GNU platforms as well.  Since some compilers define __GNUC__ on
BSDs (e.g. Clang on FreeBSD), move the relevant section to the bottom of
the platform-specific part of <isc/endian.h>, so that it only gets
evaluated when more specific platform determination criteria are not
met.  Also include <byteswap.h> so that any byte-swapping macros which
may be defined in that file on older platforms are used in the fallback
definitions of the nonstandard hto[bl]e{16,32,64}() and
[bl]e{16,32,64}toh() conversion functions.
2019-06-03 14:13:23 +02:00
Ondřej SurýandMichał Kępień 387cc00121 Add Solaris support for <isc/endian.h>
While Solaris does not support the nonstandard hto[bl]e{16,32,64}() and
[bl]e{16,32,64}toh() conversion functions, it does have some
byte-swapping macros available in <sys/byteorder.h>.  Ensure these
macros are used in the fallback definitions of the aforementioned
nonstandard functions.
2019-06-03 14:13:23 +02:00
Ondřej SurýandMichał Kępień 85059c2937 Add fallback definitions to <isc/endian.h>
Since the hto[bl]e{16,32,64}() and [bl]e{16,32,64}toh() conversion
functions are nonstandard, add fallback definitions of these functions
to <isc/endian.h>, so that their unavailability does not prevent
compilation from succeeding.
2019-06-03 14:13:23 +02:00
Michał Kępień 7ab1fb2a8d Fix <isc/endian.h> on BSD systems
Current versions of DragonFly BSD, FreeBSD, NetBSD, and OpenBSD all
support the modern variants of functions converting values between host
and big-endian/little-endian byte order while older ones might not.
Ensure <isc/endian.h> works properly in both cases.
2019-06-03 14:13:23 +02:00
Witold KręcickiandEvan Hunt e517c18d98 Fix a possible race between udp dispatch and socket code
There's a small possibility of race between udp dispatcher and
socket code - socket code can still hold internal reference to a
socket while dispatcher calls isc_socket_open, which can cause
an assertion failure. Fix it by relaxing the assertion test, and
instead simply locking the socket in isc_socket_open.
2019-05-31 11:21:28 -07:00
Witold KręcickiandOndřej Surý 02bbf1e2b9 Add --enable-pthread-rwlock option 2019-05-30 16:10:16 +02:00
Ondřej Surý 4501f646ee Implement isc_rwlock_downgrade using pthreads and single atomic_bool 2019-05-30 16:10:16 +02:00
Ondřej Surý 64fbffbbaa Use simple pthread_rwlock in place of our custom adaptive rwlock 2019-05-30 16:10:16 +02:00
Ondřej Surý 4d2d3b49ce Cleanup the way we detect json-c library to use only pkg-config 2019-05-29 15:08:52 +02:00
Witold Kręcicki 75815c1581 Fix a possible deadlock in TCP accepting
Each network thread holds an array of locks, indexed by a hash
of fd. When we accept a connection we hold a lock in accepting thread.
We then generate the thread number and lock bucket for the new
connection socket - if we hit the same thread and lock bucket as
accepting socket we get a deadlock. Avoid this by checking if we're
in the same thread/lock bucket and not locking in this case.
2019-05-24 03:18:41 -04:00
Mark Andrews 505ec918d7 include <isc/string.h> for isc_string_strerror_r prototype 2019-05-24 16:27:40 +10:00
Mark Andrews 978a37c827 use atomics in lib/isc/win32/app.c 2019-05-24 16:27:40 +10:00
Ondřej Surý d5055665ca Remove isc_hash_reverse function 2019-05-21 10:23:17 +00:00
Ondřej Surý 2e7d82443f Convert isc_hash functions to use isc_siphash24 2019-05-21 10:23:13 +00:00
Ondřej Surý 2cbf633192 Add tests for the isc_siphash24 function 2019-05-20 19:01:31 +02:00
Ondřej Surý a197df137a Add reference SipHash 2-4 implementation 2019-05-20 19:01:31 +02:00
Ondřej Surý 0efc36c19a Add portable <isc/endian.h> header 2019-05-20 19:01:31 +02:00
Ondřej Surý eb8c9bdd55 Make lib/isc/app.c opaque and thread-safe
This work cleans up the API which includes couple of things:

1. Make the isc_appctx_t type fully opaque

2. Protect all access to the isc_app_t members via stdatomics

3. sigwait() is part of POSIX.1, remove dead non-sigwait code

4. Remove unused code: isc_appctx_set{taskmgr,sockmgr,timermgr}
2019-05-20 18:13:02 +02:00
Ondřej Surý 94cb73d96c Use SO_REUSEPORT_LB on FreeBSD if available 2019-05-15 07:30:23 +02:00
Ondřej Surý 1c672367a0 Add safeguard against the other usage of SO_REUSEPORT 2019-05-15 07:30:23 +02:00
Ondřej Surý ab389695b0 Add most useful relaxed and acquire-relase stdatomic convenience macros
The header file <isc/atomic.h> now contains convenience macros for
most useful explicit memory ordering for C11 stdatomics, only relaxed
and acquire-release semantics is being used.  These macros SHOULD be
used instead of atomic_<func>_explicit functions.
2019-05-13 12:17:21 +07:00
Mark Andrews f546769b8b arm: just use the compiler's default yield support 2019-05-12 21:39:43 -04:00
Ondřej Surý 7ec9502ec5 Add benchmark for isc_{mem,mempool}_{get,put} operations 2019-05-11 04:02:35 +07:00
Mark Andrews 4886701c03 clear pointer before hash table 2019-05-07 10:37:37 +10:00