net: l2: openthread: Fix error logs on adding already present address
Error checking of otIp6AddUnicastAddress() and otIp6SubscribeMulticastAddress() was added recently, however it wasn't taken into account that those APIs return an error on attempt to register an IPv6 address that is already present on the OT interface. Therefore, add more specific error checks, to return silently in case address was already present. As those two APIs are not very consistent, and otIp6AddUnicastAddress() returns OT_ERROR_INVALID_ARGS in such cases, add an extra check if the address is already present before attempting to register the address. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
parent
d89c61bd64
commit
be46c94e3e
1 changed files with 15 additions and 1 deletions
|
@ -216,9 +216,19 @@ void add_ipv6_addr_to_ot(struct openthread_context *context,
|
||||||
}
|
}
|
||||||
|
|
||||||
openthread_mutex_lock();
|
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();
|
openthread_mutex_unlock();
|
||||||
|
|
||||||
|
if (error == OT_ERROR_ALREADY) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (error != OT_ERROR_NONE) {
|
if (error != OT_ERROR_NONE) {
|
||||||
NET_ERR("Failed to add IPv6 unicast address %s [%d]",
|
NET_ERR("Failed to add IPv6 unicast address %s [%d]",
|
||||||
net_sprint_ipv6_addr(addr6), error);
|
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);
|
error = otIp6SubscribeMulticastAddress(openthread_get_default_instance(), &addr);
|
||||||
openthread_mutex_unlock();
|
openthread_mutex_unlock();
|
||||||
|
|
||||||
|
if (error == OT_ERROR_ALREADY) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (error != OT_ERROR_NONE) {
|
if (error != OT_ERROR_NONE) {
|
||||||
NET_ERR("Failed to add IPv6 multicast address %s [%d]",
|
NET_ERR("Failed to add IPv6 multicast address %s [%d]",
|
||||||
net_sprint_ipv6_addr(addr6), error);
|
net_sprint_ipv6_addr(addr6), error);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue