mirror of
https://github.com/espressif/openthread.git
synced 2026-07-28 06:37:46 +00:00
[address-resolver] update EID-to-RLOC cache when attaching MTD child (#4282)
This commits removes deprecated EID-to-RLOC cache if there is entry for the unicast address registered by MTD child in case this child switches its parent.
This commit is contained in:
@@ -115,6 +115,20 @@ void AddressResolver::Remove(uint16_t aRloc16)
|
||||
}
|
||||
}
|
||||
|
||||
void AddressResolver::Remove(const Ip6::Address &aEid)
|
||||
{
|
||||
for (int i = 0; i < kCacheEntries; i++)
|
||||
{
|
||||
if (mCache[i].mState == Cache::kStateInvalid || mCache[i].mTarget != aEid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
InvalidateCacheEntry(mCache[i], kReasonRemovingEid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
AddressResolver::Cache *AddressResolver::NewCacheEntry(void)
|
||||
{
|
||||
Cache *rval = NULL;
|
||||
@@ -174,6 +188,10 @@ const char *AddressResolver::ConvertInvalidationReasonToString(InvalidationReaso
|
||||
case kReasonEvictingForNewEntry:
|
||||
str = "evicting for new entry";
|
||||
break;
|
||||
|
||||
case kReasonRemovingEid:
|
||||
str = "removing eid";
|
||||
break;
|
||||
}
|
||||
|
||||
return str;
|
||||
|
||||
@@ -102,6 +102,14 @@ public:
|
||||
*/
|
||||
void Remove(uint8_t aRouterId);
|
||||
|
||||
/**
|
||||
* This method removes the cache entry for the EID.
|
||||
*
|
||||
* @param[in] aEid A reference to the EID.
|
||||
*
|
||||
*/
|
||||
void Remove(const Ip6::Address &aEid);
|
||||
|
||||
/**
|
||||
* This method updates an existing cache entry for the EID.
|
||||
*
|
||||
@@ -197,6 +205,7 @@ private:
|
||||
kReasonRemovingRloc16,
|
||||
kReasonReceivedIcmpDstUnreachNoRoute,
|
||||
kReasonEvictingForNewEntry,
|
||||
kReasonRemovingEid,
|
||||
};
|
||||
|
||||
static const char *ConvertInvalidationReasonToString(InvalidationReason aReason);
|
||||
|
||||
@@ -2036,6 +2036,9 @@ otError MleRouter::UpdateChildAddresses(const Message &aMessage, uint16_t aOffse
|
||||
|
||||
IgnoreReturnValue(iter.GetChild()->RemoveIp6Address(GetInstance(), address));
|
||||
}
|
||||
|
||||
// Clear EID-to-RLOC cache for the unicast address registered by the child.
|
||||
Get<AddressResolver>().Remove(address);
|
||||
}
|
||||
|
||||
if (registeredCount == 0)
|
||||
|
||||
Reference in New Issue
Block a user