net: openthread: Fix the handling of address state changes

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>
This commit is contained in:
Łukasz Duda 2024-08-18 18:12:48 +02:00 committed by Anas Nashif
parent dde46a94ba
commit 6eb1e652de

View file

@ -32,7 +32,7 @@ static bool is_mesh_local(struct openthread_context *context,
const otMeshLocalPrefix *ml_prefix = const otMeshLocalPrefix *ml_prefix =
otThreadGetMeshLocalPrefix(context->instance); 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) int pkt_list_add(struct openthread_context *context, struct net_pkt *pkt)
@ -156,9 +156,8 @@ void add_ipv6_addr_to_zephyr(struct openthread_context *context)
context, address->mAddress.mFields.m8); context, address->mAddress.mFields.m8);
/* Mark address as deprecated if it is not preferred. */ /* Mark address as deprecated if it is not preferred. */
if (!address->mPreferred) { if_addr->addr_state =
if_addr->addr_state = NET_ADDR_DEPRECATED; address->mPreferred ? NET_ADDR_PREFERRED : NET_ADDR_DEPRECATED;
}
} }
} }