mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 05:18:23 +02:00
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.
This commit is contained in:
parent
e5637dc089
commit
224937f5dd
5 changed files with 15 additions and 25 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue