Commit graph

15771 commits

Author SHA1 Message Date
Mark Andrews
6440743bdc RPZ canonical warning displays zone entry incorrectly
Do not insert a NUL into ip_str too early as the full value
is needed later.  Only insert the NUL immediately before
displaying just the prefix string.

(cherry picked from commit 283da99f02)
2025-09-02 23:43:40 +00:00
Michał Kępień
cae623fa69
Obsolete the "tkey-domain" statement
The "tkey-domain" statement has effectively been a no-op since commit
bd4576b3ce, which removed the only bit of
code using it: the logic implementing TKEY Mode 2 (Diffie-Hellman).

A subsequent cleanup commit, 885c132f4a,
also missed the opportunity to remove the "tkey-domain" statement
altogether.

Mark the "tkey-domain" statement as obsolete and remove all code and
documentation related to it.

(cherry picked from commit 805f1c0f65)
2025-09-01 22:34:08 +02:00
Michał Kępień
5700c77a6f Deprecate the "tkey-gssapi-credential" statement
The "tkey-gssapi-keytab" statement enables GSS-TSIG to be set up in a
simpler and more reliable way than using the "tkey-gssapi-credential"
statement and setting environment variables (e.g. KRB5_KTNAME).

Mark the "tkey-gssapi-credential" statement as deprecated to eventually
only have one method for setting up GSS-TSIG in named.  Do not mention
"tkey-gssapi-credential" in the section of the ARM on dynamic updates.

(cherry picked from commit 6de435c528)
2025-09-01 19:34:14 +00:00
Ondřej Surý
a5d7c8f7db 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.

(cherry picked from commit 9e350c1774)
2025-08-28 14:24:48 +00:00
Thomas Abraham
add7cd3640 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

(cherry picked from commit 5cfdbeba72)
2025-08-28 08:57:12 +00:00
Aram Sargsyan
369a350e04 Resolve false positive compilation warning from some GCC versions
The complier claims that 'qresult_type' may be used uninitialized,
though all the cases inside the switch either set the variable
or return from the function, and the warning is generated on a line
after the switch-case block.

Slightly modify the code to set a default value for the variable when
declaring it.

    In function 'rpz_rewrite',
        inlined from 'query_checkrpz' at query.c:7288:12,
        inlined from 'query_gotanswer' at query.c:7724:12:
    query.c:4693:14: error: 'qresult_type' may be used uninitialized [-Werror=maybe-uninitialized]
     4693 |             !dnsrps_set_p(&emsg, client, st, qtype, &rdataset,
          |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     4694 |                           qresult_type != qresult_type_recurse))
          |                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    query.c: In function 'query_gotanswer':
    query.c:4268:24: note: 'qresult_type' was declared here
     4268 |         qresult_type_t qresult_type;
          |                        ^~~~~~~~~~~~
    cc1: all warnings being treated as errors
2025-08-27 10:00:45 +00:00
Aram Sargsyan
ec2c3db702 Implement '-T slowrpz' named testing option
When used, named processes RPZ zones slowly. Useful for system tests.

(cherry picked from commit 5e718dd220)
2025-08-27 10:00:45 +00:00
Aram Sargsyan
ee29e133ac 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.

(cherry picked from commit 41387b8d30)
2025-08-27 10:00:45 +00:00
Aram Sargsyan
a7a5c79d9a 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.

(cherry picked from commit 88ed81e12d)
2025-08-27 10:00:45 +00:00
Matthijs Mekking
b022a05cad Detect if keymgr made changes
If so we also want to tickle the apex because DNSKEY/CDNSKEY/CDS
RRsets may need to be re-signed.

Note that this may be overzealous, because if state transitions
happen just because of timing events (RUMOURED -> OMNIPRESENT,
UNRETENTIVE -> HIDDEN) this would have to cause changes in the
zone DNSSEC records.

(cherry picked from commit a0dc0434e5)
2025-08-27 08:16:52 +00:00
Matthijs Mekking
c75cab3f96 Implement manual-mode for kasp
When a key retire, key generation/introduction, or a state transition
to RUMOURED/UNRETENTIVE should happen, instead they are logged.
When those logs look good, you can run 'rndc dnssec -step' to run the
keymgr and apply those steps.

(cherry picked from commit aa49850b5e)
2025-08-27 08:16:52 +00:00
Matthijs Mekking
40d2f99852 Add manual-mode config option
Add a new option 'manual-mode' to 'dnssec-policy'. The intended
use is that if it is enabled, it will not automatically move to the
next state transition (RUMOURED, UNRETENTIVE), only after manual
confirmation. The intended state transition should be logged.

(cherry picked from commit 63c5b453e0)
2025-08-27 08:16:52 +00:00
Ondřej Surý
08328a9cce
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>
(cherry picked from commit 9f7ba584cf)
2025-08-26 21:13:25 +02:00
Ondřej Surý
06e3d996c1
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>
(cherry picked from commit 982ca161c2)
2025-08-26 21:12:21 +02:00
Ondřej Surý
8f8fb10232
Use ControlStatementsExceptControlMacros for SpaceBeforeParens
> Put a space before opening parentheses only after control statement
> keywords (for/if/while...) except this option doesn’t apply to ForEach
> and If macros. This is useful in projects where ForEach/If macros are
> treated as function calls instead of control statements.

(cherry picked from commit 42496f3f4a)
2025-08-19 08:08:23 +02:00
Ondřej Surý
58791b5cfe
Add and apply InsertBraces statement
> Insert braces after control statements (if, else, for, do, and while)
> in C++ unless the control statements are inside macro definitions or
> the braces would enclose preprocessor directives.

(cherry picked from commit d051e1e8f8)
2025-08-19 08:07:41 +02:00
Mark Andrews
afb019f3f0 Use DNS_RDATACOMMON_INIT to hide branch differences
Initialization of the common members of rdata type structures varies
across branches. Standardize it by using the DNS_RDATACOMMON_INIT
macro for all types, so that new types are more likely to use it,
and hence backport more cleanly.
2025-08-15 06:22:47 +10:00
Mark Andrews
34c9dde184 Add support for parsing and displaying DSYNC rdata type
(cherry picked from commit c47615094e)
2025-08-06 13:47:33 +10:00
Mark Andrews
ce6078d2b9 Add support for parsing DSYNC scheme mnemonics
Adds dns_dsyncscheme_fromtext, dns_dsyncscheme_totext and
dns_dsyncscheme_format.  Adds type dns_dsyncscheme_t.

(cherry picked from commit 6e1311c624)
2025-08-06 13:13:34 +10:00
Alessio Podda
2705e13339 Tune min and max chunk size
Before implementing adaptive chunk sizing, it was necessary to ensure
that a chunk could hold up to 48 twigs, but the new logic will size-up
new chunks to ensure that the current allocation can succeed.

We exploit the new logic in two ways:
 - We make the minimum chunk size smaller than the old limit of 2^6,
   reducing memory consumption.
 - We make the maximum chunk size larger, as it has been observed that
   it improves resolver performance.

(cherry picked from commit d7064c9b88)
2025-08-05 12:48:19 +02:00
alessio
d21f63884a Adaptive memory allocation strategy for qp-tries
qp-tries allocate their nodes (twigs) in chunks to reduce allocator
pressure and improve memory locality. The choice of chunk size presents
a tradeoff: larger chunks benefit qp-tries with many values (as seen
in large zones and resolvers) but waste memory in smaller use cases.

Previously, our fixed chunk size of 2^10 twigs meant that even an
empty qp-trie would consume 12KB of memory, while reducing this size
would negatively impact resolver performance.

This commit implements an adaptive chunking strategy that:
 - Tracks the size of the most recently allocated chunk.
 - Doubles the chunk size for each new allocation until reaching a
   predefined maximum.

This approach effectively balances memory efficiency for small tries
while maintaining the performance benefits of larger chunk sizes for
bigger data structures.

This commit also splits the callback freeing qpmultis into two
phases, one that frees the underlying qptree, and one that reclaims
the qpmulti memory. In order to prevent races between the qpmulti
destructor and chunk garbage collection jobs, the second phase is
protected by reference counting.

(cherry picked from commit 70b1777d8a)
2025-08-05 12:48:19 +02:00
Matthijs Mekking
1936303158 Add ede for zone with rpz cname override policy
When the zone is configured with a CNAME override policy, also add the
configured EDE code.

When the zone is contains a wildcard CNAME, also add the configured
EDE code.

(cherry picked from commit 2f70a0ef12)
2025-08-05 12:13:15 +02:00
Mark Andrews
f78430bb74 validator.c:check_signer now clones val->sigrdataset
Spurious validation failures were traced back to check_signer looping
over val->sigrdataset directly.  Cloning val->sigrdataset prevents
check_signer from interacting with callers that are also looping
over val->sigrdataset.

(cherry picked from commit 8aa130f253)
2025-08-01 21:56:33 +10:00
Matthijs Mekking
03eb9aabe1 Special case refresh stale ncache data
When refreshing stale ncache data, the qctx->rdataset is NULL and
requires special processing.

(cherry picked from commit 7774f16ed5)
2025-07-23 12:12:51 +00:00
Matthijs Mekking
667d81b52b Make serve-stale refresh behave as prefetch
A serve-stale refresh is similar to a prefetch, the only difference
is when it triggers. Where a prefetch is done when an RRset is about
to expire, a serve-stale refresh is done when the RRset is already
stale.

This means that the check for the stale-refresh window needs to
move into query_stale_refresh(). We need to clear the
DNS_DBFIND_STALEENABLED option at the same places as where we clear
DNS_DBFIND_STALETIMEOUT.

Now that serve-stale refresh acts the same as prefetch, there is no
worry that the same rdataset is added to the message twice. This makes
some code obsolete, specifically where we need to clear rdatasets from
the message.

(cherry picked from commit a66b04c8d4)
2025-07-23 12:12:51 +00:00
Ondřej Surý
485aac9213
Rename 'free' variable to 'nfree' to not clash with free()
The beauty and horrors of the C - the compiler properly detects variable
shadowing, but you can freely shadow a standard function 'free()' with
variable called 'free'.  And if you reference 'free()' just as 'free'
you get the function pointer which means you can do also pointer
arithmetics, so 'free > 0' is always valid even when you delete the
local variable.

Replace the local variables 'free' with a name that doesn't shadow the
'free()' function to prevent future hard to detect bugs.

(cherry picked from commit 855960ce46)
2025-07-22 14:28:15 +02:00
Mark Andrews
e4d64a0c33 Fix find_coveringnsec in qpcache.c
dns_qp_lookup was returning ISC_R_NOTFOUND rather than DNS_R_PARTIALMATCH
when there wasn't a parent with a NSEC record in the cache.  This was
causing find_coveringnsec to fail rather than returing the covering NSEC.

(cherry picked from commit 7de4207cb6)
2025-07-21 17:46:00 +02:00
Andoni Duarte Pintado
4255d6d80a Merge tag 'v9.20.11' into bind-9.20 2025-07-16 17:20:09 +02:00
Mark Andrews
77e6b07fae Digest type GOST is also deprecated
(cherry picked from commit 125a232bfb)
2025-07-16 01:42:17 +10:00
Mark Andrews
d03d58a10f Warn about deprecated DNSKEY and DS algorithms / digest types
DNSKEY algorithms RSASHA1 and RSASHA-NSEC3-SHA1 and DS digest type
SHA1 are deprecated.  Log when these are present in primary zone
files and when generating new DNSKEYs, DS and CDS records.

(cherry picked from commit cb6903c55e)
2025-07-16 01:39:58 +10:00
Ondřej Surý
822ada5db1 When overmem, clean enough memory when adding new ADB names/entries
The purge_stale_names()/purge_stale_entries() is opportunistic even when
we are under memory pressure (overmem).  Split the opportunistic LRU
cleaning and overmem cleaning.  This makes the stale purging much
simpler as we don't have to try that hard and makes the overmem cleaning
always cleanup double the amount of the newly allocated ADB name/entry.

(cherry picked from commit eb0ffa0d5f)
2025-07-11 13:58:11 +02:00
Aram Sargsyan
6a33125d7a Log dropped or slipped responses in the query-errors category
As mentioned in the comments block before the changed code block,
the dropped or slipped responses should be logged in the query
category (or rather query-errors category as done in lib/ns/client.c),
so that requests are not silently lost.

