Skip to content
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

net: openthread: Fix the handling of address state changes #77210

Merged
merged 1 commit into from
Aug 20, 2024

Conversation

LuDuda
Copy link
Contributor

@LuDuda LuDuda commented Aug 18, 2024

The #76671 fixed the issue where a deprecated address might have been used as a source address, leading to routing issues until the address was completely removed. What was missed in the implementation was the case where the address changes its state back to "preferred" from "deprecated." In such case OpenThread emits OT_CHANGED_IP6_ADDRESS_REMOVED and OT_CHANGED_IP6_ADDRESS_ADDED events, but it does so simultaneously in one callback and without the hard removal that was previously assumed. This commit simply removes the if-statement, allowing the address state to be set at any time, whether during the initial addition of the address or during any update. Btw. I believe the current implementation of synchronization of the addresses coulb be simplified by utilizing a new API otIp6SetAddressCallback - i can look at this in the future.

Testing was conducted manually by removing/adding the prefix and observing the net ipv6 shell output.

Additionally, during static code analysis, I believe I found an issue with prefix comparison in the is_mesh_prefix function. It was assumed that the prefix was the size of a pointer, which in rare situations, where the mesh-local prefix and on-mesh prefix have the same first bytes, may lead to a situation where no communication can occur.

This commit ensures that the state of the address can be changed from
the Deprecated state to the Preferred state.

Additionally, an issue with improper memory comparison size for the mesh
local prefix has been fixed.

Signed-off-by: Łukasz Duda <lukasz.duda@nordicsemi.no>
@edmont edmont added the bug The issue is a bug, or the PR is fixing a bug label Aug 19, 2024
@nashif nashif merged commit 6eb1e65 into zephyrproject-rtos:main Aug 20, 2024
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Networking area: OpenThread bug The issue is a bug, or the PR is fixing a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants