2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 22:15:20 +00:00
Commit Graph

36014 Commits

Author SHA1 Message Date
Petr Špaček
2a8eda0084 Fix mismatch between docutils version in CI and ReadTheDocs
Currently our CI images we use to build docs (which subsequently get
into release tarballs) are using docutils 0.17.1, which is latest version
which fulfills Sphinx 4.5.0 requirement for docutils < 0.18.

The old requirement for docutils < 0.17 was causing discrepancy between
the way we build release artifacts and the docs on ReadTheDocs.org which
uses doc/arm/requirements.txt from our repo.

Remove the limit for RDT with hope that it will pull latest permissible
version of docutils.

For the long history of messing with docutils version read also
isc-projects/images@d4435b97be
isc-projects/bind9@6a2daddf5b
2022-04-26 14:28:11 +02:00
Ondřej Surý
31f1eab8be Merge branch '3288-adb-cancelfind-race' into 'main'
lock find when unlinking adbname->finds in dns_adb_cancelfind()

Closes #3288

See merge request isc-projects/bind9!6141
2022-04-26 11:34:44 +00:00
Evan Hunt
a1e9a59e2b lock find when unlinking adbname->finds in dns_adb_cancelfind()
In dns_adb_cancelfind(), we need to release the find lock and
then acquire the bucket and find locks in that order, for
consistency with locking hierarchy elsehwere. Previously we
were only acquiring the bucket lock.

Also rewrote the function for better readability.
2022-04-26 12:59:59 +02:00
Petr Špaček
227b488418 Merge branch '3301-support-sphinx-149' into 'main'
Split negative and positive dig/mdig/delv options to support Sphinx 1.4.9

Closes #3301

See merge request isc-projects/bind9!6175
2022-04-26 10:43:28 +00:00
Petr Špaček
ac0c2378ca Add hyperlinks to dig/mdig/delv +options 2022-04-26 12:43:13 +02:00
Petr Špaček
0342dddce7 Split negative and positive dig/mdig/delv options to support Sphinx 1.4.9
Man pages for dig/mdig/delv used `.. option:: +[no]bla` to describe two
options at once, and very old Sphinx does not support that [] in option
names.

Solution is to split negative and positive options into `+bla, +nobla`
form. In the end it improves readability because it transforms hard to
read strings with double brackets from
`+[no]subnet=addr[/prefix-length]` to
`+subnet=addr[/prefix-length], +nosubnet`.

As a side-effect it also allows easier linking to dig/mdig/delv options
using their name directly instead of always overriding the link target
to `+[no]bla` form.

Transformation was done using regex:
    s/:: +\[no\]\(.*\)/:: +\1, +no\1
... and manual review around occurences matching regex
    +no.*=

Fixes: #3301
2022-04-26 12:43:09 +02:00
Ondřej Surý
0d90b40bd2 Merge branch '835-use-UV_UDP_LINUX_RECVERR-to-detect-destination-unreachable' into 'main'
Set IP(V6)_RECVERR on connect UDP sockets (via libuv)

Closes #835

