2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 05:28:00 +00:00

43776 Commits

Author SHA1 Message Date
Ondřej Surý
6e2ca5e0d7
Remove the negative type logic from qpcache
Previously, when a negative header was stored in the cache, it would be
stored in the dns_typepair_t as .type = 0, .covers = <negative type>.
When searching the cache internally, we would have to look for both
positive and negative typepair and the slabheader .down list could be a
mix of positive and negative types.

Remove the extra representation of the negative type and simply use the
negative attribute on the slabheader.  Other units (namely dns_ncache)
can still insert the (0, type) negative rdatasets into the cache, but
internally, those will be converted into (type, 0) slabheaders, and vice
versa - when binding the rdatasets, the negative (type, 0) slabheader
will be converted to (0, type) rdataset.  Simple DNS_TYPEPAIR() helper
macro was added to simplify converting single rdatatype to typepair
value.

As a side-effect, the search logic in all places can exit early if
there's a negative header for the type we are looking for, f.e. when
searching for the zone cut, we don't have to walk through all the
slabheaders, if there's a stored negative slabheader.
2025-08-15 07:22:52 +02:00
Ondřej Surý
3445362918
Add dns_rdatatype_isnsec() helper function
Replace the checks for both NSEC and NSEC3 with a single helper
function.
2025-08-15 07:22:52 +02:00
Ondřej Surý
59d1326175
Use dns_rdatatype_none more consistently
Use dns_rdatatype_none instead of plain '0' for dns_rdatatype_t and
dns_typepair_t manipulation.  While plain '0' is technically ok, it
doesn't carry the required semantic meaning, and using the named
dns_rdatatype_none constant makes the code more readable.
2025-08-15 07:22:52 +02:00
Ondřej Surý
8837491697
Add strict checks on typepair values in the developer's mode
When in developer's mode, make the DNS_TYPEPAIR_* macros be more
strict on the contents of the 'base' and 'covers', so we can catch
invalid use of the API.
2025-08-15 07:22:52 +02:00
Ondřej Surý
76c027e949
Disallow TYPE0 to be queried or inserted into the database
The RR type 0 is a reserved type for SIG[1] resource record.  It should
not be ever inserted into the database nor queried.  Add a special
handling to bail out quickly with DNS_R_DISALLOWED when inserting and
ISC_R_NOTFOUND when looking up TYPE0.  This is also prerequisite for
stricter checks in the follow-up commit.

1. https://www.rfc-editor.org/rfc/rfc2535#section-4.1.8.1
2025-08-15 07:22:52 +02:00
Ondřej Surý
f7143dca3f
Fix typo in nsupdate where covers would be equal to type
There was an apparent typo where rdatalist->covers would be assigned the
same value as rdatalist->type.  As nsupdate can't update signatures, the
covers must be dns_rdatatype_none.
2025-08-15 07:22:51 +02:00
Ondřej Surý
101b1e5a57
Unify the dns_typepair_t variable naming and usage
The dns_typepair_t and dns_rdatatype_t variables were both named 'type'
in multiple places.  Rename all dns_typepair_t variables to include word
'pair' in the variable name to make sure that the distinction between
the two types is more clear.
2025-08-15 07:22:51 +02:00
Ondřej Surý
5682469a5a fix: dev: Simplify the DNS_R_UNCHANGED handling in dns_resolver unit
Instead of catching the DNS_R_UNCHANGED from dns_db_addrdataset() (via
cache_rrset() and dns_ncache_add()) individually, mask it properly as
soon as possible by moving the sigrdataset caching logic inside the
cache_rrset() and returning ISC_R_SUCCESS from cache_rrset() and
dns_ncache_add() when the database was unchanged.

Closes #5473

Merge branch '5473-fix-crash-in-validated' into 'main'

See merge request isc-projects/bind9!10850
2025-08-15 07:06:11 +02:00
Ondřej Surý
c22f156404
Simplify the DNS_R_UNCHANGED handling in dns_resolver unit
Instead of catching the DNS_R_UNCHANGED from dns_db_addrdataset() (via
cache_rrset() and dns_ncache_add()) individually, mask it properly as
soon as possible, by moving the sigrdataset caching logic inside
cache_rrset() and returning ISC_R_SUCCESS from cache_rrset() and
dns_ncache_add() when the database was unchanged.
2025-08-15 06:28:01 +02:00
Ondřej Surý
13e3c6bfe6 fix: dev: result could be set incorrectly in validated()
During a recent refactoring of `validated()`, a line was
removed, causing `result` to be left unchanged. This
caused time to be wasted continuing to try to validate when a
non-recoverable error had occurred, and also caused the wrong
reason to be logged in `add_bad()`.

Closes #5468

Merge branch '5468-fix-deadcode' into 'main'

See merge request isc-projects/bind9!10851
2025-08-15 06:25:23 +02:00
Ondřej Surý
2b269fd0a4 Always delete the cached results on broken chain
The logic to delete records from the cache was relying on the contents
of the validation answer.  Change the logic to always delete the
contents of the cache on the broken chain result.
2025-08-14 16:08:56 -07:00
Evan Hunt
70e99bb27a result could be set incorrectly in validated()
during a recent refactoring of validated(), a line was
removed, causing 'result' to be left unchanged. this
wasted time continuing to try to validate when a
non-recoverable error had occured, and caused the wrong
reason to be logged in add_bad().
2025-08-14 16:07:54 -07:00
Mark Andrews
144d8f4295 fix: dev: 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.

Closes #5467

Merge branch '5467-use-dns_rdatacommon_init-to-hide-branch-differences' into 'main'

See merge request isc-projects/bind9!10831
2025-08-15 08:07:33 +10:00
Mark Andrews
841d1647d4 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 07:30:30 +10:00
Nicki Křížek
90e50ce683 fix: ci: Update DNS Shotgun parameters for an updated dataset
We've switched to an updated dataset for shotgun jobs. The change in
underlying traffic caused the more sensitive doh-get (and partially dot)
jobs to overload the resolver, making the jobs unstable and unreliable,
due to an increased number of timeouts.

Readjust the load parameters slightly to avoid exceeding ~2 % of
timeouts in the cold cache scenario to stabilize the job results.

Merge branch 'nicki/ci-shotgun-load-new-dataset' into 'main'

See merge request isc-projects/bind9!10841
2025-08-14 20:57:03 +02:00
Nicki Křížek
338389b3eb Update DNS Shotgun parameters for an updated dataset
We've switched to an updated dataset for shotgun jobs. The change in
underlying traffic caused the more sensitive doh-get (and partially dot)
jobs to overload the resolver, making the jobs unstable and unreliable,
due to an increased number of timeouts.

Readjust the load parameters slightly to avoid exceeding ~2 % of
timeouts in the cold cache scenario to stabilize the job results.
2025-08-14 18:40:28 +02:00
Andoni Duarte
e040dded00 chg: doc: Set up version for BIND 9.21.12
Merge branch 'andoni/set-up-version-for-bind-9.21.12' into 'main'

See merge request isc-projects/bind9!10854
2025-08-14 11:14:59 +00:00
Andoni Duarte Pintado
49c68c18b9 Update BIND version to 9.21.12-dev 2025-08-14 12:28:14 +02:00
Alessio Podda
b084f8387f chg: dev: Split dbmethods into node and db vtable
All databases in the codebase follow the same structure: a database is
an associative container from DNS names to nodes, and each node is an
associative container from RR types to RR data.

Each database implementation (qpzone, qpcache, sdlz, builtin, dyndb) has
its own corresponding node type (qpznode, qpcnode, etc). However, some
code needs to work with nodes generically regardless of their specific
type - for example, to acquire locks, manage references, or
register/unregister slabs from the heap.

Before this MR, these generic node operations were implemented as methods in
a `dns_dbmethods_t` vtable. This created a coupling between the database
and node lifetimes. If a node were to outlive its parent database, the node
destructor would destroy all RR data, and each RR data destructor would
try to unregister from heaps by calling a virtual function from the
database vtable. Since the database was already freed, this would cause a
crash.

This MR breaks the coupling by standardizing the layout of all
database nodes, adding a `dns_dbnode_methods_t` vtable for node
operations, and moving node-specific methods from the database vtable to
the node vtable.

Merge branch 'alessio/dbnode-vtable' into 'main'

See merge request isc-projects/bind9!10728
2025-08-14 10:10:21 +00:00
Andoni Duarte Pintado
dc452c32d6 Update BIND version for release v9.21.11 2025-08-13 19:10:38 +02:00
Andoni Duarte
ae574efdca new: doc: Prepare documentation for BIND 9.21.11
Merge branch 'andoni/prepare-documentation-for-bind-9.21.11' into 'v9.21.11-release'

See merge request isc-private/bind9!824
2025-08-13 16:33:22 +00:00
Andoni Duarte Pintado
4829cdab26 Tweak and reword release notes 2025-08-13 17:48:16 +02:00
Andoni Duarte Pintado
f2ba8924a4 Prepare release notes for BIND 9.21.11 2025-08-12 10:38:00 +02:00
Andoni Duarte Pintado
74ac6a816d Generate changelog for BIND 9.21.11 2025-08-12 10:34:32 +02:00
Alessio Podda
a05db4196f Remove unused dns_slabheader_reset argument
As a part of the previous refactor, the db argument of
dns_slabheader_reset is now unused, and can be removed.
2025-08-07 11:39:38 -07:00
Alessio Podda
ae6a34cbda Decouple database and node lifetimes by adding node-specific vtables
All databases in the codebase follow the same structure: a database is
an associative container from DNS names to nodes, and each node is an
associative container from RR types to RR data.

