From eb3247c09707be41a34987b8d5e0037139f7bfb0 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 15 Jun 2016 13:15:07 +0200 Subject: [PATCH] core: fix comparing nm_setting_wired_get_mac_address() with permanent MAC address `man nm-settings` says about ethernet.mac-address: If specified, this connection will only apply to the Ethernet device whose permanent MAC address matches. --- man/nm-settings-ifcfg-rh.xsl | 5 +++++ src/settings/nm-settings.c | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/man/nm-settings-ifcfg-rh.xsl b/man/nm-settings-ifcfg-rh.xsl index aac457c80b..80d33f2bdd 100644 --- a/man/nm-settings-ifcfg-rh.xsl +++ b/man/nm-settings-ifcfg-rh.xsl @@ -257,6 +257,11 @@ DEVICETYPE=TeamPort assigns the interface 10.42.0.1, or it uses the first static address, if configured. + + HWADDR - + initscripts compare the currently set hardware address of a device, while + NetworkManager considers the permanent one. + diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c index a11696fd65..284e173d24 100644 --- a/src/settings/nm-settings.c +++ b/src/settings/nm-settings.c @@ -1879,11 +1879,11 @@ have_connection_for_device (NMSettings *self, NMDevice *device) NMSettingConnection *s_con; NMSettingWired *s_wired; const char *setting_hwaddr; - const char *device_hwaddr; + const char *perm_hw_addr; g_return_val_if_fail (NM_IS_SETTINGS (self), FALSE); - device_hwaddr = nm_device_get_hw_address (device); + perm_hw_addr = nm_device_get_permanent_hw_address (device, FALSE); /* Find a wired connection locked to the given MAC address, if any */ g_hash_table_iter_init (&iter, priv->connections); @@ -1917,8 +1917,8 @@ have_connection_for_device (NMSettings *self, NMDevice *device) setting_hwaddr = nm_setting_wired_get_mac_address (s_wired); if (setting_hwaddr) { /* A connection mac-locked to this device */ - if ( device_hwaddr - && nm_utils_hwaddr_matches (setting_hwaddr, -1, device_hwaddr, -1)) + if ( perm_hw_addr + && nm_utils_hwaddr_matches (setting_hwaddr, -1, perm_hw_addr, -1)) return TRUE; } else { /* A connection that applies to any wired device */