From 4e5a7b9bc463a47d7f0067f3a665811d6591e919 Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Mon, 18 Sep 2017 13:31:27 -0700 Subject: [PATCH] [mle] fix partition merging bug when determining singleton partitions (#2203) The Thread 1.1.1 Specification currently defines a "singleton" as a Thread network partition that consists of a single router that has no router-eligible end device children. At the same time, Thread 1.1.1 does not provide a way for a router to decipher between a Full End Device (FED) and a router-eligible end device (REED). This ambiguity can cause two partitions to avoid merging, since each partition may determine that they are higher priority than the other. This commit makes the change to counting only active routers, which eliminates the ambiguity above. --- src/core/thread/mle_router.cpp | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp index 7cb3b92fc..a241f1846 100644 --- a/src/core/thread/mle_router.cpp +++ b/src/core/thread/mle_router.cpp @@ -1175,23 +1175,8 @@ bool MleRouter::IsSingleton(void) { bool rval = true; - switch (mRole) + if (IsAttached() && ((mDeviceMode & ModeTlv::kModeFFD) != 0)) { - case OT_DEVICE_ROLE_DISABLED: - case OT_DEVICE_ROLE_DETACHED: - ExitNow(rval = true); - break; - - case OT_DEVICE_ROLE_CHILD: - ExitNow(rval = ((mDeviceMode & ModeTlv::kModeFFD) == 0)); - break; - - case OT_DEVICE_ROLE_ROUTER: - ExitNow(rval = false); - break; - - case OT_DEVICE_ROLE_LEADER: - // not a singleton if any other routers exist for (int i = 0; i <= kMaxRouterId; i++) { @@ -1200,17 +1185,6 @@ bool MleRouter::IsSingleton(void) ExitNow(rval = false); } } - - // not a singleton if any children are REEDs - for (int i = 0; i < mMaxChildrenAllowed; i++) - { - if (mChildren[i].GetState() == Neighbor::kStateValid && mChildren[i].IsFullThreadDevice()) - { - ExitNow(rval = false); - } - } - - break; } exit: