From f578b91a5cd3aa0852ea4ce01f2a060adcc1b32d Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 15 Jun 2016 14:11:16 +0200 Subject: [PATCH] device: let infiniband prefer permanent MAC address for infiniband.mac-address setting Note that usually for infiniband we cannot get a permanent MAC address via ethtool. Thus, nm_device_get_permanent_hw_address() will return the current address due to fallback_fake=TRUE. --- src/devices/nm-device-infiniband.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c index ae9543e4e9..17f50ba2c7 100644 --- a/src/devices/nm-device-infiniband.c +++ b/src/devices/nm-device-infiniband.c @@ -147,10 +147,15 @@ check_connection_compatible (NMDevice *device, NMConnection *connection) if (nm_device_is_real (device)) { const char *mac; + const char *hw_addr; mac = nm_setting_infiniband_get_mac_address (s_infiniband); - if (mac && !nm_utils_hwaddr_matches (mac, -1, nm_device_get_hw_address (device), -1)) - return FALSE; + if (mac) { + hw_addr = nm_device_get_permanent_hw_address (device, TRUE); + if ( !hw_addr + || !nm_utils_hwaddr_matches (mac, -1, hw_addr, -1)) + return FALSE; + } } return TRUE; @@ -183,7 +188,7 @@ complete_connection (NMDevice *device, } setting_mac = nm_setting_infiniband_get_mac_address (s_infiniband); - hw_address = nm_device_get_hw_address (device); + hw_address = nm_device_get_permanent_hw_address (device, TRUE); if (setting_mac) { /* Make sure the setting MAC (if any) matches the device's MAC */ if (!nm_utils_hwaddr_matches (setting_mac, -1, hw_address, -1)) { @@ -209,7 +214,7 @@ static void update_connection (NMDevice *device, NMConnection *connection) { NMSettingInfiniband *s_infiniband = nm_connection_get_setting_infiniband (connection); - const char *mac = nm_device_get_hw_address (device); + const char *mac = nm_device_get_permanent_hw_address (device, TRUE); const char *transport_mode = "datagram"; int ifindex;