Commit Graph

8690 Commits

Author SHA1 Message Date
Abtin Keshavarzian 5b2bcee271 [srp-client] enhance single service mode (#11634)
This commit enhances the `Srp::Client` "single service mode". This
mode is enabled when a prepared SRP update message exceeds the IPv6
MTU size. In this mode, the client registers its services one by one,
with each SRP update containing only a single service.

The implementation is simplified by changing the `mSingleServiceMode`
flag from a persistent member variable of the `Client` class to a
field within the `MsgInfo` struct, making its scope
message-specific.

State transitions are now correctly applied to host and service
entries when operating in single service mode. This, in turn, helps
ensure that SRP message transaction IDs are managed correctly: the
same ID is used for retries of an unchanged service, while a new ID
is used if the service information has changed.

Finally, a new test case, `TestSrpClientSingleServiceMode`, is added
to `test_srp_server` to cover this behavior and its associated retry
logic in detail.
2025-06-25 16:45:49 -07:00
Abtin Keshavarzian c55098af5e [message] change queues to use non-circular linked list (#11630)
This commit updates the `MessageQueue` and `PriorityQueue`
implementations to use non-circular doubly linked lists instead of
the previous circular ones. Using a non-circular list requires the
queue to track the head element, but it simplifies common operations
like getting the head and iterating over the messages.

Particularly, `Message::GetNext()` now simply returns the `mNext`
pointer. Previously, `Message` had to store a pointer to its `mQueue`
within its `Metadata` to identify the tail of the queue and stop the
iteration correctly.

This commit also updates the unit tests. In particular,
`test_priority_queue` is significantly enhanced to cover many
scenarios, such as multiple messages with the same priority, and
messages with different priorities being added and removed in various
orders.
2025-06-25 13:03:43 -07:00
Yakun Xu 5d1d380012 [style] include include cleaner (#11635) 2025-06-25 12:22:05 -07:00
Abtin Keshavarzian 3aab10a8fb [srp-client] update message ID assignment model (#11592)
This commit updates the SRP client message ID assignment model.
Message IDs are now selected randomly, ensuring they differ from the
last ID used. The same message ID is reused when a message is
retried.

This replaces the earlier design where all messages, including
retries, used sequential message IDs.

The unit test is also updated to validate the new behavior.
2025-06-24 12:10:45 -07:00
Abtin Keshavarzian 84295be3f8 [message] add TxCallback to track transmission outcome (#11614)
This commit introduces new public APIs to register a `TxCallback` on a
message to be notified of its transmission outcome.

The callback is invoked with an error code indicating the transmission
status of the IPv6 message to an immediate neighbor (a one-hop
transmission). It does not indicate that the message was received by
its final, multi-hop destination.

For a unicast IPv6 message, a success (`OT_ERROR_NONE`) indicates that
the message, including all its corresponding fragments if applicable,
was successfully delivered to the immediate neighbor and a MAC layer
acknowledgment was received for all fragments. This is reported
regardless of whether the message is sent using direct or indirect
transmission (e.g., to a sleepy child via CSL or a data poll).

For a multicast message, an `OT_ERROR_NONE` status indicates that the
message and all its fragments were successfully broadcast. Note that
no MAC-level acknowledgment is required for a broadcast frame
transmission.
2025-06-24 09:37:15 -07:00
Abtin Keshavarzian 093d2a8427 [dhcp6-pd-client] initialize msgType to fix compiler warning (#11631)
This commit updates `SendMessage()` to initialize the `msgType`
variable before the `switch` statement.

This change addresses a compiler warning for a possibly uninitialized
variable, flagged by `-Werror=maybe-uninitialized`.

Note that the situation where `mState` would be an undefined value is
not technically possible in the current logic. However, the compiler
cannot guarantee this and therefore generates a warning. Initializing
the variable upfront resolves this issue.
2025-06-24 09:30:08 -07:00
Abtin Keshavarzian c6f3f1ff31 [message] disallow SetPriority() on enqueued messages in PriorityQueue (#11624)
This commit modifies `Message::SetPriority()` to prevent changing a
message's priority after it has been enqueued in a `PriorityQueue`.
Attempting to do so will now return `kErrorInvalidState`.

The functionality for altering the priority of an already-enqueued
message is not currently used or required. Should this behavior
become necessary in the future, the recommended approach is to
explicitly dequeue the message first, then change its priority, and
finally re-add it to the queue. This makes the intended behavior
clearer and more explicit within the code.

This commit also updates the `test_priority_queue` unit test to
reflect this change.
2025-06-23 13:15:53 -07:00
dependabot[bot] 7617b602b6 github-actions: bump actions/setup-python from 5.5.0 to 5.6.0 (#11626)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5.5.0 to 5.6.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/8d9ed9ac5c53483de85588cdf95a591a75ab9f55...a26af69be951a213d495a4c3e4e4022e16d87065)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-version: 5.6.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-23 08:13:50 -07:00
Abtin Keshavarzian 984b3cb1c8 [mle] remove kReattachStart from ReattachState enum (#11609)
This commit simplifies the code by removing the `kReattachStart` state
from the `ReattachState` enumeration. This enum is used after MLE
`Start()` to track whether to attempt to attach using a persisted
Active or Pending Dataset.

Previously, `kReattachStart` was a transitory state set in `Start()`
and then changed in the `Attach()` method to either `kReattachActive`
 or `kReattachStop`, based on whether the device had a saved Active
 Dataset.

This change simplifies the code by determining the state directly in
`Mle::Start()`, which allows for the removal of the now unnecessary
`kReattachStart` case.
2025-06-23 07:50:14 -07:00
Abtin Keshavarzian c221dae3e4 [test] ensure v1_2_test_backbone_router_service.py uses correct seqno (#11621)
This commit ensures `v1_2_test_backbone_router_service.py` uses the
correct logic for checking the next seq number.
2025-06-23 07:39:48 -07:00
Abtin Keshavarzian f90d50b220 [dhcp6] implement DHCPv6 Prefix Delegation (PD) client (#11584)
This commit introduces the `Dhcp6PdClient` class, which implements
DHCPv6 Prefix Delegation (PD) client functionality. It integrates
with `BorderRouter::RoutingManager` and its `PdPrefixManager`
sub-component. The CMake `OT_BORDER_ROUTING_DHCP6_PD_CLIENT` mapped
to `OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_CLIENT_ENABLE` config
enables this feature.

Previously, the platform layer was expected to implement client
functionality, acquiring and providing the delegated prefix(es) to
the OT stack using `otPlatBorderRouter*` callbacks. This approach
continues to be supported. The `Dhcp6PdClient` feature adds native
support for this functionality in the OpenThread core.

The `Dhcp6PdClient` implementation follows RFC 8415, focusing on
prefix delegation and all required behaviors. The client follows the
standard four-message Solicit/Advertise/Request/Reply exchange to
obtain a delegated prefix, followed by a two-message Renew/Reply or
Rebind/Reply exchange to extend the lifetime of the delegated prefix.
When the prefix is no longer needed, a two-message Release/Reply
exchange ends its lease. The current client implementation does not
support the optional "Reconfigure Accept" mechanism.

A set of `otPlatInfraIfDhcp6PdClient*` platform APIs are also
introduced for use by the `Dhcp6PdClient`. These APIs are used to
enable or disable listening for DHCPv6 messages and to handle sending
and receiving them on the standard client and server UDP ports
(546 and 547), effectively acting as a UDP socket.

This commit also includes a comprehensive unit test covering various
aspects of `Dhcp6PdClient`, including common behaviors and many
specific edge cases.
2025-06-20 19:35:44 -07:00
Abtin Keshavarzian faadc5baed [message] remove MessagePool from the Message::Metadata (#11616)
This commit simplifies the `Message::Metadata` so that it no longer
tracks the `MessagePool`. Instead the `Message` now tracks the
`ot::Instance` it is associated with and acts as a `GetProvider`,
allowing access to any component within `Instance`, including
the `MessagePool`.
2025-06-20 19:21:30 -07:00
Abtin Keshavarzian 6d0618fc78 [routing-manager] enhance peer BR count tracking and signaling (#11594)
This commit enhances how changes in the number of reachable peer
Border Routers (BRs) are tracked and signaled. This tracking is
handled by `RxRaTracker` and utilized by the `MultiAilDetector` to
determine if BRs are connected to different AILs.

The `RxRaTracker::DecisionFactors` class now includes and tracks
`mReachablePeerBrCount`. This value is updated in the `Evaluate()`
method, which is invoked upon any change to the internal state
tracked by `RxRaTracker` (e.g., changes in discovered prefixes or
routers). This ensures that any change in the number of peer BRs is
promptly detected and signaled to other sub-components, allowing them
to update their state or take necessary actions.
2025-06-18 23:17:41 +09:00
Handa Wang e99a523726 [routing-manager] remove duplicate logging of RA header (#11604) 2025-06-18 23:10:42 +09:00
Yakun Xu 41320dc809 [license] fix typo (#11608) 2025-06-18 23:09:47 +09:00
dependabot[bot] c11e0f4659 github-actions: bump codecov/codecov-action from 5.4.2 to 5.4.3 (#11597)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 5.4.2 to 5.4.3.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/ad3126e916f78f00edff4ed0317cf185271ccc2d...18283e04ce6e62d37312384ff67231eb8fd56d24)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-version: 5.4.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-17 21:32:17 +09:00
Yakun Xu 48407719cd [crypto] avoid directly include config/crypto.h (#11603)
This commit avoids directly including `config/crypto.h` which breaks
configuration in project headers.
2025-06-17 21:06:48 +09:00
Yakun Xu a640f85db8 [posix] reliable transport for virtual time (#10984)
This commit changes the virtual time event transport from UDP to
SEQPACKET unix socket to ensure events are delivered successfully.
2025-06-17 21:05:24 +09:00
Yakun Xu b945928d72 [gn] move gn build into etc (#11577) 2025-06-17 14:21:37 +09:00
xusiyu 3dd19d9123 [trel] fix a format error of log (#11586)
According to precedents in other parts of the OpenThread source code,
a 32-bit unsigned integer should be printed using `%lu` instead of
`%u`.
2025-06-17 13:48:17 +09:00
Abtin Keshavarzian 3fd719063f [posix] fix MdnsSocket iteration over message queue (#11599)
This commit updates how `MdnsSocket::SendQueuedMessages()` iterates
over the message queue. The iteration is changed to get the next
message before processing the current one. This is necessary because
the current message may be dequeued and freed within the loop, which
would invalidate the pointer to the next message.
2025-06-17 13:47:05 +09:00
Abtin Keshavarzian aab0c29793 [mle] move AnnounceHandler methods together (#11598)
This commit moves the `Mle::AnnounceHandler` methods to be located
together in the same section.

The `AnnounceHandler` sub-component was added in a previous commit,
but its methods were intentionally left in their original locations
to keep the `git diff` small and easy to review. This change simply
relocates the methods to their proper place and includes no logical
modifications.
2025-06-17 13:46:29 +09:00
Abtin Keshavarzian 00e4e42c57 [cli] fix output of fractional part of ping average round-trip time (#11587)
This commit addresses an issue where the fractional part of the ping
average round-trip time (RTT) was not consistently formatted.
Previously, it used ".%u" with `(avgRoundTripTime % 1000)` which
could omit leading zeros for fractional values. It now uses ".%03u"
to ensure three digits are always displayed, padding with leading
zeros when necessary.
2025-06-17 13:45:49 +09:00
Rongli Sun 8a19434b8a [routing-manager] enhance MultiAilDetector (#11589)
This commit counts only reachable peer BRs for quick multi-AIL detection
when peer BR moves to a different infrastructure link.
thread-reference-20250612
2025-06-12 22:03:48 +09:00
Jason Zhang baf13fc994 [posix] fix region configuration loading order (#11585)
Fix the initialization order in ProcessRadioUrl() to ensure that
configuration files are loaded before region settings are applied.

Previously, the region code was set before configuration files
(product-config-file and factory-config-file) were processed. This
caused region-specific settings such as target power to be applied
from stale configuration data rather than the newly loaded
configuration file.

The fix reorders the parameter processing sequence:
1. Basic radio parameters (fem-lnagain, cca-threshold)
2. Configuration file loading (product-config-file, factory-config-file)
3. Region setting (region)
4. Other parameters (bus-latency, max-power-table, coex settings)

This ensures that when a region is set, it will use the correct
configuration data from the newly loaded files, allowing region-specific
power settings and other parameters to be properly refreshed.

Change-Id: Idcf16d194eea65d3efe3ae380d6fa90e71bd5499
2025-06-11 06:38:06 +09:00
Yakun Xu 6b03321cb2 [style] apply IWYU to public headers (#11580)
It would be easier to use OpenThread public headers if they are
self-contained and follows the IWYU style guide. This commit fixes some
style issues to make the public headers self-contained and IWYU. The
existing pretty check is also extended to verify the OpenThread public
headers are self-contained and follows IWYU.
2025-06-11 06:37:41 +09:00
Yakun Xu c8714060ea [test] stabilize Cert_5_1_05_RouterAddressTimeout (#11564)
With the router restoration, longer delay is expected. This commit
defines the router restoration delay and apply it on the unstable test
case Cert_5_1_05_RouterAddressTimeout.
2025-06-10 22:09:33 +09:00
dependabot[bot] b0e7b14963 github-actions: bump github/codeql-action from 3.28.18 to 3.28.19 (#11581)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.18 to 3.28.19.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/v3.28.18...fca7ace96b7d713c7035871441bd52efbe39e27e)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.28.19
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-10 06:34:22 +09:00
Abtin Keshavarzian cbb04be4a6 [routing-manager] use consistent Dhcp6Pd term & update unit test (#11579)
This commit renames DHCPv6-PD related types and methods in
`RoutingManager` to consistently use the `Dhcp6Pd` term.

This commit also updates the related unit test in
`test_routing_manager`. The test is renamed to `TestDhcp6Pd()`, and
the code style is updated to align with other test cases in the same
file. No changes are made to the actual test steps or what is covered
by the test itself. The method for reporting PD prefixes to the
OpenThread stack is modified within the unit test. Instead of using
`otPlat` APIs, `RoutingManager` methods are now directly invoked.
This helps make the unit tests independent of the configuration,
allowing for more flexible models where platform-provided APIs may
not be provided (e.g., DHCPv6 client as part of OpenThread code).
2025-06-10 06:24:23 +09:00
Yakun Xu 6191d3b139 [otci] support reliable transport (#11575)
This commit adds reliable transport in OTCI and switch the OTCI tests to
use the reliable simulation transport.
2025-06-06 09:11:34 -07:00
Li Cao 7d64173fd3 [history-tracker] add missing UpdateAgedEntries() method to EntryList (#11576)
Adds missing method `UpdateAgedEntries` for the template
specialization of `EntryList` when size is 0.
2025-06-06 09:08:47 -07:00
Yakun Xu 1662ca8001 [simulation] add reliable virtual time transport (#11029)
This commit adds a reliable transport based on SEQPACKET unix socket to
simulation platform and use this for tests on simulation platform.
2025-06-04 23:32:25 -07:00
Abtin Keshavarzian a1de12fd49 [dhcp6] introduce Option::Iterator class (#11574)
This commit adds the `Option::Iterator` class for searching for and
iterating over DHCPv6 options with a specific code within a message.
The iteration can cover the entire message or be constrained to a
given `OffsetRange`.

The `Option::Iterator` is used to simplify the `Dhcp6::Client` and
`Dhcp6.Server` implementations, particularly when iterating over
`IaAddressOption`s within an `IaNaOption`.
2025-06-04 23:30:42 -07:00
Lucien Zürcher 4b43f6de76 [coap] match only token for multicast and anycast (#11570) (#11571) 2025-06-04 17:20:01 -07:00
Yakun Xu 5201231daa [test] fix warning of escape in regex string (#11566) 2025-06-04 13:35:36 -07:00
Jonathan Hui 206698702d [fuzz] load only value enum values (#11573) 2025-06-04 13:25:32 -07:00
Jonathan Hui 5c8351b43d [github-actions] update fuzz workflow to latest recommended (#11563) 2025-06-04 11:21:26 -07:00
Jonathan Hui 45fc50cb2e [fuzz] allow border router services to start (#11561) 2025-06-04 11:19:35 -07:00
Yakun Xu a1e170cb94 [routing-manager] fix typo (#11568) 2025-06-04 07:32:53 -07:00
Abtin Keshavarzian 7533b1d93a [secure-transport] add ~SecureTransport() destructor (#11562)
This commit adds a destructor for `SecureTransport` that closes the
socket, and disconnects and removes any tracked sessions.

Removing the sessions ensures that the `SecureSession` instances and
any data allocated within them are properly freed. This handles the
case where the `otInstance` itself is destroyed, ensuring that all
heap-allocated items are cleaned up correctly to prevent memory
leaks.
2025-06-03 22:34:22 -07:00
Yakun Xu 2ae5522bed [style] avoid deprecated setDaemon (#11565) 2025-06-03 22:33:17 -07:00
Abtin Keshavarzian e4ac7162eb [mle] introduce AnnounceHandler class (#11558)
This commit introduces the `AnnounceHandler` class within `Mle` to
encapsulate logic for handling Announce messages. This change
simplifies the `Mle` module and makes the code easier to read and
follow.

The `AnnounceHandler` class handles received Announce messages with a
newer timestamp and different channel and/or PAN ID. It can delay
processing to collect and handle subsequent Announce messages.

It also manages starting the "announce attach" process, where the device
attempts to attach using the parameters from a processed Announce
message.
- If the attach is successful, this class sends an Announce on the old
  channel to inform other devices. This is done immediately after
  attaching as a MTD child or after a router transition attempt
  completes (on FTD).
- If the attach fails, the class ensures the channel and PAN ID are
  restored to their original values.

In particular, the new `AnnounceHandler` uses its own `Timer` to delay
the start of an announce attach. Previously, the `AttachTimer` was
repurposed for this, in addition to its use for attach state
management.
2025-06-03 13:33:49 -07:00
Abtin Keshavarzian 18c731764a [dhcp6] enhance DUID parsing and generation (#11559)
This commit updates and enhances the parsing and generation of the
DHCPv6 DUID in Client/Server Identifier Options.

DHCPv6 DUIDs can be specified in a variety of ways, and clients and
servers must treat them as opaque values that are compared for
equality. This change adds an `Eui64Duid` type to represent a DHCPv6
DUID based on the EUI-64 Link-Layer address format (DUID-LL).

A set of common helper methods are added to parse, match, and append
the DUID in a Client or Server Identifier option:
- `ReadDuid()`: Reads the raw DUID as a blob of data.
- `ReadAsEui64Duid()`: Reads a DUID, validating that it follows the
  DUID-LL format, and parses the EUI-64 address.
- `MatchesEui64Duid()`: Reads a DUID and checks that it matches a
  given EUI-64 address.
- `AppendWithEui64Duid()`: Appends a Client/Server ID option with a
  DUI using the DUID-LL format.

This commit also introduces `Option::AppendOption()` which appends a
DHCPv6 Option with a given code and data to a message.

These methods are then used to simplify the `Dhcp6::Server` and
`Dhcp6::Client` code.
2025-06-03 10:46:48 -07:00
Jonathan Hui 4e52d8eb7c [nexus] add missing case in ConnectEventToString() (#11560) 2025-06-03 10:43:57 -07:00
Esko Dijk 1804273276 [posix] set sin6_scope_id / ipi6_ifindex for all transmits to link-local (#11555)
This will avoid the problem that scope id or ifindex remains 0 for a
link-local transmission. If 0, the OS cannot decide which network
interface to use based on address alone.
2025-06-03 09:22:41 -07:00
Esko Dijk 151cf324bc [tcp][posix] ensure struct fields are initialized (#11552)
This aims to fix some instances in core/tcp6 and posix/udp where the
complete struct was not initialized. In otPlatUdpJoinMulticastGroup
and otPlatUdpLeaveMulticastGroup an explicit redundant setting to '0'
is added just for clarity for people reading the code.
2025-06-03 08:24:09 -07:00
Tony Zhou 5050bec030 [cli] add "dataset active|pending -ns" support (#11518)
This CLI command argument "-ns" prints out the dataset fields and
redact the sensitive values, including the network key and PSKc
fields.
2025-06-03 08:20:49 -07:00
Li Cao ea3a3da0ee [border-agent] add epskc journey statistics (#11530)
This commit adds some new statistics for ePSKc to show the time
duration of various sub process during the credential sharing.

A Nexus unit test is added to verify the stats are counted correctly.

A few small points to be noted:
* The `StopReason` which was used internally in `EphemeralKeyManager`
  is renamed as `DeactivationReason`, defined as public and is mapped
  to the public enum `otHistoryTrackerEpskcDeactivationReason`.
* The original reason `Timeout` is renamed to `SessionTimeout` to
  indicate this is a timeout of the secure session. This is to
  differentiate with the epskc mode timeout.
* A new reason `EpskcTimeout` to indicate the timeout is due to epskc
  mode timeout.
2025-06-02 22:23:07 -07:00
Jonathan Hui f9be8f76ee [fuzz] enable border router services (#11557)
- Border Routing Manager
- DHCPv6 PD
- NAT64
- SRP Server
- TCP
2025-06-02 15:58:25 -07:00
Yang Song 7fb682f928 [posix] fix misleading log message in DNS resolver (#11545)
The log message "No domain name servers found in %s, default to
127.0.0.1" is misleading because the code does not actually default to
127.0.0.1 if no nameservers are found.

This commit updates the log message to accurately reflect the
behavior.
2025-06-02 15:22:17 -07:00