From 71ebacca53dd34d7b71da668f5f5dc430bb027cb Mon Sep 17 00:00:00 2001 From: Simon Lin Date: Fri, 31 Dec 2021 14:48:23 +0800 Subject: [PATCH] [border-routing] invalidate discovered OMR prefixes when Network Data change (#7246) This commit enhances Border Routing to ignore discovered OMR Prefixes when Network Data change. It's possible that a BR may learn an OMR prefix from RA, and later learn the same OMR Prefix from Network Data. In such case, the BR should remove the discovered OMR Prefix. --- src/core/border_router/routing_manager.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/core/border_router/routing_manager.cpp b/src/core/border_router/routing_manager.cpp index 591e57a0d..8c7894816 100644 --- a/src/core/border_router/routing_manager.cpp +++ b/src/core/border_router/routing_manager.cpp @@ -327,6 +327,8 @@ void RoutingManager::HandleNotifierEvents(Events aEvents) if (mIsRunning && aEvents.Contains(kEventThreadNetdataChanged)) { + // Invalidate discovered prefixes because OMR Prefixes in Network Data may change. + InvalidateDiscoveredPrefixes(); StartRoutingPolicyEvaluationDelay(); } @@ -1177,6 +1179,9 @@ void RoutingManager::UpdateDiscoveredOmrPrefix(const RouterAdv::RouteInfoOption ExitNow(); } + // Ignore own OMR prefix. + VerifyOrExit(mLocalOmrPrefix != prefix); + // Ignore OMR prefixes advertised by ourselves or in current Thread Network Data. // The `mAdvertisedOmrPrefixes` and the OMR prefix set in Network Data should eventually // be equal, but there is time that they are not synchronized immediately: @@ -1251,8 +1256,14 @@ void RoutingManager::InvalidateDiscoveredPrefixes(const Ip6::Prefix *aPrefix, bo for (const ExternalPrefix &prefix : mDiscoveredPrefixes) { - if ((aPrefix != nullptr && prefix.mPrefix == *aPrefix && prefix.mIsOnLinkPrefix == aIsOnLinkPrefix) || - (prefix.GetExpireTime() <= now)) + if ( + // Invalidate specified prefix + (aPrefix != nullptr && prefix.mPrefix == *aPrefix && prefix.mIsOnLinkPrefix == aIsOnLinkPrefix) || + // Invalidate expired prefix + (prefix.GetExpireTime() <= now) || + // Invalidate Local OMR prefixes + (!prefix.mIsOnLinkPrefix && + (mAdvertisedOmrPrefixes.Contains(prefix.mPrefix) || NetworkDataContainsOmrPrefix(prefix.mPrefix)))) { RemoveExternalRoute(prefix.mPrefix); }