mirror of
https://github.com/espressif/openthread.git
synced 2026-08-06 10:47:46 +00:00
[network-data] ensure ExternalRouteLookup() picks longest match (#8582)
This commit updates the `ExternalRouteLookup()` to ensure we pick the longest match before checking the route preference.
This commit is contained in:
@@ -334,7 +334,8 @@ Error LeaderBase::ExternalRouteLookup(uint8_t aDomainId, const Ip6::Address &aDe
|
||||
for (const HasRouteEntry *entry = hasRoute->GetFirstEntry(); entry <= hasRoute->GetLastEntry();
|
||||
entry = entry->GetNext())
|
||||
{
|
||||
if (bestRouteEntry == nullptr || CompareRouteEntries(*entry, *bestRouteEntry) > 0)
|
||||
if ((bestRouteEntry == nullptr) || (prefixLength > bestMatchLength) ||
|
||||
CompareRouteEntries(*entry, *bestRouteEntry) > 0)
|
||||
{
|
||||
bestRouteEntry = entry;
|
||||
bestMatchLength = prefixLength;
|
||||
|
||||
Reference in New Issue
Block a user