mirror of
https://github.com/espressif/openthread.git
synced 2026-08-05 18:37:45 +00:00
[routing-manager] simplify how RxRaTracker handles local on-link prefix (#10291)
This commit introduces the following changes: - Adds a new callback `HandleLocalOnLinkPrefixChanged()` for `OnLinkPrefixManager` to signal changes to the local on-link prefix (derived from the extended PAN ID). - Modifies `RxRaTracker` to always ignore a PIO prefix matching the local on-link prefix, regardless of the current state of `OnLinkPrefixManager`. Such a PIO originates from another Thread border router connected to the same Thread network and is not used by `OnLinkPrefixManager` to decide whether it needs to advertise the local on-link prefix. - Updates `RxRaTracker` to be notified when the local on-link prefix changes. In its `HandleLocalOnLinkPrefixChanged()`, it removes any prefixes in the table matching the new prefix.
This commit is contained in:
@@ -750,6 +750,22 @@ exit:
|
||||
return;
|
||||
}
|
||||
|
||||
void RoutingManager::HandleLocalOnLinkPrefixChanged(void)
|
||||
{
|
||||
// This is a callback from `OnLinkPrefixManager` indicating
|
||||
// that the local on-link prefix is changed. The local on-link
|
||||
// prefix is derived from extended PAN ID.
|
||||
|
||||
VerifyOrExit(mIsRunning);
|
||||
|
||||
mRoutePublisher.Evaluate();
|
||||
mRxRaTracker.HandleLocalOnLinkPrefixChanged();
|
||||
ScheduleRoutingPolicyEvaluation(kAfterRandomDelay);
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
|
||||
bool RoutingManager::NetworkDataContainsUlaRoute(void) const
|
||||
{
|
||||
// Determine whether leader Network Data contains a route
|
||||
@@ -1123,10 +1139,7 @@ void RoutingManager::RxRaTracker::ProcessPrefixInfoOption(const PrefixInfoOption
|
||||
ExitNow();
|
||||
}
|
||||
|
||||
if (Get<RoutingManager>().mOnLinkPrefixManager.IsPublishingOrAdvertising())
|
||||
{
|
||||
VerifyOrExit(prefix != Get<RoutingManager>().mOnLinkPrefixManager.GetLocalPrefix());
|
||||
}
|
||||
VerifyOrExit(prefix != Get<RoutingManager>().mOnLinkPrefixManager.GetLocalPrefix());
|
||||
|
||||
LogPrefixInfoOption(prefix, aPio.GetValidLifetime(), aPio.GetPreferredLifetime());
|
||||
|
||||
@@ -1348,13 +1361,14 @@ void RoutingManager::RxRaTracker::FindFavoredOnLinkPrefix(Ip6::Prefix &aPrefix)
|
||||
}
|
||||
}
|
||||
|
||||
void RoutingManager::RxRaTracker::RemoveOnLinkPrefix(const Ip6::Prefix &aPrefix)
|
||||
void RoutingManager::RxRaTracker::HandleLocalOnLinkPrefixChanged(void)
|
||||
{
|
||||
bool didRemove = false;
|
||||
const Ip6::Prefix &prefix = Get<RoutingManager>().mOnLinkPrefixManager.GetLocalPrefix();
|
||||
bool didRemove = false;
|
||||
|
||||
for (Router &router : mRouters)
|
||||
{
|
||||
didRemove |= router.mOnLinkPrefixes.RemoveAndFreeAllMatching(aPrefix);
|
||||
didRemove |= router.mOnLinkPrefixes.RemoveAndFreeAllMatching(prefix);
|
||||
}
|
||||
|
||||
VerifyOrExit(didRemove);
|
||||
@@ -2315,13 +2329,6 @@ void RoutingManager::OnLinkPrefixManager::Evaluate(void)
|
||||
|
||||
PublishAndAdvertise();
|
||||
|
||||
// We remove the local on-link prefix from the discovered prefix
|
||||
// table, in case it was previously discovered and is now
|
||||
// deprecating. `ShouldProcessPrefixInfoOption()` also prevents
|
||||
// adding the local prefix to the table while we're advertising it.
|
||||
|
||||
Get<RoutingManager>().mRxRaTracker.RemoveOnLinkPrefix(mLocalPrefix);
|
||||
|
||||
mFavoredDiscoveredPrefix.Clear();
|
||||
}
|
||||
else if (IsPublishingOrAdvertising())
|
||||
@@ -2566,11 +2573,7 @@ void RoutingManager::OnLinkPrefixManager::HandleExtPanIdChange(void)
|
||||
break;
|
||||
}
|
||||
|
||||
if (Get<RoutingManager>().mIsRunning)
|
||||
{
|
||||
Get<RoutingManager>().mRoutePublisher.Evaluate();
|
||||
Get<RoutingManager>().ScheduleRoutingPolicyEvaluation(kAfterRandomDelay);
|
||||
}
|
||||
Get<RoutingManager>().HandleLocalOnLinkPrefixChanged();
|
||||
|
||||
exit:
|
||||
return;
|
||||
|
||||
@@ -755,8 +755,8 @@ private:
|
||||
|
||||
void FindFavoredOnLinkPrefix(Ip6::Prefix &aPrefix) const;
|
||||
|
||||
void HandleLocalOnLinkPrefixChanged(void);
|
||||
void HandleNetDataChange(void);
|
||||
void RemoveOnLinkPrefix(const Ip6::Prefix &aPrefix);
|
||||
|
||||
void RemoveOrDeprecateOldEntries(TimeMilli aTimeThreshold);
|
||||
|
||||
@@ -1028,7 +1028,6 @@ private:
|
||||
void HandleRaPrefixTableChanged(void);
|
||||
bool ShouldPublishUlaRoute(void) const;
|
||||
Error AppendAsPiosTo(RouterAdvert::TxMessage &aRaMessage);
|
||||
bool IsPublishingOrAdvertising(void) const;
|
||||
void HandleNetDataChange(void);
|
||||
void HandleExtPanIdChange(void);
|
||||
void HandleTimer(void);
|
||||
@@ -1052,6 +1051,7 @@ private:
|
||||
|
||||
State GetState(void) const { return mState; }
|
||||
void SetState(State aState);
|
||||
bool IsPublishingOrAdvertising(void) const;
|
||||
void GenerateLocalPrefix(void);
|
||||
void PublishAndAdvertise(void);
|
||||
void Deprecate(void);
|
||||
@@ -1392,6 +1392,7 @@ private:
|
||||
bool NetworkDataContainsUlaRoute(void) const;
|
||||
|
||||
void HandleRaPrefixTableChanged(void);
|
||||
void HandleLocalOnLinkPrefixChanged(void);
|
||||
|
||||
static bool IsValidBrUlaPrefix(const Ip6::Prefix &aBrUlaPrefix);
|
||||
static bool IsValidOnLinkPrefix(const PrefixInfoOption &aPio);
|
||||
|
||||
Reference in New Issue
Block a user