diff options
author | Thomas Haller <thaller@redhat.com> | 2016-05-20 09:12:40 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-06-30 08:29:54 +0200 |
commit | 224937f5dddb1c3a2e6af195f2c58ef05a81d5c9 (patch) | |
tree | 51b0d7a1ca919b38b905b6d4189dd33468418591 | |
parent | e5637dc0897c9d1b0a2470795580465cf0703b00 (diff) | |
download | NetworkManager-224937f5dddb1c3a2e6af195f2c58ef05a81d5c9.tar.gz |
device: always set "cloned-mac-address" even with missing NMSettingWired
When the entire NMSettingWired setting is missing, it should be treated
exactly the same as each property having the default/unset value.
Otherwise, adding a NMSettingWired setting only to set (say) MTU,
would result in different behavior. Although effectively the
"cloned-mac-address" shall be in both cases the same.
-rw-r--r-- | src/devices/nm-device-ethernet.c | 8 | ||||
-rw-r--r-- | src/devices/nm-device-macvlan.c | 8 | ||||
-rw-r--r-- | src/devices/nm-device-tun.c | 8 | ||||
-rw-r--r-- | src/devices/nm-device-vlan.c | 8 | ||||
-rw-r--r-- | src/devices/nm-device-vxlan.c | 8 |
5 files changed, 15 insertions, 25 deletions
diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index 1367555b3e..a3e88f390b 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -814,7 +814,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) NMDeviceEthernet *self = NM_DEVICE_ETHERNET (dev); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); NMSettingWired *s_wired; - const char *cloned_mac; + const char *cloned_mac = NULL; NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS; g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE); @@ -822,11 +822,9 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) ret = NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->act_stage1_prepare (dev, reason); if (ret == NM_ACT_STAGE_RETURN_SUCCESS) { s_wired = (NMSettingWired *) nm_device_get_applied_setting (dev, NM_TYPE_SETTING_WIRED); - if (s_wired) { - /* Set device MAC address if the connection wants to change it */ + if (s_wired) cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired); - 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 * a previous PPPoE connection was torn down, wait a bit to allow the diff --git a/src/devices/nm-device-macvlan.c b/src/devices/nm-device-macvlan.c index c5443ecd23..d2ebc38c34 100644 --- a/src/devices/nm-device-macvlan.c +++ b/src/devices/nm-device-macvlan.c @@ -504,7 +504,7 @@ static NMActStageReturn act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) { NMSettingWired *s_wired; - const char *cloned_mac; + const char *cloned_mac = NULL; NMActStageReturn ret; g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE); @@ -514,11 +514,9 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) return ret; s_wired = (NMSettingWired *) nm_device_get_applied_setting (dev, NM_TYPE_SETTING_WIRED); - if (s_wired) { - /* Set device MAC address if the connection wants to change it */ + if (s_wired) cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired); - 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 01cd8ea6a3..63b3fd6173 100644 --- a/src/devices/nm-device-tun.c +++ b/src/devices/nm-device-tun.c @@ -292,7 +292,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) NMDeviceTun *self = NM_DEVICE_TUN (device); NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE (self); NMSettingWired *s_wired; - const char *cloned_mac; + const char *cloned_mac = NULL; NMActStageReturn ret; g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE); @@ -306,11 +306,9 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) return NM_ACT_STAGE_RETURN_SUCCESS; s_wired = (NMSettingWired *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRED); - if (s_wired) { - /* Set device MAC address if the connection wants to change it */ + if (s_wired) cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired); - 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 95f36298f5..ca3ed2cadc 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -551,7 +551,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (dev); NMSettingVlan *s_vlan; NMSettingWired *s_wired; - const char *cloned_mac; + const char *cloned_mac = NULL; NMActStageReturn ret; g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE); @@ -561,11 +561,9 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) return ret; s_wired = (NMSettingWired *) nm_device_get_applied_setting (dev, NM_TYPE_SETTING_WIRED); - if (s_wired) { - /* Set device MAC address if the connection wants to change it */ + if (s_wired) cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired); - nm_device_set_hw_addr (dev, cloned_mac, "set", LOGD_VLAN); - } + nm_device_set_hw_addr (dev, cloned_mac, "set", LOGD_VLAN); /* Change MAC address to parent's one if needed */ if (priv->parent) diff --git a/src/devices/nm-device-vxlan.c b/src/devices/nm-device-vxlan.c index ba2b2d68d7..ffd05ac678 100644 --- a/src/devices/nm-device-vxlan.c +++ b/src/devices/nm-device-vxlan.c @@ -512,7 +512,7 @@ static NMActStageReturn act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) { NMSettingWired *s_wired; - const char *cloned_mac; + const char *cloned_mac = NULL; NMActStageReturn ret; g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE); @@ -522,11 +522,9 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) return ret; s_wired = (NMSettingWired *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRED); - if (s_wired) { - /* Set device MAC address if the connection wants to change it */ + if (s_wired) cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired); - 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; } |