Commit 6a642f72 authored by Matt Leotta's avatar Matt Leotta Committed by Brad King

SystemInformation: Skip loopback devices in search for FQDN

DNS lookup on loopback devices is not needed to find the FQDN and just
slows down this function, especially when the DNS lookup times out.

Change-Id: I3f8b565cf8786b92cfef23b693c3c4fab57a904e
parent 18c65411
......@@ -79,6 +79,7 @@ typedef int siginfo_t;
#include <sys/sysctl.h>
#if defined(KWSYS_SYS_HAS_IFADDRS_H)
#include <ifaddrs.h>
#include <net/if.h>
#define KWSYS_SYSTEMINFORMATION_IMPLEMENT_FQDN
#endif
#endif
......@@ -99,6 +100,7 @@ typedef int siginfo_t;
#include <sys/sysctl.h>
#if defined(KWSYS_SYS_HAS_IFADDRS_H)
#include <ifaddrs.h>
#include <net/if.h>
#define KWSYS_SYSTEMINFORMATION_IMPLEMENT_FQDN
#endif
#if !(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ - 0 >= 1050)
......@@ -113,6 +115,7 @@ typedef int siginfo_t;
#include <sys/socket.h>
#if defined(KWSYS_SYS_HAS_IFADDRS_H)
#include <ifaddrs.h>
#include <net/if.h>
#if !defined(__LSB_VERSION__) /* LSB has no getifaddrs */
#define KWSYS_SYSTEMINFORMATION_IMPLEMENT_FQDN
#endif
......@@ -1696,7 +1699,9 @@ int SystemInformationImplementation::GetFullyQualifiedDomainName(
for (ifa = ifas; ifa != NULL; ifa = ifa->ifa_next) {
int fam = ifa->ifa_addr ? ifa->ifa_addr->sa_family : -1;
if ((fam == AF_INET) || (fam == AF_INET6)) {
// Skip Loopback interfaces
if (((fam == AF_INET) || (fam == AF_INET6)) &&
!(ifa->ifa_flags & IFF_LOOPBACK)) {
char host[NI_MAXHOST] = { '\0' };
const size_t addrlen = (fam == AF_INET ? sizeof(struct sockaddr_in)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment