]> git.ipfire.org Git - thirdparty/bind9.git/log
thirdparty/bind9.git
13 months agoRemove -n option from dnssec-keygen/keyfromlabel
Evan Hunt [Fri, 14 Mar 2025 02:57:24 +0000 (19:57 -0700)] 
Remove -n option from dnssec-keygen/keyfromlabel

The -n (nametype) option for keys defaults to ZONE for DNSKEY
type keys, and HOST for KEY type keys. There is currently no
practical reason to use any other name type; we can simplify
things by removing the option.

13 months agoRemove -t option from dnssec-keygen/keyfromlabel
Evan Hunt [Thu, 13 Mar 2025 19:20:55 +0000 (12:20 -0700)] 
Remove -t option from dnssec-keygen/keyfromlabel

The key type flag (indicating whether a key is valid for
authentication, confidentiality, or both) is essentially
unused. By default, all DNSKEY and KEY records are valid
for both uses. Non-authenticating DNSKEY records are undefined
and meaningless, and validity checks for flags in KEY records
are sporadic at best.

We can simplify the parameters to dnssec-keygen by removing
the -t option completely.

13 months agofix: test: Limit X-Bloat header size to 100KB
Michal Nowak [Tue, 25 Mar 2025 15:52:47 +0000 (15:52 +0000)] 
fix: test: Limit X-Bloat header size to 100KB

Otherwise curl 8.13 rejects the line with:

    I:Check HTTP/1.1 keep-alive with truncated stream (21)
    curl: option --header: error encountered when reading a file
    curl: try 'curl --help' or 'curl --manual' for more information

Also, see https://github.com/curl/curl/pull/16572.

Closes #5249

Merge branch '5249-statschannel-limit-http-header-size' into 'main'

See merge request isc-projects/bind9!10319

13 months agoLimit X-Bloat header size to 100KB
Michal Nowak [Tue, 25 Mar 2025 13:14:52 +0000 (14:14 +0100)] 
Limit X-Bloat header size to 100KB

Otherwise curl 8.13 rejects the line with:

    I:Check HTTP/1.1 keep-alive with truncated stream (21)
    curl: option --header: error encountered when reading a file
    curl: try 'curl --help' or 'curl --manual' for more information

Also, see https://github.com/curl/curl/pull/16572.

13 months agorem: dev: Remove lock upgrading from the hot path in the QP cache
Ondřej Surý [Tue, 25 Mar 2025 09:58:09 +0000 (09:58 +0000)] 
rem: dev: Remove lock upgrading from the hot path in the QP cache

In QPcache, there were two places that tried to upgrade the lock.  In `clean_stale_header()`, the code would try to upgrade the lock and clean up the header, and in `qpzonode_release()`, the tree lock would be optionally upgraded, so we can clean up the node directly if empty. These
optimizations are not needed and they have no effect on the performance.

Merge branch 'ondrej/no-lock-upgrade-in-check_stale_headers' into 'main'

See merge request isc-projects/bind9!10305

13 months agoRemove lock upgrading from the hot path in the cache
Ondřej Surý [Fri, 21 Mar 2025 02:06:16 +0000 (03:06 +0100)] 
Remove lock upgrading from the hot path in the cache

In QPcache, there were two places that tried to upgrade the lock.  In
clean_stale_header(), the code would try to upgrade the lock and cleanup
the header, and in qpzonode_release(), the tree lock would be optionally
upgraded, so we can cleanup the node directly if empty.  These
optimizations are not needed and they have no effect on the performance.

13 months agofix: dev: Fix invalid cache-line padding for qpcache buckets
Ondřej Surý [Tue, 25 Mar 2025 09:56:49 +0000 (09:56 +0000)] 
fix: dev: Fix invalid cache-line padding for qpcache buckets

The isc_queue_t was missing in the calculation of the required
padding size inside the qpcache bucket structure.

Merge branch 'ondrej/qpcache-fix-invalid-padding' into 'main'

See merge request isc-projects/bind9!10306

13 months agoFix invalid cache-line padding for qpcache buckets
Ondřej Surý [Fri, 21 Mar 2025 08:29:17 +0000 (09:29 +0100)] 
Fix invalid cache-line padding for qpcache buckets

The isc_queue_t was missing in the calculation of the required
padding size inside the qpcache bucket structure.

13 months agofix: dev: Fix a bug in the ns_query's get_key() function
Arаm Sаrgsyаn [Tue, 25 Mar 2025 09:25:15 +0000 (09:25 +0000)] 
fix: dev: Fix a bug in the ns_query's get_key() function

After a refactoring in 2e6107008dae09d32e3d34fb5423b3d78c4ff651 the
dst_key_free() call is invalid and can cause an assertion. Remove the
dst_key_free() call.

Merge branch 'aram/fix-ns_query-get_key-bug' into 'main'

See merge request isc-projects/bind9!10311

13 months agoDon't call dst_key_free(keyp) on an invalid 'keyp'
Aram Sargsyan [Mon, 24 Mar 2025 16:34:00 +0000 (16:34 +0000)] 
Don't call dst_key_free(keyp) on an invalid 'keyp'

After a refactoring in 2e6107008dae09d32e3d34fb5423b3d78c4ff651 the
dst_key_free() call is invalid and can cause an assertion. Remove the
dst_key_free() call.

13 months agofix: usr: Don't enforce NOAUTH/NOCONF flags in DNSKEYs
Evan Hunt [Tue, 25 Mar 2025 06:39:07 +0000 (06:39 +0000)] 
fix: usr: Don't enforce NOAUTH/NOCONF flags in DNSKEYs

All DNSKEY keys are able to authenticate. The `DNS_KEYTYPE_NOAUTH` (and `DNS_KEYTYPE_NOCONF`) flags were defined for the KEY rdata type, and are not applicable to DNSKEY. Previously, however, because the DNSKEY implementation was built on top of KEY, the `_NOAUTH` flag prevented authentication in DNSKEYs as well. This has been corrected.

Closes #5240

Merge branch '5240-ignore-noauth-flag' into 'main'

See merge request isc-projects/bind9!10261

13 months agoDNS_KEYTYPE_NOKEY is only applicable to KEY
Mark Andrews [Tue, 25 Mar 2025 03:15:37 +0000 (14:15 +1100)] 
DNS_KEYTYPE_NOKEY is only applicable to KEY

13 months agoDon't check DNS_KEYFLAG_NOAUTH
Evan Hunt [Fri, 14 Mar 2025 00:44:49 +0000 (17:44 -0700)] 
Don't check DNS_KEYFLAG_NOAUTH

All DNSKEY keys are able to authenticate. The DNS_KEYTYPE_NOAUTH
(and DNS_KEYTYPE_NOCONF) flags were defined for the KEY rdata type,
and are not applicable to DNSKEY.

Previously, because the DNSKEY implementation was built on top of
KEY, the NOAUTH flag prevented authentication in DNSKEYs as well.
This has been corrected.

13 months agoTidy up keyvalue.h definitions
Evan Hunt [Thu, 13 Mar 2025 19:20:40 +0000 (12:20 -0700)] 
Tidy up keyvalue.h definitions

Use enums for DNS_KEYFLAG_, DNS_KEYTYPE_, DNS_KEYOWNER_, DNS_KEYALG_,
and DNS_KEYPROTO_ values.

Remove values that are never used.

Eliminate the obsolete DNS_KEYFLAG_SIGNATORYMASK. Instead, add three
more RESERVED bits for the key flag values that it covered but which
were never used.

13 months agorem: dev: Remove dns_qpmulti_lockedread declaration
Evan Hunt [Tue, 25 Mar 2025 05:58:47 +0000 (05:58 +0000)] 
rem: dev: Remove dns_qpmulti_lockedread declaration

This function was removed in 6217e434b57bd5d60ed69f792ae9a1a65a008f57 but not from the header file.

Merge branch 'matthijs-remove-unused-qpmulti-lockedread' into 'main'

See merge request isc-projects/bind9!10308

13 months agoRemove dns_qpmulti_lockedread declaration
Matthijs Mekking [Fri, 21 Mar 2025 09:20:07 +0000 (10:20 +0100)] 
Remove dns_qpmulti_lockedread declaration

This function was removed in 6217e434b57bd5d60ed69f792ae9a1a65a008f57
but not from the header file.

13 months agochg: test: Use isctest.asyncserver in the "upforwd" test 5256-add-code-to-allow-all-key-flags-to-be-set-for-testing 10313/head
Michał Kępień [Tue, 25 Mar 2025 04:06:01 +0000 (04:06 +0000)] 
chg: test: Use isctest.asyncserver in the "upforwd" test

Replace the custom DNS server used in the "upforwd" system test with new
code based on the isctest.asyncserver module.  The ans4 server currently
used in that test is a copy of bin/tests/system/ans.pl modified to
receive queries over UDP and TCP without ever responding to any of them.

Closes #5012

Merge branch '5012-upforwd-asyncserver' into 'main'

See merge request isc-projects/bind9!10283

13 months agoUse isctest.asyncserver in the "upforwd" test
Michał Kępień [Tue, 25 Mar 2025 04:01:34 +0000 (05:01 +0100)] 
Use isctest.asyncserver in the "upforwd" test

Replace the custom DNS server used in the "upforwd" system test with new
code based on the isctest.asyncserver module.  The ans4 server currently
used in that test is a copy of bin/tests/system/ans.pl modified to
receive queries over UDP and TCP without ever responding to any of them.

13 months agoAdd a response handler for ignoring all queries
Michał Kępień [Tue, 25 Mar 2025 04:01:34 +0000 (05:01 +0100)] 
Add a response handler for ignoring all queries

Dropping all incoming queries is a typical use case for a custom server
used in BIND 9 system tests.  Add a response handler implementing that
behavior so that it can be reused.

13 months agoMake response handlers global by default
Michał Kępień [Tue, 25 Mar 2025 04:01:34 +0000 (05:01 +0100)] 
Make response handlers global by default

Instead of requiring each class inheriting from ResponseHandler to
define its match() method, make the latter non-abstract and default to
returning True for all queries.  This will reduce the amount of
boilerplate code in custom servers.

13 months agochg: usr: When forwarding, query with CD=0 first
Evan Hunt [Tue, 25 Mar 2025 01:11:07 +0000 (01:11 +0000)] 
chg: usr: When forwarding, query with CD=0 first

Previously, when queries were forwarded to a remote resolver, the CD (checking disabled) bit was used, which could lead to bogus data being retrieved that might have been corrected if validation had been permitted. The CD bit is now only used as a fallback if an initial query without CD fails. See #5132.

Merge branch '5132-cd-retry' into 'main'

See merge request isc-projects/bind9!10024

13 months agowhen forwarding, try with CD=0 first
Evan Hunt [Sat, 25 Jan 2025 02:00:14 +0000 (18:00 -0800)] 
when forwarding, try with CD=0 first

when sending a query to a forwarder for a name within a secure domain,
the first query is now sent with CD=0. when the forwarder itself
is validating, this will give it a chance to detect bogus data and
replace it with valid data before answering. this reduces our chances
of being stuck with data that can't be validated.

if the forwarder returns SERVFAIL to the initial query, the query
will be repeated with CD=1, to allow for the possibility that the
forwarder's validator is faulty or that the bogus answer is covered
by an NTA.

note: previously, CD=1 was only sent when the query name was in a
secure domain. today, validating servers have a trust anchor at the
root by default, so virtually all queries are in a secure domain.
therefore, the code has been simplified.  as long as validation is
enabled, any forward query that receives a SERVFAIL response will be
retried with CD=1.

13 months agonew: usr: Add support for EDNS ZONEVERSION option
Mark Andrews [Mon, 24 Mar 2025 23:09:39 +0000 (23:09 +0000)] 
new: usr: Add support for EDNS ZONEVERSION option

`dig` and `named` can now make requests with an EDNS `ZONEVERSION` option present.

Two new `named.conf` options have been added: `request-zoneversion` and
`provide-zoneversion`.  `request-zoneversion` is `off` by default. `provide-zoneversion`
is `on` by default.

Closes #4767

Merge branch '4767-implement-zoneversion' into 'main'

See merge request isc-projects/bind9!9103

13 months agoReturn raw zone serial for inline zones
Mark Andrews [Fri, 4 Oct 2024 01:55:58 +0000 (11:55 +1000)] 
Return raw zone serial for inline zones

13 months agoDisable ZONEVERSION for built-in chaos and empty zones
Mark Andrews [Thu, 29 Aug 2024 03:15:29 +0000 (13:15 +1000)] 
Disable ZONEVERSION for built-in chaos and empty zones

13 months agoCheck that 'provide-zoneversion no;' works
Mark Andrews [Thu, 29 Aug 2024 00:09:34 +0000 (10:09 +1000)] 
Check that 'provide-zoneversion no;' works

13 months agoAdd an option to disable ZONEVERSION responses
Mark Andrews [Wed, 28 Aug 2024 23:43:21 +0000 (09:43 +1000)] 
Add an option to disable ZONEVERSION responses

The option provide-zoneversion controls whether ZONEVERSION is
returned.  This applies to primary, secondary and mirror zones.

13 months agoCheck that received ZONEVERSION is logged
Mark Andrews [Mon, 17 Jun 2024 01:38:19 +0000 (11:38 +1000)] 
Check that received ZONEVERSION is logged

13 months agoAdd option request-zoneversion
Mark Andrews [Fri, 14 Jun 2024 01:23:53 +0000 (11:23 +1000)] 
Add option request-zoneversion

This can be set at the option, view and server levels and causes
named to add an EDNS ZONEVERSION option to requests.  Replies are
logged to the 'zoneversion' category.

13 months agoAdd system tests for EDNS zoneversion
Mark Andrews [Thu, 13 Jun 2024 00:32:49 +0000 (10:32 +1000)] 
Add system tests for EDNS zoneversion

13 months agoReturn EDNS ZONEVERSION if requested
Mark Andrews [Wed, 12 Jun 2024 22:36:32 +0000 (08:36 +1000)] 
Return EDNS ZONEVERSION if requested

If there was an EDNS ZONEVERSION option in the DNS request and the
answer was from a zone, return the zone's serial and number of
labels excluding the root label with the type set to 0 (ZONE-SERIAL).

13 months agoAdd dns_zone_getzoneversion
Mark Andrews [Thu, 29 Aug 2024 01:05:09 +0000 (11:05 +1000)] 
Add dns_zone_getzoneversion

Returns the EDNS ZONEVERSION for the zone.  Return the database
specific version otherwise return a type 0 version (serial).

13 months agoAdd dns_db_getzoneversion
Mark Andrews [Thu, 29 Aug 2024 01:26:58 +0000 (11:26 +1000)] 
Add dns_db_getzoneversion

Provides a database method to return a database specific EDNS
ZONEVERSION option.  The default EDNS ZONEVERSION is serial.

13 months agoAdd EDNS ZONEVERSION option counter
Mark Andrews [Wed, 12 Jun 2024 22:13:28 +0000 (08:13 +1000)] 
Add EDNS ZONEVERSION option counter

13 months agoAdd support for EDNS ZONEVERSION to dig
Mark Andrews [Wed, 12 Jun 2024 21:53:59 +0000 (07:53 +1000)] 
Add support for EDNS ZONEVERSION to dig

This add the +[no]zoneversion option to dig which adds the
EDNS ZONEVERSION option to requests.

13 months agoExtend message code to display ZONEVERSION
Mark Andrews [Wed, 12 Jun 2024 21:34:59 +0000 (07:34 +1000)] 
Extend message code to display ZONEVERSION

13 months agoCheck EDNS ZONEVERSION when parsing OPT record
Mark Andrews [Wed, 12 Jun 2024 06:23:05 +0000 (16:23 +1000)] 
Check EDNS ZONEVERSION when parsing OPT record

13 months agofix: ci: Set more lenient respdiff limits
Michal Nowak [Mon, 24 Mar 2025 14:11:03 +0000 (14:11 +0000)] 
fix: ci: Set more lenient respdiff limits

After !9950, respdiff's maximal disagreement percentage needs to be
adjusted as target disagreements between the tested version of the
"main" branch and the reference one jumped for the respdiff,
respdiff:asan, and respdiff:tsan jobs from on average 0.07% to 0.16% and
from 0.12% to 0.17% for the respdiff-third-party job.

In !9950, we concluded setting MAX_DISAGREEMENTS_PERCENTAGE to double
the average disagreement percentage works fine in the CI.

Merge branch 'mnowak/more-lenient-respdiff-limits' into 'main'

See merge request isc-projects/bind9!10293

13 months agoSet more lenient respdiff limits
Michal Nowak [Wed, 19 Mar 2025 13:02:32 +0000 (14:02 +0100)] 
Set more lenient respdiff limits

After !9950, respdiff's maximal disagreement percentage needs to be
adjusted as target disagreements between the tested version of the
"main" branch and the reference one jumped for the respdiff,
respdiff:asan, and respdiff:tsan jobs from on average 0.07% to 0.16% and
from 0.12% to 0.17% for the respdiff-third-party job.

In !9950, we concluded setting MAX_DISAGREEMENTS_PERCENTAGE to double
the average disagreement percentage works fine in the CI.

13 months agofix: dev: Fix adbname reference
Mark Andrews [Fri, 21 Mar 2025 00:26:25 +0000 (00:26 +0000)] 
fix: dev: Fix adbname reference

Call `dns_adbname_ref` before calling `dns_resolver_createfetch` to
ensure `adbname->name` remains stable for the life of the fetch.

Closes #5239

Merge branch '5239-fix-adb-reference-counting' into 'main'

See merge request isc-projects/bind9!10290

13 months agoFix gaining adbname reference
Mark Andrews [Wed, 19 Mar 2025 02:31:35 +0000 (13:31 +1100)] 
Fix gaining adbname reference

Call dns_adbname_ref before calling dns_resolver_createfetch to
ensure adbname->name remains stable for the life of the fetch.

13 months agofix: dev: Optimize key ID check when searching for matching keys
Evan Hunt [Thu, 20 Mar 2025 18:25:05 +0000 (18:25 +0000)] 
fix: dev: Optimize key ID check when searching for matching keys

When searching through a DNSKEY or KEY rrset for the key matching a particular algorithm and ID, it's a waste of time to convert every key into a `dst_key` object; it's faster to compute the key ID from the rdata, then do the full key conversion after determining that we've found the right key. This optimization was already used in the validator, but it's been refactored for code clarity, and is now also used in query.c and message.c.

Merge branch 'each-refactor-key-search' into 'main'

See merge request isc-projects/bind9!10258

13 months agooptimize key ID check when searching for matching keys
Evan Hunt [Fri, 14 Mar 2025 23:41:47 +0000 (16:41 -0700)] 
optimize key ID check when searching for matching keys

when searching a DNSKEY or KEY rrset for the key that matches
a particular algorithm and ID, it's a waste of time to convert
every key into a dst_key object; it's faster to compute the key
ID by checksumming the region, and then only do the full key
conversion once we know we've found the correct key.

this optimization was already in use in the validator, but it's
been refactored for code clarity, and is now also used in query.c
and message.c.

13 months agomove dns_zonekey_iszonekey() to dns_dnssec module
Evan Hunt [Thu, 13 Mar 2025 20:01:47 +0000 (13:01 -0700)] 
move dns_zonekey_iszonekey() to dns_dnssec module

dns_zonekey_iszonekey() was the only function defined in the
dns_zonekey module, and was only called from one place. it
makes more sense to group this with dns_dnssec functions.

13 months agochg: dev: Switch symtab to use fxhash hashing
Alessio Podda [Thu, 20 Mar 2025 13:00:12 +0000 (13:00 +0000)] 
chg: dev: Switch symtab to use fxhash hashing

This merge request resolves some performance regressions introduced
with the change from isc_symtab_t to isc_hashmap_t.

The key improvements are:

1. Using a faster hash function than both isc_hashmap_t and
   isc_symtab_t. The previous implementation used SipHash, but the
   hashflood resistance properties of SipHash are unneeded for config
   parsing.
2. Shrinking the initial size of the isc_hashmap_t used inside
   isc_symtab_t. Symtab is mainly used for config parsing, and the
   when used that way it will have between 1 and 50 keys, but the
   previous implementation initialized a map with 128 slots.
   By initializing a smaller map, we speed up mallocs and optimize for
   the typical case of few config keys.
3. Slight optimization of the string matching in the hashmap, so that
   the tail is handled in a single load + comparison, instead of byte
   by byte.
   Of the three improvements, this is the least important.

Merge branch 'alessio/fxhash-symtab' into 'main'

See merge request isc-projects/bind9!10204

13 months agoSwitch symtab to use fxhash hashing
alessio [Thu, 27 Feb 2025 06:37:04 +0000 (07:37 +0100)] 
Switch symtab to use fxhash hashing

This merge request resolves some performance regressions introduced
with the change from isc_symtab_t to isc_hashmap_t.

The key improvements are:

1. Using a faster hash function than both isc_hashmap_t and
   isc_symtab_t. The previous implementation used SipHash, but the
   hashflood resistance properties of SipHash are unneeded for config
   parsing.
2. Shrinking the initial size of the isc_hashmap_t used inside
   isc_symtab_t. Symtab is mainly used for config parsing, and the
   when used that way it will have between 1 and ~50 keys, but the
   previous implementation initialized a map with 128 slots.
   By initializing a smaller map, we speed up mallocs and optimize for
   the typical case of few config keys.
3. Slight optimization of the string matching in the hashmap, so that
   the tail is handled in a single load + comparison, instead of byte
   by byte.
   Of the three improvements, this is the least important.

13 months agofix: usr: Fix several small DNSSEC timing issues
Matthijs Mekking [Thu, 20 Mar 2025 10:13:22 +0000 (10:13 +0000)] 
fix: usr: Fix several small DNSSEC timing issues

The following small issues related to `dnssec-policy` have been fixed:
- In some cases the key manager inside BIND 9 could run every hour, while it could have run less often.
- While `CDS` and `CDNSKEY` records will be removed correctly from the zone when the corresponding `DS` record needs to be updated, the expected timing metadata when this will happen was never set.
- There were a couple of cases where the safety intervals are added inappropriately, delaying key rollovers longer than necessary.
- If you have identical `keys` in your `dnssec-policy`, they may be retired inappropriately. Note that having keys with identical properties is discouraged in all cases.

Closes #5242

Merge branch '5242-several-keymgr-issues' into 'main'

See merge request isc-projects/bind9!10251

13 months agoUpdate Retired and Removed if we update lifetime
Matthijs Mekking [Tue, 18 Mar 2025 11:23:34 +0000 (12:23 +0100)] 
Update Retired and Removed if we update lifetime

If we are updating the lifetime, and it was not set before, also
set/update the Retired and Removed timing metadata.

13 months agoFix a key generation issue in the tests
Matthijs Mekking [Mon, 24 Feb 2025 10:36:53 +0000 (11:36 +0100)] 
Fix a key generation issue in the tests

The dnssec-keygen command for the ZSK generation for the zone
multisigner-model2.kasp was wrong (no ZSK was generated in the setup
script, but when 'named' is started, the missing ZSK was created
anyway by 'dnssec-policy'.

13 months agoFix keymgr bug wrt setting the next time
Matthijs Mekking [Tue, 4 Mar 2025 16:18:36 +0000 (17:18 +0100)] 
Fix keymgr bug wrt setting the next time

Only set the next time the keymgr should run if the value is non zero.
Otherwise we default back to one hour. This may happen if there is one
or more key with an unlimited lifetime.

13 months agokeymgr: also set DeleteCDS when setting PublishCDS
Matthijs Mekking [Tue, 4 Mar 2025 16:14:33 +0000 (17:14 +0100)] 
keymgr: also set DeleteCDS when setting PublishCDS

The keymgr never set the expected timing metadata when CDS/CDNSKEY
records for the corresponding key will be removed from the zone. This
is not troublesome, as key states dictate when this happens, but with
the new pytest we use the timing metadata to determine if the CDS and/or
CDNSKEY for the given key needs to be published.

13 months agoFix wrong usage of safety intervals in keymgr
Matthijs Mekking [Mon, 3 Mar 2025 11:07:03 +0000 (12:07 +0100)] 
Fix wrong usage of safety intervals in keymgr

There are a couple of cases where the safety intervals are added
inappropriately:

1. When setting the PublishCDS/SyncPublish timing metadata, we don't
   need to add the publish-safety value if we are calculating the time
   when the zone is completely signed for the first time. This value
   is for when the DNSKEY has been published and we add a safety
   interval before considering the DNSKEY omnipresent.

2. The retire-safety value should only be added to ZSK rollovers if
   there is an actual rollover happening, similar to adding the sign
   delay.

3. The retire-safety value should only be added to KSK rollovers if
   there is an actual rollover happening. We consider the new DS
   omnipresent a bit later, so that we are forced to keep the old DS
   a bit longer.

13 months agoFix a small keymgr bug
Matthijs Mekking [Tue, 25 Feb 2025 07:40:33 +0000 (08:40 +0100)] 
Fix a small keymgr bug

While converting the kasp system test to pytest, I encountered a small
bug in the keymgr code. We retire keys when there is more than one
key matching a 'keys' line from the dnssec-policy. But if there are
multiple identical 'keys' lines, as is the case for the test zone
'checkds-doubleksk.kasp', we retire one of the two keys that have the
same properties.

Fix this by checking if there are double matches. This is not fool proof
because there may be many keys for a few identical 'keys' lines, but it
is good enough for now. In practice it makes no sense to have a policy
that dictates multiple keys with identical properties.

13 months agofix: usr: Fix write after free in validator code
Mark Andrews [Thu, 20 Mar 2025 01:30:11 +0000 (01:30 +0000)] 
fix: usr: Fix write after free in validator code

Raw integer pointers were being used for the validator's nvalidations
and nfails values but the memory holding them could be freed before
they ceased to be used.  Use reference counted counters instead.

Closes #5239

Merge branch '5239-use-counter-for-nvalidations-and-nfailss' into 'main'

See merge request isc-projects/bind9!10248

13 months agoUse reference counted counters for nfail and nvalidations
Mark Andrews [Fri, 14 Mar 2025 04:23:43 +0000 (15:23 +1100)] 
Use reference counted counters for nfail and nvalidations

The fetch context that held these values could be freed while there
were still active pointers to the memory.  Using a reference counted
pointer avoids this.

13 months agoMerge tag 'v9.21.6'
Andoni Duarte Pintado [Wed, 19 Mar 2025 16:36:14 +0000 (17:36 +0100)] 
Merge tag 'v9.21.6'

13 months agofix: test: Fix the log-report-channel zones check
Michal Nowak [Wed, 19 Mar 2025 08:00:42 +0000 (08:00 +0000)] 
fix: test: Fix the log-report-channel zones check

The check looks for logs that are not present, fails to make the
possible failure visible, and fails to bump the check enumerator:

    I:checking that log-report-channel zones fail if '*._er/TXT' is missing (129)
    grep: test.out4.129: No such file or directory
    grep: test.out4.129: No such file or directory
    I:checking that raw zone with bad class is handled (129)

The issue appeared in #3659.

Merge branch 'mnowak/checkzone-test-fix' into 'main'

See merge request isc-projects/bind9!10286

13 months agoFix the log-report-channel zones check
Michal Nowak [Tue, 18 Mar 2025 15:10:49 +0000 (16:10 +0100)] 
Fix the log-report-channel zones check

The check looks for logs that are not present, fails to make the
possible failure visible, and fails to bump the check enumerator:

    I:checking that log-report-channel zones fail if '*._er/TXT' is missing (129)
    grep: test.out4.129: No such file or directory
    grep: test.out4.129: No such file or directory
    I:checking that raw zone with bad class is handled (129)

13 months agofix: test: Fix failing grep invocation on OpenBSD
Mark Andrews [Wed, 19 Mar 2025 00:04:39 +0000 (00:04 +0000)] 
fix: test: Fix failing grep invocation on OpenBSD

Lines starting with A or NSEC are expected but not matched with the
OpenBSD grep. Extended regular expressions with direct use of
parentheses and the pipe symbol is more appropriate.

    I:checking RRSIG query from cache (154)
    I:failed

The issue appeared in #4805.

Merge branch 'mnowak/openbsd-grep-fix' into 'main'

See merge request isc-projects/bind9!10285

13 months agoFix failing grep invocation on OpenBSD
Michal Nowak [Tue, 18 Mar 2025 15:00:53 +0000 (16:00 +0100)] 
Fix failing grep invocation on OpenBSD

Lines starting with A or NSEC are expected but not matched with the
OpenBSD grep. Extended regular expressions with direct use of
parentheses and the pipe symbol is more appropriate.

    I:checking RRSIG query from cache (154)
    I:failed

13 months agofix: usr: Fix resolver statistics counters for timed out responses
Arаm Sаrgsyаn [Tue, 18 Mar 2025 17:05:23 +0000 (17:05 +0000)] 
fix: usr: Fix resolver statistics counters for timed out responses

When query responses timed out, the resolver could incorrectly increase the regular responses counters, even if no response was received. This has been fixed.

Closes #5193

Merge branch '5193-resolver-statistics-counters-fix' into 'main'

See merge request isc-projects/bind9!10227

13 months agoTest resolver statistics when responses time out
Aram Sargsyan [Thu, 6 Mar 2025 14:37:09 +0000 (14:37 +0000)] 
Test resolver statistics when responses time out

Add a test to check that the timed out responses do not skew the
normal responses statistics counters, and that they do update the
timeouts counter.

13 months agoFix the resolvers RTT-ranged responses statistics counters
Aram Sargsyan [Thu, 6 Mar 2025 14:28:48 +0000 (14:28 +0000)] 
Fix the resolvers RTT-ranged responses statistics counters

When a response times out the fctx_cancelquery() function
incorrectly calculates it in the 'dns_resstatscounter_queryrtt5'
counter (i.e. >=1600 ms). To avoid this, the rctx_timedout()
function should make sure that 'rctx->finish' is NULL. And in order
to adjust the RTT values for the timed out server, 'rctx->no_response'
should be true. Update the rctx_timedout() function to make those
changes.

13 months agoFix resolver responses statistics counter
Aram Sargsyan [Thu, 6 Mar 2025 14:26:23 +0000 (14:26 +0000)] 
Fix resolver responses statistics counter

The resquery_response() function increases the response counter without
checking if the response was successful. Increase the counter only when
the result indicates success.

13 months agochg: test: asyncserver.py: TCP improvements
Michał Kępień [Tue, 18 Mar 2025 15:30:35 +0000 (15:30 +0000)] 
chg: test: asyncserver.py: TCP improvements

This branch started off as `michal/upforwd-asyncserver`.  It quickly
turned out that the critical `asyncserver.py` change that was needed for
the `upforwd` system test was for the server to be able to read multiple
TCP queries on a single connection.  As currently present in `main`,
`asyncserver.py` closes every client connection after servicing a single
query.  Retaining that behavior would cause the `upforwd` system test to
fail and, in general, capturing all data sent by a client seems more
useful in tests than just closing connections quickly.  `asyncserver.py`
can always be extended in the future (e.g. by adding a new
`ResponseAction` that the networking code would react to) to reinstate
the original behavior, if it turns out to be necessary.

While working on changing that particular `asyncserver.py` behavior, I
noticed a couple of other deficiencies in the TCP connection handling
code, so I started addressing them.  One thing led to another and before
I noticed, enough changes were applied to be worth doing a separate
merge request, particularly given that the actual rewrite of
`upforwd/ans4/ans.pl` using `asyncserver.py` is trivial once the
required changes to `asyncserver.py` itself are applied.

Merge branch 'michal/asyncserver-tcp-improvements' into 'main'

See merge request isc-projects/bind9!10276

13 months agoHandle queries indefinitely on each TCP connection
Michał Kępień [Tue, 18 Mar 2025 15:28:18 +0000 (16:28 +0100)] 
Handle queries indefinitely on each TCP connection

Instead of closing every incoming TCP connection after handling a single
query, continue receiving queries on each TCP connection until the
client disconnects itself.  When coupled with response dropping, this
enables silently receiving all incoming data, simulating an unresponsive
server.

13 months agoEnable receiving chunked TCP DNS messages
Michał Kępień [Tue, 18 Mar 2025 15:28:18 +0000 (16:28 +0100)] 
Enable receiving chunked TCP DNS messages

A TCP DNS client may send its queries in chunks, causing
StreamReader.read() to return less data than previously declared by the
client as the DNS message length; even the two-octet DNS message length
itself may be split up into two single-octet transmissions.  Sending
data in chunks is valid client behavior that should not be treated as an
error.  Add a new helper method for reading TCP data in a loop, properly
distinguishing between chunked queries and client disconnections.  Use
the new method for reading all TCP data from clients.

13 months agoExtend TCP logging
Michał Kępień [Tue, 18 Mar 2025 15:28:18 +0000 (16:28 +0100)] 
Extend TCP logging

Emit more log messages from TCP connection handling code and extend
existing ones to improve debuggability of servers using asyncserver.py.

13 months agoHandle connection resets during reading
Michał Kępień [Tue, 18 Mar 2025 15:28:18 +0000 (16:28 +0100)] 
Handle connection resets during reading

A TCP peer may reset the connection at any point, but asyncserver.py
currently only handles connection resets when it is sending data to the
client.  Handle connection resets during reading in the same way.

13 months agoRefactor AsyncDnsServer._handle_tcp()
Michał Kępień [Tue, 18 Mar 2025 15:28:18 +0000 (16:28 +0100)] 
Refactor AsyncDnsServer._handle_tcp()

Split up AsyncDnsServer._handle_tcp() into a set of smaller methods to
improve code readability.

13 months agoGracefully handle TCP client disconnections
Michał Kępień [Tue, 18 Mar 2025 15:28:18 +0000 (16:28 +0100)] 
Gracefully handle TCP client disconnections

Prevent premature client disconnections during reading from triggering
unhandled exceptions in TCP connection handling code.

13 months agoSimplify peer address formatting
Michał Kępień [Tue, 18 Mar 2025 15:28:18 +0000 (16:28 +0100)] 
Simplify peer address formatting

Add a helper class, Peer, which holds the <host, port> tuple of a
connection endpoint and gets pretty-printed when formatted as a string.
This enables passing instances of this new class directly to logging
functions, eliminating the need for the AsyncDnsServer._format_peer()
helper method.

13 months agochg: ci: Allow re-run of the shotgun jobs to reduce false positives
Nicki Křížek [Tue, 18 Mar 2025 09:29:10 +0000 (09:29 +0000)] 
chg: ci: Allow re-run of the shotgun jobs to reduce false positives

The false positive rate is about 10-20 % when evaluating shotgun results
from a single run. Attempt to reduce the false positive rate by allowing
a re-run of failed jobs.

Merge branch 'nicki/ci-shotgun-reduce-false-positives' into 'main'

See merge request isc-projects/bind9!10271

13 months agoAllow re-run of the shotgun jobs to reduce false positive
Nicki Křížek [Wed, 12 Mar 2025 16:24:05 +0000 (17:24 +0100)] 
Allow re-run of the shotgun jobs to reduce false positive

The false positive rate is about 10-20 % when evaluating shotgun results
from a single run. Attempt to reduce the false positive rate by allowing
a re-run of failed jobs.

While there is a slight risk that barely noticable decreases in
performance might slip by more easily in MRs, they'd still likely pop up
during nightly or pre-release testing.

Also increase the tolerance threshold for DoH latency comparisons, as
those tests often experience increased jitter in the tail end latencies.

13 months agoAdjust the load factor for shotgun:tcp test
Nicki Křížek [Wed, 12 Mar 2025 16:03:50 +0000 (17:03 +0100)] 
Adjust the load factor for shotgun:tcp test

With the slightly decreased load for the TCP test, the results appear to
be a little bit more stable.

13 months agochg: test: Use isctest.asyncserver in the "qmin" test
Michał Kępień [Tue, 18 Mar 2025 05:55:17 +0000 (05:55 +0000)] 
chg: test: Use isctest.asyncserver in the "qmin" test

Replace custom DNS servers used in the "qmin" system test with new code
based on the isctest.asyncserver module.  The revised code employs zone
files and a limited amount of custom logic, which massively improves
test readability and maintainability, extends logging, and fixes
non-compliant replies sent by some of the custom servers in response to
certain queries (e.g. AA=0 in authoritative empty non-terminal
responses, non-glue address records in ADDITIONAL section).

Merge branch 'michal/qmin-asyncserver' into 'main'

See merge request isc-projects/bind9!10195

13 months agoBroaden vulture exclude glob for ans.py servers
Michał Kępień [Tue, 18 Mar 2025 05:19:01 +0000 (06:19 +0100)] 
Broaden vulture exclude glob for ans.py servers

The vulture tool seems to be unable to follow how the parent classes
defined in bin/tests/system/qmin/qmin_ans.py use mandatory properties
specified by child classes in bin/tests/system/qmin/ans*/ans.py.  Make
the tool ignore not just ans.py servers, but also *_ans.py utility
modules above the ansX/ subdirectories to prevent false positives about
unused code from causing CI pipeline failures.

13 months agoIgnore .hypothesis files created by system tests
Michał Kępień [Tue, 18 Mar 2025 05:19:01 +0000 (06:19 +0100)] 
Ignore .hypothesis files created by system tests

Some versions of the Hypothesis Python library - notably the one
included in stock OS repositories for Ubuntu 20.04 Focal Fossa - cause a
.hypothesis file to be created in a Python script's working directory
when the hypothesis module is present in its import chain.  Ignore such
files by adding them to the list of expected test artifacts to prevent
pytest teardown checks from failing due to these files appearing in the
file system after running system tests.

13 months agoFix PYTHONPATH set for ans.py servers by start.pl
Michał Kępień [Tue, 18 Mar 2025 05:19:01 +0000 (06:19 +0100)] 
Fix PYTHONPATH set for ans.py servers by start.pl

Commit 6c010a5644324947c8c13b5600cd8d988ae7684f caused the PYTHONPATH
environment variable to be set for ans.py servers started using
start.pl.  However, no system test has actually used the new
isctest.asyncserver module since that change was applied, so it has not
been noticed until now that including the source directory in PYTHONPATH
is only sufficient for in-tree builds.  Include the build directory
instead of the source directory in the PYTHONPATH environment variable
set for ans.py servers started by start.pl so that they work correctly
for both in-tree and out-of-tree builds.

13 months agoUse isctest.asyncserver in the "qmin" test
Michał Kępień [Tue, 18 Mar 2025 05:19:01 +0000 (06:19 +0100)] 
Use isctest.asyncserver in the "qmin" test

Replace custom DNS servers used in the "qmin" system test with new code
based on the isctest.asyncserver module.  The revised code employs zone
files and a limited amount of custom logic, which massively improves
test readability and maintainability, extends logging, and fixes
non-compliant replies sent by some of the custom servers in response to
certain queries (e.g. AA=0 in authoritative empty non-terminal
responses, non-glue address records in ADDITIONAL section).

13 months agorem: dev: Cleanup BIND 8 compatibility code
Ondřej Surý [Tue, 18 Mar 2025 00:12:31 +0000 (00:12 +0000)] 
rem: dev: Cleanup BIND 8 compatibility code

There was some code in dns_resolver unit meant to keep compatibility with BIND 8 breaking the DNS protocol.  These should not be needed anymore.

Merge branch 'ondrej/resolver-bind-8-cleanup' into 'main'

See merge request isc-projects/bind9!10270

13 months agoRemove a kludge to process non-authoritative CNAME response
Ondřej Surý [Mon, 17 Mar 2025 15:31:14 +0000 (16:31 +0100)] 
Remove a kludge to process non-authoritative CNAME response

A BIND 8 server could return a non-authoritative answer when a CNAME is
followed.  This is no longer handled as a valid answer.

13 months agoRemove the kludges for records in the bad sections
Ondřej Surý [Mon, 17 Mar 2025 14:27:38 +0000 (15:27 +0100)] 
Remove the kludges for records in the bad sections

There were kludges to help process responses from authoritative servers
giving RRs in wrong sections (mentioning BIND 8).  These should just go
away and such responses should not be processed.

13 months agoSmall cleanup in dns_adb unit
Ondřej Surý [Mon, 17 Mar 2025 14:23:00 +0000 (15:23 +0100)] 
Small cleanup in dns_adb unit

13 months agochg: ci: Disable linkcheck on dl.acm.org
Michal Nowak [Mon, 17 Mar 2025 17:07:40 +0000 (17:07 +0000)] 
chg: ci: Disable linkcheck on dl.acm.org

The check fails with the following error for some time:

    403 Client Error: Forbidden for url: https://dl.acm.org/doi/10.1145/1315245.1315298

Merge branch 'mnowak/linkcheck-disable-dl-acm-org' into 'main'

See merge request isc-projects/bind9!10272

13 months agoDisable linkcheck on dl.acm.org
Michal Nowak [Mon, 17 Mar 2025 16:39:36 +0000 (17:39 +0100)] 
Disable linkcheck on dl.acm.org

The check fails with the following error for some time:

    403 Client Error: Forbidden for url: https://dl.acm.org/doi/10.1145/1315245.1315298

13 months agonew: dev: Implement -T cookiealwaysvalid
Arаm Sаrgsyаn [Mon, 17 Mar 2025 11:36:57 +0000 (11:36 +0000)] 
new: dev: Implement -T cookiealwaysvalid

When `-T cookiealwaysvalid` is passed to `named`, DNS cookie checks for
the incoming queries always pass, given they are structurally correct.

Merge branch 'aram/new-named-minus-T-option-of-cookiealwaysvalid' into 'main'

See merge request isc-projects/bind9!10232

13 months agoTest -T cookiealwaysvalid
Aram Sargsyan [Tue, 11 Mar 2025 14:29:22 +0000 (14:29 +0000)] 
Test -T cookiealwaysvalid

Add a check in the "cookie" system test to make sure that the new
'-T cookiealwaysvalid' option works.

13 months agoImplement -T cookiealwaysvalid
Aram Sargsyan [Tue, 11 Mar 2025 14:03:56 +0000 (14:03 +0000)] 
Implement -T cookiealwaysvalid

When -T cookiealwaysvalid is passed to named, DNS cookie checks for
the incoming queries always pass, given they are structurally correct.

13 months agofix: dev: Add missing locks when returning addresses
Mark Andrews [Sat, 15 Mar 2025 06:04:34 +0000 (06:04 +0000)] 
fix: dev: Add missing locks when returning addresses

Add missing locks in dns_zone_getxfrsource4 et al.  Addresses CID 468706, 468708, 468741, 468742, 468785, and 468778.

Cleanup dns_zone_setxfrsource4 et al to now return void.

Remove double copies with dns_zone_getprimaryaddr and dns_zone_getsourceaddr.

Closes #4933

Merge branch '4933-add-missing-locks-when-returning-addresses' into 'main'

See merge request isc-projects/bind9!9485

13 months agoAdd missing locks when returning addresses
Mark Andrews [Thu, 12 Sep 2024 02:54:25 +0000 (12:54 +1000)] 
Add missing locks when returning addresses

Add missing locks in dns_zone_getxfrsource4 et al. Addresses CID
468706, 468708, 468741, 468742, 468785 and 468778.

Cleanup dns_zone_setxfrsource4 et al to now return void.

Remove double copies with dns_zone_getprimaryaddr and dns_zone_getsourceaddr.

13 months agofix: nil: Add new convenience functions to classify rdata types
Evan Hunt [Sat, 15 Mar 2025 01:26:35 +0000 (01:26 +0000)] 
fix: nil: Add new convenience functions to classify rdata types

- `dns_rdatatype_ismulti()` returns true if a given type can have
  multiple answers: ANY, RRSIG, or SIG.
- `dns_rdatatype_issig()` returns true for a signature: RRSIG or SIG.
- `dns_rdatatype_isaddr()` returns true for an address: A or AAAA.
- `dns_rdatatype_isalias()` returns true for an alias: CNAME or DNAME.

Code has been modified to use these functions where applicable.

These and all similar functions (e.g., `dns_rdatatype_ismeta()`, `dns_rdatatype_issingleton()`, etc) are now `static inline` functions defined in `rdata.h`.

Merge branch 'each-rdatatype-functions' into 'main'

See merge request isc-projects/bind9!10216

13 months agouse new dns_rdatatype classification functions
Evan Hunt [Tue, 4 Mar 2025 23:51:49 +0000 (15:51 -0800)] 
use new dns_rdatatype classification functions

modify code to use dns_rdatatype_ismulti(), dns_rdatatype_issig(),
dns_rdatatype_isaddr(), and dns_rdatatype_isalias() where applicable.

13 months agoconvert rdatatype classification routines to inline
Evan Hunt [Wed, 5 Mar 2025 00:21:50 +0000 (16:21 -0800)] 
convert rdatatype classification routines to inline

turn the dns_rdatatype_is*() functions into static inline
functions in rdata.h.

13 months agoadd new functions to classify rdata types
Evan Hunt [Tue, 4 Mar 2025 23:51:49 +0000 (15:51 -0800)] 
add new functions to classify rdata types

- dns_rdatatype_ismulti() returns true if a given type can have
  multiple answers: ANY, RRSIG, or SIG.
- dns_rdatatype_issig() returns true for a signature: RRSIG or SIG.
- dns_rdatatype_isaddr() returns true for an address: A or AAAA.
- dns_rdatatype_isalias() returns true for an alias: CNAME or DNAME.

13 months agofix: dev: step() could ignore rollbacks
Evan Hunt [Fri, 14 Mar 2025 23:19:36 +0000 (23:19 +0000)] 
fix: dev: step() could ignore rollbacks

The `step()` function (used for stepping to the prececessor or successor of a database node) could overlook a node if there was an rdataset that was marked IGNORE because it had been rolled back, covering an active rdataset under it.

Closes #5170

Merge branch '5170-step-ignores-rollback' into 'main'

See merge request isc-projects/bind9!10103

13 months agoadd a unit test with an empty node
Evan Hunt [Wed, 5 Mar 2025 23:46:17 +0000 (15:46 -0800)] 
add a unit test with an empty node

the db_test unit test now looks up an empty nonterminal node
to exercise the behavior of the step() function in qpzone.

13 months agoadd a unit test to check database rollback
Evan Hunt [Wed, 5 Mar 2025 04:21:04 +0000 (20:21 -0800)] 
add a unit test to check database rollback

check that a database rollback works and the correct
(original) data is found on lookup.

13 months agoqpzone.c:step() could ignore rollbacks
Evan Hunt [Sat, 15 Feb 2025 05:42:34 +0000 (21:42 -0800)] 
qpzone.c:step() could ignore rollbacks

the step() function (used for stepping to the prececessor or
successor of a database node) could overlook a node because
there was an rdataset marked IGNORE because it had been rolled
back, covering an active rdataset under it.

13 months agofix: dev: Fix handling of revoked keys
Evan Hunt [Fri, 14 Mar 2025 22:26:36 +0000 (22:26 +0000)] 
fix: dev: Fix handling of revoked keys

When a key is revoked, its key ID changes due to the inclusion of the "revoked" flag. A collision between this changed key ID
and an unrelated public-only key could cause a crash in `dnssec-signzone`.

Closes #5231

Merge branch '5231-fix-keyid-collision' into 'main'

See merge request isc-projects/bind9!10233