Commit graph

43778 commits

Author SHA1 Message Date
Ondřej Surý
37fa960bd5
Add few missing qpcache_hit() calls
There were couple of missing qpcache_hit() calls in qpcache.c:add()
function where existing data was better than the newly added header.
2025-08-28 19:28:56 +02:00
Ondřej Surý
7b7901494d
Refactoring in qpcache.c:add()
There were several consequtive foreach loops when adding new entry into
the cache.  Merge the multiple foreach loops into a single pass loop
with some effort and a lot of comments.
2025-08-28 19:28:55 +02:00
Ondřej Surý
e3c0a2a0fd
Add DNS_SLABTOP_FOREACH macros
Add foreach macros to iterate through the dns_slabtop_t
single-linked lists.
2025-08-28 19:28:55 +02:00
Ondřej Surý
c60bdbcf5c
Remove double non-NULL guard around bindrdataset()
The bindrdataset() already has a logic to skip the rest of the function
if the passed rdataset is NULL.  Remove the external guarding for
'addedrdataset' to simplify the code flow both from the zone and cache
databases.
2025-08-28 19:28:55 +02:00
Colin Vidal
bc5c9cf62b chg: dev: move handle to keystores from the view to zonemgr
This is a follow-up of !10895 where the keystore pointer was removed
from the zone (as not specific to the zone) and moved to the view. But
in order to avoid adding extra lifecycle dependencies from the zone to
the view, the keystore pointer is now moved to the zonemgr, which also
makes more sense as this is a global settings, and zonemgr wraps a bunch
of other global settings to be accessibles from the zones.

Because the zonemgr lifecycle is the same of the keystores (which are
both depending on named_g_server) this should be a safe change.

Merge branch 'colin/keystores-zonemgr' into 'main'

See merge request isc-projects/bind9!10901
2025-08-28 17:30:57 +02:00
Colin Vidal
26b397bd0f move handle to keystores from the view to zonemgr
This is a follow-up of !10895 where the keystore pointer was removed
from the zone (as not specific to the zone) and moved to the view. But
in order to avoid adding extra lifecycle dependencies from the zone to
the view, the keystore pointer is now moved to the zonemgr, which also
makes more sense as this is a global settings, and zonemgr wraps a bunch
of other global settings to be accessibles from the zones.

Because the zonemgr lifecycle is the same of the keystores (which are
both depending on named_g_server) this should be a safe change.
2025-08-28 16:52:28 +02:00
Ondřej Surý
53cfb29205 fix: dev: Add and use __attribute__((nonnull)) in dnssec-signzone.c
Clang 20 was spuriously warning about the possibility of passing a NULL file pointer
to `fprintf()`, which uses the 'nonnull' attribute. To silence the warning, the functions
calling `fprintf()` have been marked with the same attribute to assure that NULL can't be
passed to them in the first place.

Close #5487

Merge branch '5487-mark-passed-file-pointer-as-nonnull-in-dnssec-signzone' into 'main'

See merge request isc-projects/bind9!10888
2025-08-28 16:24:08 +02:00
Ondřej Surý
9e350c1774 Add and use __attribute__((nonnull)) in dnssec-signzone.c
Clang 20 is complaining about passing NULL to an argument with 'nonnull'
attribute.  Mark these two functions with the same attribute to assure
that these two function also don't accept NULL as an argument.
2025-08-28 16:23:59 +02:00
Ondřej Surý
40b7f5b7ba fix: dev: Ensure file descriptors 0-2 are in use
libuv expect file descriptors <= STDERR_FILENO are in use. otherwise,
it may abort when closing a file descriptor it opened.

Closes #5226

Merge branch 'main' into 'main'

See merge request isc-projects/bind9!10582
2025-08-28 10:56:29 +02:00
Petr Špaček
e415c5c996
Test command line tools without stdio fds
Testing all combinations seems unnecessary but is cheap.
I was too lazy to run this against all tools we have. nsupdate was
chosen because it is one of few tools which actually use stdin and the
original issue was reproducible even without any network communication,
which was not the case for simple dig invocation.

Sorry for new shell test but doing this in Python seemed very
complicated and fragile.
2025-08-28 08:16:06 +02:00
Thomas Abraham
5cfdbeba72
ensure file descriptors 0-2 are in use before using libuv
libuv expects file descriptors <= STDERR_FILENO are in use. otherwise,
it may abort when closing a file descriptor it opened.

