Commit graph

44966 commits

Author SHA1 Message Date
Štěpán Balážik
df0be6b4bd Fix some 'Formatting a regular string which could be an f-string' errors
Generated with:
ruff check --select UP031,UP032 --fix --unsafe-fixes && black .
2026-02-20 15:17:31 +01:00
Štěpán Balážik
b7000ba9b0 Add a small config for the ruff tool
It will be used for automated refactors of Python code.
2026-02-20 15:17:31 +01:00
Štěpán Balážik
601fc1f1cf Centralize Python tooling configuration in pyproject.toml
This allows easy running of the tools from the project root both in CI
and locally.
2026-02-20 15:17:31 +01:00
Štěpán Balážik
4253d7298c Fix 'Import should be placed at the top of the module'
In preparation for running pylint on more Python code.
2026-02-20 15:17:31 +01:00
Štěpán Balážik
38a47d9f7c Fix 'Using open without explicitly specifying an encoding'
In preparation for running pylint on more code.
2026-02-20 15:17:31 +01:00
Štěpán Balážik
d0079b5722 Use relative imports and __init__.py in the statschannel test
This is in preparation for automatic import sorting.
2026-02-20 15:17:31 +01:00
Štěpán Balážik
4684c9c091 Issue errors on re.compile only when isctest is imported
This is in preparation of running pylint on more parts of the codebase.
2026-02-20 15:17:31 +01:00
Štěpán Balážik
407df9599c Run custom servers as Python modules
Use `python -m` for running the custom servers.

This allows the use of relative imports in the server modules and in
turn linting the modules.
2026-02-20 15:17:31 +01:00
Ondřej Surý
b3d13387f6 chg: usr: Optimize the TCP source port selection on Linux
Enable a socket option on the outgoing TCP sockets to allow faster selection of the source <address,port> tuple for different destination <address,port> tuples when nearing over 70-80% of the source port utilization.

Merge branch 'improve-selection-of-outgoing-TCP-port' into 'main'

See merge request isc-projects/bind9!11569
2026-02-20 14:07:13 +01:00
Ondřej Surý
295139f8ca
Rename isc_net_getudpportrange() to isc_net_getportrange()
This better reflects the true nature of the function as we are reading
the ephemeral port range which is not related to UDP at all.
2026-02-20 14:06:23 +01:00
Ondřej Surý
04c81b55d2
Implement IP_LOCAL_PORT_RANGE socket option for Linux
For Linux >= 6.8:

Since 2023, Linux has introduced a change to the IP_LOCAL_PORT_RANGE
socket option that eliminates the need for the random window
shifting (implemented as a fallback in the next commit).

By setting IP_LOCAL_PORT_RANGE option, we tell the kernel to use better
approach to the source port selection.

For Linux << 6.8:

This implement selecting port by random shifting range leveraging the
IP_LOCAL_PORT_RANGE socket option.  The network manager is initialized
with the ephemeral port range (on startup and on reconfig) and then for
every outgoing TCP connection, we define a custom port range (1000
ports) and then randomly shift the custom range within the system range.

This helps the kernel to reduce the search space to the custom window
between <random_offset, random_offset + 1000>.

Reference:
https://blog.cloudflare.com/linux-transport-protocol-port-selection-performance/#kernel
2026-02-20 14:06:23 +01:00
Ondřej Surý
2c48fcaeed
Improve the source port selection on Linux
Since 2015, Linux has introduced a new socket option to overcome TCP
limitations: When an application needs to force a source IP on an active
TCP socket it has to use bind(IP, port=x).  As most applications do not
want to deal with already used ports, x is often set to 0, meaning the
kernel is in charge to find an available port.  But kernel does not know
yet if this socket is going to be a listener or be connected. This
IP_BIND_ADDRESS_NO_PORT socket option ask the kernel to ignore the 0
port provided by application in bind(IP, port=0) and only remember the
given IP address. The port will be automatically chosen at connect()
time, in a way that allows sharing a source port as long as the 4-tuples
are unique.

Enable IP_BIND_ADDRESS_NO_PORT on the outgoing TCP sockets to overcome
this TCP limitation.
2026-02-20 14:06:23 +01:00
Ondřej Surý
c3ec414d88
Remove return value from isc_net_getudpportrange()
The function was already marked as never failing, always returning
ISC_R_SUCCESS, so there was a lot of dead code around checking whether
the result would be ISC_R_SUCCESS.  This has been cleaned up.
2026-02-20 14:06:23 +01:00
Ondřej Surý
254d41f733 fix: usr: Fix read UAF in BIND9 dns_client_resolve() via DNAME Response
An attacker controlling a malicious DNS server returns a DNAME record,
and the we stores a pointer to resp->foundname, frees the response
structure, then uses the dangling pointer in dns_name_fullcompare()
possibly causing invalid match.  Only the `delv`is affected.  This has
been fixed.

Closes #5728

Merge branch '5728-heap-uaf-in-bind9-dns_client_resolve-via-dname-response' into 'main'

See merge request isc-projects/bind9!11570
2026-02-20 12:51:41 +01:00
Ondřej Surý
9135b71a7a
Fix read UAF in BIND9 dns_client_resolve() via DNAME Response
An attacker controlling a malicious DNS server returns a DNAME record,
and the we stores a pointer to resp->foundname, frees the response
structure, then uses the dangling pointer in dns_name_fullcompare()
possibly causing invalid match.  Only the `delv`is affected.  This has
been fixed.
2026-02-20 11:58:13 +01:00
Andoni Duarte
68826a9f6c fix: ci: Fix the update-stable-tag job
Fix the `update-stable-tag` job, necessary for updating Read the Docs.

Merge branch 'andoni/fix-update-stable-branch-for-rtd-job' into 'main'

See merge request isc-projects/bind9!11559
2026-02-19 19:56:23 +00:00
Andoni Duarte Pintado
81b71d5aa6 Fix CI stable branch update job bug
The update script clones a fresh copy each time, if more than one
invocation is needed intermediate copies need to be removed.
2026-02-19 14:14:06 +00:00
Ondřej Surý
d72b5fd5f6 fix: usr: Fix errors when retrying over TCP in notify_send_toaddr
If the source address is not available do not attempt
to retry over TCP otherwise clear the TSIG key from the
message prior to retrying.

Closes #5457

Merge branch '5457-remove-tcp-retry-in-notify-send-toaddr' into 'main'

See merge request isc-projects/bind9!10805
2026-02-19 13:47:03 +01:00
Mark Andrews
f99d7f4217
Check notify with bad notify source address and tsig
named was asserting when the notify source address was not available
and TSIG was being used.  Check this scenario by adding a nameserver
to the zone which is configured to uses a non-existent source address
and a blackholed destination address and a TSIG using a server clause
for that destination address.
2026-02-19 13:44:33 +01:00
Ondřej Surý
5a5bc6de22
Don't retry notify over TCP if it could not successed
Prevent retrying the notify over TCP in case the source address is not
available or the source vs the destination address family mismatch or
when the destination address has been blackholed.  Properly log the
hard notify failures.
2026-02-19 13:44:28 +01:00
Ondřej Surý
ee3391a146
Fix assertion failure when sending notify fails over UDP
When dns_request_create() fails in notify_send_toaddr() the TSIG key was
not cleared when retrying over TCP causing assertion failure.  Set the
TSIG key to NULL in the dns_message to prevent the assertion failure.
2026-02-19 13:44:23 +01:00
Mark Andrews
ce954f1ded fix: dev: Return FORMERR for ECS family 0
RFC 7871 only defines family 1 (IPv4) and 2 (IPv6). Additionally
it requires FORMERR to be returned for all unknown families.

Merge branch 'marka-formerr-family-0' into 'main'

See merge request isc-projects/bind9!11563
2026-02-19 20:47:54 +11:00
Mark Andrews
757e503536 Return FORMERR for ECS family 0
RFC 7871 only defines family 1 (IPv4) and 2 (IPv6). Additionally
it requires FORMERR to be returned for all unknown families.
2026-02-19 13:17:19 +11:00
Petr Špaček
efadf228b1 chg: ci: cross-version-config-tests should hard fail again
Merge branch 'reenable-cross-version-tests' into 'main'

See merge request isc-projects/bind9!11560
2026-02-18 15:20:14 +00:00
Petr Špaček
ae657429f6 Cross-version-config-tests should hard fail again
New tag was released so we can now re-enable check disabled in
093bef9211.
2026-02-18 15:19:28 +00:00
Ondřej Surý
aa546d5155 chg: nil: Remove dns_rdataslab_merge() and friends
After the split to dns_rdataslab and dns_rdatavec, the
dns_rdataslab_merge() function was unused and it suffered from the same
data race as fixed in the previous commit.  Instead of fixing it, just
remove the function and bunch of other unused functions from the
dns_rdataslab unit.

Merge branch 'ondrej/cleanup-dns_rdataslab' into 'main'

See merge request isc-projects/bind9!11376
2026-02-18 15:08:08 +01:00
Ondřej Surý
b8e07a0b5a
Use offsetof() instead of pointer arithmetics to get slabheader
In rdataset_getheader() a cast of the raw buffer to dns_slabheader_t and
pointer arithmetics was used to get the start of the slabheader
structure.  Use more correct offsetof(dns_slabheader_t, raw) to
calculate the correct start of the dns_slabheader_t from the flexible
member raw[].
2026-02-18 14:29:16 +01:00
Ondřej Surý
499cfc2f24
Move the count of items in the slabheader from raw data to struct
The count of items was stored in the raw data as first two bytes.
Instead of reading this from the raw header, move the number of the
items into the structure itself.

