From 289d24e06e53634dc797a68e96ab3f6f192db65b Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Thu, 22 Dec 2022 10:41:08 -0800 Subject: [PATCH] [router-table] signal if router is removed from `UpdateRouterIdSet()` (#8573) This commit updates the `RouterTable::RemoveRouter()` to check if `Router` being removed is a neighbor and signal its removal. This ensures that we correctly signal neighboring router removal from a call to either `UpdateRouterIdSet()` or `Release(aRouterId)`. --- src/core/thread/router_table.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/thread/router_table.cpp b/src/core/thread/router_table.cpp index ed836195e..838022a7a 100644 --- a/src/core/thread/router_table.cpp +++ b/src/core/thread/router_table.cpp @@ -101,6 +101,11 @@ void RouterTable::RemoveRouter(Router &aRouter) // Remove an existing `aRouter` entry from `mRouters` and update the // `mRouterIdMap`. + if (aRouter.IsStateValid()) + { + Get().Signal(NeighborTable::kRouterRemoved, aRouter); + } + mRouterIdMap.Release(aRouter.GetRouterId()); mRouters.Remove(aRouter); @@ -186,11 +191,6 @@ Error RouterTable::Release(uint8_t aRouterId) router = FindRouterById(aRouterId); VerifyOrExit(router != nullptr, error = kErrorNotFound); - if (router->IsStateValid()) - { - Get().Signal(NeighborTable::kRouterRemoved, *router); - } - RemoveRouter(*router); for (Router &otherRouter : mRouters)