Skip to content

Commit

Permalink
[routing-manager] check local on-link prefix in IsAddressOnLink() (o…
Browse files Browse the repository at this point in the history
…penthread#10836)

This commit adds `OnLinkPrefixManager::AddressMatchesLocalPrefix()`
method, which checks whether a given address matches the current
local on-link prefix only when the prefix is valid (being published,
advertised, or deprecated by the BR). This method is used in
`RxRaTracker::IsAddressOnLink()`, ensuring that the local prefix is
always explicitly checked. This makes the check more robust and
independent of whether `RxRaTracker` receives and tracks
self-generated RAs.
  • Loading branch information
abtink authored Oct 17, 2024
1 parent b807084 commit deb35b0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/core/border_router/routing_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1845,7 +1845,9 @@ void RoutingManager::RxRaTracker::SetHeaderFlagsOn(RouterAdvert::Header &aHeader

bool RoutingManager::RxRaTracker::IsAddressOnLink(const Ip6::Address &aAddress) const
{
bool isOnLink = false;
bool isOnLink = Get<RoutingManager>().mOnLinkPrefixManager.AddressMatchesLocalPrefix(aAddress);

VerifyOrExit(!isOnLink);

for (const Router &router : mRouters)
{
Expand Down Expand Up @@ -2623,6 +2625,17 @@ void RoutingManager::OnLinkPrefixManager::Stop(void)
}
}

bool RoutingManager::OnLinkPrefixManager::AddressMatchesLocalPrefix(const Ip6::Address &aAddress) const
{
bool matches = false;

VerifyOrExit(GetState() != kIdle);
matches = aAddress.MatchesPrefix(mLocalPrefix);

exit:
return matches;
}

void RoutingManager::OnLinkPrefixManager::Evaluate(void)
{
VerifyOrExit(!Get<RoutingManager>().mRsSender.IsInProgress());
Expand Down
1 change: 1 addition & 0 deletions src/core/border_router/routing_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,7 @@ class RoutingManager : public InstanceLocator
void Evaluate(void);
const Ip6::Prefix &GetLocalPrefix(void) const { return mLocalPrefix; }
const Ip6::Prefix &GetFavoredDiscoveredPrefix(void) const { return mFavoredDiscoveredPrefix; }
bool AddressMatchesLocalPrefix(const Ip6::Address &aAddress) const;
bool IsInitalEvaluationDone(void) const;
void HandleRaPrefixTableChanged(void);
bool ShouldPublishUlaRoute(void) const;
Expand Down

0 comments on commit deb35b0

Please sign in to comment.