This needs the flexible member raw[] to be aligned on the size of the
pointer to prevent unaligned access to the start of the header from
rdataset_getheader() function that casts the raw[] to dns_slabheader_t.
2026-02-18 14:29:16 +01:00
Ondřej Surý
aaf3454079
Cleanup the unused members of dns_slabheader_t
After the rdataslab -> rdataslab,rdatavec split, there were couple of
unused struct members.  Remove all the unused members, reorder the
members to eliminate the padding holes and thus reduce the
dns_slabheader_t and dns_slabtop_t structure sizes.
2026-02-18 14:29:16 +01:00
Ondřej Surý
3a4ad1fd12
Remove dns_rdataslab_merge() and friends
After the split to dns_rdataslab and dns_rdatavec, the
dns_rdataslab_merge() function was unused and it suffered from the same
data race as fixed in the previous commit.  Instead of fixing it, just
remove the function and bunch of other unused functions from the
dns_rdataslab unit.
2026-02-18 14:29:16 +01:00
Petr Špaček
8085b1bc23 Merge tag 'v9.21.18' 2026-02-18 10:29:45 +00:00
Mark Andrews
cc643cad17 fix: usr: DNSTAP wasn't logging forwarded queries correctly
Closes #5724

Merge branch '5724-dnstap-forwarder-queries-logging' into 'main'

See merge request isc-projects/bind9!11509
2026-02-17 14:32:22 +11:00
Mark Andrews
ea32141e48 Use shell function 'check_count' to check counts 2026-02-17 13:17:43 +11:00
Mark Andrews
24f85bc3f3 Document UPDATE QUERY and UPDATE RESPONSE 2026-02-17 13:17:43 +11:00
Mark Andrews
591096f131 Test forward query/response counts 2026-02-17 13:17:43 +11:00
Mark Andrews
38b626d58d Correctly identify forwarded queries with DNSTAP
Queries using forwarders where not being correctly identified
when using dnstap.
2026-02-17 13:17:43 +11:00
Mark Andrews
77278beaf3 Add missed ret!=0 checks 2026-02-17 13:17:38 +11:00
Matthijs Mekking
dcf118f0a6 fix: doc: Minor documentation fixes for the 'rndc dnssec' command
List 'rndc dnssec' arguments in alphabetic order.
The `-step` argument was erroneously omitted from the usage output.

Closes #5731

Merge branch '5731-rndc-documentation-corrections' into 'main'

See merge request isc-projects/bind9!11529
2026-02-16 16:28:58 +00:00
Matthijs Mekking
4a22921936 List 'rndc dnssec' arguments in alphabetic order
Same as rndc usage orderning,
2026-02-16 16:28:47 +00:00
Matthijs Mekking
0dd61d8773 Add rndc dnssec -step command to usage
The `-step` argument was erroneously omitted from the usage output.
2026-02-16 16:28:47 +00:00
Michał Kępień
9c4c48a8ae chg: test: Use isctest.asyncserver in the "pipelined" test
Replace the custom DNS server used in the "pipelined" system test with
new code based on the isctest.asyncserver module.

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

See merge request isc-projects/bind9!11516
2026-02-13 15:03:36 +01:00
Michał Kępień
3954025218
Use isctest.asyncserver in the "pipelined" test
Replace the custom DNS server used in the "pipelined" system test with
new code based on the isctest.asyncserver module.
2026-02-13 14:27:10 +01:00
Michał Kępień
10a2fc7f1f
Implement a response handler that forwards queries
Add a new response handler, ForwarderHandler, which enables forwarding
all queries to another DNS server.  To simplify implementation, always
forward queries to the target server via UDP, even if they are
originally received using a different transport protocol.
2026-02-13 14:27:10 +01:00
Michał Kępień
d3d9d166ed
Log the server socket receiving each query
Extend AsyncDnsServer._log_query() and AsyncDnsServer._log_response() so
that they also log the <address, port> tuple for the socket on which a
given query was received on.  Minimize the signatures of those methods
by taking advantage of all the information contained in the QueryContext
instances passed to them.
2026-02-13 14:27:10 +01:00
Michał Kępień
94a4793596
Store server socket information in QueryContext
Extend the QueryContext class with a field holding the <address, port>
tuple for the socket on which a given query was received.  This will
enable query handlers to act upon that information in arbitrary ways.
2026-02-13 14:27:10 +01:00
Alessio Podda
db6fe7bd16 chg: dev: Remove unnecessary dns_name_copy copies in qpzone_lookup
Followup on !11339, which removes further unnecessary copies in the lookups in qpzone.c. The performance impact seems minor though.

Merge branch 'alessio/qpzone-fewer-name-copies' into 'main'

See merge request isc-projects/bind9!11418
2026-02-12 23:01:10 +00:00
Alessio Podda
169cbe8431
Return node pointer in step
Part of an refactor to eliminate intermediate copies in qpzone_find.
2026-02-12 17:36:48 +01:00
Alessio Podda
33dfd3c0ce
Fewer name copies in step
Part of an refactor to eliminate intermediate copies in qpzone_find.
2026-02-12 17:32:34 +01:00
Alessio Podda
d0e04ed0e7
Fewer name copies in previous_closest_nsec
Part of an refactor to eliminate intermediate copies in qpzone_find.
2026-02-12 17:32:30 +01:00
Matthijs Mekking
242dd34ad8 rem: nil: Remove unused dns_view_load() and dns_zt_load()
We always load zones asynchronously.

Merge branch 'matthijs-remove-unused-zt-and-view-load' into 'main'

See merge request isc-projects/bind9!11515
2026-02-12 13:43:21 +00:00