forked from mooncake-track/Mooncake
[TE] fix: filter out DOWN network interfaces in findLocalIpAddresses() (#422)
Signed-off-by: phoenixwu0229 <phoenixwu0229@icloud.com>
This commit is contained in:
parent
072248ba68
commit
9bcdbf36ff
|
|
@ -867,9 +867,18 @@ std::vector<std::string> findLocalIpAddresses() {
|
|||
continue;
|
||||
}
|
||||
|
||||
// Check if interface is UP and RUNNING
|
||||
if (!(ifa->ifa_flags & IFF_UP) || !(ifa->ifa_flags & IFF_RUNNING)) {
|
||||
LOG(INFO) << "Skipping interface " << ifa->ifa_name
|
||||
<< " (not UP or not RUNNING)";
|
||||
continue;
|
||||
}
|
||||
|
||||
char host[NI_MAXHOST];
|
||||
if (getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in), host,
|
||||
NI_MAXHOST, nullptr, 0, NI_NUMERICHOST) == 0) {
|
||||
LOG(INFO) << "Found active interface " << ifa->ifa_name
|
||||
<< " with IP " << host;
|
||||
ips.push_back(host);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue