[ip6] prefer RLOC source with RLOC dest in SelectSourceAddress() (#4377)

Prefer ML-EID for any mesh-local traffic that does not have RLOC
destination.

Credit to Rongli Sun <[email protected]> for identifying this issue.
This commit is contained in:
Jonathan Hui
2019-12-04 08:23:07 -08:00
parent b22f00aea9
commit 4e73575703
+7 -13
View File
@@ -1364,19 +1364,6 @@ const NetifUnicastAddress *Ip6::SelectSourceAddress(MessageInfo &aMessageInfo)
continue;
}
}
else if ((rvalAddr->GetScope() == Address::kRealmLocalScope) && (addr->GetScope() == Address::kRealmLocalScope))
{
// Additional rule: Prefer EID
if (rvalAddr->GetAddress().IsRoutingLocator())
{
rvalAddr = addr;
rvalPrefixMatched = candidatePrefixMatched;
}
else
{
continue;
}
}
else if (addr->mPreferred && !rvalAddr->mPreferred)
{
// Rule 3: Avoid deprecated addresses
@@ -1391,6 +1378,13 @@ const NetifUnicastAddress *Ip6::SelectSourceAddress(MessageInfo &aMessageInfo)
rvalAddr = addr;
rvalPrefixMatched = candidatePrefixMatched;
}
else if ((candidatePrefixMatched == rvalPrefixMatched) &&
(destination->IsRoutingLocator() == candidateAddr->IsRoutingLocator()))
{
// Additional rule: Prefer RLOC source for RLOC destination, EID source for anything else
rvalAddr = addr;
rvalPrefixMatched = candidatePrefixMatched;
}
else
{
continue;