From 9e7b57d7fb6c23485db2678281d3b95b65416523 Mon Sep 17 00:00:00 2001 From: Yakun Xu Date: Thu, 13 Mar 2025 01:36:54 +0800 Subject: [PATCH] [joiner] keep discovering when UDP port is bad (#11337) This commit fixes the issue that the joiner starts joining process immediately when an invalid Joiner UDP Port is encountered. This issue was introduced by #9445 which attempts to ignore joiner routers having an invalid Joiner UDP Port. --- src/core/meshcop/joiner.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/meshcop/joiner.cpp b/src/core/meshcop/joiner.cpp index 280f9811b..0173940aa 100644 --- a/src/core/meshcop/joiner.cpp +++ b/src/core/meshcop/joiner.cpp @@ -249,7 +249,7 @@ void Joiner::HandleDiscoverResult(Mle::DiscoverScanner::ScanResult *aResult) { VerifyOrExit(mState == kStateDiscover); - if (aResult != nullptr && aResult->mJoinerUdpPort > 0) + if (aResult != nullptr) { SaveDiscoveredJoinerRouter(*aResult); } @@ -270,9 +270,11 @@ void Joiner::SaveDiscoveredJoinerRouter(const Mle::DiscoverScanner::ScanResult & { uint8_t priority; bool doesAllowAny; - JoinerRouter *end = GetArrayEnd(mJoinerRouters); + JoinerRouter *end; JoinerRouter *entry; + VerifyOrExit(aResult.mJoinerUdpPort > 0); + doesAllowAny = AsCoreType(&aResult.mSteeringData).PermitsAllJoiners(); LogInfo("Joiner discover network: %s, pan:0x%04x, port:%d, chan:%d, rssi:%d, allow-any:%s", @@ -284,6 +286,8 @@ void Joiner::SaveDiscoveredJoinerRouter(const Mle::DiscoverScanner::ScanResult & // We keep the list sorted based on priority. Find the place to // add the new result. + end = GetArrayEnd(mJoinerRouters); + for (entry = &mJoinerRouters[0]; entry < end; entry++) { if (priority > entry->mPriority)