Commit Graph

3243 Commits

Author SHA1 Message Date
Tinderbox User
ed6da5ec3d prep 9.11.14 2019-12-12 05:01:05 +00:00
Ondřej Surý
e50abe8a70 Cleanup the isc_stats code 2019-12-04 19:39:57 -03:00
Diego Fronza
8680c367cd Fix tcp-higwater stats for some specific platforms
The previous code had some errors that would be triggered on platforms
without stdatomics but with support for xadd assembly instruction.

The major error was combining two uint32_t values from the
multifield atomic structure using a logical AND '&&' instead of a
bitwise OR '|'.

Some preprocessor rules were redundant and thus were simplified,
regarding the definition of ISC_STATS_USEMULTIFIELDS macro.

Correctly changed rwlock type to read on isc_stats_get_counter.
2019-12-04 19:39:56 -03:00
Evan Hunt
99203103b7 Merge tag 'v9_11_13' into merge-v9_11_13 2019-11-20 13:43:34 -08:00
Ondřej Surý
d2c86b2159 Internally, use {PATH,NAME}_MAX instead of ISC_DIR_{PATH,NAME}MAX 2019-11-12 09:31:40 +01:00
Samuel Thibault
88061c2acb hurd: Fix build
Move PATH_MAX, NAME_MAX, IOV_MAX default definitions to the common
<isc/platform.h>.

(cherry picked from commit d10fbdec84)
2019-11-12 09:22:15 +01:00
Tinderbox User
336d24089b prep 9.11.13 2019-11-06 21:26:36 +00:00
Michał Kępień
4876a88fc0 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

(cherry picked from commit 65a8b53bd0)
2019-11-06 21:11:20 +01:00
Ondřej Surý
55b0da1381 Backport isc_quota_getused() function 2019-11-06 12:54:40 +01:00
Ondřej Surý
e8bf3c60f2 Avoid an extra atomic_load() call 2019-11-06 12:54:40 +01:00
Diego Fronza
4ad2ab54cd 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.

(cherry picked from commit 66fe8627de)
2019-11-06 12:54:40 +01:00
Diego Fronza
5a9c5166ce 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.

(cherry picked from commit a544e2e300)
2019-11-06 12:35:33 +01:00
Diego Fronza
e4ebeff0e4 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
(cherry picked from commit 0fc98ef2d5)
2019-11-06 12:35:33 +01:00
Tinderbox User
5dfdc818d2 Merge branch 'v9_11_12' into v9_11 2019-10-24 05:58:38 +00:00
Michał Kępień
cacba609c7 Suppress cppcheck 1.89 false positive
cppcheck 1.89 emits a false positive for lib/isc/sha1.c:

    lib/isc/sha1.c:273:16: error: Uninitialized variable: block [uninitvar]
     (void)memmove(block, buffer, 64);
                   ^
    lib/isc/sha1.c:272:10: note: Assignment 'block=&workspace', assigned value is <Uninit>
     block = &workspace;
             ^
    lib/isc/sha1.c:273:16: note: Uninitialized variable: block
     (void)memmove(block, buffer, 64);
                   ^

This message started appearing with cppcheck 1.89 [1], but it will be
gone in the next release [2], so just suppress it for the time being.

[1] af214e8212

[2] 2595b82634
2019-10-17 11:13:30 +02:00
Mark Andrews
42f998ee14 Detect partial prefixes / incomplete IPv4 address in acls.
(cherry picked from commit fb87e669fb)
2019-10-14 22:12:16 +11:00
Mark Andrews
d2c51b9c4b Address cppcheck reports
(cherry picked from commit fcebc4f15b)
2019-10-04 14:34:21 +10:00
Ondřej Surý
b06f36a726 lib/isc/include/isc/stdatomic.h: Suppress preprocessorErrorDirective error from Cppcheck 2019-10-03 14:21:47 +02:00
Ondřej Surý
61b3ab76a5 lib/isc/random.c: Suppress preprocessorErrorDirective error from Cppcheck 2019-10-03 14:21:47 +02:00
Ondřej Surý
d26c36a338 Remove randomly scattered additional style check suppressions that caused unmatchedSuppression
(cherry picked from commit a0d3614a60)
2019-10-03 14:21:47 +02:00
Ondřej Surý
8f23f39fee lib/isc/unix/socket.c: Suppress preprocessorErrorDirective error from Cppcheck
(cherry picked from commit 026cf2ff4f)
2019-10-03 14:21:46 +02:00
Ondřej Surý
0e8e4c9174 lib/isc/task.c: Fix invalid order of DbC checks that could cause dereference before NULL check
(cherry picked from commit c662969da1)
2019-10-03 14:21:46 +02:00
Ondřej Surý
91999a143d lib/isc/pkc11.c: Fix possible NULL pointer dereference in push_attribute()
(cherry picked from commit e8948fd9b4)
2019-10-03 14:21:46 +02:00
Ondřej Surý
7accb1029f lib/isc/buffer.c: Fix invalid order of DbC checks that could cause dereference before NULL check
(cherry picked from commit e9f30fc211)
2019-10-03 14:21:46 +02:00
Tinderbox User
e21d12ee89 prep 9.11.12 2019-10-02 06:55:33 +00:00
Mark Andrews
9f144a5281 suppress cppcheck warning: literalWithCharPtrCompare 2019-10-02 09:25:00 +10:00
Mark Andrews
bef21ed45d suppress cppcheck warning: constArgument 2019-10-02 09:25:00 +10:00
Mark Andrews
07e5969fe0 suppress cppcheck warning: leakNoVarFunctionCall 2019-10-02 09:25:00 +10:00
Mark Andrews
0936009af6 fix cppcheck warning: unusedVariable by reducing the scope of 'result' 2019-10-02 09:25:00 +10:00
Mark Andrews
73c1a7e03b fix cppcheck warnings: unreadVariable 2019-10-02 09:25:00 +10:00
Michał Kępień
61e4c9198a 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.

(cherry picked from commit 0476e8f1ac)
2019-09-27 12:13:39 +02:00
Mark Andrews
7fb0a0db53 reinstate error handler 2019-09-13 14:17:32 +10:00
Mark Andrews
0d23bc5b55 declare alloc_failure 2019-09-13 13:57:41 +10:00
Mark Andrews
9ee27573af declare result 2019-09-13 13:48:20 +10:00
Mark Andrews
ff700b2259 address or suppress cppcheck warnings
(cherry picked from commit b59fe46e76)
2019-09-12 19:31:56 +10:00
Tinderbox User
1860bab56b prep for 9.11.11 2019-09-09 14:22:44 +00:00
Mark Andrews
5c23d41ba3 check that 'valuep' is not NULL befor assigning to '*valuep' 2019-09-06 11:50:30 +10:00
Mark Andrews
34eba51728 fix backport of maxudp for windows 2019-09-04 16:09:07 +10:00
Mark Andrews
b44ad05d20 implement maxudp under windows
(cherry picked from commit 2f558854b7)
2019-09-04 11:09:31 +10:00
Ondřej Surý
3c85a1f104 Fix alignment issues in the native implementation of isc_siphash24()
The native implementation's conversion from the uint8_t buffers to uint64_t now
follows the reference implementation that doesn't require aligned buffers.
2019-09-02 13:22:40 +02:00
Tinderbox User
eb55184bda prep 9.11.10 2019-08-13 09:34:56 +00:00
Michał Kępień
3806811c04 Fix faulty backport which broke the Windows build
Commit 91307842b8 inadvertently mangled
the XML structure inside lib/isc/win32/libisc.vcxproj.filters.in, thus
breaking the Windows build.  Add the missing XML tags to make Windows
builds work again.
2019-08-08 20:45:30 +02:00
Ondřej Surý
6353032a8a lib/isc/app_api.c: Protect the global is_running bool variable with a mutex 2019-08-06 15:03:35 +02:00
Mark Andrews
75d89f023a handle connect() returning ETIMEDOUT on a non-blocking socket
(cherry picked from commit 91a0cb5da3)
2019-07-31 11:03:56 +10:00
Michał Kępień
28c89c37b0 Do not use legacy time zone names
"PST8PDT" is a legacy time zone name whose use in modern code is
discouraged.  It so happens that using this time zone with musl libc
time functions results in different output than for other libc
implementations, which breaks the lib/isc/tests/time_test unit test.
Use the "America/Los_Angeles" time zone instead in order to get
consistent output across all tested libc implementations.

(cherry picked from commit f4daf6e0e7)
2019-07-30 22:22:28 +02:00
Michał Kępień
3098c79270 Always include <errno.h> instead of <sys/errno.h>
Including <sys/errno.h> instead of <errno.h> raises a compiler warning
when building against musl libc.  Always include <errno.h> instead of
<sys/errno.h> to prevent that compilation warning from being triggered
and to achieve consistency in this regard across the entire source tree.

(cherry picked from commit b5cd146033)
2019-07-30 22:22:28 +02:00
Michał Kępień
eb13d4b279 Unify header ordering in unit tests
Make sure all unit tests include headers in a similar order:

 1. Three headers which must be included before <cmocka.h>.
 2. System headers.
 3. UNIT_TESTING definition, followed by the <cmocka.h> header.
 4. libisc headers.
 5. Headers from other BIND libraries.
 6. Local headers.

Also make sure header file names are sorted alphabetically within each
block of #include directives.

(cherry picked from commit 5381ac0fcc)
2019-07-30 22:22:28 +02:00
Michał Kępień
5e9ac86c2b Include <sched.h> where necessary for musl libc
All unit tests define the UNIT_TESTING macro, which causes <cmocka.h> to
replace malloc(), calloc(), realloc(), and free() with its own functions
tracking memory allocations.  In order for this not to break
compilation, the system header declaring the prototypes for these
standard functions must be included before <cmocka.h>.

Normally, these prototypes are only present in <stdlib.h>, so we make
sure it is included before <cmocka.h>.  However, musl libc also defines
the prototypes for calloc() and free() in <sched.h>, which is included
by <pthread.h>, which is included e.g. by <isc/mutex.h>.  Thus, unit
tests including "dnstest.h" (which includes <isc/mem.h>, which includes
<isc/mutex.h>) after <cmocka.h> will not compile with musl libc as for
these programs, <sched.h> will be included after <cmocka.h>.

Always including <cmocka.h> after all other header files is not a
feasible solution as that causes the mock assertion macros defined in
<isc/util.h> to mangle the contents of <cmocka.h>, thus breaking
compilation.  We cannot really use the __noreturn__ or analyzer_noreturn
attributes with cmocka assertion functions because they do return if the
tested condition is true.  The problem is that what BIND unit tests do
is incompatible with Clang Static Analyzer's assumptions: since we use
cmocka, our custom assertion handlers are present in a shared library
(i.e. it is the cmocka library that checks the assertion condition, not
a macro in unit test code).  Redefining cmocka's assertion macros in
<isc/util.h> is an ugly hack to overcome that problem - unfortunately,
this is the only way we can think of to make Clang Static Analyzer
properly process unit test code.  Giving up on Clang Static Analyzer
being able to properly process unit test code is not a satisfactory
solution.

Undefining _GNU_SOURCE for unit test code could work around the problem
(musl libc's <sched.h> only defines the prototypes for calloc() and
free() when _GNU_SOURCE is defined), but doing that could introduce
discrepancies for unit tests including entire *.c files, so it is also
not a good solution.

All in all, including <sched.h> before <cmocka.h> for all affected unit
tests seems to be the most benign way of working around this musl libc
quirk.  While quite an ugly solution, it achieves our goals here, which
are to keep the benefit of proper static analysis of unit test code and
to fix compilation against musl libc.

(cherry picked from commit 59528d0e9d)
2019-07-30 22:22:27 +02:00
Ondřej Surý
63666fc926 Revise the Windows section of <isc/endian.h>
Add a comment and remove redundant definitions.

(cherry picked from commit 84ff6a6963)
2019-07-22 08:09:48 -04:00
Ondřej Surý
1fd8b2d9f4 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.

(cherry picked from commit c727a31eab)
2019-07-22 08:09:48 -04:00