diff --git a/subsys/net/l2/openthread/openthread_utils.c b/subsys/net/l2/openthread/openthread_utils.c index 28b8f9f7fe6..8aacc864f69 100644 --- a/subsys/net/l2/openthread/openthread_utils.c +++ b/subsys/net/l2/openthread/openthread_utils.c @@ -216,9 +216,19 @@ void add_ipv6_addr_to_ot(struct openthread_context *context, } openthread_mutex_lock(); - error = otIp6AddUnicastAddress(openthread_get_default_instance(), &addr); + if (!otIp6HasUnicastAddress(openthread_get_default_instance(), + &addr.mAddress)) { + error = otIp6AddUnicastAddress(openthread_get_default_instance(), + &addr); + } else { + error = OT_ERROR_ALREADY; + } openthread_mutex_unlock(); + if (error == OT_ERROR_ALREADY) { + return; + } + if (error != OT_ERROR_NONE) { NET_ERR("Failed to add IPv6 unicast address %s [%d]", net_sprint_ipv6_addr(addr6), error); @@ -239,6 +249,10 @@ void add_ipv6_maddr_to_ot(struct openthread_context *context, error = otIp6SubscribeMulticastAddress(openthread_get_default_instance(), &addr); openthread_mutex_unlock(); + if (error == OT_ERROR_ALREADY) { + return; + } + if (error != OT_ERROR_NONE) { NET_ERR("Failed to add IPv6 multicast address %s [%d]", net_sprint_ipv6_addr(addr6), error);