[mle] invalidate EID-to-RLOC cache entries while removing a neighbor

Signed-off-by: Duda, Lukasz <[email protected]>
This commit is contained in:
Duda, Lukasz
2018-01-05 17:16:07 +00:00
committed by Jonathan Hui
parent c26f5e3bbe
commit 41e4b3202b
3 changed files with 37 additions and 3 deletions
+17 -2
View File
@@ -97,17 +97,28 @@ exit:
return error;
}
void AddressResolver::Remove(uint8_t routerId)
void AddressResolver::Remove(uint8_t aRouterId)
{
for (int i = 0; i < kCacheEntries; i++)
{
if (Mle::Mle::GetRouterId(mCache[i].mRloc16) == routerId)
if (Mle::Mle::GetRouterId(mCache[i].mRloc16) == aRouterId)
{
InvalidateCacheEntry(mCache[i], kReasonRemovingRouterId);
}
}
}
void AddressResolver::Remove(uint16_t aRloc16)
{
for (int i = 0; i < kCacheEntries; i++)
{
if (mCache[i].mRloc16 == aRloc16)
{
InvalidateCacheEntry(mCache[i], kReasonRemovingRloc16);
}
}
}
AddressResolver::Cache *AddressResolver::NewCacheEntry(void)
{
Cache *rval = NULL;
@@ -156,6 +167,10 @@ const char *AddressResolver::ConvertInvalidationReasonToString(InvalidationReaso
str = "removing router id";
break;
case kReasonRemovingRloc16:
str = "removing rloc16";
break;
case kReasonReceivedIcmpDstUnreachNoRoute:
str = "received icmp no route";
break;
+10 -1
View File
@@ -94,7 +94,15 @@ public:
otError GetEntry(uint8_t aIndex, otEidCacheEntry &aEntry) const;
/**
* This method removes a Router ID from the EID-to-RLOC cache.
* This method removes the EID-to-RLOC cache entries corresponding to an RLOC16.
*
* @param[in] aRloc16 The RLOC16 address.
*
*/
void Remove(uint16_t aRloc16);
/**
* This method removes all EID-to-RLOC cache entries assossiated with a Router ID.
*
* @param[in] aRouterId The Router ID.
*
@@ -169,6 +177,7 @@ private:
enum InvalidationReason
{
kReasonRemovingRouterId,
kReasonRemovingRloc16,
kReasonReceivedIcmpDstUnreachNoRoute,
kReasonEvictingForNewEntry,
};
+10
View File
@@ -3244,6 +3244,13 @@ otError MleRouter::RemoveNeighbor(Neighbor &aNeighbor)
aNeighbor.SetState(Neighbor::kStateInvalid);
netif.GetMeshForwarder().UpdateIndirectMessages();
netif.GetNetworkDataLeader().SendServerDataNotification(aNeighbor.GetRloc16());
if (aNeighbor.GetDeviceMode() & ModeTlv::kModeFFD)
{
// Clear all EID-to-RLOC entries assossiated with the child.
netif.GetAddressResolver().Remove(aNeighbor.GetRloc16());
}
RemoveStoredChild(aNeighbor.GetRloc16());
}
else if ((aNeighbor.GetState() == Neighbor::kStateValid) && IsActiveRouter(aNeighbor.GetRloc16()))
@@ -3270,6 +3277,9 @@ otError MleRouter::RemoveNeighbor(Neighbor &aNeighbor)
if (routerToRemove.GetNextHop() == kInvalidRouterId)
{
ResetAdvertiseInterval();
// Clear all EID-to-RLOC entries assossiated with the router.
netif.GetAddressResolver().Remove(GetRouterId(aNeighbor.GetRloc16()));
}
}