2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00
Commit Graph

3511 Commits

Author SHA1 Message Date
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ý
ac3d9b97a3 Fix Windows build by moving #include <pthread.h> to correct #ifdef block 2019-06-05 11:17:19 -07:00
Ondřej Surý
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ý
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ý
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ý
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ý
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ý
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ęcicki
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ęcicki
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
Evan Hunt
4e5edb35e4 simplify the isc_stat structure to take avantage of atomics 2019-05-06 12:53:45 -07:00
Evan Hunt
2f3876d187 refactor tcpquota and pipeline refs; allow special-case overrun in isc_quota
- if the TCP quota has been exceeded but there are no clients listening
  for new connections on the interface, we can now force attachment to the
  quota using isc_quota_force(), instead of carrying on with the quota not
  attached.
- the TCP client quota is now referenced via a reference-counted
  'ns_tcpconn' object, one of which is created whenever a client begins
  listening for new connections, and attached to by members of that
  client's pipeline group. when the last reference to the tcpconn
  object is detached, it is freed and the TCP quota slot is released.
- reduce code duplication by adding mark_tcp_active() function
- convert counters to stdatomic

(cherry picked from commit a8dd133d270873b736c1be9bf50ebaa074f5b38f)
(cherry picked from commit 4a8fc979c4)
2019-04-25 16:32:05 +02:00
Mark Andrews
265554f895 use isc_refcount_decrement to decrement NEWCONNSOCK(dev)->references; use isc_refcount_increment instead of isc_refcount_init in socket_create 2019-04-23 00:12:17 -04:00
Ondřej Surý
2e40cc94dc On non-GNUC systems, use uintmax_t in the ISC_ALIGN macro 2019-04-18 12:55:25 +02:00
Mark Andrews
a520662ed4 allow dlz to signal that the view's transfer acl should be used 2019-03-11 14:27:13 +11:00
Ondřej Surý
7eea756858 Restore missing check for flockfile and getc_unlocked 2019-03-08 21:20:20 +01:00
Ondřej Surý
a04a390195 Convert *.vcxproj.user to CRLF line endings 2019-03-08 18:01:48 +01:00
Ondřej Surý
c2637c8429 Use ForcedIncludeFiles directive to include config.h everywhere automatically 2019-03-08 17:14:38 +01:00
Ondřej Surý
1b25d8a0ca Remove explicit '#include <config.h>' from the header files (the include should not have been there in the first place) 2019-03-08 15:15:05 +01:00
Ondřej Surý
78d0cb0a7d Use coccinelle to remove explicit '#include <config.h>' from the source files 2019-03-08 15:15:05 +01:00
Mark Andrews
435ae2f29a Handle EDQUOT and ENOSPC errors 2019-03-07 21:02:48 -08:00
Witold Kręcicki
b57a38ae43 Fix a race in socket code when internal_{accept, send, receive} is called
from event loop on an socket and, in the meantime, someone has closed this
socket.
2019-03-06 12:56:11 -08:00
Mark Andrews
cb913177ae improve clang / cmocka integration 2019-03-05 10:20:29 -08:00
Evan Hunt
efb0d1e83d documentation changes setting up 9.15 development branch 2019-02-21 16:42:17 -08:00
Mark Andrews
f87b88e520 remove dead assignments 2019-02-19 08:12:09 +11:00
Mark Andrews
76a1c1531a assert result is ISC_R_SUCCESS 2019-02-19 07:57:14 +11:00
Tinderbox User
b4d3f78293 prep 9.13.6 2019-02-06 22:13:05 +00:00
Evan Hunt
2f13524164 initalize a named_g_defaultbindkeys variable 2019-02-06 13:18:00 +11:00
Ondřej Surý
3a3e75042d Remove support for compiling without assertions (Both ISC_CHECK_ALL, ISC_CHECK_NONE are now gone) 2019-01-31 11:16:08 +01:00
Ondřej Surý
27eb6189a8 Fix Centos 6 build by explicitly casting to __typeof__(obj) in atomic_compare_exchange_strong shim function 2019-01-30 15:54:17 +01:00