Also fix a couple of errors/typos in the code comments.

(cherry picked from commit 27e7961479)
2025-07-10 08:57:27 +00:00
Petr Menšík
c2f37f5da4 Add few extra WANT_QUERYTRACE logs into resume_qmin
Print optionally a bit more details not passed to event in case
dns_view_findzonecut returns unexpected result. Result would be
visible later in foundevent, but found fname would be lost. Print it
into the log.

(cherry picked from commit d2c6966232)
2025-07-09 11:05:27 +10:00
Petr Mensik
5fa9008a2d Handle CNAME and DNAME in resume_min in a special way
When authoritative zone is loaded when query minimization query for the
same zone is already pending, it might receive unexpected result codes.

Normally DNS_R_CNAME would follow to query_cname after processing sent
events, but dns_view_findzonecut does not fill CNAME target into
event->foundevent. Usual lookup via query_lookup would always have that
filled.

Ideally we would restart the query with unmodified search name, if
unexpected change from recursing to local zone cut were detected. Until
dns_view_findzonecut is modified to export zone/cache source of the cut,
at least fail queries which went into unexpected state.

(cherry picked from commit 2fd3da54f9)
2025-07-09 00:56:04 +00:00
Mark Andrews
5c0057cc11 Separate out adbname flags that are hashed
There are three adbname flags that are used to identify different
types of adbname lookups when hashing rather than using multiple
hash tables.  Separate these to their own structure element as these
need to be able to be read without locking the adbname structure.

