From eb5b42a86e8bc58e28b6290045457ad2c4caa223 Mon Sep 17 00:00:00 2001 From: Simon Lin Date: Thu, 5 Sep 2019 13:02:26 +0800 Subject: [PATCH] [mle] reset MLE adv timer when cost changes to/from infinite (#4129) --- src/core/thread/mle_router.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp index b90c664f5..8927b9ed5 100644 --- a/src/core/thread/mle_router.cpp +++ b/src/core/thread/mle_router.cpp @@ -1427,7 +1427,8 @@ void MleRouter::UpdateRoutes(const RouteTlv &aRoute, uint8_t aRouterId) uint8_t cost; uint8_t linkQuality; bool update; - bool changed = false; + bool resetAdvInterval = false; + bool changed = false; neighbor = mRouterTable.GetRouter(aRouterId); VerifyOrExit(neighbor != NULL); @@ -1461,7 +1462,16 @@ void MleRouter::UpdateRoutes(const RouteTlv &aRoute, uint8_t aRouterId) if (neighbor->GetLinkQualityOut() != linkQuality) { + uint8_t oldLinkCost = mRouterTable.GetLinkCost(*neighbor); neighbor->SetLinkQualityOut(linkQuality); + nextHop = mRouterTable.GetRouter(neighbor->GetNextHop()); + + // reset MLE advertisement timer if neighbor route cost changed to or from infinite + if (nextHop == NULL && + (oldLinkCost >= kMaxRouteCost) != (mRouterTable.GetLinkCost(*neighbor) >= kMaxRouteCost)) + { + resetAdvInterval = true; + } update = true; } } @@ -1494,7 +1504,7 @@ void MleRouter::UpdateRoutes(const RouteTlv &aRoute, uint8_t aRouterId) { if (nextHop == NULL && mRouterTable.GetLinkCost(*router) >= kMaxRouteCost) { - ResetAdvertiseInterval(); + resetAdvInterval = true; } router->SetNextHop(aRouterId); @@ -1505,7 +1515,7 @@ void MleRouter::UpdateRoutes(const RouteTlv &aRoute, uint8_t aRouterId) { if (mRouterTable.GetLinkCost(*router) >= kMaxRouteCost) { - ResetAdvertiseInterval(); + resetAdvInterval = true; } router->SetNextHop(kInvalidRouterId); @@ -1538,6 +1548,11 @@ void MleRouter::UpdateRoutes(const RouteTlv &aRoute, uint8_t aRouterId) } while (update); + if (resetAdvInterval) + { + ResetAdvertiseInterval(); + } + #if (OPENTHREAD_CONFIG_LOG_MLE && (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO)) VerifyOrExit(changed);