-
Notifications
You must be signed in to change notification settings - Fork 42
[WIP] Update OpenThread stack #215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Cristib05
wants to merge
300
commits into
zephyrproject-rtos:main
Choose a base branch
from
Cristib05:update_openthread_stack_border_router
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
[WIP] Update OpenThread stack #215
Cristib05
wants to merge
300
commits into
zephyrproject-rtos:main
from
Cristib05:update_openthread_stack_border_router
+33,896
−640,524
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This change updates the `Mapping::Matches` methods to accept `Ip4::Headers` and `Ip6::Headers` objects instead of separate IP address and port arguments. This simplifies the callers `FindOrAllocateMapping` and `FindMapping` by encapsulating the conditional logic for port translation within the `Mapping::Matches` methods. This allows for a single, unified `FindMatching` method on the active mappings list.
This commit adds a test case to `TestMultiPacket` to validate the correct eviction of pending truncated queries. The test scenario sends the same truncated query multiple times, followed by a query containing a matching known answer. It then verifies that no response is sent, confirming that the initial pending queries were successfully evicted from the message queue. This validates the fix from #11854.
This change introduces a new history list to record the DHCPv6 Prefix Delegation (PD) state and the delegated prefix. The recorded history can be iterated using the new API `otHistoryTrackerIterateDhcp6PdHistory()` and viewed from the CLI using the new `history dhcp6pd` command.
This commit introduces several cleanups and smaller improvements to the IPv4 types. - Optimizes `Cidr::ToString(StringWriter&)` by writing the address directly to the provided writer, avoiding the allocation of a temporary `String` object. - Moves the IPv4 header field offset constants from the public `ip4_types.hpp` header into the unit test file, as this was their only place of use. This cleans up the `Ip4::Header` public API. - Replaces hardcoded values for address and string sizes with the corresponding `OT_IP4_*` definitions for consistency. - Corrects the format specifier in `Address::ToString()` from `%d` to `%u` to properly print unsigned octet values.
Bumps [docker/metadata-action](https://github.com/docker/metadata-action) from 5.7.0 to 5.8.0. - [Release notes](https://github.com/docker/metadata-action/releases) - [Commits](docker/metadata-action@902fa8e...c1e5197) --- updated-dependencies: - dependency-name: docker/metadata-action dependency-version: 5.8.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This change streamlines NAT64 mapping management by removing the `FindMapping()` and `FindOrAllocateMapping()` helper methods. Following recent simplifications, such as adding new `Matches()` flavors, the logic within these `Find` methods became much simpler. Their functionality is now incorporated directly into `TranslateToIp6()` and `TranslateFromIp6()`, respectively. Additionally, the `Mapping::Touch()` method is simplified to no longer require the current time as an argument. It now retrieves the time internally.
This commit places the `mSrcPortOrId` and `mTranslatedPortOrId` members of the `Translator::Mapping` struct under the `OPENTHREAD_CONFIG_NAT64_PORT_TRANSLATION_ENABLE` build-time flag. This optimization reduces the memory footprint of each `Mapping` entry and the `mMappingPool` when the NAT64 port translation feature is disabled.
This change introduces `RouterUpgradeReasonToString()` to provide human-readable strings for router upgrade reasons, which is used to enhance logging in `BecomeRouter()` and `ProcessAddressSolicit()`. These additions provide clearer insight into why a device is attempting to become a router, aiding in debugging and network analysis.
…n (#11855) This commit improves the NAT64 address mapping iterator to ensure the remaining lifetime for all mapping entries is reported consistently. The iterator now internally stores a timestamp upon initialization. This timestamp is then used as a common reference to calculate the remaining lifetime for each `otNat64AddressMapping` entry, ensuring consistent values throughout a single iteration. The public C APIs remain unchanged, while the underlying implementation and the `otNat64AddressMappingIterator` struct are updated.
…#11865) The logic for sharing an IPv4 address, intended for scenarios with a small address pool (CIDR prefix > /28), was incorrectly being applied even when port translation was disabled. When `OPENTHREAD_CONFIG_NAT64_PORT_TRANSLATION_ENABLE` is disabled, each mapping requires a unique IPv4 address. The previous implementation would incorrectly reuse the same address from the pool. This commit makes the address sharing logic conditional on the `OPENTHREAD_CONFIG_NAT64_PORT_TRANSLATION_ENABLE` configuration. When disabled, the translator now correctly allocates a unique IPv4 address for each mapping and returns it to the pool upon release.
This change introduces `ShouldRegisterMulticastAddrsWithParent()` to consolidate the logic for determining when a child should register its multicast addresses with its parent, thereby avoiding repeated code. The criteria for registration remain the same: a child registers its multicast addresses if it is a Sleepy End Device (SED), or if it is a Minimal End Device (MED) and its parent is running Thread 1.2 or a later version.
Previously, a NAT64 mapping's lifetime was only extended upon its initial allocation. This meant that if an existing mapping was found and reused, its expiration timer would not be refreshed, potentially leading to its premature removal. This change moves the `mapping->Touch()` call from `AllocateMapping()` to `TranslateFromIp6()`. This ensures that a mapping's lifetime is extended every time it is used for translation, whether it is newly allocated or an existing one being reused.
…874) This change updates multiple modules to consistently use `Get<Mle::Mle>()` for accessing the MLE component, removing the need for local `Mle::Mle &mle` references. This approach aligns with the common `Get<Module>()` access pattern used across the codebase, improving consistency.
The `Cidr` class was incorrectly inheriting from `Clearable<Address>` instead of `Clearable<Cidr>`. This oversight meant that calling `Clear()` on a `Cidr` object would not clear its `mLength` member, only the `mAddress` field. This change corrects the template parameter for the `Clearable` base class to `Cidr`, ensuring the entire object is properly zeroed out. This bug could cause issues in the NAT64 translator. When a user calls `otNat64ClearIp4Cidr()` to disable translation, the underlying `mIp4Cidr.Clear()` method would fail to clear the CIDR length. The `Nat64::Translator` would check `mIp4Cidr.mLength > 0` in its `UpdateState()` method to determine if a valid CIDR is configured. Because `mLength` was not cleared, this check would pass incorrectly, causing NAT64 translation to continue with an invalid, partially-cleared CIDR instead of stopping as expected.
This change enhances the unit tests for the NAT64 `Translator` to improve readability. The key improvements include: - Replaced raw hex dumps of packets with new helper functions that parse and log IPv4/IPv6 headers in a human-readable format. - Simplified the counter tests and validation of the `ProtocolCounters`. - Reworked the main test case functions, `Verify6To4()` and `Verify4To6()`, to leverage the new logging and verification helpers for better output.
This commit simplifies the implementation of `SendMessage()` by changing its parameter from a `Message` reference to an `OwnedPtr`. The `OwnedPtr` now manages the lifetime of the message, ensuring it is always freed, whether the translation and send operation succeed or fail. This change removes the need for a manual tracking flag and an explicit `Free()` call in the error path, resulting in cleaner and more robust code.
The mix-in helper classes like `Clearable<T>`, `Equatable<T>`, and `Unequatable<T>` are intended for CRTP style inheritance, where `T` is the derived class itself. A mistaken inheritance, such as `class Foo : public Clearable<Bar>`, can compile successfully but lead to subtle bugs. This change enforces the correct CRTP usage at compile time. By making the constructors of these helper classes `private` and declaring the derived template class `T` as a `friend`, any incorrect inheritance will now result in a build failure. This approach correctly detects such a mistake, even if `Foo` and `Bar` happen to be `friend`s of each other. Additionally, `Equatable<T>` is updated to provide both `operator==` and `operator!=`, removing its dependency on `Unequatable<T>`. This change allows us to apply the `private` constructor enforcement to `Equatable<T>` as well.
… (#11583) Adding two extensions: 1. Add an api function to configure a response fallback callback with `otCoapSetResponseFallback`. 2. Enable fire and forget for NON requests, supporting requests which do not expect a response.
This change updates the management of active NAT64 mappings to use an `OwningList`. To support this, the `Mapping` struct now inherits from `InstanceLocatorInit` and includes a new `Free()` method. This method encapsulates the logic for releasing the associated IPv4 address and the `Mapping` entry back to their corresponding pools. This new design simplifies the `Translator` class by removing the redundant `ReleaseMapping()`, `ReleaseMappings()`, and `ReleaseExpiredMappings()` methods. All mapping cleanup operations are now handled by the `OwningList` class (which invokes `Mapping::Free()` on entries as they are removed).
This commit introduces a new common helper class `ExpirationChecker`. This class is designed to be used as a "matcher" for finding expired entries in collections like `LinkedList` or `Array`. It encapsulates a "now" time and provides an `IsExpired()` method to check if a given time has passed. This change consolidates duplicated private similar structs that previously existed in `RoutingManager`, `Mdns`, and `SrpAdvertisingProxy`, updating all users to the new common implementation. This simplifies the code by removing redundancy.
This commit moves two global constants, `kBufferSize` and `kNumBuffers`, into their respective class scopes to improve encapsulation and avoid potential name conflicts. The `kBufferSize` constant is moved into the `Buffer` class as `Buffer::kSize`. As `kBufferSize` is a generic and commonly used name, this change prevents potential symbol collisions. Similarly, the `kNumBuffers` constant is moved into the `MessagePool` class, as it is exclusively used within that class. All usages of these constants have been updated throughout the codebase to reflect their new names.
This commit introduces a new Nexus test to validate the functionality of the NAT64 translator. The test is divided into two main parts: - `TestNat64StateChanges`: Verifies the state management of the translator. It checks that the translator transitions correctly between `kStateDisabled`, `kStateNotRunning`, and `kStateActive` when the feature is enabled/disabled or when the IPv4 CIDR and NAT64 prefix are configured or cleared. This test also confirms that state change notifications are properly signaled. - `TestNat64Mapping`: Validates the address mapping and translation logic. It ensures that address mappings are correctly created for new IPv6-to-IPv4 traffic, reused for subsequent packets from the same IPv6 source, and eventually expire and are removed after a period of inactivity. It also verifies that the mapping table is cleared when the configured IPv4 CIDR is changed.
This commit introduces a new header file, `common/bit_utils.hpp`, to consolidate bit manipulation utility functions. These functions were previously located in `common/num_utils.hpp`. Moving them to a dedicated file improves code organization and clarity by separating them from general numerical utilities. All files that used these functions have been updated to include the new header.
…886) When `OPENTHREAD_CONFIG_NAT64_PORT_TRANSLATION_ENABLE` is enabled, multiple `Mapping` entries can exist for the same IPv6 and IPv4 addresses, differing only by their protocol ports. To distinguish between these entries in logs and diagnostics, this change updates `Mapping::ToString()` to include the source and translated port numbers in the generated string output.
This commit implements a minimum P2P which only supports sending/receiving wake-up frames and establishing P2P links between rx-on-when-idle devices.
This commit introduces a mechanism within the `RoutingManager` to track the IPv6 addresses used by the Border Router itself on the infrastructure interface, particularly when sending Router Advertisements. This provides visibility for debugging and monitoring purposes. A new data structure, `otBorderRoutingIfAddrEntry`, is added to represent an address and the time elapsed since it was last used as the source of an RA. The tracked addresses can be retrieved using the new public API `otBorderRoutingGetNextIfAddrEntry` or CLI command `br ifaddrs`.
This change moves the `kBitsPerByte` constant and the `BitSizeOf()` and `BytesForBitSize()` macros from `numeric_limits.hpp` to the more specialized `bit_utils.hpp` header. This consolidation places common bit-utility definitions into a more appropriate, dedicated header, improving code organization and logical grouping. Headers that relied on these definitions are updated accordingly.
This change introduces a new utility function `CountMatchingBits()` to calculate the number of matching leading bits between two byte arrays. This new fn replaces the now-removed `Ip6::Prefix::MatchLength()`. The previous implementation was specific to the `Ip6::Prefix` class. The new generic function is placed in `common/bit_utils` and is used to update `Ip6::Prefix`, `Ip6::Address`, `Ip4::Cidr`, and `PrefixTlv`. A new unit test `test_bit_utils` is added with comprehensive tests for the new function. The existing tests for `CountBitsInMask` are also moved into this new test file.
This commit introduces a set of public APIs to allow manipulation of `otSteeringData`. The new APIs are provided when the configuration `OPENTHREAD_CONFIG_MESHCOP_STEERING_DATA_API_ENABLE` is enabled. The internal `SteeringData` is also improved to enhance robustness. Methods such as `Init()`, `UpdateBloomFilter()` now return an `Error` to signal failures on invalid arguments (e.g., invalid length) instead of asserting.
This commit introduces validation for names provided to mDNS browser, resolver, and querier start and stop functions. New `ValidateNamesIn()` overloads are added to check the validity of service types, instance names, and host names passed to APIs like `otMdnsStartBrowser()`, `otMdnsStartSrvResolver()`, etc.
This change adds `EvictActiveCommissioner()` to the Border Agent, which sends a `LeaderKeepAlive` TMF message with a `StateTlv` of `kReject` to the Leader, causing the current active commissioner to be evicted. The feature is exposed through: - A new public C API `otBorderAgentEvictActiveCommissioner()`. - A new CLI command `ba evictcommissioner`. The entire feature is guarded by a new configuration flag, `OPENTHREAD_CONFIG_BORDER_AGENT_COMMISSIONER_EVICTION_API_ENABLE`, which is disabled by default. This provides an administrator-level tool to remove a stale or misbehaving commissioner, which is particularly useful when the commissioner is connected through a different border agent and cannot be managed locally. A new test is also added to verify the eviction behavior.
This commit fixes an issue with `Utils::Heap::CAlloc()` method. This method performs a multiplication of `aCount` and `aSize` input and then casts the result to `uint16_t`. This commit adds a check to ensure that this conversion does not result in an integer overflow, which would cause the size to warp to an unexpected smaller value.
This commit updates `RxMessage::Init()` to handle failures when reserving capacity for the questions array. Previously, an allocation failure would trigger an assertion. By switching to `SuccessOrExit`, the method can now gracefully handle the allocation failure by returning an error and dropping the message. This aligns with the general error handling strategy for received messages and makes the implementation more robust against out-of-memory conditions.
…195) This commit disables Discovery Proxy in otbr Backbone CI. Because in this item, `BORDER_ROUTING` is explicitly disabled and it is required by OT discovery proxy. This commit removes `"-DOTBR_DNS_UPSTREAM_QUERY=ON"` in build script because this option will automatically handled in the cmake options file and it also depends on BORDER_ROUTING. Force it to be ON will cause a conflict when BORDER_ROUTING is OFF.
The sanitizer code won't be used on posix platform.
Bumps [actions/github-script](https://github.com/actions/github-script) from 7.0.1 to 8.0.0. - [Release notes](https://github.com/actions/github-script/releases) - [Commits](actions/github-script@60a0d83...ed59741) --- updated-dependencies: - dependency-name: actions/github-script dependency-version: 8.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit changes the virtual UART to be configured at runtime, which eliminates a build variants, which causes code coverage process problem.
This commit introduces a client/server mechanism to the History Tracker module. This allows a device to query history information from another device over the Thread network using TMF messages. The new functionality is composed of three main parts: - Server (`HistoryTracker::Server`): This component is responsible for handling incoming TMF query requests (`h/qy`). It collects the requested local history entries (e.g., Network Info), formats them into TLVs, and sends them back to the requester in one or more TMF answer messages (`h/an`). It can fragment large responses into multiple messages. - Client (`HistoryTracker::Client`): This provides a new public API (`otHistoryTrackerQueryNetInfo`) to send a query to a remote device. It handles sending the request and processing the received answer(s), passing the retrieved history entries to the user via a callback. A function to cancel an ongoing query (`otHistoryTrackerCancelQuery`) is also added. - TLVs (`history_tracker_tlvs`): New TLVs are defined for the query/answer protocol, including `RequestTlv` to specify the query parameters, `AnswerTlv` to manage multi-message responses, `NetworkInfoTlv` to carry the data, and `QueryIdTlv` to correlate requests and responses. A new CLI command, `history query netinfo`, is added to use the new client API. The existing `history netinfo` output logic is refactored into helper methods to be shared by both the local and remote history commands. The new feature can be enabled/disabled using two new configuration flags: - `OPENTHREAD_CONFIG_HISTORY_TRACKER_SERVER_ENABLE` - `OPENTHREAD_CONFIG_HISTORY_TRACKER_CLIENT_ENABLE`
This commit introduces new APIs to handle Thread Administration One-Time Passcodes (TAP). The new `otBorderAgentEphemeralKeyGenerateTap()` API generates a cryptographically secure 9-character TAP string. This consists of eight random numeric digits and a final check digit calculated using the Verhoeff algorithm for error detection. The corresponding `otBorderAgentEphemeralKeyValidateTap()` API validates a given TAP string by checking its length, ensuring it contains only digits, and verifying the Verhoeff checksum. A new test is added to ensure the correctness of both the generation and validation logic, covering success and failure scenarios.
This commit enhances the robustness of interface management with two improvements: 1. The `SendIcmp6Nd` function now explicitly handles `EADDRNOTAVAIL` and `ENODEV` errors from the `sendmsg()` system call. These errors often indicate that the interface is down or has lost its addresses. Upon that, we trigger an immediate re-evaluation of the interface's state by calling `otPlatInfraIfStateChanged()`. 2. The `GetFlags` function has been updated to also verify mInfraIndex and mInfraName not changed.
Add a MessagePool destructor that calls the new `otPlatMessagePoolDeinit` hook so platform-managed buffer pools get torn down.
This commit clarifies the expected platform behavior for handling a DNS upstream query cancellation. The previous documentation was inconsistent. The documentation of `otPlatDnsStartUpstreamQuery()` incorrectly stated that the platform must not call `otPlatDnsUpstreamQueryDone()` on a cancelled transaction, while the opposite was mentioned in `otPlatDnsCancelUpstreamQuery()`. This is now corrected to state that the platform MUST always invoke the `otPlatDnsUpstreamQueryDone()` callback for every `otPlatDnsStartUpstreamQuery()`, even if the query is cancelled using `otPlatDnsCancelUpstreamQuery()`.
…212) Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 5.0.0 to 6.0.0. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](actions/upload-artifact@330a01c...b7c566a) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-version: 6.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit enhances the build process by introducing a mechanism to automatically clean intermediate build artifacts. Specifically, it configures the build script to remove object and archive files, a process that is conditionally activated, primarily within GitHub Actions workflows, to optimize build environments and manage disk space more efficiently.
This commit adds the tcp support in gn build for projects relying on OpenThread.
This change moves the CLI implementation for the Border Agent from the main `cli.cpp` into a new dedicated `Ba` class within `cli_ba.cpp` and `cli_ba.hpp`. The new `Ba` module is integrated into the main `Interpreter` class, following the same pattern used by other CLI modules such as `Bbr` and `Br`. This improves code organization and modularity, making the CLI codebase easier to navigate and maintain. The functionality of the `ba` commands remains unchanged.
…der (#12215) This change moves all public APIs related to the Border Agent's ephemeral key feature out of `border_agent.h` and into a new, dedicated header file `border_agent_ephemeral_key.h`. The corresponding C API implementations are also moved from `border_agent_api.cpp` into a new dedicated `border_agent_ephemeral_key_api.cpp` file. This improves the organization and modularity of the public API, making the codebase easier to navigate and understand.
…2220) This commit introduces `SafeMultiply()` in `num_utils.hpp` as a centralized and safe way to multiply two unsigned integers while checking for overflow. It updates `Coap::TxParameters::IsValid()` to use this new helper for validating `TxParameters`, replacing a less robust local `Multiply` implementation. It also updates `Heap::CAlloc()` to use this function for safely calculating the total allocation size. Unit tests are updated to verify `SafeMultiply()` implementation.
This commit moves the implementation of `InvokeResponseFallback()` to the `cpp` file. It also ensures that the implementation follows the style guide requirement of single `return` from any method/function.
…hs (#12224) This commit enhances the `TestMessage()` unit test by parameterizing it to run with various reserved length values. The test is now executed in a loop with a set of different headroom reservation values. This change improves test coverage for the `Message` class by verifying that all its core operations function correctly when messages are allocated with various initial reserved header lengths.
This commit adds a compile-time check to ensure that the Linux kernel version is 4.18 or newer for prefix route metric as `IFA_RT_PRIORITY` attribute for netlink messages was introduced in v4.18. `OPENTHREAD_POSIX_CONFIG_INSTALL_OMR_ROUTES_ENABLE` can be an alternative for prioritizing Off-Mesh-Routable (OMR) prefixes for older kernels.
This commit introduces a new public NAT66 related API function, `otNat64StateToString()`, to convert an `otNat64State` enum value into a human-readable string. The `nat64 state` CLI command is updated to use this new function, removing its local and duplicated enum-to-string logic.
This commit replaces `// Fall through` with `OT_FALL_THROUGH` because the former is not recognized by some compilers.
…12217) This change introduces new overloads for `Coap::SendMessage()` that accept an `OwnedPtr<Message>`, transferring ownership of the message to the CoAP layer upon being called. The modules `BorderAgent` and `Commissioner` are updated to use this new method. The use of `OwnedPtr<Message>` simplifies the message allocation and cleanup. This removes the need for manual clean up calls(e.g., `FreeMessageOnError()`) and makes the code safer.
This change improves the design and implementation of the CoAP response caching mechanism. The main changes are: - `ResponsesQueue` is renamed to `ResponseCache` to better reflect its purpose. - `ResponseCache` is moved to be a private nested class within `CoapBase` to improve encapsulation. - The responsibility of sending a cached response is moved into the `ResponseCache` class. A new `SendCachedResponse()` method handles finding, cloning, and sending the cached response, which simplifies the `ProcessReceivedRequest()` method in `CoapBase`. - Method names within `ResponseCache` are updated for better clarity (e.g., `DequeueAllResponses()` to `RemoveAll()`). - Comments are updated to align with the new design. This change results in a cleaner design with better-defined responsibilities for the `ResponseCache` and `CoapBase` classes.
This commit updates `Server::PrepareAndSendAnswers()` to utilize `Tlv::ParsedInfo` for more robust TLV parsing and validation. This ensures correct validation and size calculation for both standard and extended TLVs when iterating over TLVs through the received message. This change also adds an explicit check to skip over extended TLVs, ensuring the implementation correctly handles cases where extended TLVs may be present.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a draft PR which will be updated in the near future with a newer OpenThread commit.
The purpose of this PR is to make use of the newly added features in OpenThread stack code.