[PATCH] 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
---
 src/platform/nm-platform-utils.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/platform/nm-platform-utils.c b/src/platform/nm-platform-utils.c
index 953ac8c..696dcb9 100644
--- a/src/platform/nm-platform-utils.c
+++ b/src/platform/nm-platform-utils.c
@@ -142,7 +142,8 @@ nmp_utils_ethtool_get_permanent_address (const char *ifname,
                struct ethtool_perm_addr e;
                guint8 _extra_data[NM_UTILS_HWADDR_LEN_MAX + 1];
        } edata;
-       guint zeros[NM_UTILS_HWADDR_LEN_MAX] = { 0 };
+       static const guint8 zeros[NM_UTILS_HWADDR_LEN_MAX] = { 0x00 };
+       static const guint8 ones[NM_UTILS_HWADDR_LEN_MAX] = { 0xFF };
 
        if (!ifname)
                return FALSE;
@@ -156,10 +157,12 @@ nmp_utils_ethtool_get_permanent_address (const char *ifname,
 
        g_assert (edata.e.size <= NM_UTILS_HWADDR_LEN_MAX);
 
-       /* Some drivers might return a permanent address of all zeros.
-        * Reject that (rh#1264024) */
+       /* Some drivers might return a permanent address of all zeros or
+        * all ones.  Reject that (rh#1264024) */
        if (memcmp (edata.e.data, zeros, edata.e.size) == 0)
                return FALSE;
+       if (memcmp (edata.e.data, ones, edata.e.size) == 0)
+               return FALSE;
 
        memcpy (buf, edata.e.data, edata.e.size);
        *length = edata.e.size;
-- 
2.4.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]