[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:
Rongli Sun
2019-11-07 04:48:50 -08:00
committed by Jonathan Hui
parent aab693f9c3
commit 75bb2a9dd1
3 changed files with 30 additions and 0 deletions
+18
View File
@@ -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;
+9
View File
@@ -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);
+3
View File
@@ -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)