Commit graph

43890 commits

Author SHA1 Message Date
Ondřej Surý
63ed3cd0bd fix: nil: Fix dns_qpmulti_memusage() on empty dns_qpmulti_t instance
The dns_qpmulti_memusage() causes assertion failure when called on
freshly created qpmulti instance because the qp->usage hasn't been
allocated yet.

Merge branch 'ondrej/fix-qpmulti_memusage' into 'main'

See merge request isc-projects/bind9!10977
2025-09-16 16:43:46 +02:00
Ondřej Surý
b2f653b332
Fix dns_qpmulti_memusage() on empty dns_qpmulti_t instance
The dns_qpmulti_memusage() causes assertion failure when called on
freshly created qpmulti instance because the qp->usage hasn't been
allocated yet.
2025-09-16 16:30:15 +02:00
Colin Vidal
722ce92f10 chg: dev: simplify nchildren count in isc_nm_listenudp
Slight simplification of the logic to define .nchildren listening UDP
socket.

Merge branch 'colin/simplify-socket-nchildren-count' into 'main'

See merge request isc-projects/bind9!10978
2025-09-16 15:49:49 +02:00
Colin Vidal
2cbe958df6 simplify nchildren count in isc_nm_listenudp
Slight simplification of the logic to define .nchildren listening UDP
socket.
2025-09-16 14:22:15 +02:00
Mark Andrews
f2f2488bbe fix: usr: Add chroot check to meson.build
The meson build procedure was not checking for the existence of
the chroot function.  This has been fixed.

Closes #5519

Merge branch '5519-add-chroot-check-to-meson-build' into 'main'

See merge request isc-projects/bind9!10973
2025-09-16 22:06:46 +10:00
Mark Andrews
574d3147d5 Check if chroot exists 2025-09-16 20:44:44 +10:00
Colin Vidal
96855b5449 rem: dev: remove orphan dns_loadmgr_t type
dns_loadmgr_t typedef is declared but never defines as well as a pointer
of this type in named_server_t. Removing it.

Merge branch 'colin/removednsloadmgr' into 'main'

See merge request isc-projects/bind9!10974
2025-09-15 22:39:14 +02:00
Colin Vidal
c16e944b3c remove orphan dns_loadmgr_t type
dns_loadmgr_t typedef is declared but never defines as well as a pointer
of this type in named_server_t. Removing it.
2025-09-15 22:03:11 +02:00
Evan Hunt
29fc7850f1 fix: dev: clean up the dns_db API
Some of the API calls in `dns_db` were obsolete, and have been removed. Others were more complicated than necessary, and have been refactored to simplify.

Merge branch 'each-cleanup-db-api' into 'main'

See merge request isc-projects/bind9!10830
2025-09-15 16:11:59 +00:00
Evan Hunt
4122143c4d remove dns_db_{un,}locknode
remove the dns_db_locknode() and _unlocknode() calls, so that callers no
longer have the ability to directly manipulate the internal locking of
cache and zone databases.
2025-09-15 16:11:50 +00:00
Evan Hunt
17101fa491 make getoriginnode implementation optional
if the dns_db_getoriginnode() call is not implemented, we can
fall back to running dns_db_findnode() on the database origin.
we now only implement getoriginnode directly in databases where
it's clearly faster than the fallback implementation would be.
2025-09-15 16:11:50 +00:00
Evan Hunt
7a5344d591 minor cleanup in sdlz.c
dns_db_issecure() and dns_db_nodecount() return false and 0,
respectively, if they are not implemented, so there's no need to
have implementation functions that only return false and 0.
2025-09-15 16:11:50 +00:00
Evan Hunt
b2009e1ebc remove unnecessary dns_db_nodefullname()
now that node->name is accessible as a common dbnode member,
it's no longer necessary to provide an API call for that.
2025-09-15 16:11:50 +00:00
Evan Hunt
18db48eb2c remove node lock for settrust and clearprefetch
dns_rdataset_clearprefetch() performs an atomic operation,
so it didn't actually need to lock the database node.

dns_rdataset_settrust() updates header->trust; this is also
now atomic, so it doesn't need to lock the node now either.
2025-09-15 16:11:50 +00:00
Evan Hunt
4de396f955 merge dns_db_find/findext and dns_db_findnode/findnodeext
the dns_db_findext and _findnodeext calls are extended versions
of dns_db_find and _findnode, which take additional arguments for
client information in order to support ECS. previously, database
implementations could support either API call, with cross-compatibility
so that, for example, dns_db_findext() could call a find implementation
if findext was not implemented, and dns_db_find() could call findext
if find was not implemented.

this has now been simplified. the find and findnodeext implementations
now support client info.  all database implementations will now provide
these calls.  implementations which do not support ECS will simply
ignore the clientinfo and clientinfomethods parameters.

this only affects the underlying implementation; callers will still
use the same interface. dns_db_find() and dns_db_findnode() are now
macros which pass NULL to the clientinfo parameters, so that callers
don't have to do so explicitly. dns_db_findext() and dns_db_findnodeext()
are still available for callers that do wish to pass clientinfo pointers.
2025-09-15 16:11:50 +00:00
Evan Hunt
9e14fcd259 remove obsolete dns_db_hashsize()
this function's purpose was to populate the "CacheBuckets" statistic,
but there are no databases left that implemented it, so the return
value was always 0. "CacheBuckets" has now been removed from the
statistics, and the dns_db_hashsize() API call has been removed.
2025-09-15 16:11:50 +00:00
Evan Hunt
0222c385aa dns_rdatalist functions are not for general use
the rdataset method implementation functions in dns/rdatalist.c (i.e.,
dns_rdatalist_first, _next, etc) are not meant to be called directly;
they're called via dns_rdataset_first(), dns_rdataset_next(), etc.

in dnssec-ksr.c, a list-based rdataset was iterated using these
functions. this has been fixed, and the functions have been renamed
to use the `dns__` prefix as a signal that they aren't meant to be
used outside the rdataset implementation.
2025-09-15 16:11:50 +00:00
Evan Hunt
7e7d8bece7 remove obsolete dns_db_setloop()
no database implementation has needed an event loop
since the RBT cache was removed, so the setloop API call
is no longer needed.
2025-09-15 16:11:50 +00:00
Ondřej Surý
f717bad108 fix: dev: Fix detection of whether node is active in find_wildcard()
The current code would fail during the write transaction.  The first
header would not match the search->serial and the node might be
incorrectly detected as inactive.

Merge branch 'ondrej/fix-find-wildnode-active-node-detection' into 'main'

See merge request isc-projects/bind9!10972
2025-09-15 17:45:15 +02:00
Ondřej Surý
1e9430ffad
Fix detection whether node is active in find_wildcard()
The current code would fail during the write transaction.  The first
header would not match the search->serial and the node might be
incorrectly detected as inactive.
2025-09-15 17:44:57 +02:00
Ondřej Surý
dbc4731292 chg: dev: Make the database ownercase modifiable only via addrdataset()
Simplify the implementation around the database ownercase.  Remove the
dns_rdataset_setownercase() implementation for the slabheaders and only
allow setting ownercase on rdatalists and rdatasets.  The ownercase in
the database can now be set only with dns_db_addrdataset() by passing
rdataset with correctly set ownercase.

Merge branch 'ondrej/make-database-ownercase-mostly-constant' into 'main'

See merge request isc-projects/bind9!10971
2025-09-15 17:31:50 +02:00
Ondřej Surý
a8c3661e2b
Make the database ownercase modifiable only via addrdataset()
Simplify the implementation around the database ownercase.  Remove the
dns_rdataset_setownercase() implementation for the slabheaders and only
allow setting ownercase on rdatalists and rdatasets.  The ownercase in
the database can now be set only with dns_db_addrdataset() by passing
rdataset with correctly set ownercase.
2025-09-13 06:56:58 +02:00
Andoni Duarte Pintado
07378266c3 Merge tag 'v9.21.12' 2025-09-11 15:57:40 +02:00
Colin Vidal
e7156fe57a fix: dev: do not inline dns_zone_gethooktable
Since !10959 `dns_zone_gethooktable()` is only called once per query,
and the suspicion (from perflab analysis) that this (simple, as just
returning a pointer) call was slowing things down (perhaps because of
code locality reasons?) doesn't matter anymore. So even if !10959
inlined it, it shouldn't matter anymore.

