Skip to content

Commit

Permalink
Ignore resolved interface IDs for non-LinkLocal IPv6 Addresses (#8912)
Browse files Browse the repository at this point in the history
  • Loading branch information
sagar-apple authored Aug 11, 2021
1 parent 7359d19 commit 6672e78
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,13 +754,23 @@ void DeviceController::PersistNextKeyId()
#if CHIP_DEVICE_CONFIG_ENABLE_MDNS
void DeviceController::OnNodeIdResolved(const chip::Mdns::ResolvedNodeData & nodeData)
{
CHIP_ERROR err = CHIP_NO_ERROR;
Device * device = nullptr;
CHIP_ERROR err = CHIP_NO_ERROR;
Device * device = nullptr;
Inet::InterfaceId interfaceId = INET_NULL_INTERFACEID;

err = GetDevice(nodeData.mPeerId.GetNodeId(), &device);
SuccessOrExit(err);

err = device->UpdateAddress(Transport::PeerAddress::UDP(nodeData.mAddress, nodeData.mPort, nodeData.mInterfaceId));
// Only use the mDNS resolution's InterfaceID for addresses that are IPv6 LLA.
// For all other addresses, we should rely on the device's routing table to route messages sent.
// Forcing messages down an InterfaceId might fail. For example, in bridged networks like Thread,
// mDNS advertisements are not usually received on the same interface the peer is reachable on.
if (nodeData.mAddress.IsIPv6LinkLocal())
{
interfaceId = nodeData.mInterfaceId;
}

err = device->UpdateAddress(Transport::PeerAddress::UDP(nodeData.mAddress, nodeData.mPort, interfaceId));
SuccessOrExit(err);

PersistDevice(device);
Expand Down

0 comments on commit 6672e78

Please sign in to comment.