From a7edd859ee5dfbe492b0ba5c8e9c884aca494f3a Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Wed, 3 May 2023 17:20:38 -0700 Subject: [PATCH] [netdata] prefer BR acting as router over ED (when all other checks are same) (#9012) This commit updates the `CompareRouteEntries()` method so that if all of the earlier checks (preference, path cost) are the same, it will prefer a border router (BR) acting as a router over one acting as an end device. The reason is that a device can more accurately calculate the path cost to a router node than to an end device. This is because the link quality between an end device and its parent is not known to other devices. --- src/core/thread/network_data_leader.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/thread/network_data_leader.cpp b/src/core/thread/network_data_leader.cpp index 95d20ba6b..351ea69a7 100644 --- a/src/core/thread/network_data_leader.cpp +++ b/src/core/thread/network_data_leader.cpp @@ -296,6 +296,11 @@ int LeaderBase::CompareRouteEntries(int8_t aFirstPreference, // that the first entry is preferred over the second one. result = ThreeWayCompare(Get().GetPathCost(aSecondRloc), Get().GetPathCost(aFirstRloc)); + VerifyOrExit(result == 0); + + // If all the same, prefer the BR acting as a router over an + // end device. + result = ThreeWayCompare(Mle::IsActiveRouter(aFirstRloc), Mle::IsActiveRouter(aSecondRloc)); #endif exit: