From f7cfddf57d135205257e041331ed5e85e524cb15 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Mon, 14 Jun 2021 10:23:33 -0700 Subject: [PATCH] [mle-router] ensure route table is logged only when changed (#6722) --- src/core/thread/mle_router.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp index 93204402e..1e678ea9f 100644 --- a/src/core/thread/mle_router.cpp +++ b/src/core/thread/mle_router.cpp @@ -1441,7 +1441,7 @@ void MleRouter::UpdateRoutes(const RouteTlv &aRoute, uint8_t aRouterId) if (nextHop == nullptr || nextHop == neighbor) { - // route has no next hop or next hop is neighbor (sender) + // router has no next hop or next hop is neighbor (sender) if (cost + mRouterTable.GetLinkCost(*neighbor) < kMaxRouteCost) { @@ -1450,9 +1450,17 @@ void MleRouter::UpdateRoutes(const RouteTlv &aRoute, uint8_t aRouterId) resetAdvInterval = true; } - router->SetNextHop(aRouterId); - router->SetCost(cost); - changed = true; + if (router->GetNextHop() != aRouterId) + { + router->SetNextHop(aRouterId); + changed = true; + } + + if (router->GetCost() != cost) + { + router->SetCost(cost); + changed = true; + } } else if (nextHop == neighbor) {