Each database implementation (qpzone, qpcache, sdlz, builtin, dyndb) has
its own corresponding node type (qpznode, qpcnode, etc). However, some
code needs to work with nodes generically regardless of their specific
type - for example, to acquire locks, manage references, or
register/unregister slabs from the heap.

Currently, these generic node operations are implemented as methods in
the database vtable, which creates problematic coupling between database
and node lifetimes. If a node outlives its parent database, the node
destructor will destroy all RR data, and each RR data destructor will
try to unregister from heaps by calling a virtual function from the
database vtable. Since the database was already freed, this causes a
crash.

This commit breaks the coupling by standardizing the layout of all
database nodes, adding a dedicated vtable for node operations, and
moving node-specific methods from the database vtable to the node
vtable.
2025-08-07 11:39:38 -07:00
Alessio Podda
4a8f77e483 Refactor sdlz to use name instead of pointer to name
Right now dns_sdlzlookup has a slight difference from other dbnode
implementations in that it stores a pointer to a dns name instead of
the dns name itself.

This commit harmonizes dns_sdlzlookup with other dbnode
implementations, facilitating further refactoring.
2025-08-07 11:44:18 +02:00
Andoni Duarte
723439908a fix: ci: backtraces are not generated for core files from failed unit tests
Closes #5466

Merge branch '5466-fix-ci-backtraces-are-not-generated-for-core-files' into 'main'

See merge request isc-projects/bind9!10824
2025-08-06 12:11:02 +00:00
Andoni Duarte Pintado
e5a364c741 Add a different log file for each meson test
Each run of `meson test` overwrites the default log file testlog.txt,
this means we lose the backtraces of previous run. This commit assigns
a different log file for each run.
2025-08-06 11:09:22 +00:00
Nicki Křížek
0d344ac5fb fix: ci: Allow unit tests to fail on AlmaLinux 8
The doh unit test has been timing out recently and we don't have a fix
for it yet. Mark it as warning rather than a hard failure, since it's a
known issue.

Related #5448

Merge branch '5448-allow-failure-unit-almalinux8-doh' into 'main'

See merge request isc-projects/bind9!10835
2025-08-06 12:38:32 +02:00
Nicki Křížek
5423bae2dc Allow unit tests to fail on AlmaLinux 8
The doh unit test has been timing out recently and we don't have a fix
for it yet. Mark it as warning rather than a hard failure, since it's a
known issue.

Related #5448
2025-08-06 10:38:17 +02:00
Evan Hunt
89473898ff new: test: Update filter-aaaa test
Renamed the `filter-aaaa` system test to `filters`, converted it to python, and added test cases to exercise the `filter-a` plugin as well.

Merge branch 'each-test-filter-a' into 'main'

See merge request isc-projects/bind9!10730
2025-08-06 06:42:01 +00:00
Nicki Křížek
e49c467efb Use full path for shared test code imports in rollover tests
Previously, symlinks and relative directory imports were used in test
modules. This caused a name clash when a shared code module "common.py"
was introduced for a different test. To avoid the issue, use full paths
in imports.
2025-08-05 23:01:04 -07:00
Nicki Křížek
cbebeacec1 Split up and parametrize filters tests
Move tests which use different configuration to dedicated modules to
avoid possible interference with other tests.

Parametrize the test cases to have a dedicated test for each server
configuration.

Turn the check_filter() comments into log messages to help with
debugging.
2025-08-05 23:01:04 -07:00
Evan Hunt
28a3706ec5 rename filter-aaaa to filters
since the test now covers both plugins, the filter-aaaa name is
misleading.
2025-08-05 23:01:03 -07:00
Evan Hunt
1c5363cf99 add filter-a tests
add test cases to exercise the filter-a plugin.
2025-08-05 23:01:03 -07:00
Evan Hunt
58fe984c95 reduce code duplication in filter-aaaa test
cut down the number of identical lines in the filter-aaaa test:
- replace identical test cases with small check functions
  (check_aaaa_only, check_any, check_nodata, etc).
- group those together into large check functions (check_filter,
  check_filter_other_family) that have options for recursive and
  break_dnssec, then run those for each combination of options
  on servers connfigured with filter-aaaa-on-v4 and filter-aaaa-on-v6.
2025-08-05 23:01:03 -07:00
Evan Hunt
b234c6d954 convert filter-aaaa test to python
use pytest for the filter-aaaa test.

