]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
nicinfo: skip loopback devices
authorOliver Kurth <okurth@vmware.com>
Tue, 4 Sep 2018 22:41:00 +0000 (15:41 -0700)
committerOliver Kurth <okurth@vmware.com>
Tue, 4 Sep 2018 22:41:00 +0000 (15:41 -0700)
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.

open-vm-tools/lib/nicInfo/nicInfoPosix.c

index 31c1d1ab3443b7a9db2aa7f054906fbe39bafed3..f95e980f2a8bc4fe4d05e5b745b611a04000f4b2 100644 (file)
@@ -277,6 +277,13 @@ GuestInfoGetInterface(struct ifaddrs *ifaddrs,
 
       if (sll != NULL && sll->sll_family == AF_PACKET) {
          char macAddress[NICINFO_MAC_LEN];
+         /*
+          * Ignore loopback and downed devices.
+          */
+         if (!(pkt->ifa_flags & IFF_UP) || pkt->ifa_flags & IFF_LOOPBACK) {
+            continue;
+         }
+
          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 +308,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;