Merge branch 'colin/minimize-hooktable-lookup-followup' into 'main'

See merge request isc-projects/bind9!10962
2025-09-11 14:21:24 +02:00
Colin Vidal
d42d8891ac do not inline dns_zone_gethooktable
Since !10959 `dns_zone_gethooktable()` is only called once per query,
and the suspicion (from perflab analysis) that this (simple, as just
returning a pointer) call was slowing things down (perhaps because of
code locality reasons?) doesn't matter anymore. So even if !10959
inlined it, it shouldn't matter anymore.
2025-09-11 14:21:10 +02:00
Petr Špaček
676d55376a chg: doc: ARM tweaks
Merge branch 'pspacek/reorder-arm-toc' into 'main'

See merge request isc-projects/bind9!10960
2025-09-11 11:04:35 +00:00
Petr Špaček
66e58d3315 Prevent Sphinx from messing up syntax with "smartquotes" feature
Sphinx's smartquotes feature was rewriting -- to en-dash, "" to proper
English quotes etc. This was messing up syntax at unpredictable places.
Disable this feature instead of attempting to escape all the places in
the manual.
2025-09-11 11:04:10 +00:00
Petr Špaček
ed0db245be Reorder appendices in ARM
The new order hopefully reflects likelihood of someone reading from start
to the end:

DNSSEC Guide
Manual Pages
General DNS Reference Information
Release Notes
Changelog
A Brief History of the DNS and BIND
2025-09-11 11:04:10 +00:00
Colin Vidal
89039e0d78 fix: dev: minimize zone hooktable lookups
Merging !10483 caused a performance regression because the zone hooktable had to be looked up every time a hook point was reached, even if no zone plugins were configured. We now look up the zone hooktable when a zone is attached to the query context, and keep a pointer to it until the qctx is destroyed.

Merge branch 'each-zoneplugin-zonehook-once' into 'main'

See merge request isc-projects/bind9!10959
2025-09-11 08:37:03 +02:00
Evan Hunt
0cdcc8a8f4 rename NS_QUERY_RESET to NS_QUERY_CLEANUP
query_reset() is called during query initialization, but the only
time the NS_QUERY_SETUP hook runs is when it's called from
query_cleanup().  it makes more sense to move the hook point to
there and rename it to NS_QUERY_CLEANUP.

this change caused a crash in the unit tests due to the view being
unnecessarily detached before ns__client_reset_cb() was called.
this has also been fixed.
2025-09-10 17:46:53 -07:00
Colin Vidal
b6a292b03f don't call hooks when a query hasn't started
guard the call to the NS_QUERY_RESET hook so it's called only if
the view has been set. If the view is NULL, it means the client has
been reset _before_ the query even started, and no other hook could
have been called, so it doesn't make sense to call this one.

this also enables us to avoid a NULL-check on the qctx->view in the
CALL_HOOK macros.
2025-09-10 14:14:36 -07:00
Evan Hunt
637e8d01d2 minimize calls to dns_zone_gethooktable per qctx
add a 'zhooks' member to the query_ctx structure, so that we only
need to look up the hook table for the zone once when iniitalizing
a qctx, and not once for every hook point.
2025-09-10 14:05:42 -07:00
Evan Hunt
65f6e8fdbc chg: nil: followup changes from !10779
Two follow up changes from !10779: turning a sh-based config test into a python one, as well as guarding a pointer initialization.

Merge branch 'colin/zone-plugins-followup' into 'main'

See merge request isc-projects/bind9!10958
2025-09-10 17:37:27 +00:00
Evan Hunt
8204843bc4 convert config sh-based hooks tests to python
The test cases that call named-checkconf have been moved from
tests.sh into the python tests, which are now renamed back
to tests_hooks.py.
2025-09-10 12:43:05 +02:00
Evan Hunt
0194a265fe check target pointer validity in qctx_save
Make sure the target pointer address (getting the allocated instance of
qctx) is valid and the pointer is NULL.
2025-09-10 12:43:05 +02:00
Ondřej Surý
f1568c1729 chg: nil: Reduce the code duplication around getting slabheaders from slabtop
There was a lot of duplicated code around getting the first header that
exists, is active, and matches the version header from the qpzonedb.
Move the duplicate code into a helper function and unify the same
approach for the qpcache too even though the code is much simpler there.
It should come handy when top->header is something more complicated than
a pointer to first slabheader.

Merge branch 'ondrej/refactor-getting-the-first-slabheader-from-slabtop' into 'main'

See merge request isc-projects/bind9!10953
2025-09-10 11:40:32 +02:00
Ondřej Surý
4dc711ef86
Reduce the code duplication around getting slabheaders from slabtop
There was a lot of duplicated code around getting the first header that
exists, is active, and matches the version header from the qpzonedb.
Move the duplicate code into a helper function and unify the same
approach for the qpcache too even though the code is much simpler there.
It should come handy when top->header is something more complicated than
a pointer to first slabheader.
2025-09-10 10:18:48 +02:00
Mark Andrews
5fcc063ce9 fix: usr: Missing DNSSEC information when CD bit is set in query
The RRSIGs for glue records were not being cached correctly for CD=1 queries.  This has been fixed.

Closes #5502

Merge branch '5502-fix-missing-rrsig-with-cd' into 'main'

See merge request isc-projects/bind9!10938
2025-09-10 15:54:33 +10:00
Mark Andrews
b7e73edd12 test that rrsigs are returned for glue with +cd 2025-09-10 14:20:22 +10:00
Mark Andrews
7d765a3514 Remove dns_rdataset_equals as unneeded 2025-09-10 14:20:22 +10:00
Mark Andrews
b954a1df43 Fix missing RRSIGs for "glue" lookups with CD=1
The code to test whether to store the RRSIGs on DNS_R_UNCHANGED
with CD=1 was failing because the comparison methods of the two
rdatatset instances were not compatible.  Move the testing into
dns_db_addrdataset(), and request it by setting the DNS_ADD_EQUALOK
option.  If the option is set and the old and new rrsets compare
as equal, dns_db_addrdataset() returns ISC_R_SUCCESS instead of
DNS_R_UNCHANGED.
2025-09-10 14:20:22 +10:00
Evan Hunt
943756aac3 fix: test: remove 'signer' files from dnssec test
When the `dnssec-signzone` tests were moved to the `dnssectools`
system test, an unused copy of the `signer` directory was left in
the `dnssec` test. This has been removed.

Merge branch 'each-cleanup-dnssec-files' into 'main'

See merge request isc-projects/bind9!10873
2025-09-10 04:12:34 +00:00
Evan Hunt
7f69a20963 remove 'signer' files from dnssec test
when the dnssec-signzone tests were moved to the dnssectools
system test, a unused copy of the 'signer' directory was left in
the dnssec test. This has been removed.
2025-09-10 04:12:01 +00:00
Mark Andrews
8aff2bbc5a fix: nil: Fix last argument to cache_rrset is wrong
The last argument to cache_rrset should be a bool (false)
not a pointer (NULL).

Closes #5509

Merge branch '5509-last-argument-to-cache_rrset-is-wrong' into 'main'

See merge request isc-projects/bind9!10934
2025-09-10 11:26:38 +10:00
Mark Andrews
e968d0fb8e The last argument to cache_rrset is wrong
The last argument to cache_rrset should be a bool (false)
not a pointer (NULL).
2025-09-10 10:51:21 +10:00
Colin Vidal
65fa569357 new: usr: support for zone-specific plugins
Query plugins can now be configured at the `zone` level, as well as globally or at the `view` level. A plugin's hooks are then called only while that specific zone's database is being used to answer a query.

This simplifies the implementation of plugins that are only needed for specific namespaces for which the server is authoritative. It can also enable quicker responses, since plugins will only be called when they are needed.

Closes #5356

Merge branch 'colin/zone-plugins' into 'main'

See merge request isc-projects/bind9!10483
2025-09-09 21:56:03 +02:00
Colin Vidal
8a9b1197ed rename test hooks python file
As bin/tests/system/hooks/tests_hooks.py still contains wrapper to a
shell-based test (even if not only), rename the file name into
tests_sh_hooks.py
2025-09-09 10:13:40 +02:00
Colin Vidal
d676ce8085 remove query_ctx_t detach_client property
Since the removal of NS_QUERY_QCTX_DESTROYED hook, there is no need for
the `qctx->detach_client` object anymore, as this was designed to tell
the plugin whether the client object is about to be, or is already,
freed from memory.  This is not needed anymore, as NS_QUERY_RESET is
called _always_ when the client object is about to be freed from memory.

Remove `detach_client` and tidy up the code a bit by including the
freeing of the qctx object (when allocated) inside the qctx_destroy
function instead of requiring extra calls.
2025-09-09 10:02:32 +02:00
Colin Vidal
125e3832bc update hooks tests to use NS_QUERY_RESET
Update hooks-related unit tests since the removal of
NS_QUERY_QCTX_DESTROY and the introduction of NS_QUERY_RESET hook. This
also simplifies (a bit) the plugin usage as NS_QUERY_RESET is _always_
called when the client plugin is about to be freed from memory.
2025-09-09 09:42:34 +02:00
Colin Vidal
95c71c2739 replace QCTX_INIT/_DESTROY hooks with QUERY_SETUP/_RESET
The hook NS_QUERY_QCTX_DESTROY is problematic with zone plugins because
it can be called in some contexts where `qctx->client` is invalid (the
pointer is dangling); which would lead to a use-after-free (spotted by
TSAN build) as `qctx->client` is used to get the zone hooktable, to find
out whether there is an authoritive zone which would have
NS_QUERY_QCTX_DESTROY registered.

This can't easily be fixed, because there is no easy way to know from
query.c code if `client` is still a valid object: `client->reqhandle`,
representing the request from a client, is refcounted, and the `client`
object is freed from memory once its refcounter gets to 0. While
`reqhandle` is attached from query.c code, it can be attached more than
once from asynchronous code and there is no clear path where detaching
it would lead to a client free. Hence, there is no way to know for sure
when to set `qctx->client = NULL` (this is why the pointer remains
dangling).

Back to the original problem; this is why the NS_QUERY_QCTX_DESTROY hook
is incompatible with zone plugins. `qctx->detach_client`, which is used
to tell a plugin that the `client` object is either free or about to be
free can't be use either, because in some cases the client is still
there, and should be used.

Code issue aside, the `qctx` object is really just an aggregate of
various data to pass easily in the various functions and callbacks,
initially stored on the stack, but allocated in some cases (for some
asynchronous flow, when recursion is needed), so the point it gets
created/"destroyed" is really just an implementation "detail", and
providing a higher level hook for the plugin would be beneficial. Hence,
NS_QUERY_RESET and NS_QUERY_INIT are removed, and instead, the existing
NS_QUERY_SETUP can be used as well as the newly introduced
NS_QUERY_RESET (which replaces NS_QUERY_QCTX_DESTROY). The advanage is
that NS_QUERY_RESET is called _only_ when the client object is _always_
about to be freed, which avoids usage of the extra `qctx->detach_client`
usage from the plugin.

The way NS_QUERY_RESET works is that when the `client` is freed, a
callback (from `query.c`) is called. This callback creates a transient
qctx object on the stack with a pointer to the view, and uses that
to call the hook.
2025-09-09 09:42:34 +02:00