From: Oliver Kurth Date: Mon, 17 Sep 2018 23:41:18 +0000 (-0700) Subject: nicinfo: skip loopback devices X-Git-Tag: stable-10.3.5~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=064d0a3458991f0c34a397664b6b5cd8cc00e5b3;p=thirdparty%2Fopen-vm-tools.git nicinfo: skip loopback devices When libdnet isn't used, loopback devices were reported. This change skips these interfaces. Also skip interfaces that are down. The interface was visible with vim-cmd, but not in the VC or ESX UI. It did not contain any IP addresses. --- diff --git a/open-vm-tools/lib/nicInfo/nicInfoPosix.c b/open-vm-tools/lib/nicInfo/nicInfoPosix.c index 8a063a080..a22981d5a 100644 --- a/open-vm-tools/lib/nicInfo/nicInfoPosix.c +++ b/open-vm-tools/lib/nicInfo/nicInfoPosix.c @@ -277,6 +277,22 @@ GuestInfoGetInterface(struct ifaddrs *ifaddrs, if (sll != NULL && sll->sll_family == AF_PACKET) { char macAddress[NICINFO_MAC_LEN]; + + /* + * PR 2193804: + * On ESXi, AF_PACKET family is reported for vmk* interfaces only + * and its ifa_flags is reported as 0. No AF_PACKET family ifaddrs + * is reported for loopback interface. + */ +#if !defined(USERWORLD) + /* + * Ignore loopback and downed devices. + */ + if (!(pkt->ifa_flags & IFF_UP) || pkt->ifa_flags & IFF_LOOPBACK) { + continue; + } +#endif + Str_Sprintf(macAddress, sizeof macAddress, "%02x:%02x:%02x:%02x:%02x:%02x", sll->sll_addr[0], sll->sll_addr[1], sll->sll_addr[2], @@ -301,6 +317,8 @@ GuestInfoGetInterface(struct ifaddrs *ifaddrs, unsigned nBits = 0; /* * Ignore any loopback addresses. + * A loopback address would indicate a misconfiguration, since + * this is not a loopback device (we checked for that above). */ if (family == AF_INET) { struct sockaddr_in *sin = (struct sockaddr_in *)sa;