Skip to content

Commit

Permalink
[mle] update router table after adding a new neighbor (#10288)
Browse files Browse the repository at this point in the history
Use the `Route64 TLV` to update the router table after adding a new
neighbor in `HandleLinkAccept`.

With this change, when a router re-joins the network, it will restore
its nexthop table while processing the `link accept`, rather than
having to wait for an `mle advertisement`.
  • Loading branch information
gytxxsy committed May 23, 2024
1 parent 1b2ad3d commit e7535f7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/core/thread/mle_router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,7 @@ Error MleRouter::HandleLinkAccept(RxInfo &aRxInfo, bool aRequest)
RouteTlv routeTlv;
LeaderData leaderData;
uint8_t linkMargin;
bool shouldUpdateRoutes = false;

SuccessOrExit(error = Tlv::Find<SourceAddressTlv>(aRxInfo.mMessage, sourceAddress));

Expand Down Expand Up @@ -972,6 +973,7 @@ Error MleRouter::HandleLinkAccept(RxInfo &aRxInfo, bool aRequest)
mLinkRequestAttempts = 0;
mRetrieveNewNetworkData = true;
IgnoreError(SendDataRequest(aRxInfo.mMessageInfo.GetPeerAddr()));
shouldUpdateRoutes = true;

#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
Get<TimeSync>().HandleTimeSyncMessage(aRxInfo.mMessage);
Expand Down Expand Up @@ -1007,8 +1009,7 @@ Error MleRouter::HandleLinkAccept(RxInfo &aRxInfo, bool aRequest)
router = mRouterTable.FindRouterById(routerId);
OT_ASSERT(router != nullptr);
}

mRouterTable.UpdateRoutes(routeTlv, routerId);
shouldUpdateRoutes = true;
break;

case kErrorNotFound:
Expand Down Expand Up @@ -1043,6 +1044,11 @@ Error MleRouter::HandleLinkAccept(RxInfo &aRxInfo, bool aRequest)

mNeighborTable.Signal(NeighborTable::kRouterAdded, *router);

if (shouldUpdateRoutes)
{
mRouterTable.UpdateRoutes(routeTlv, routerId);
}

aRxInfo.mClass = RxInfo::kAuthoritativeMessage;
ProcessKeySequence(aRxInfo);

Expand Down

0 comments on commit e7535f7

Please sign in to comment.