Skip to content

Commit ef09f53

Browse files
committed
Merge bitcoin/bitcoin#29984: net: Replace ifname check with IFF_LOOPBACK in Discover
a68fed1 net: Fix misleading comment for Discover (laanwj) 7766dd2 net: Replace ifname check with IFF_LOOPBACK in Discover (laanwj) Pull request description: Checking the interface name is kind of brittle. In the age of network namespaces and containers, there is no reason a loopback interface can't be called differently. Check for the `IFF_LOOPBACK` flag to detect loopback interface instead. Also remove a misleading comment in Discover's doc comment. ACKs for top commit: sipa: utACK a68fed1 willcl-ark: utACK a68fed1 theuni: utACK a68fed1. Satoshi-era brittleness :) Tree-SHA512: e2d7fc541f40f6a6af08286e7bcb0873ff55debdcd8b38b03f274897b673a6fb51d84d6c7241a02a9567ddf2645f50231d91bb1f55307ba7c6e68196c29b0edf
2 parents 63d0b93 + a68fed1 commit ef09f53

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

src/net.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3113,8 +3113,7 @@ void Discover()
31133113
{
31143114
if (ifa->ifa_addr == nullptr) continue;
31153115
if ((ifa->ifa_flags & IFF_UP) == 0) continue;
3116-
if (strcmp(ifa->ifa_name, "lo") == 0) continue;
3117-
if (strcmp(ifa->ifa_name, "lo0") == 0) continue;
3116+
if ((ifa->ifa_flags & IFF_LOOPBACK) != 0) continue;
31183117
if (ifa->ifa_addr->sa_family == AF_INET)
31193118
{
31203119
struct sockaddr_in* s4 = (struct sockaddr_in*)(ifa->ifa_addr);

src/net.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ struct CSerializedNetMsg {
137137
/**
138138
* Look up IP addresses from all interfaces on the machine and add them to the
139139
* list of local addresses to self-advertise.
140-
* The loopback interface is skipped and only the first address from each
141-
* interface is used.
140+
* The loopback interface is skipped.
142141
*/
143142
void Discover();
144143

0 commit comments

Comments
 (0)