Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit a5f9b81

Browse files
authored
Merge pull request #395 from robszewczyk/bug/device-layer-address-removal
Fix re-joining to the disconnected Thread network
2 parents 37b3c15 + c78478e commit a5f9b81

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/adaptations/device-layer/LwIP/WarmSupport.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,15 @@ PlatformResult AddRemoveHostAddress(InterfaceType inInterfaceType, const Inet::I
132132
else
133133
{
134134
lwipErr = netif_remove_ip6_address_with_route(netif, &ip6addr, inPrefixLength);
135+
// There are two possible errors from netif_remove_ip6_address: ERR_ARG
136+
// if call was made with wrong arguments, or ERR_VAL if the action could
137+
// not be performed (e.g. the address was already removed). We squash
138+
// ERR_VAL, and return SUCCESS so that WARM can set its state correctly.
139+
if (lwipErr == ERR_VAL)
140+
{
141+
WeaveLogProgress(DeviceLayer, "netif_remove_ip6_address_with_route: Already removed");
142+
lwipErr = ERR_OK;
143+
}
135144
err = System::MapErrorLwIP(lwipErr);
136145
if (err != WEAVE_NO_ERROR)
137146
{
@@ -311,6 +320,16 @@ PlatformResult AddRemoveThreadAddress(InterfaceType inInterfaceType, const Inet:
311320
else
312321
{
313322
otErr = otIp6RemoveUnicastAddress(ThreadStackMgrImpl().OTInstance(), &otAddress.mAddress);
323+
// There are two possible errors from otIp6RemoveUnicastAddress:
324+
// OT_ERROR_INVALID_ARGS if the address was a multicast address, and
325+
// OT_ERROR_NOT_FOUND if the address does not exist on the thread
326+
// interface. We squash the OT_ERROR_NOT_FOUND so that WARM sets its
327+
// state correctly.
328+
if (otErr == OT_ERROR_NOT_FOUND)
329+
{
330+
WeaveLogProgress(DeviceLayer, "otIp6RemoveUnicastAddress: already removed");
331+
otErr = OT_ERROR_NONE;
332+
}
314333
}
315334

316335
ThreadStackMgrImpl().UnlockThreadStack();
@@ -442,4 +461,3 @@ const char * WarmInterfaceTypeToStr(InterfaceType inInterfaceType)
442461
} // namespace DeviceLayer
443462
} // namespace Weave
444463
} // namespace nl
445-

0 commit comments

Comments
 (0)