Skip to content

Commit dd54224

Browse files
committed
ipv6: Fix getHomeAddress() to properly iterate interfaces and find valid home address
The for loop contained an unconditional return in its body, so the loop increment was never executed and it always operated on the first interface only. Replace with direct access to the first interface using an if check.
1 parent 846093b commit dd54224

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/inet/networklayer/ipv6/Ipv6RoutingTable.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,8 +747,11 @@ const Ipv6Address& Ipv6RoutingTable::getHomeAddress()
747747
{
748748
for (int i = 0; i < ift->getNumInterfaces(); ++i) {
749749
NetworkInterface *ie = ift->getInterface(i);
750-
751-
return ie->getProtocolData<Ipv6InterfaceData>()->getMNHomeAddress();
750+
if (auto ipv6Data = ie->findProtocolData<Ipv6InterfaceData>()) {
751+
const Ipv6Address& addr = ipv6Data->getMNHomeAddress();
752+
if (!addr.isUnspecified())
753+
return addr;
754+
}
752755
}
753756

754757
return Ipv6Address::UNSPECIFIED_ADDRESS;

0 commit comments

Comments
 (0)