mirror of
https://github.com/espressif/openthread.git
synced 2026-08-24 11:19:51 +00:00
[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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user