Commit Graph

8778 Commits

Author SHA1 Message Date
Li Cao 8dadae2ea1 [format] upgrade clang-format to 19 (#11783)
We just updated the version from 14 to 16. But very unfortunately
clang-format-16 was just deprecated recently. So this time we update
the version to the latest available one. There are newer releases than
19 (like 20) but as I tested, sudo apt-get install -y clang-format-19
can work while 20 doesn't work.

misc-include-cleaner in clang-tidy-19 exerts a very strict check which
requires to directly include all headers for every symbols in the
source file. However in our current code we intentionally use some
indirect include. So this commit disables misc-include-cleaner.
2025-08-06 10:49:52 -07:00
Jonathan Hui 956e1a0c7d [fuzz] add fuzzer for otIp6Send (#11790) 2025-08-05 19:55:50 -07:00
Jonathan Hui dba483ac69 [tcp] skip checksum validation during fuzz tests (#11789) 2025-08-05 15:51:25 -07:00
Abtin Keshavarzian a9a9d84061 [trel] fix possible use-after-free in HandleTxtResult() (#11781)
This change fixes a potential use-after-free issue in the
`PeerDiscoverer::HandleTxtResult()` method.

When processing a TXT record, the corresponding `Peer` object could be
removed if it was identified as the device itself. However, a
subsequent call to `UpdatePeerState()` would still use the dangling
reference to the removed `Peer` object.

The fix merges the logic from the now-removed `ProcessPeerTxtData()`
method directly into `HandleTxtResult()`. After a `Peer` is removed,
the local `peer` pointer is set to `nullptr`, and the call to
`UpdatePeerState()` is guarded by a null check to prevent using
the invalid pointer.
2025-08-04 16:56:11 -07:00
dependabot[bot] 063dbc36d7 github-actions: bump umbrelladocs/action-linkspector from 1.3.4 to 1.3.7 (#11776)
Bumps [umbrelladocs/action-linkspector](https://github.com/umbrelladocs/action-linkspector) from 1.3.4 to 1.3.7.
- [Release notes](https://github.com/umbrelladocs/action-linkspector/releases)
- [Commits](https://github.com/umbrelladocs/action-linkspector/compare/a0567ce1c7c13de4a2358587492ed43cab5d0102...874d01cae9fd488e3077b08952093235bd626977)

---
updated-dependencies:
- dependency-name: umbrelladocs/action-linkspector
  dependency-version: 1.3.7
  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-08-04 10:33:54 -07:00
Jonathan Hui 31adbd0edc [fuzz] add fuzzer for otPlatInfraIfRecvIcmp6Nd (#11773) 2025-08-02 10:23:58 -07:00
Abtin Keshavarzian 0cf1ee09eb [mle] simplify WillBecomeRouterSoon for clarity (#11768)
This commit renames `IsExpectedToBecomeRouterSoon()` to
`WillBecomeRouterSoon()` to better reflect its behavior.

The implementation is simplified by using the `VerifyOrExit` pattern
instead of a single complex boolean expression, which improves code
readability.
2025-08-01 11:10:52 -07:00
Jonathan Hui 9cd5a2d93e [fuzz] add fuzzer for otPlatMdnsHandleReceive (#11772) 2025-07-31 13:28:23 -07:00
Yakun Xu 590c56e238 [config] include logging.h (#11766)
This commit includes `<openthread/platform/logging.h>` because
it uses `OT_LOG_LEVEL_CRIT`.
2025-07-30 17:05:58 -07:00
Abtin Keshavarzian 8bd5d73f9d [mesh-diag] add API to configure response timeout (#11753)
This change introduces new APIs to allow configuration of the response
timeout for mesh diagnostic queries. A corresponding CLI command
`meshdiag responsetimeout` is also added to get or set the timeout
value.

When set, the new response timeout is used for subsequent queries and
does not affect any that are ongoing. The timeout value is clamped
between 50 milliseconds and 10 minutes to ensure it stays within a
reasonable range.
2025-07-30 15:53:08 -07:00
Abtin Keshavarzian e93d281288 [history-tracker] move HistoryTracker to its own namespace (#11756)
This commit refactors `Utils::HistoryTracker` by moving it into its
own dedicated `ot::HistoryTracker` namespace for better code
organization.

The main implementation class is renamed from `HistoryTracker` to
`Local`, making the new class `ot::HistoryTracker::Local`. This
allows additional components (like server and client) to be defined
within the `HistoryTracker` namespace.

Nested types, such as `Iterator`, are now direct members of the new
`HistoryTracker` namespace.
2025-07-30 14:15:47 -07:00
arnulfrupp bb5585d412 [tcat] add tcat implementations and bug fixes (#11402)
Commit adds check if commissioning is possible and if the tcat device is already commissioned.
Adds advertisement update on disconnected and role change.
Fixes key handling for key references.
Fixes the authorization processing.
Implements recent changes of the application TLVs.
2025-07-30 12:27:10 -07:00
Abtin Keshavarzian 6c55d53a50 [mle] move child ID allocation logic to ChildTable (#11764)
This commit moves the child ID allocation logic from `Mle` to
`ChildTable`.

A new `AllocateNewChildRloc16()` method is added to `ChildTable` to
contain the allocation logic, and the `mNextChildId` counter is moved
to `ChildTable`. `Mle` is updated to use this new method.

This refactoring improves code encapsulation by making the
`ChildTable` responsible for managing all aspects of the children it
contains, including ID allocation.
2025-07-29 17:03:02 -07:00
Abtin Keshavarzian 72ee935dec [netdiag] fix incorrect bitmask for AnswerTlv index (#11762)
The `kIndexMask` within `AnswerTlv` was incorrectly defined as `0x7f`,
which only covers the lower 7 bits of the `mFlagsIndex` field. This
would improperly truncate the message index value.

This change corrects the mask to `0x7fff`, which properly utilizes the
lower 15 bits for the index, while the most significant bit remains
reserved for the `kIsLastFlag`.
2025-07-29 17:02:11 -07:00
Li Cao 34bb0e4ab1 [test] remove the node type rcp-ncp (#11752)
The type `rcp-ncp` was meant to run nodes of NCP on posix. But we
don't have NCP on posix anymore. So this can be removed.
2025-07-28 11:20:43 -07:00
Abtin Keshavarzian fcfee4ec7a [mle] introduce PrevRoleRestorer to manage role restoration (#11731)
This commit introduces `Mle::PrevRoleRestorer` to consolidate the
logic for restoring a device's previous role (child or router/leader)
after an MLE restart.

This new class replaces and encapsulates the functionality from the
now-removed `RouterRoleRestorer` class and `RestorePrevRole()` method.

`PrevRoleRestorer` manages its own timer and retransmission logic. It
handles sending Child Update Requests to restore a child role, or
multicast Link Requests to restore a router/leader role. It also adds
a small random delay before the first transmission attempt to avoid
synchronized transmissions when multiple devices restart at once.

This change simplifies the `Mle` class by centralizing all role
restoration logic into a single component, making future enhancements
to this process easier.
2025-07-23 18:46:11 -07:00
Jonathan Hui 382c4c44c4 [dns] add missing include (#11748) 2025-07-22 13:35:36 -07:00
Abtin Keshavarzian 44046b7b68 [history-tracker] add Network Data DNS/SRP address entry tracking (#11685)
This commit introduces a new feature in `HistoryTracker` to track
Network Data DNS/SRP unicast/anycast address entries. This new
functionality records when different Border Routers add or remove
these entries in the Network Data. This change also introduces new
public APIs and CLI command `history dnssrpaddr` to expose this
information.
2025-07-22 11:00:43 -07:00
Abtin Keshavarzian f73d64e611 [settings] change save/delete methods to return void (#11735)
This commit simplifies the `Settings` API by modifying all "Save"
and "Delete" methods to return `void` instead of `Error`.

Settings operations are required for a Thread device to function, so a
failure to save or delete from non-volatile storage should be treated
as a critical error. Previously, the code effectively ignored these
errors using `IgnoreError()`. This change instead treats any such
failure as a critical error, triggering an assert within the
`Settings` module.

The key changes include:
- `Settings::Save<T>()`, `Delete<T>()`, `DeleteAllChildInfo()`, and
  similar methods now return `void`.
- Internal `Settings` methods use `SuccessOrAssert()` to assert on
  errors.
- The responsibility for asserting on `kErrorNotImplemented` is moved
  to the `SettingsDriver` layer.

This update simplifies the caller logic by removing the need for
`IgnoreError()` at many call sites. Consequently, several methods
that primarily wrapped `Settings` calls, such as `Mle::Store()` and
`BorderAgent::SetId()`, have also been updated to return `void`.
2025-07-21 22:46:19 -07:00
Abtin Keshavarzian c9ee6d0576 [dns-client] increase default response timeout to 7 seconds (#11741)
This commit increases the default DNS response timeout config,
`OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_RESPONSE_TIMEOUT`, to 7000
milliseconds.

The default value of 7000 is selected to be longer than the
six-second wait time for queries resolved by the Discovery Proxy
(per RFC 8766, Section 5.6, first bullet).
2025-07-21 22:44:26 -07:00
Jonathan Hui 6a6afd8da4 [posix] call FinalizeMulticastRouterSock() in TearDown() (#11742) 2025-07-21 22:20:07 -07:00
Abtin Keshavarzian 4ded380722 [discover-scanner] use TxCallback to handle discovery request tx done (#11736)
This commit updates the handling of discovery request transmission
completion by using a `TxCallback`.

Previously, `MeshForwarder` contained special-case logic to identify a
discovery request message and would then explicitly call into
`DiscoverScanner::HandleDiscoveryRequestFrameTxDone()`.

This is changed so that `DiscoverScanner` now registers a `TxCallback`
directly on the discovery request message itself.
2025-07-18 08:56:13 -07:00
Abtin Keshavarzian 3019d3c6c4 [mle] reorganize Detacher methods (#11734)
This commit moves the `Detacher::Detach()` method implementation to
group it with other `Detacher` method definitions.

When the `Detacher` class was added in PR #11723, its methods were
intentionally kept in their original locations to keep the `git diff`
smaller and easier to review.

This is a pure code-move refactoring to improve code organization and
has no functional changes.
2025-07-16 15:23:27 -07:00
Abtin Keshavarzian 86590870d3 [mle] introduce GenerateRandomDelay() helper (#11729)
This commit introduces `GenerateRandomDelay()`, to simplify the
logic for generating a random delay up to a given max delay.
This is then used through `Mle` class.
2025-07-16 15:22:47 -07:00
Abtin Keshavarzian 8c4d537696 [posix] implement Posix::Dhcp6PdSocket for otPlatInfraIfDhcp6Pd* (#11607)
This commit implements `ot::Posix::Dhcp6PdSocket`, which provides the
`otPlatInfraIfDhcp6PdClient*` socket-like APIs for use by the core
`Dhcp6PdClient` module.

The `Posix::Dhcp6PdSocket` is a sub-component of `Posix::InfraNetif`.
2025-07-16 15:09:06 -07:00
Abtin Keshavarzian 5219147160 [trel] ignore mDNS service removal for peer table update (#11692)
This commit modifies TREL to disregard mDNS (DNS-SD) service removal
events when updating the peer table. Since mDNS peer removal signals
can be unreliable, this change prevents such signals from causing a
peer's removal. Instead, a peer entry is retained as long as TREL
packets and acks are successfully exchanged, moving towards the goal
of eliminating TREL's dependency on mDNS for peer discovery and
tracking.

This commit also introduces a new mechanism to track the last
interaction time with each peer. This information is used to evict
the least recently used entry when the peer table gets full and to
remove inactive peers after a long expiration period (7.5 min)
passes.

The `test_trel` Nexus test is updated to validate these new
behaviors.
2025-07-16 14:53:41 -07:00
Abtin Keshavarzian 23e54f680d [mle] refactor previous router/leader role restoration (#11728)
This commit updates `RestorePrevRole()` to directly start the
`RouterRoleRestorer` instead of calling `BecomeRouter()`.

Consequently, `BecomeRouter()` is simplified by removing the logic for
handling the `kRoleDetached` state. The method now focuses on the
child-to-router transition by sending an Address Solicit message, and
its initial role validation is made more explicit.

This change ensures the logic for restoring a previous router/leader
role is separate from the child-to-router transition logic.
2025-07-16 10:31:16 -07:00
Yakun Xu 5108ccdcf5 [size-report] correct the checkout ref (#11732)
The commit corrects the checkout ref to pull/<number>/merge, which is
the ref after merging and should be used for size checking.
2025-07-16 10:07:24 -07:00
Yakun Xu 2f1183f387 [git-tool] do not use GITHUB_TOKEN (#11730)
This commit stops using GITHUB_TOKEN in git-tool for better security.
2025-07-16 07:11:17 -07:00
Abtin Keshavarzian 6e1a6ff190 [mle] add Mle::Detacher class to manage graceful detach process (#11723)
This commit introduces a new `Mle::Detacher` class to encapsulate all
state and logic for the graceful detach process. By managing its own
internal state, timer, and completion callback, the `Detacher` class
centralizes the detach logic, improving code clarity and
maintainability.
2025-07-15 14:09:40 -07:00
Abtin Keshavarzian dbfc0cd94b [mle] register Message::TxCallback when sending "Child ID Req" (#11720)
This commit updates the mechanism for notifying the transmit
completion of a Child ID Request message.

Instead of `MeshForwarder` checking the message type and calling into
`Mle` upon transmit completion, `Mle::SendChildIdRequest()` now
registers a `TxCallback` directly on the message.

This change simplifies `MeshForwarder` by removing the need for it to
be aware of specific `Mle` message types.
2025-07-15 14:08:25 -07:00
Abtin Keshavarzian 5f623944b2 [mle] fix int conversion when setting TLV length (#11727)
This commit resolves a potential unsafe integer conversion warning by
explicitly casting the size of the status sub-TLV to `uint8_t` before
setting the length of the main TLV in
`SendLinkMetricsManagementResponse`.

Additionally, this change enables MLE_LINK_METRICS_SUBJECT_ENABLE`
feature in the `toranj` test configuration, allowing this feature to
be covered under its builds.
2025-07-15 12:18:53 -07:00
Yakun Xu d4734df8bb [size-report] checkout pull request head (#11724) 2025-07-15 10:48:46 -07:00
Abtin Keshavarzian e72e68a05e [mle] simplify requesting shorter Child ID Request msg (#11719)
This commit inlines `RequestShorterChildIdRequest()`  into its only
call site within `HandleChildIdRequestTxDone()`.
2025-07-15 08:04:46 -07:00
Yakun Xu 1803a957e2 [srp-server] skip looking for conflicts on host of the same key (#11716) 2025-07-15 07:46:07 -07:00
Abtin Keshavarzian 79d833ba3a [mle] avoid scheduling RetxTracker timer when disabled (#11721)
This commit adds a check in `RetxTracker::ScheduleTimer()` to ensure
the timer is not scheduled if MLE operations are disabled.

This change improves safety by handling an edge case during the
graceful detach process. In this scenario, a child sends a "Child
Update Request" with a zero timeout and, upon receiving a response,
immediately stops MLE. The added check prevents the retransmission
timer from being incorrectly scheduled after MLE has been stopped.
2025-07-15 07:41:36 -07:00
Abtin Keshavarzian f262475a49 [ip6] refactor Filter::Accept to Filter::Apply and return Error (#11714)
This commit refactors the IPv6 filter by renaming `Filter::Accept()`
to `Filter::Apply()` and changing its return type from `bool` to
`Error`.

The new method now returns `kErrorNone` for an accepted message and
`kErrorDrop` for a message that should be dropped. This change
improves clarity and aligns the filter's logic with the common
`SuccessOrExit` error handling pattern used throughout the codebase.
2025-07-15 07:39:50 -07:00
Abtin Keshavarzian bc4e3cdaa6 [check-size] use pull_request_target event to trigger post report (#11722)
This commit changes the workflow trigger event from `pull_request` to
`pull_request_target` so to match the event type that triggers the
`check-size` workflow.
2025-07-14 20:45:58 -07:00
Yakun Xu f4e239e651 [size-report] migrate to GitHub Actions (#11681) 2025-07-14 16:01:32 -07:00
Yakun Xu 579d834e0d [dnssd] limit TTL of Discovery Proxy result (#11687)
This commit limits the TTL of Discovery Proxy result according to RFC
8766 Section 5.5.1 and 5.6.
2025-07-14 16:00:26 -07:00
Abtin Keshavarzian 26f23ad635 [core] fix implicit integer conversion warnings (#11709)
This commit enables the `-Wimplicit-int-conversion` compiler flag for
`ftd`, `mtd`, and `radio` to improve code quality by detecting
potential data loss from implicit type conversions. This is enabled
when clang toolchain is used.

All resulting warnings have been addressed by either:
- Changing variable, parameter, or return types to ensure consistency
  and prevent overflows.
- Adding explicit `static_cast` where the type conversion is intended
  and safe.
2025-07-14 13:06:27 -07:00
Li Cao 02e73a0586 [format] enable simplify demorgan option (#11715) 2025-07-14 10:30:45 -07:00
Abtin Keshavarzian 5944b5e983 [mle] simplify HandleParentRequest (#11705)
This commit simplifies the `HandleParentRequest()`.

- The logic for detecting duplicate Parent Requests is made more
  readable by introducing the `kParentRequestDuplicateTimeout`
  constant.
- To reduce unnecessary log noise, checks like `IsRouterEligible()`
  or `!IsDetached()` no longer set and return an error. This
  prevents logging failure messages for conditions that are not
  actual errors.
- Verbose comments are removed in favor of self-documenting code.
2025-07-14 10:20:48 -07:00
Abtin Keshavarzian 8c9dd22d2c [mle] use uint32_t for delay parameter in DelayedSender (#11708)
This commit changes the `aDelay` parameter type in
`Mle::DelayedSender` methods from `uint16_t` to `uint32_t`.

This update supports specifying message transmission delays longer
than the previous 65-second limit and avoids potential implicit
integer downcasting.
2025-07-14 10:17:40 -07:00
dependabot[bot] 296034c25e github-actions: bump github/codeql-action from 3.28.19 to 3.29.2 (#11718)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.19 to 3.29.2.
- [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/fca7ace96b7d713c7035871441bd52efbe39e27e...181d5eefc20863364f96762470ba6f862bdef56b)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.29.2
  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-07-14 10:00:48 -07:00
Yang Song e9b05b45a5 [nd6] correct comment for (#11717) 2025-07-14 08:19:38 -07:00
Zhanglong Xia 6bbcec9445 [diag] add a method IsFrameLengthValid() to check the frame length (#11712) 2025-07-14 08:18:59 -07:00
Jonathan Hui 9f88ca0288 [tests] explicitly disable border agent in test_publish_meshcop_service (#11713)
The `test_publish_meshcop_service` is updated to explicitly disable
the border agent before factory resetting `br`. This makes the
test more reliable by ensuring the MeshCoP service is unpublished.
2025-07-11 15:13:48 -07:00
Abtin Keshavarzian 23127fda98 [tests] explicitly enable/disable border agent in test_publish_meshcop_service (#11707)
The `test_publish_meshcop_service` is updated to explicitly disable
the border agent before stopping the `otbr-service`. This makes the
test more reliable by ensuring the MeshCoP service is unpublished
before stopping `otbr-service`.
2025-07-10 22:16:18 -07:00
Abtin Keshavarzian 406b1dee6e [instance] remove border agent disabling in Finalize (#11711)
This commit removes the explicit call to disable the `BorderAgent`
during instance finalization. This change prevents issues where the
call may trigger platform interactions that can fail due to the
platform layer being deinitialized before the `Finalize` is called.
2025-07-10 22:15:28 -07:00