]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
guest info: ignore interfaces with invalid MAC address.
authorVMware, Inc <>
Tue, 19 Oct 2010 18:39:36 +0000 (11:39 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Tue, 19 Oct 2010 18:39:36 +0000 (11:39 -0700)
When the OS is messing with interfaces (such as bringing them up or down),
the guest info plugin may see an interface with an invalid MAC address, at
least on Solaris. Trying to write that iface's data to the nic info
structure causes the plugin to crash (probably because addr_ntoa doesn't
understand the address and is returning garbage, that we then try to read
when writing it as a string).

So just skip those. When the gather loop runs again, we'll pick up any
changed interfaces.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/services/plugins/guestInfo/getlib/guestInfoPosix.c

index 285a0c4b65768d95e0b96b034852e72cb7ac3711..4423ae522afa978884ec2b46aafa755794bb52d6 100644 (file)
@@ -278,23 +278,32 @@ ReadInterfaceDetails(const struct intf_entry *entry,  // IN: current interface e
       GuestNicV3 *nic = NULL;
       char macAddress[NICINFO_MAC_LEN];
 
-      Str_Sprintf(macAddress, sizeof macAddress, "%s",
-                  addr_ntoa(&entry->intf_link_addr));
-      nic = GuestInfoAddNicEntry(nicInfo, macAddress, NULL, NULL);
-      ASSERT_MEM_ALLOC(nic);
-
-      /* Record the "primary" address. */
-      if (entry->intf_addr.addr_type == ADDR_TYPE_IP ||
-          entry->intf_addr.addr_type == ADDR_TYPE_IP6) {
-         RecordNetworkAddress(nic, &entry->intf_addr);
-      }
+      /*
+       * There is a race where the guest info plugin might be iterating over the
+       * interfaces while the OS is modifying them (i.e. by bringing them up
+       * after a resume). If we see an ethernet interface with an invalid MAC,
+       * then ignore it for now. Subsequent iterations of the gather loop will
+       * pick up any changes.
+       */
+      if (entry->intf_link_addr.addr_type == ADDR_TYPE_ETH) {
+         Str_Sprintf(macAddress, sizeof macAddress, "%s",
+                     addr_ntoa(&entry->intf_link_addr));
+         nic = GuestInfoAddNicEntry(nicInfo, macAddress, NULL, NULL);
+         ASSERT_MEM_ALLOC(nic);
+
+         /* Record the "primary" address. */
+         if (entry->intf_addr.addr_type == ADDR_TYPE_IP ||
+             entry->intf_addr.addr_type == ADDR_TYPE_IP6) {
+            RecordNetworkAddress(nic, &entry->intf_addr);
+         }
 
-      /* Walk the list of alias's and add those that are IPV4 or IPV6 */
-      for (i = 0; i < entry->intf_alias_num; i++) {
-         const struct addr *alias = &entry->intf_alias_addrs[i];
-         if (alias->addr_type == ADDR_TYPE_IP ||
-             alias->addr_type == ADDR_TYPE_IP6) {
-            RecordNetworkAddress(nic, alias);
+         /* Walk the list of alias's and add those that are IPV4 or IPV6 */
+         for (i = 0; i < entry->intf_alias_num; i++) {
+            const struct addr *alias = &entry->intf_alias_addrs[i];
+            if (alias->addr_type == ADDR_TYPE_IP ||
+                alias->addr_type == ADDR_TYPE_IP6) {
+               RecordNetworkAddress(nic, alias);
+            }
          }
       }
    }