From 39a1f55447f3eec0cf089d8bec29b3303f3e7f99 Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Mon, 8 Nov 2021 21:33:21 -0800 Subject: [PATCH] [routing-manager] require on-link prefix to support SLAAC (#7142) Existing IPv6 implementations may not implement DHCPv6 to acquire an IPv6 address. As a result, a Thread Border Router must advertise a ULA if there is no existing prefix that supports SLAAC (i.e. has A flag set). --- src/core/border_router/routing_manager.cpp | 11 +++++------ src/core/border_router/routing_manager.hpp | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/core/border_router/routing_manager.cpp b/src/core/border_router/routing_manager.cpp index 85ba1e804..693832a97 100644 --- a/src/core/border_router/routing_manager.cpp +++ b/src/core/border_router/routing_manager.cpp @@ -795,10 +795,9 @@ bool RoutingManager::IsValidOmrPrefix(const Ip6::Prefix &aOmrPrefix) (aOmrPrefix.mLength >= 3 && (aOmrPrefix.GetBytes()[0] & 0xE0) == 0x20); } -bool RoutingManager::IsValidOnLinkPrefix(const RouterAdv::PrefixInfoOption &aPio, bool aManagedAddrConfig) +bool RoutingManager::IsValidOnLinkPrefix(const RouterAdv::PrefixInfoOption &aPio) { - return IsValidOnLinkPrefix(aPio.GetPrefix()) && aPio.GetOnLink() && - (aPio.GetAutoAddrConfig() || aManagedAddrConfig); + return IsValidOnLinkPrefix(aPio.GetPrefix()) && aPio.GetOnLink() && aPio.GetAutoAddrConfig(); } bool RoutingManager::IsValidOnLinkPrefix(const Ip6::Prefix &aOnLinkPrefix) @@ -1015,7 +1014,7 @@ void RoutingManager::HandleRouterAdvertisement(const Ip6::Address &aSrcAddress, if (pio->IsValid()) { - needReevaluate |= UpdateDiscoveredPrefixes(*pio, routerAdvMessage->GetManagedAddrConfig()); + needReevaluate |= UpdateDiscoveredPrefixes(*pio); } } break; @@ -1052,7 +1051,7 @@ exit: return; } -bool RoutingManager::UpdateDiscoveredPrefixes(const RouterAdv::PrefixInfoOption &aPio, bool aManagedAddrConfig) +bool RoutingManager::UpdateDiscoveredPrefixes(const RouterAdv::PrefixInfoOption &aPio) { Ip6::Prefix prefix = aPio.GetPrefix(); bool needReevaluate = false; @@ -1060,7 +1059,7 @@ bool RoutingManager::UpdateDiscoveredPrefixes(const RouterAdv::PrefixInfoOption ExternalPrefix onLinkPrefix; ExternalPrefix *existingPrefix = nullptr; - if (!IsValidOnLinkPrefix(aPio, aManagedAddrConfig)) + if (!IsValidOnLinkPrefix(aPio)) { otLogInfoBr("Ignore invalid on-link prefix in PIO: %s", prefix.ToString().AsCString()); ExitNow(); diff --git a/src/core/border_router/routing_manager.hpp b/src/core/border_router/routing_manager.hpp index 4d26d2628..bdf86c2b2 100644 --- a/src/core/border_router/routing_manager.hpp +++ b/src/core/border_router/routing_manager.hpp @@ -306,7 +306,7 @@ private: void DeprecateOnLinkPrefix(void); void HandleRouterSolicit(const Ip6::Address &aSrcAddress, const uint8_t *aBuffer, uint16_t aBufferLength); void HandleRouterAdvertisement(const Ip6::Address &aSrcAddress, const uint8_t *aBuffer, uint16_t aBufferLength); - bool UpdateDiscoveredPrefixes(const RouterAdv::PrefixInfoOption &aPio, bool aManagedAddrConfig); + bool UpdateDiscoveredPrefixes(const RouterAdv::PrefixInfoOption &aPio); bool UpdateDiscoveredPrefixes(const RouterAdv::RouteInfoOption &aRio); bool InvalidateDiscoveredPrefixes(const Ip6::Prefix *aPrefix = nullptr, bool aIsOnLinkPrefix = true); void InvalidateAllDiscoveredPrefixes(void); @@ -315,7 +315,7 @@ private: static bool IsValidOmrPrefix(const NetworkData::OnMeshPrefixConfig &aOnMeshPrefixConfig); static bool IsValidOmrPrefix(const Ip6::Prefix &aOmrPrefix); - static bool IsValidOnLinkPrefix(const RouterAdv::PrefixInfoOption &aPio, bool aManagedAddrConfig); + static bool IsValidOnLinkPrefix(const RouterAdv::PrefixInfoOption &aPio); static bool IsValidOnLinkPrefix(const Ip6::Prefix &aOnLinkPrefix); // Indicates whether the Routing Manager is running (started).