mirror of
https://github.com/espressif/openthread.git
synced 2026-08-13 22:27:47 +00:00
[router-table] fix signalling when neighbor routers are removed (#6948)
This commit updates `RouterTable` to ensure signalling removal of neighbor routers when router table is fully cleared or when a `Router` with a specific released router ID is cleared.
This commit is contained in:
@@ -89,6 +89,7 @@ exit:
|
||||
|
||||
void RouterTable::Clear(void)
|
||||
{
|
||||
ClearNeighbors();
|
||||
mAllocatedRouterIds.Clear();
|
||||
memset(mRouterIdReuseDelay, 0, sizeof(mRouterIdReuseDelay));
|
||||
UpdateAllocation();
|
||||
@@ -265,18 +266,26 @@ Error RouterTable::Release(uint8_t aRouterId)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
uint16_t rloc16 = Mle::Mle::Rloc16FromRouterId(aRouterId);
|
||||
Router * router;
|
||||
|
||||
OT_ASSERT(aRouterId <= Mle::kMaxRouterId);
|
||||
|
||||
VerifyOrExit(Get<Mle::MleRouter>().IsLeader(), error = kErrorInvalidState);
|
||||
VerifyOrExit(IsAllocated(aRouterId), error = kErrorNotFound);
|
||||
|
||||
router = GetNeighbor(rloc16);
|
||||
|
||||
if (router != nullptr)
|
||||
{
|
||||
Get<NeighborTable>().Signal(NeighborTable::kRouterRemoved, *router);
|
||||
}
|
||||
|
||||
mAllocatedRouterIds.Remove(aRouterId);
|
||||
UpdateAllocation();
|
||||
|
||||
mRouterIdReuseDelay[aRouterId] = Mle::kRouterIdReuseDelay;
|
||||
|
||||
for (Router *router = GetFirstEntry(); router != nullptr; router = GetNextEntry(router))
|
||||
for (router = GetFirstEntry(); router != nullptr; router = GetNextEntry(router))
|
||||
{
|
||||
if (router->GetNextHop() == rloc16)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user