From cf0640973e9c4686189e16b5582cc42d19cecb39 Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Fri, 19 Feb 2021 09:32:53 -0800 Subject: [PATCH] [bbr] handle case where no PBBR exists in network data (#6165) --- src/core/backbone_router/bbr_leader.cpp | 2 +- src/core/thread/network_data_service.cpp | 11 +++++------ src/core/thread/network_data_service.hpp | 5 +---- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/core/backbone_router/bbr_leader.cpp b/src/core/backbone_router/bbr_leader.cpp index e17cf3e76..01a7c37c0 100644 --- a/src/core/backbone_router/bbr_leader.cpp +++ b/src/core/backbone_router/bbr_leader.cpp @@ -180,7 +180,7 @@ void Leader::UpdateBackboneRouterPrimary(void) State state; uint32_t origMlrTimeout; - IgnoreError(Get().GetBackboneRouterPrimary(config)); + Get().GetBackboneRouterPrimary(config); if (config.mServer16 != mConfig.mServer16) { diff --git a/src/core/thread/network_data_service.cpp b/src/core/thread/network_data_service.cpp index 3fb52fa64..7745d9f3b 100644 --- a/src/core/thread/network_data_service.cpp +++ b/src/core/thread/network_data_service.cpp @@ -83,17 +83,18 @@ otError Manager::GetServiceId(uint8_t aServiceNumber, bool aServerStable, uint8_ #if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2) -otError Manager::GetBackboneRouterPrimary(ot::BackboneRouter::BackboneRouterConfig &aConfig) const +void Manager::GetBackboneRouterPrimary(ot::BackboneRouter::BackboneRouterConfig &aConfig) const { - otError error = OT_ERROR_NOT_FOUND; const uint8_t serviceData = BackboneRouter::kServiceNumber; const ServerTlv * rvalServerTlv = nullptr; const BackboneRouter::ServerData *rvalServerData = nullptr; Iterator iterator; + aConfig.mServer16 = Mac::kShortAddrInvalid; + iterator.mServiceTlv = Get().FindService(kThreadEnterpriseNumber, &serviceData, sizeof(serviceData)); - VerifyOrExit(iterator.mServiceTlv != nullptr, aConfig.mServer16 = Mac::kShortAddrInvalid); + VerifyOrExit(iterator.mServiceTlv != nullptr); while (IterateToNextServer(iterator) == OT_ERROR_NONE) { @@ -125,10 +126,8 @@ otError Manager::GetBackboneRouterPrimary(ot::BackboneRouter::BackboneRouterConf aConfig.mReregistrationDelay = rvalServerData->GetReregistrationDelay(); aConfig.mMlrTimeout = rvalServerData->GetMlrTimeout(); - error = OT_ERROR_NONE; - exit: - return error; + return; } #endif // (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2) diff --git a/src/core/thread/network_data_service.hpp b/src/core/thread/network_data_service.hpp index eb99dbb98..74ed6ecf8 100644 --- a/src/core/thread/network_data_service.hpp +++ b/src/core/thread/network_data_service.hpp @@ -323,11 +323,8 @@ public: * * @param[out] aConfig The Primary Backbone Router configuration. * - * @retval OT_ERROR_NONE Successfully got the Primary Backbone Router configuration. - * @retval OT_ERROR_NOT_FOUND No Backbone Router Service in the Thread Network. - * */ - otError GetBackboneRouterPrimary(ot::BackboneRouter::BackboneRouterConfig &aConfig) const; + void GetBackboneRouterPrimary(ot::BackboneRouter::BackboneRouterConfig &aConfig) const; #endif /**