See merge request isc-projects/bind9!6171
2022-04-26 10:41:08 +00:00
Ondřej Surý
834a2ddb4e Add CHANGES note for [GL #4251] 2022-04-26 12:22:18 +02:00
Ondřej Surý
407b37c3f2 Set IP(V6)_RECVERR on connect UDP sockets (via libuv)
The connect()ed UDP socket provides feedback on a variety of ICMP
errors (eg port unreachable) which bind can then use to decide what to
do with errors (report them to the client, try again with a different
nameserver etc).  However, Linux's implementation does not report what
it considers "transient" conditions, which is defined as Destination
host Unreachable, Destination network unreachable, Source Route Failed
and Message Too Big.

Explicitly enable IP_RECVERR / IPV6_RECVERR (via libuv uv_udp_bind()
flag) to learn about ICMP destination network/host unreachable.
2022-04-26 12:22:18 +02:00
Ondřej Surý
7b506384f0 Merge branch 'ondrej-enforce-minimal-libuv-version' into 'main'
Abort when libuv at runtime mismatches libuv at compile time

See merge request isc-projects/bind9!6176
2022-04-26 10:21:43 +00:00
Ondřej Surý
eb8f2974b1 Abort when libuv at runtime mismatches libuv at compile time
When we compile with libuv that has some capabilities via flags passed
to f.e. uv_udp_listen() or uv_udp_bind(), the call with such flags would
fail with invalid arguments when older libuv version is linked at the
runtime that doesn't understand the flag that was available at the
compile time.

Enforce minimal libuv version when flags have been available at the
compile time, but are not available at the runtime.  This check is less
strict than enforcing the runtime libuv version to be same or higher
than compile time libuv version.
2022-04-26 11:40:40 +02:00
Ondřej Surý
ed4dd7bef7 Merge branch 'ondrej-fix-route_recv-use-after-free' into 'main'
The route socket and its storage was detached while still reading

See merge request isc-projects/bind9!6169
2022-04-25 15:42:38 +00:00
Ondřej Surý
9ae34a04e8 The route socket and its storage was detached while still reading
The interfacemgr and the .route was being detached while the network
manager had pending read from the socket.  Instead of detaching from the
socket, we need to cancel the read which in turn will detach the route
socket and the associated interfacemgr.
2022-04-25 17:19:33 +02:00
Tony Finch
2be07a4316 Merge branch 'fanf-random-failures' into 'main'
Revert "Move random number re-seeding out of the hot path"

See merge request isc-projects/bind9!6172
2022-04-25 15:13:51 +00:00
Tony Finch
b2950c96de Revert "Move random number re-seeding out of the hot path"
This reverts commit b1bb41603e.
2022-04-25 15:18:58 +01:00
Petr Špaček
eaaf59d1e6 Merge branch '3295-support-sphinx-185' into 'main'
Use unique program + option names for link anchors to support Sphinx 1.8.5

Closes #3295

See merge request isc-projects/bind9!6167
2022-04-25 12:45:59 +00:00
Petr Špaček
bbb24264bb Use unique program + option names for link anchors to support Sphinx 1.8.5
Sphinx "standard domain" provides directive types ".. program::" and
".. option::" to create link anchor for a program name + option combination.
These can be referenced using :ref:`program option` syntax.

The problem is that Sphinx 1.8.5 (e.g. in Ubuntu 18.04) generates
conflicting link targets if a page contains two option directives
starting with the same word, e.g.:

.. program:: dnssec-settime
.. option:: -P date
.. option:: -P ds date

The reason is that option directive consumes only first word as "option
name" (-P) and all the rest is considered "option argument" (date, ds
date). Newer versions of Sphinx (e.g. 4.5.0) handle this by creating
numbered link anchors, but older versions warn and BIND build system
turns the warning into a hard error.

To handle that we use method recommended by Sphinx maintainer:
https://github.com/sphinx-doc/sphinx/issues/10218#issuecomment-1059925508
As a bonus it provides more accurate link anchors for sub-options.

Alternatives considered:
- Replacing standard domain definition of .. option - causes more
  problems, see BIND issue #3294.
- Removing hyperlinks for options - that would be a step back.

Fixes: #3295
2022-04-25 14:27:34 +02:00
Tony Finch
870f785e49 Merge branch 'fanf-lemire-nearly-divisionless' into 'main'
Make isc_random_uniform() nearly divisionless

See merge request isc-projects/bind9!6161
2022-04-22 17:38:34 +00:00
Tony Finch
719638639e CHANGES note for [GL !6161]
[cleanup]	Use Daniel Lemire's "nearly divisionless" algorithm
		for unbiased bounded random numbers, and move
		re-seeding out of the hot path.
2022-04-22 16:41:19 +01:00
Tony Finch
b1bb41603e Move random number re-seeding out of the hot path
Instead of checking if we need to re-seed for every isc_random call,
seed the random number generator in the libisc global initializer
and the per-thread initializer.
2022-04-22 16:40:37 +01:00
Tony Finch
254d2abafb Clean up isc_random
Remove redundant comments and avoid implicit casts.
2022-04-22 16:40:37 +01:00
Tony Finch
d20ea4a703 Make isc_random_uniform() nearly divisionless
It used to require two 32-bit integer divisions to get a random number
less than some limit. Now we use Daniel Lemire's "nearly-divisionless"
algorithm for unbiased bounded random numbers, which requires one
64-bit integer multiply in the usual case, and one 32-bit integer
division in rare slow cases. Even the slow cases are faster than
before; there are also fewer branches.

I think this algorithm is exceptionally beautiful. It also has more
clever tricks than lines of code, so I have done my best to explain
how it works.
2022-04-22 16:40:37 +01:00
Ondřej Surý
5d76ac686a Merge branch '3298-dont-check-exiting-in-dns__adb_attach' into 'main'
Allow attaching to dns_adb which is shutting down

Closes #3298

See merge request isc-projects/bind9!6165
2022-04-22 15:29:43 +00:00
Ondřej Surý
b37c173cf8 Add CHANGES note for [GL #3298] 2022-04-22 17:00:10 +02:00
Ondřej Surý
b55e8a959f Allow attaching to dns_adb which is shutting down
The dns__adb_attach() had an assertion failure that prevented to attach
to dns_adb if the dns_adb was shutting down.  There was a race between
checking for .exiting in dns_adb_createfind and creating new_adbfind() -
other thread could have set the .exiting to true between the check.

Remove the assertion failure and allow attaching to dns_adb even while
shutting down.  The process of dns_adb shutting down would be noticed
only a moments later when any other callback is called.
2022-04-22 16:48:37 +02:00
Ondřej Surý
4d216e68ab Merge branch 'ondrej-use-correct-task-for-resume_dslookup' into 'main'
Use right task for the internal dns_resolver fetches

See merge request isc-projects/bind9!6163
2022-04-22 13:42:53 +00:00
Ondřej Surý
741a7096fc Run resume_dslookup() from the correct task
The rctx_chaseds() function calls dns_resolver_createfetch(), passing
fctx->task as the target task to run resume_dslookup() from.  This
breaks task-based serialization of events as fctx->task is the task that
the dns_resolver_createfetch() caller wants to receive its fetch
completion event in; meanwhile, intermediate fetches started by the
resolver itself (e.g. related to QNAME minimization) must use
res->buckets[bucketnum].task instead.  This discrepancy may cause
trouble if the resume_dslookup() callback happens to be run concurrently
with e.g. fctx_doshutdown().

Fix by passing the correct task to dns_resolver_createfetch() in
rctx_chaseds().
2022-04-22 14:25:32 +02:00
Michał Kępień
0136eb0450 Merge branch 'michal/fix-loading-plugins-using-just-their-filenames' into 'main'
Fix loading plugins using just their filenames

See merge request isc-projects/bind9!6142
2022-04-22 11:31:38 +00:00
Michał Kępień
5065c4686e Fix loading plugins using just their filenames
BIND 9 plugins are installed using Automake's pkglib_LTLIBRARIES stanza,
which causes the relevant shared objects to be placed in the
$(libdir)/@PACKAGE@/ directory, where @PACKAGE@ is expanded to the
lowercase form of the first argument passed to AC_INIT(), i.e. "bind".
Meanwhile, NAMED_PLUGINDIR - the preprocessor macro that the
ns_plugin_expandpath() function uses for determining the absolute path
to a plugin for which only a filename has been provided (rather than a
path) - is set to $(libdir)/named.  This discrepancy breaks loading
plugins using just their filenames.  Fix the issue (and also prevent it
from reoccurring) by setting NAMED_PLUGINDIR to $(pkglibdir).
2022-04-22 13:27:12 +02:00
Michał Kępień
966fbd1615 Merge branch 'michal/regenerate-man-pages-with-sphinx-4.5.0' into 'main'
Regenerate man pages with Sphinx 4.5.0

See merge request isc-projects/bind9!6159
2022-04-22 11:15:56 +00:00
Michał Kępień
e80ce6cfe2 Regenerate man pages with Sphinx 4.5.0
The Debian 11 (bullseye) Docker image, which GitLab CI uses for building
documentation, currently contains the following package versions:

  - Sphinx 4.5.0
  - sphinx-rtd-theme 1.0.0
  - docutils 0.17.1

Regenerate the man pages to match contents produced in a Sphinx
environment using the above package versions.  This is necessary to
prevent the "docs" GitLab CI job from failing.
2022-04-22 13:05:10 +02:00
Michał Kępień
cb42b9b400 Merge branch '3297-fix-a-pylint-2.13.7-error' into 'main'
Fix a PyLint 2.13.7 error

Closes #3297

See merge request isc-projects/bind9!6150
2022-04-22 10:13:40 +00:00
Michał Kępień
3f5318f094 Fix a PyLint 2.13.7 error
PyLint 2.13.7 reports the following error:

    bin/tests/system/doth/conftest.py:34:28: E0601: Using variable 'stderr' before assignment (used-before-assignment)

The reason the current code has not caused problems before is that
invoking gnutls-cli with just the --logfile=/dev/null argument causes it
to always return with a non-zero exit code, either due to the option not
being supported or due to the hostname argument not being provided.  In
other words, the 'except' branch has always been taken.  PyLint is
obviously right on a syntactical level, though.

Instead of relying on a less than obvious code flow (where the 'except'
branch is always taken), rework the flagged code by employing
subprocess.run(..., check=False) instead of subprocess.check_output(),
making exception handling redundant.

While this issue was investigated, it was also noticed that
subprocess.check_output() was incorrectly used as a context manager:
Popen objects are context managers, but subprocess.check_output() and
subprocess.run() are not.  Fix by dropping the relevant 'with'
statement.
2022-04-22 11:25:27 +02:00
Michał Kępień
aaa0223752 Fix "digdelv" system test requirements
Commit 3ec5d2d6ed added a Python-based
name server (bin/tests/system/digdelv/ans8/ans.py) to the "digdelv"
system test, but did not update bin/tests/system/Makefile.am to ensure
Python is present in the test environment before the "digdelv" system
test is run.  Update bin/tests/system/Makefile.am to enforce that
requirement.
2022-04-22 11:25:27 +02:00
Michał Kępień
beaaa7f4e2 Require Python 3.6+ for running Python-based tests
configure.ac currently requires Python 3.4 for running Python-based
system tests.  Meanwhile, there are some features in Python 3.6+ that we
would like to use for making our Python code cleaner (e.g. f-strings).
Update the minimum Python version required for running Python-based
system tests to 3.6, noting that:

  - Python 3.4 has reached end-of-life on March 18th, 2019.
  - Python 3.5 has reached end-of-life on September 5th, 2020.
2022-04-22 11:25:27 +02:00
Michał Kępień
7f3b559b04 Merge branch '3287-prevent-memory-bloat-caused-by-a-jemalloc-quirk' into 'main'
Prevent memory bloat caused by a jemalloc quirk

Closes #3287

See merge request isc-projects/bind9!6137
2022-04-21 12:21:24 +00:00
Michał Kępień
e33aef4e39 Add CHANGES entry for GL #3287 2022-04-21 14:19:39 +02:00
Michał Kępień
7aa7b6474b Prevent memory bloat caused by a jemalloc quirk
Since version 5.0.0, decay-based purging is the only available dirty
page cleanup mechanism in jemalloc.  It relies on so-called tickers,
which are simple data structures used for ensuring that certain actions
are taken "once every N times".  Ticker data (state) is stored in a
thread-specific data structure called tsd in jemalloc parlance.  Ticks
are triggered when extents are allocated and deallocated.  Once every
1000 ticks, jemalloc attempts to release some of the dirty pages hanging
around (if any).  This allows memory use to be kept in check over time.

This dirty page cleanup mechanism has a quirk.  If the first
allocator-related action for a given thread is a free(), a
minimally-initialized tsd is set up which does not include ticker data.
When that thread subsequently calls *alloc(), the tsd transitions to its
nominal state, but due to a certain flag being set during minimal tsd
initialization, ticker data remains unallocated.  This prevents
decay-based dirty page purging from working, effectively enabling memory
exhaustion over time. [1]

The quirk described above has been addressed (by moving ticker state to
a different structure) in jemalloc's development branch [2], but not in
any numbered jemalloc version released to date (the latest one being
5.2.1 as of this writing).

Work around the problem by ensuring that every thread spawned by
isc_thread_create() starts with a malloc() call.  Avoid immediately
calling free() for the dummy allocation to prevent an optimizing
compiler from stripping away the malloc() + free() pair altogether.

An alternative implementation of this workaround was considered that
used a pair of isc_mem_create() + isc_mem_destroy() calls instead of
malloc() + free(), enabling the change to be fully contained within
isc__trampoline_run() (i.e. to not touch struct isc__trampoline), as the
compiler is not allowed to strip away arbitrary function calls.
However, that solution was eventually dismissed as it triggered
ThreadSanitizer reports when tools like dig, nsupdate, or rndc exited
abruptly without waiting for all worker threads to finish their work.

[1] https://github.com/jemalloc/jemalloc/issues/2251
[2] c259323ab3
2022-04-21 14:19:39 +02:00
Michał Kępień
4a0dbc9faf Merge branch 'michal/revise-release-related-git-workflow' into 'main'
Revise release-related Git workflow

See merge request isc-projects/bind9!6124
2022-04-21 07:59:24 +00:00
Michał Kępień
eb83b1a79f Update release checklist 2022-04-21 09:57:14 +02:00
Mark Andrews
c70f34c218 Merge branch '2898-improve-functions-parameter-validation-in-lib-dns-message-c-to-prevent-accessing-the-1-index' into 'main'
Resolve "Improve functions parameter validation in lib/dns/message.c to prevent accessing the -1 index of an array"

Closes #2898

See merge request isc-projects/bind9!5824
2022-04-19 22:13:47 +00:00
Mark Andrews
d4892f7cdc Tighten DBC restrictions on message sections
dns_message_findname and dns_message_sectiontotext incorrectly accepted
DNS_SECTION_ANY.  If DNS_SECTION_ANY was passed the section array could
be incorrectly accessed at (-1).

dns_message_pseudosectiontotext and dns_message_pseudosectiontoyaml
incorrectly accepted DNS_PSEUDOSECTION_ANY.  These functions are
designed to process a single section.
2022-04-19 22:12:38 +00:00
Tony Finch
3358f712c9 Merge branch '3275-notify-test-fix' into 'main'
Avoid timeouts in the notify system test

Closes #3275

See merge request isc-projects/bind9!6121
2022-04-19 17:10:59 +00:00
Tony Finch
f4c2909353 Use wait_for_log_re in the autosign system test
Fix another occurrence of the mistake of passing a regex to
wait_for_log by using the new wait_for_log_re instead.
2022-04-19 17:00:31 +01:00
Tony Finch
4a30733ae5 Avoid timeouts in the notify system test
There were two problems in the notify system test when it waited for
log messages to appear: the shellcheck refactoring introduced a call
to `wait_for_log` with a regex, but `wait_for_log` only supports fixed
strings, so it always ran for the full 45 second timeout; and the new
test to ensure that notify messages time out failed to reset the
nextpart pointer, so if the notify messages timed out before the test
ran, it would fail to see them.

This change adds a `wait_for_log_re` helper that matches a regex, and
uses it where appropriate in the notify system test, which stops the
test from waiting longer than necessary; and it resets the nextpart
pointer so that the notify timeout test works reliably.

Closes #3275
2022-04-19 17:00:31 +01:00
Ondřej Surý
670b1598d5 Merge branch 'ondrej-improve-taskmgr-tracing' into 'main'
Add detailed tracing when TASKMGR_TRACE is define

See merge request isc-projects/bind9!6036
2022-04-19 13:14:03 +00:00
Ondřej Surý
b090cb95b2 Merge branch 'ondrej/remove-isc-task-sendto' into 'main'
Remove isc_task_sendto(anddetach) functions

See merge request isc-projects/bind9!6139
2022-04-19 12:25:59 +00:00
Ondřej Surý
d1d88a2895 Add detailed tracing when TASKMGR_TRACE is defined
When TASKMGR_TRACE=1 is defined, the task and event objects have
detailed tracing information about function, file, line, and
backtrace (to the extent tracked by gcc) where it was created.

At exit, when there are unfinished tasks, they will be printed along
with the detailed information.
2022-04-19 14:25:23 +02:00
Ondřej Surý
f0feaa3305 Remove isc_task_sendto(anddetach) functions
The only place where isc_task_sendto() was used was in dns_resolver
unit, where the "sendto" part was actually no-op, because dns_resolver
uses bound tasks.  Remove the isc_task_sendto() and
isc_task_sendtoanddetach() functions in favor of using bound tasks
create with isc_task_create_bound().

Additionally, cache the number of running netmgr threads (nworkers)
locally to reduce the number of function calls.
2022-04-19 14:24:36 +02:00
Ondřej Surý
861f25d930 Merge branch 'ondrej/remove-isc_event_constallocate' into 'main'
Remove isc_event_constallocate()

See merge request isc-projects/bind9!6138
2022-04-19 12:23:30 +00:00