See https://github.com/libuv/libuv/pull/4559

Closes #5226
2025-08-28 08:16:06 +02:00
Arаm Sаrgsyаn
bcca7a6834 fix: usr: Fix a catalog zone issue when having an unset 'default-primaries' configuration clause
A catalog zone with an unset ``default-primaries`` clause could cause
an unexpected termination of the :iscman:`named` process after two
reloading or reconfiguration commands. This has been fixed.

Closes #5494

Merge branch '5494-catz-crash-with-unset-default-primaries-and-double-reconfig' into 'main'

See merge request isc-projects/bind9!10896
2025-08-27 16:16:05 +00:00
Aram Sargsyan
40d040b7d5 Add a catalog zone with an unset 'default-primaries' to the catz test
And unset 'default-primaries' is causing an assertion failure after
two reload/reconfig commands. Add such a catalog zone to check the fix.
2025-08-27 15:01:02 +00:00
Aram Sargsyan
db36ae47d2 Fix a bug in configure_catz_zone()
When dns_catz_zone_add() returns ISC_R_EXISTS and there is no
'default-primaries' or 'default-masters', the ISC_R_EXISTS result
code doesn't get reset to ISC_R_SUCCESS, and the function returns
ISC_R_EXISTS instead of ISC_R_SUCCESS. Which means that the zone
is successfully added, but the caller assumes that the function has
failed.

Reset 'result' to ISC_R_SUCCESS when dns_catz_zone_add() returns
ISC_R_EXISTS (it's not an error condition).

Refactor the code go call dns_catz_zone_add() when all other error
conditions are already checked.
2025-08-27 15:01:02 +00:00
Petr Špaček
6a76b143a7 chg: doc: Clarify forward, stub, and static-stub zone usage
Merge branch 'pspacek/doc-forward-stub-zones' into 'main'

See merge request isc-projects/bind9!10417
2025-08-27 14:17:19 +00:00
Petr Špaček
e84b98a9fc Clarify forward, stub, and static-stub zone usage
Clarify that forwarding points to a resolver and stub to auths.
Add cross-links. Rewrite stub zone type description.
2025-08-27 14:12:58 +00:00
Ondřej Surý
af0594f482 chg: dev: Rewrite the bit rotate functions using __builtin or generic
In gcc 15, __builtin_stdc_rotate_{left,right} was added.  Use these
builtins when available otherwise rewrite the ISC_ROTATE_LEFT and
ISC_ROTATE_RIGHT using _Generic.

Merge branch 'ondrej/use-__builtin_stdc_rotate_left_right' into 'main'

See merge request isc-projects/bind9!10893
2025-08-27 11:53:13 +02:00
Ondřej Surý
e01151f729 Rewrite the bit rotate functions using __builtin or generic
In gcc 15, __builtin_stdc_rotate_{left,right} was added.  Use these
builtins when available otherwise rewrite the ISC_ROTATE_LEFT and
ISC_ROTATE_RIGHT using _Generic.
2025-08-27 11:53:05 +02:00
Colin Vidal
7e12c7de0b chg: dev: move keystores handle from the zone to the view
The list of keystores is owned by the single server object
(named_g_server), but dns_zone_t has a pointer into it in order to
preserve encapsulation (lib/dns won't link to bin/named for good
reasons).

However, getting the keystores from the zone uses the zone lock whereas
this is not needed (as the pointer value doesn't depends on the zone,
and is initialized only with the same named_g_server->keystores value);
also storing an extra pointer per zone is not needed; also, there was a
logic based on the zone->secure property which was not needed (as there
is only one keystore).

The keystores pointer is now accessible and lock-free at view level,
it also simplifies a bit the various zone configuration APIs (server.c,
zoneconf.c).

Merge branch 'colin/move-keystore-to-view' into 'main'

See merge request isc-projects/bind9!10895
2025-08-27 11:01:15 +02:00
Colin Vidal
529fd913db move keystores handle from the zone to the view
The list of keystores is owned by the single server object
(named_g_server), but dns_zone_t has a pointer into it in order to
preserve encapsulation (lib/dns won't link to bin/named for good
reasons).

However, getting the keystores from the zone uses the zone lock whereas
this is not needed (as the pointer value doesn't depends on the zone,
and is initialized only with the same named_g_server->keystores value);
also storing an extra pointer per zone is not needed; also, there was a
logic based on the zone->secure property which was not needed (as there
is only one keystore).

The keystores pointer is now accessible and lock-free at view level,
it also simplifies a bit the various zone configuration APIs (server.c,
zoneconf.c).
2025-08-27 10:25:20 +02:00
Ondřej Surý
72189af7bf fix: usr: Prevent spurious SERVFAILs for certain 0-TTL resource records
Under certain circumstances, BIND 9 can return SERVFAIL when updating
existing entries in the cache with new NS, A, AAAA, or DS records with 0-TTL.

Closes #5294

Merge branch '5294-preserve-ZEROTTL-on-cache-update' into 'main'

See merge request isc-projects/bind9!10897
2025-08-26 21:03:43 +02:00
Ondřej Surý
9f7ba584cf
Don't preserve cache entries if new TTL is smaller than existing
Under certain circumstances, cache entries with equivalent rdataset
might not get replaced.  Previously such entry would get preserved
regardless of the new TTL and expire time on the existing header would
get updated when the expire time was less than the expire time on the
existing header.  Change the logic to preserve the existing header only
if the new expire time is larger than the existing one and replace the
existing cache entry when the new expire time is less than the existing
one.

Co-authored-by: Jinmei Tatuya <jtatuya@infoblox.com>
2025-08-26 18:26:34 +02:00
Ondřej Surý
982ca161c2
Preserve ZEROTTL attribute when replacing NS RRset
Previously, BIND 9 would drop the ZEROTTL attribute when updating
previously cached NS entry with ZEROTTL attribute set.

Co-authored-by: Jinmei Tatuya <jtatuya@infoblox.com>
2025-08-26 18:26:34 +02:00
Ondřej Surý
bfbc58063a chg: dev: Improve C23 compatibility
Use C23 stdckdint.h when available and define ckd_{mul,add,sub} shims to __builtin_{mul,add,sub}_overflow(). Require all the __builtin functions to be supported to further simplify the non-C23 implementation.  Rename the <stdbit.h>-shims in <isc/bit.h> to their C23 names.

Merge branch 'ondrej/use-stdckdint.h-if-available' into 'main'

See merge request isc-projects/bind9!10818
2025-08-26 16:35:53 +02:00
Ondřej Surý
443bbc6491
Use the <stdbit.h> names for bit manipulation shims
When <stdbit.h> is unavailable, use the stdc names like stdc_count_zeros
instead of ISC_COUNT_ZERO macros to simplify the code.
2025-08-26 15:32:53 +02:00
Ondřej Surý
38124cfcb2
Simplify add/sub/mul overflow checks
Use C23 stdckdint.h when available and define ckd_{mul,add,sub} shims to
__builtin_{mul,add,sub}_overflow().  Require the __builtin functions
unconditionally.
2025-08-26 15:32:53 +02:00
Ondřej Surý
40fda03e50
Require the __builtin functions unconditionally
Currently following __builtin functions are used:

    __builtin_add_overflow
    __builtin_mul_overflow
    __builtin_prefetch
    __builtin_sub_overflow
    __builtin_unreachable

These are generally available on our supported platform, and also we use
some of these unconditionally anyway in qp.c.  Thus make the support for
these functions mandatory so we fail early in the 'setup' step.
2025-08-26 15:32:53 +02:00
Petr Špaček
56704f4bfb fix: ci: Reverse config grammar checks and docs builds
See #5379

Merge branch 'pspacek/fix-doc-misc-patch-generator' into 'main'

See merge request isc-projects/bind9!10891
2025-08-26 10:13:10 +00:00
Petr Špaček
9f318b21b5 Reverse config grammar checks and docs builds
Make grammar check in CI more user friendly. Previously Sphinx docs
build might have failed because outdated grammar files and this would
have prevented CI from generating grammar file patch.
2025-08-26 10:13:00 +00:00
Ondřej Surý
492fd02409 fix: dev: Update fxhash constants
The fxhash implementation was missing a constant for 32-bit platforms.
This has been fixed.  Constant for 64-bit platform was update to match
the current Rust constants.

Merge branch 'ondrej/update-fxhash-constants' into 'main'

See merge request isc-projects/bind9!10894
2025-08-26 09:46:14 +02:00
Ondřej Surý
24ba4ba3ad
Update fxhash constants
The fxhash implementation was missing a constant for 32-bit platforms.
This has been fixed.  Constant for 64-bit platform was update to match
the current Rust constants.
2025-08-26 09:45:58 +02:00
Ondřej Surý
11bbef0eec fix: dev: Allow negative RRSIGs in the qpcache again
The previous refactoring added an assertion failure when negative RRSIG
would be added to the cache database.  As result, any query for RRSIG in
any unsigned zone would trigger that assertion failure.

Allow the negative RRSIG entries to be stored in the cache database
again as not caching these would trigger new remote fetch every time
such query would be received from a client.

Closes #5489

Merge branch '5489-allow-negative-RRSIGs-in-qpcache' into 'main'

See merge request isc-projects/bind9!10876
2025-08-26 09:40:53 +02:00
Ondřej Surý
91289eb1b0
Allow negative RRSIGs in the qpcache again
The previous refactoring added an assertion failure when negative RRSIG
would be added to the cache database.  As result, any query for RRSIG in
any unsigned zone would trigger that assertion failure.

Allow the negative RRSIG entries to be stored in the cache database
again as not caching these would trigger new remote fetch every time
such query would be received from a client.
2025-08-26 09:03:04 +02:00
Ondřej Surý
bdd59dace8
Add a test for non-existence of RRSIG in the unsigned zone
This tests that the result is NOERROR and a single SOA record is
returned.
2025-08-26 09:03:04 +02:00
Ondřej Surý
449245b059 fix: dev: Fix ISC_ROTATE_LEFTSIZE macro on MacOS"
Closes #5497

Merge branch '5497-isc_rotate_leftsize-doesn-t-work-on-macos' into 'main'

See merge request isc-projects/bind9!10892
2025-08-26 07:33:22 +02:00
Ondřej Surý
a274cf6ce6
Workaround the compile failure on macOS
The following check:

    __builtin_types_compatible_p(size_t, uint64_t)

doesn't work with default compiler on macOS.  Workaround the issue
by typing the size_t to matching unsigned int type.
2025-08-26 06:53:27 +02:00
Aydın Mercan
160bc1a198 fix: dev: switch bit rotation functions to statement expressions
Using `static inline` functions in the headers break gcov as it cannot
properly track the hits. To fix the issue, convert the expressions to
statement macros. The added static assertions will ensure integer
promotion cannot occur unlike its previous function counterpart.

Merge branch 'aydin/rotate-as-macro' into 'main'

See merge request isc-projects/bind9!10878
2025-08-25 15:08:44 +03:00
Aydın Mercan
7b7c853c07
switch bit rotation functions to statement expressions
Using `static inline` functions in the headers break gcov as it cannot
properly track the hits. To fix the issue, convert the expressions to
statement macros. The added static assertions will ensure integer
promotion cannot occur unlike its previous function counterpart.
2025-08-25 13:02:03 +03:00
Arаm Sаrgsyаn
ec1e919389 new: usr: Add a new 'servfail-until-ready' configuration option for RPZ
By default, when :iscman:`named` is started it may start answering to
queries before the response policy zones are completely loaded
and processed. This new feature gives an option to the users to
tell :iscman:`named` that incoming requests should result in SERVFAIL answer
until all the response policy zones are processed and ready. Note that if
one or more response policy zones fail to load, :iscman:`named` starts
responding to queries according to those zones that did load.

Closes #5222

Merge branch '5222-stop-sending-responses-until-rpz-is-ready' into 'main'

See merge request isc-projects/bind9!10839
2025-08-22 18:37:20 +00:00
Aram Sargsyan
924230f05a Test the new 'servfail-until-ready' option
Test whether 'servfail-until-ready yes' works by enabling slow
RPZ loading with a USDT probe activation, and checking that named
returns SERVFAIL during the initial RPZ zones processing stage.

The test requires SystemTap (stap, dtrace) to activate the USDT
probe.
2025-08-22 17:17:28 +00:00
Aram Sargsyan
5e718dd220 Implement '-T slowrpz' named testing option
When used, named processes RPZ zones slowly. Useful for system tests.
2025-08-22 16:31:17 +00:00
Aram Sargsyan
41387b8d30 Add a new 'servfail-until-ready' configuration option for RPZ
By default, when named is started it may start answering to
queries before the response policy zones are completely loaded
and processed. This new feature gives an option to the users to
tell named that incoming requests should result in SERVFAIL anwser
until all the response policy zones are procesed and ready.
2025-08-22 16:31:17 +00:00
Aram Sargsyan
88ed81e12d Add 'first_time' member to 'dns_rpz_zones_t'
During the initial configuration of named after startup, 'first_time'
is true. This is needed for implementing the new 'servfail-until-ready'
configuration option, which should take into effect only during the
initial configuration.
2025-08-22 16:31:17 +00:00
Matthijs Mekking
888b5f55a8 new: usr: Add manual mode configuration option to dnsec-policy
Add a new option ``manual-mode`` to :any:`dnssec-policy`. The intended use is that if it is enabled, it will not automatically move to the
next state transition, but instead the transition is logged. Only after manual confirmation with ``rndc dnssec -step`` the transition is made.

Closes #4606

Merge branch '4606-dnssec-policy-dry-run' into 'main'

See merge request isc-projects/bind9!10774
2025-08-21 15:18:15 +00:00
Matthijs Mekking
e4529b6308 Test manual-mode error case
If we hit an error when issuing an 'rndc dnssec -step' command, and the
keymgr runs again at a later scheduled time, we don't want to enforce
transitions.
2025-08-21 16:09:55 +02:00
Matthijs Mekking
1df76e2c24 Test manual-mode while enabling DNSSEC
Similar to previous commit.

Parametrize each test case and in case of manual-mode, execute
additional checks. First a keymgr run should not change the existing
key state (with exceptions of timing events such as moving from
RUMOURED to OMNIPRESENT, and from UNRETENTIVE to HIDDEN). Appropriate
messages must be logged.

After enforcing the next step with 'rndc dnssec -step', the key state
should be the same as if the step were to be taken automatically.
2025-08-21 16:09:55 +02:00
Matthijs Mekking
0aa5dee474 Test manual-mode with ZSK rollover
Similar to previous commit.

Parametrize each test case and in case of manual-mode, execute
additional checks. First a keymgr run should not change the existing
key state (with exceptions of timing events such as moving from
RUMOURED to OMNIPRESENT, and from UNRETENTIVE to HIDDEN). Appropriate
messages must be logged.

After enforcing the next step with 'rndc dnssec -step', the key state
should be the same as if the step were to be taken automatically.
2025-08-21 16:09:55 +02:00
Matthijs Mekking
6904e43510 Test manual-mode with KSK rollover
Similar to previous commit.

Parametrize each test case and in case of manual-mode, execute
additional checks. First a keymgr run should not change the existing
key state (with exceptions of timing events such as moving from
RUMOURED to OMNIPRESENT, and from UNRETENTIVE to HIDDEN). Appropriate
messages must be logged.

After enforcing the next step with 'rndc dnssec -step', the key state
should be the same as if the step were to be taken automatically.
2025-08-21 16:09:55 +02:00
Matthijs Mekking
e35e103d7f Test manual-mode with CSK rollover (2)
Similar to previous commit.

Parametrize each test case and in case of manual-mode, execute
additional checks. First a keymgr run should not change the existing
key state (with exceptions of timing events such as moving from
RUMOURED to OMNIPRESENT, and from UNRETENTIVE to HIDDEN). Appropriate
messages must be logged.

After enforcing the next step with 'rndc dnssec -step', the key state
should be the same as if the step were to be taken automatically.
2025-08-21 16:09:55 +02:00
Matthijs Mekking
73ecc7223e Test manual-mode with CSK rollover (1)
Similar to previous commits.

Parametrize each test case and in case of manual-mode, execute
additional checks. First a keymgr run should not change the existing
key state (with exceptions of timing events such as moving from
RUMOURED to OMNIPRESENT, and from UNRETENTIVE to HIDDEN). Appropriate
messages must be logged.

After enforcing the next step with 'rndc dnssec -step', the key state
should be the same as if the step were to be taken automatically.
2025-08-21 16:09:55 +02:00