(cherry picked from commit 9158e63218)
2025-07-07 11:10:07 +10:00
Aram Sargsyan
9c7a63142d
Reset DNS_DBFIND_STALETIMEOUT in query_lookup()
If ns__query_start() is called because of a chained query (e.g.
after encountering a CNAME), a previously set DNS_DBFIND_STALETIMEOUT
flag on the query's 'dboptions' field can cause an assertion
failure if the new query's 'stalefirst' value is not true (e.g. if the
target qname is an authoritative zone for the server). Reset the
DNS_DBFIND_STALETIMEOUT flag in the query_lookup() function before
evaluating the 'stalefirst' value, and make sure to assign a fresh
value to the `stalefirst' flag instead of conditionally assigning it
only if the value is 'true'.

(cherry picked from commit 3d8bd8bbf1)
2025-07-03 13:54:41 +02:00
Mark Andrews
53738b0e5e Use clang-format-20 to update formatting
(cherry picked from commit 422b9118e8)
2025-06-25 13:32:08 +10:00
Mark Andrews
e70a976958 Preserve brackets in DNS_SLABHEADER_GETATTR macro
We need to turn off clang-format to preserve the brackets as
'attribute' can be an expression and we need it to be evaluated
first.

Similarly we need the entire result to be evaluated independent of
the adjoining code.

(cherry picked from commit 3620db5ea6)
2025-06-25 13:26:13 +10:00
Matthijs Mekking
54a68a4a97 Fix spurious missing key files log messages
This happens because old key is purged by one zone view, then the other
is freaking out about it.

Keys that are unused or being purged should not be taken into account
when verifying key files are available.

The keyring is maintained per zone. So in one zone, a key in the
keyring is being purged. The corresponding key file is removed.

The key maintenance is done for the other zone view. The key in that
keyring is not yet set to purge, but its corresponding key file is
removed. This leads to "some keys are missing" log errors.

We should not check the purge variable at this point, but the
current time and purge-keys duration.

This commit fixes this erroneous logic.

(cherry picked from commit d494698852)
2025-06-19 11:42:04 +02:00
Mark Andrews
c3c3b61da1 Add CO support to dig
Dig now support setting the EDNS CO as flag using "+coflag" /
"+nocoflag" rather than as part of +ednsflags.

(cherry picked from commit 6c28411c55)
2025-06-13 20:31:31 +10:00
Mark Andrews
8db49cc335 Allow keystore.c to compile on Solaris
keystore.c failed to compile on Solaris because NAME_MAX was
undefined.  Include 'isc/dir.h' which defines NAME_MAX for platforms
that don't define it.

(cherry picked from commit 521bf1d50f)
2025-05-30 06:37:09 +00:00
Mark Andrews
2ecac031ba Silence tainted scalar in client.c
Coverity detected that 'optlen' was not being checked in 'process_opt'.
This is actually already done when the OPT record was initially
parsed.  Add an INSIST to silence Coverity as is done in message.c.

(cherry picked from commit 72cd6e8591)
2025-05-29 07:01:00 +00:00
Ondřej Surý
1945fbc0dc
Set name for all the isc_mem context
The memory context for managers and dlz_dlopen_driver units had no name
and that was causing trouble with the statistics channel output.  Set
the name for the two memory context that were missing a proper name.

(cherry picked from commit 5d264b3329)
2025-05-29 05:45:12 +02:00
Aram Sargsyan
80a43c9241 Prepare a zone for shutting down when deleting it from a view
After b171cacf4f, a zone object can
remain in the memory for a while, until garbage collection is run.
Setting the DNS_ZONEFLG_EXITING flag should prevent the zone
maintenance function from running while it's in that state.
Otherwise, a secondary zone could initiate a zone transfer after
it had been deleted.

(cherry picked from commit 874ca5ca2f)
2025-05-28 18:30:45 +00:00
Aram Sargsyan
fa974811a9
Emit a ISC_R_CANCELED result instead of ISC_R_SHUTTINGDOWN
When request manager shuts down, it also shuts down all its ongoing
requests. Currently it calls their callback functions with a
ISC_R_SHUTTINGDOWN result code for the request. Since a request
manager can shutdown not only during named shutdown but also during
named reconfiguration, instead of sending ISC_R_SHUTTINGDOWN result
code send a ISC_R_CANCELED code to avoid confusion and errors with
the expectation that a ISC_R_SHUTTINGDOWN result code can only be
received during actual shutdown of named.

All the callback functions which are passed to either the
dns_request_create() or the dns_request_createraw() functions have
been analyzed to confirm that they can process both the
ISC_R_SHUTTINGDOWN and ISC_R_CANCELED result codes. Changes were
made where it was necessary.

(cherry picked from commit f4cd307c6b)
2025-05-28 19:18:19 +02:00
Aram Sargsyan
0d1251a2ec
Add a debug log in zone.c:refresh_callback()
The new debug message logs the request result in the SOA request
callback function.

(cherry picked from commit b07ec4f0b3)
2025-05-28 19:18:19 +02:00
Aram Sargsyan
7b46d898b6
Fix a zone refresh bug in zone.c:refresh_callback()
When the zone.c:refresh_callback() callback function is called during
a SOA request before a zone transfer, it can receive a
ISC_R_SHUTTINGDOWN result for the sent request when named is shutting
down, and in that case it just destroys the request and finishes the
ongoing transfer, without clearing the DNS_ZONEFLG_REFRESH flag of the
zone. This is alright when named is going to shutdown, but currently
the callback can get a ISC_R_SHUTTINGDOWN result also when named is
reconfigured during the ongoibg SOA request. In that case, leaving the
DNS_ZONEFLG_REFRESH flag set results in the zone never being able
to refresh again, because any new attempts will be caneled while
the flag is set. Clear the DNS_ZONEFLG_REFRESH flag on the 'exiting'
error path of the callback function.

(cherry picked from commit 228e441328)
2025-05-28 19:01:33 +02:00
Evan Hunt
11aa50ec83 correct the DbC assertions in message.c
the comments for some calls in the dns_message API specified
requirements which were not actually enforced in the functions.

in most cases, this has now been corrected by adding the missing
REQUIREs. in one case, the comment was incorrect and has been
revised.

(cherry picked from commit c437da59ee)
2025-05-27 16:44:24 -07:00
Michał Kępień
6ba6648935 Merge tag 'v9.20.9' into bind-9.20 2025-05-21 21:24:23 +02:00
Aram Sargsyan
a90e3b9e6f Implement a new 'notify-defer' configuration option
This new option sets the delay, in seconds, to wait before sending
a set of NOTIFY messages for a zone. Whenever a NOTIFY message is
ready to be sent, sending will be deferred for this duration.

(cherry picked from commit e42d6b4810)
2025-05-16 09:58:48 +00:00