[address-resolver] remove cache entry if its RLOC16 is unreachable (#9411)

This commit updates `AddressResolver::Resolve()` to validate that the
associated RLOC16 is reachable in the sense that a valid next hop can
be found towards it, before using a matching cache entry in
`mCachedList` or `mSnoopedList`. If the RLOC16 is not reachable, the
cache entry is removed to trigger a new address query.
This commit is contained in:
Abtin Keshavarzian
2023-09-13 11:35:32 -07:00
committed by GitHub
parent 694528a9b9
commit 45727d3dc9
+28 -17
View File
@@ -491,6 +491,34 @@ Error AddressResolver::Resolve(const Ip6::Address &aEid, Mac::ShortAddress &aRlo
entry = FindCacheEntry(aEid, list, prev);
if ((entry != nullptr) && ((list == &mCachedList) || (list == &mSnoopedList)))
{
list->PopAfter(prev);
if (Get<RouterTable>().GetNextHop(entry->GetRloc16()) == Mle::kInvalidRloc16)
{
// If the `entry->GetRloc16()` is unreachable (there is no valid
// next hop towards it), we clear the entry so to start a new
// address query.
mCacheEntryPool.Free(*entry);
entry = nullptr;
}
else
{
// Push the entry at the head of cached list.
if (list == &mSnoopedList)
{
entry->MarkLastTransactionTimeAsInvalid();
}
mCachedList.Push(*entry);
aRloc16 = entry->GetRloc16();
ExitNow();
}
}
if (entry == nullptr)
{
// If the entry is not present in any of the lists, try to
@@ -510,23 +538,6 @@ Error AddressResolver::Resolve(const Ip6::Address &aEid, Mac::ShortAddress &aRlo
list = nullptr;
}
if ((list == &mCachedList) || (list == &mSnoopedList))
{
// Remove the entry from its current list and push it at the
// head of cached list.
list->PopAfter(prev);
if (list == &mSnoopedList)
{
entry->MarkLastTransactionTimeAsInvalid();
}
mCachedList.Push(*entry);
aRloc16 = entry->GetRloc16();
ExitNow();
}
// Note that if `aAllowAddressQuery` is `false` then the `entry`
// is definitely already in a list, i.e., we cannot not get here
// with `aAllowAddressQuery` being `false` and `entry` being a