From 305330114a2a3351c86bbaaf264389d9529abebd Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Wed, 28 Nov 2018 19:19:36 -0800 Subject: [PATCH] [mle] clear router table before processing RouteTlv (#3334) This commit removes the call to clear the `mRouterTable` from `SetStateRouter()` and instead performs it before processing of a received RouteTlv (before `ProcessRouteTlv()`). This ensures that router table and router id allocation list are not deleted after a router node reset recovery. This change addresses a rare subtle issue where if a router node and a leader node are reset sequentially within a short time interval, the router node upon reset can delete the router id allocation list (RouteTlv) which in turn causes the leader to ignore "MLE Link Accept" message it receives from router (after leader resets and tries to recover) and thus cause the leader to form a new partition. This can potentially lead to a situation where the two nodes stay in two partitions without merging. --- src/core/thread/mle_router.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp index f83cc1bf0..765aad624 100644 --- a/src/core/thread/mle_router.cpp +++ b/src/core/thread/mle_router.cpp @@ -322,8 +322,6 @@ otError MleRouter::SetStateRouter(uint16_t aRloc16) netif.GetIp6().GetMpl().SetTimerExpirations(kMplRouterDataMessageTimerExpirations); netif.GetMac().SetBeaconEnabled(true); - mRouterTable.Clear(); - // remove children that do not have matching RLOC16 for (ChildTable::Iterator iter(GetInstance(), ChildTable::kInStateValidOrRestoring); !iter.IsDone(); iter++) { @@ -926,8 +924,8 @@ otError MleRouter::HandleLinkAccept(const Message & aMessage, // Route SuccessOrExit(error = Tlv::GetTlv(aMessage, Tlv::kRoute, sizeof(route), route)); VerifyOrExit(route.IsValid(), error = OT_ERROR_PARSE); + mRouterTable.Clear(); SuccessOrExit(error = ProcessRouteTlv(route)); - router = mRouterTable.GetRouter(routerId); VerifyOrExit(router != NULL); @@ -3976,8 +3974,9 @@ void MleRouter::HandleAddressSolicitResponse(Coap::Header * aHeader, // assign short address SetRouterId(routerId); - SuccessOrExit(SetStateRouter(GetRloc16(mRouterId))); + SuccessOrExit(SetStateRouter(GetRloc16(mRouterId))); + mRouterTable.Clear(); mRouterTable.ProcessTlv(routerMaskTlv); router = mRouterTable.GetRouter(routerId);