diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2016-02-26 17:15:10 +0100 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2016-02-26 17:35:21 +0100 |
commit | f541a17270f3ff69d2ea7a3262d15dc63abb74b7 (patch) | |
tree | 33a66f5028889ff74a3be61e63e36646fabf6933 | |
parent | ec35542cd52596826ce312648574b0e7cbe69cec (diff) | |
download | NetworkManager-f541a17270f3ff69d2ea7a3262d15dc63abb74b7.tar.gz |
device: when activating without cloned-mac-address, set the permanent one
Don't rely on what's already on the device. It could be that the MAC address
set on the device is not meaningful -- the NM crashed while two devices were
teamed together and now they have the same hardware address and now it's
impossible to bond them with mode=5.
-rw-r--r-- | src/devices/nm-device-ethernet.c | 3 | ||||
-rw-r--r-- | src/devices/nm-device-macvlan.c | 3 | ||||
-rw-r--r-- | src/devices/nm-device-tun.c | 3 | ||||
-rw-r--r-- | src/devices/nm-device-vlan.c | 3 | ||||
-rw-r--r-- | src/devices/nm-device-vxlan.c | 3 | ||||
-rw-r--r-- | src/devices/nm-device.c | 6 | ||||
-rw-r--r-- | src/devices/wifi/nm-device-wifi.c | 3 |
7 files changed, 11 insertions, 13 deletions
diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index 5333aba4f7..2fb8427689 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -819,8 +819,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) if (s_wired) { /* Set device MAC address if the connection wants to change it */ cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired); - if (cloned_mac) - nm_device_set_hw_addr (dev, cloned_mac, "set", LOGD_ETHER); + nm_device_set_hw_addr (dev, cloned_mac, "set", LOGD_ETHER); } /* If we're re-activating a PPPoE connection a short while after diff --git a/src/devices/nm-device-macvlan.c b/src/devices/nm-device-macvlan.c index dfb0431b01..2dc9d4f6b2 100644 --- a/src/devices/nm-device-macvlan.c +++ b/src/devices/nm-device-macvlan.c @@ -508,8 +508,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) if (s_wired) { /* Set device MAC address if the connection wants to change it */ cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired); - if (cloned_mac) - nm_device_set_hw_addr (dev, cloned_mac, "set", LOGD_HW); + nm_device_set_hw_addr (dev, cloned_mac, "set", LOGD_HW); } return TRUE; diff --git a/src/devices/nm-device-tun.c b/src/devices/nm-device-tun.c index fdb72e453e..a8ae3edc91 100644 --- a/src/devices/nm-device-tun.c +++ b/src/devices/nm-device-tun.c @@ -302,8 +302,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) if (s_wired) { /* Set device MAC address if the connection wants to change it */ cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired); - if (cloned_mac) - nm_device_set_hw_addr (device, cloned_mac, "set", LOGD_DEVICE); + nm_device_set_hw_addr (device, cloned_mac, "set", LOGD_DEVICE); } return NM_ACT_STAGE_RETURN_SUCCESS; diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index 5685b24e7b..e6e3708b75 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -551,8 +551,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) if (s_wired) { /* Set device MAC address if the connection wants to change it */ cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired); - if (cloned_mac) - nm_device_set_hw_addr (dev, cloned_mac, "set", LOGD_VLAN); + nm_device_set_hw_addr (dev, cloned_mac, "set", LOGD_VLAN); } s_vlan = (NMSettingVlan *) nm_device_get_applied_setting (dev, NM_TYPE_SETTING_VLAN); diff --git a/src/devices/nm-device-vxlan.c b/src/devices/nm-device-vxlan.c index ff0f234364..7994245870 100644 --- a/src/devices/nm-device-vxlan.c +++ b/src/devices/nm-device-vxlan.c @@ -517,8 +517,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) if (s_wired) { /* Set device MAC address if the connection wants to change it */ cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired); - if (cloned_mac) - nm_device_set_hw_addr (device, cloned_mac, "set", LOGD_DEVICE); + nm_device_set_hw_addr (device, cloned_mac, "set", LOGD_DEVICE); } return NM_ACT_STAGE_RETURN_SUCCESS; diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index b9a3485157..641b429eba 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -10858,7 +10858,11 @@ nm_device_set_hw_addr (NMDevice *self, const char *addr, const char *cur_addr = nm_device_get_hw_address (self); guint8 addr_bytes[NM_UTILS_HWADDR_LEN_MAX]; - g_return_val_if_fail (addr != NULL, FALSE); + /* Fall back to the permanent address */ + if (!addr) + addr = priv->perm_hw_addr; + if (!addr) + return FALSE; /* Do nothing if current MAC is same */ if (cur_addr && nm_utils_hwaddr_matches (cur_addr, -1, addr, -1)) { diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index 64f728d0a5..da2a0f4a89 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -2316,8 +2316,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) /* Set spoof MAC to the interface */ cloned_mac = nm_setting_wireless_get_cloned_mac_address (s_wireless); - if (cloned_mac) - nm_device_set_hw_addr (device, cloned_mac, "set", LOGD_WIFI); + nm_device_set_hw_addr (device, cloned_mac, "set", LOGD_WIFI); /* AP mode never uses a specific object or existing scanned AP */ if (priv->mode != NM_802_11_MODE_AP) { |