In order to implement this, isctest.mark can now test whether IPv6 is
configured by calling testsock6.pl.
2025-08-05 23:01:03 -07:00
Štěpán Balážik
2a078733c1 fix: test: Fix the .hypothesis directory to bin/tests/system/.hypothesis
Previously the location of the .hypothesis directory would depend on the
current working directory when running pytest.

Set the HYPOTHESIS_STORAGE_DIRECTORY explicitly.

Closes #5424

Merge branch '5424-hypothesis-artifacts' into 'main'

See merge request isc-projects/bind9!10825
2025-08-05 16:26:26 +00:00
Štěpán Balážik
a4e74ab8cd Fix the .hypothesis directory to bin/tests/system/.hypothesis
Previously the location of the .hypothesis directory would depend on the
current working directory when running pytest.

Set the HYPOTHESIS_STORAGE_DIRECTORY explicitly.
2025-08-05 16:54:13 +02:00
Ondřej Surý
4a6835b51f fix: dev: Refactor resolver cache_name() and validated() functions
These functions were excessive in length and complexity, with McCabe complexity values of 110 and 105 respectively, and also included some dead code. They have been cleaned up and split into smaller functions, with a maximum complexity of 27.  A few minor coding errors were discovered and fixed along the way.

Merge branch 'each-refactor-cache-name' into 'main'

See merge request isc-projects/bind9!10198
2025-08-05 13:27:59 +02:00
Evan Hunt
5a2938b452
refactor validated()
- there was special-case code in validated() to handle the results
  of a validator started by a CD=1 query. since that never happens,
  the code has been removed.
- the section of code that handles opportunistic caching of
  validated SOA, NS and NSEC data has been split out to a separate
  function.
- the number of goto statements has been reduced considerably.
2025-08-05 12:16:36 +02:00
Evan Hunt
9f674c43cf
split out helper functions
- fctx_setresult() sets the event result in a fetch response
  according to the rdataset being returned - DNS_R_NCACHENXDOMAIN or
  DNS_R_NXRRSET for negative responses, ISC_R_SUCCESS, DNS_R_CNAME,
  or DNS_R_DNAME for positive ones.
- cache_rrset() looks up a node and adds an rdataset.
- delete_rrset() looks up a node and removes rdatasets of a specified
  type and, optionally, the associated signatures.
- gettrust() returns the trust level of an rdataset, or dns_trust_none
  if the rdataset is NULL or not associated.
- getrrsig() scans the rdatasets associated with a name for the
  RRSIG covering a given type.
2025-08-05 12:16:36 +02:00
Evan Hunt
723d167f26
further subdivide caching functions
rctx_cacherdataset() has been split into two functions:
- rctx_cache_secure() starts validation for rdatasets
  that need it; they are then cached by the validator
  completion callback validated()
- rctx_cache_insecure() caches rdatasets immediately; it
  is called when validation is disabled or the data
  to be cached is glue.
2025-08-05 12:16:36 +02:00
Evan Hunt
ed56a91d7d
rename and refactor cache_name() and related functions
- renamed cache_message() to rctx_cachemessage()
- renamed cache_name() to rctx_cachename()
- merged ncache_message() into rctx_ncache()
- split out a new function, rctx_cacherdataset(), which is
  called by rctx_cachename() in a loop to process each of
  the rdatasets associated with the name.
2025-08-05 12:16:36 +02:00
Evan Hunt
83980d76b2
reduce code duplication around findnoqname()
every call to findnoqname() was followed by a call to
dns_rdataset_addnoqname(). we can move that call into
findnoqname() itself, and simplify the calling functions
a bit.
2025-08-05 12:16:36 +02:00
Evan Hunt
b940d40635
set ANSWERSIG flag when processing ANY responses
previously, rctx_answer_any() set the ANSWER flag for all
rdatasets in the answer section; it now sets ANSWERSIG for
RRSIG/SIG rdatasets and ANSWER for everything else.  this
error didn't cause any harm in the current code, but it
could have led to unexpected behavior in the future.
2025-08-05 12:16:36 +02:00
Evan Hunt
c23cc105a1
split out some functionality in cache_name()
there are now separate functions to check the cacheability of
an rdataset or to normalize TTLs, and the code to determine
whether validation is necessary has been simplified.
2025-08-05 12:16:36 +02:00
Evan Hunt
7841de08af
add functions to match rdataset types
- dns_rdataset_issigtype() returns true if the rdataset is
  of type RRSIG and covers a specified type
- dns_rdataset_matchestype() returns true if the rdataset
  is of the specified type *or* the RRSIG covering it.
2025-08-05 12:16:36 +02:00
Evan Hunt
51a4e00d1d
reduce steps for negative caching
whenever ncache_adderesult() was called, some preparatory code
was run first; this has now been moved into a single function
negcache() to reduce code duplication.
2025-08-05 12:16:36 +02:00