platform: ignore permanent MAC addresses of all ones (FF:FF:FF:FF:FF:FF)
Drivers are stupid, and just like the platform ignores an all zeros permanent address, so should it ignore all ones. NetworkManager[509]: <debug> [1453743778.854919] [devices/nm-device.c:8885] nm_device_update_hw_address(): [0x190370] (eth0): hardware address now 86:18:52:xx:xx:xx NetworkManager[509]: <debug> [1453743778.855438] [devices/nm-device.c:9138] constructed(): [0x190370] (eth0): read initial MAC address 86:18:52:xx:xx:xx NetworkManager[509]: <debug> [1453743778.861602] [devices/nm-device.c:9148] constructed(): [0x190370] (eth0): read permanent MAC address FF:FF:FF:FF:FF:FF
This commit is contained in:
@@ -142,7 +142,8 @@ nmp_utils_ethtool_get_permanent_address (const char *ifname,
|
|||||||
struct ethtool_perm_addr e;
|
struct ethtool_perm_addr e;
|
||||||
guint8 _extra_data[NM_UTILS_HWADDR_LEN_MAX + 1];
|
guint8 _extra_data[NM_UTILS_HWADDR_LEN_MAX + 1];
|
||||||
} edata;
|
} edata;
|
||||||
guint zeros[NM_UTILS_HWADDR_LEN_MAX] = { 0 };
|
static const guint8 zeros[NM_UTILS_HWADDR_LEN_MAX] = { 0 };
|
||||||
|
static guint8 ones[NM_UTILS_HWADDR_LEN_MAX] = { 0 };
|
||||||
|
|
||||||
if (!ifname)
|
if (!ifname)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -161,6 +162,12 @@ nmp_utils_ethtool_get_permanent_address (const char *ifname,
|
|||||||
if (memcmp (edata.e.data, zeros, edata.e.size) == 0)
|
if (memcmp (edata.e.data, zeros, edata.e.size) == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
/* Some drivers return a permanent address of all ones. Reject that too */
|
||||||
|
if (G_UNLIKELY (ones[0] != 0xFF))
|
||||||
|
memset (ones, 0xFF, sizeof (ones));
|
||||||
|
if (memcmp (edata.e.data, ones, edata.e.size) == 0)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
memcpy (buf, edata.e.data, edata.e.size);
|
memcpy (buf, edata.e.data, edata.e.size);
|
||||||
*length = edata.e.size;
|
*length = edata.e.size;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
Reference in New Issue
Block a user