mirror of
https://github.com/espressif/openthread.git
synced 2026-08-05 10:27:49 +00:00
[ip6] SelectSourceAddress() rule 1 on preferring same address (#9830)
This commit moves the check for rule 1 on preferring same address as the destination before the `(bestAddr == nullptr)` check. This ensures that rule 1 will be correctly applied even when the address happens to be first one in the `GetUnicastAddresses()` list.
This commit is contained in:
@@ -1330,18 +1330,18 @@ const Address *Ip6::SelectSourceAddress(const Address &aDestination) const
|
||||
overrideScope = destScope;
|
||||
}
|
||||
|
||||
if (bestAddr == nullptr)
|
||||
{
|
||||
// Rule 0: Prefer any address
|
||||
bestAddr = &addr;
|
||||
bestMatchLen = matchLen;
|
||||
}
|
||||
else if (addr.GetAddress() == aDestination)
|
||||
if (addr.GetAddress() == aDestination)
|
||||
{
|
||||
// Rule 1: Prefer same address
|
||||
bestAddr = &addr;
|
||||
ExitNow();
|
||||
}
|
||||
|
||||
if (bestAddr == nullptr)
|
||||
{
|
||||
bestAddr = &addr;
|
||||
bestMatchLen = matchLen;
|
||||
}
|
||||
else if (addr.GetScope() < bestAddr->GetScope())
|
||||
{
|
||||
// Rule 2: Prefer appropriate scope
|
||||
|
||||
Reference in New Issue
Block a user