Skip to content

Commit

Permalink
net: openthread: Fix the handling of address state changes
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
LuDuda committed Aug 18, 2024
1 parent ad3e941 commit b6bc933
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions subsys/net/l2/openthread/openthread_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static bool is_mesh_local(struct openthread_context *context,
const otMeshLocalPrefix *ml_prefix =
otThreadGetMeshLocalPrefix(context->instance);

return (memcmp(address, ml_prefix->m8, sizeof(ml_prefix)) == 0);
return (memcmp(address, ml_prefix->m8, sizeof(ml_prefix->m8)) == 0);
}

int pkt_list_add(struct openthread_context *context, struct net_pkt *pkt)
Expand Down Expand Up @@ -156,9 +156,7 @@ void add_ipv6_addr_to_zephyr(struct openthread_context *context)
context, address->mAddress.mFields.m8);

/* Mark address as deprecated if it is not preferred. */
if (!address->mPreferred) {
if_addr->addr_state = NET_ADDR_DEPRECATED;
}
if_addr->addr_state = address->mPreferred ? NET_ADDR_PREFERRED : NET_ADDR_DEPRECATED;

Check warning on line 159 in subsys/net/l2/openthread/openthread_utils.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LONG_LINE

subsys/net/l2/openthread/openthread_utils.c:159 line length of 101 exceeds 100 columns
}

Check notice on line 160 in subsys/net/l2/openthread/openthread_utils.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

subsys/net/l2/openthread/openthread_utils.c:160 - if_addr->addr_state = address->mPreferred ? NET_ADDR_PREFERRED : NET_ADDR_DEPRECATED; + if_addr->addr_state = + address->mPreferred ? NET_ADDR_PREFERRED : NET_ADDR_DEPRECATED;
}

Expand Down

0 comments on commit b6bc933

Please sign in to comment.