+/* Check if the DMI UUID contains a Nicira mac address that should be
+ * used for this interface. The UUID is assumed to be RFC 4122
+ * compliant. */
+static void
+set_uuid_mac(struct net_device *netdev)
+{
+ const char *uuid = dmi_get_system_info(DMI_PRODUCT_UUID);
+ const char *uptr;
+ uint8_t mac[ETH_ALEN];
+ int i;
+
+ if (!uuid || *uuid == '\0' || strlen(uuid) != 36)
+ return;
+
+ /* We are only interested version 1 UUIDs, since the last six bytes
+ * are an IEEE 802 MAC address. */
+ if (uuid[14] != '1')
+ return;
+
+ /* Pull out the embedded MAC address. The kernel's sscanf doesn't
+ * support field widths on hex digits, so we use this hack. */
+ uptr = uuid + 24;
+ for (i=0; i<ETH_ALEN; i++) {
+ unsigned char d[3];
+
+ d[0] = *uptr++;
+ d[1] = *uptr++;
+ d[2] = '\0';
+
+ mac[i] = simple_strtoul(d, NULL, 16);
+ }
+
+ /* If this is a Nicira one, then use it. */
+ if (mac[0] != 0x00 || mac[1] != 0x23 || mac[2] != 0x20)
+ return;
+
+ memcpy(netdev->dev_addr, mac, ETH_ALEN);
+}
+