mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-06-20 21:08:28 +02:00
device: move redundant act_stage1_prepare() implementations to set hwaddr to NMDevice
This is so common, that NMDevice can handle it for us.
This commit is contained in:
parent
dc27512184
commit
de439148dd
7 changed files with 17 additions and 49 deletions
|
|
@ -230,14 +230,6 @@ update_connection (NMDevice *device, NMConnection *connection)
|
|||
NULL);
|
||||
}
|
||||
|
||||
static NMActStageReturn
|
||||
act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *out_failure_reason)
|
||||
{
|
||||
if (!nm_device_hw_addr_set_cloned (dev, nm_device_get_applied_connection (dev), FALSE))
|
||||
return NM_ACT_STAGE_RETURN_FAILURE;
|
||||
return NM_ACT_STAGE_RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
|
|
@ -267,7 +259,7 @@ nm_device_6lowpan_class_init (NMDevice6LowpanClass *klass)
|
|||
device_class->connection_type_check_compatible = NM_SETTING_6LOWPAN_SETTING_NAME;
|
||||
device_class->link_types = NM_DEVICE_DEFINE_LINK_TYPES (NM_LINK_TYPE_6LOWPAN);
|
||||
|
||||
device_class->act_stage1_prepare = act_stage1_prepare;
|
||||
device_class->act_stage1_prepare_set_hwaddr_ethernet = TRUE;
|
||||
device_class->complete_connection = complete_connection;
|
||||
device_class->create_and_realize = create_and_realize;
|
||||
device_class->get_generic_capabilities = get_generic_capabilities;
|
||||
|
|
|
|||
|
|
@ -116,15 +116,6 @@ create_and_realize (NMDevice *device,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static NMActStageReturn
|
||||
act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
||||
{
|
||||
if (!nm_device_hw_addr_set_cloned (device, nm_device_get_applied_connection (device), FALSE))
|
||||
return NM_ACT_STAGE_RETURN_FAILURE;
|
||||
|
||||
return NM_ACT_STAGE_RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
|
|
@ -161,7 +152,7 @@ nm_device_dummy_class_init (NMDeviceDummyClass *klass)
|
|||
device_class->create_and_realize = create_and_realize;
|
||||
device_class->get_generic_capabilities = get_generic_capabilities;
|
||||
device_class->update_connection = update_connection;
|
||||
device_class->act_stage1_prepare = act_stage1_prepare;
|
||||
device_class->act_stage1_prepare_set_hwaddr_ethernet = TRUE;
|
||||
device_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -965,15 +965,6 @@ set_property (GObject *object, guint prop_id,
|
|||
}
|
||||
}
|
||||
|
||||
static NMActStageReturn
|
||||
act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
||||
{
|
||||
if (!nm_device_hw_addr_set_cloned (device, nm_device_get_applied_connection (device), FALSE))
|
||||
return NM_ACT_STAGE_RETURN_FAILURE;
|
||||
|
||||
return NM_ACT_STAGE_RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
|
|
@ -1060,7 +1051,7 @@ nm_device_ip_tunnel_class_init (NMDeviceIPTunnelClass *klass)
|
|||
NM_LINK_TYPE_IPIP,
|
||||
NM_LINK_TYPE_SIT);
|
||||
|
||||
device_class->act_stage1_prepare = act_stage1_prepare;
|
||||
device_class->act_stage1_prepare_set_hwaddr_ethernet = TRUE;
|
||||
device_class->link_changed = link_changed;
|
||||
device_class->can_reapply_change = can_reapply_change;
|
||||
device_class->complete_connection = complete_connection;
|
||||
|
|
|
|||
|
|
@ -415,15 +415,6 @@ update_connection (NMDevice *device, NMConnection *connection)
|
|||
NULL);
|
||||
}
|
||||
|
||||
static NMActStageReturn
|
||||
act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
||||
{
|
||||
if (!nm_device_hw_addr_set_cloned (device, nm_device_get_applied_connection (device), FALSE))
|
||||
return NM_ACT_STAGE_RETURN_FAILURE;
|
||||
|
||||
return NM_ACT_STAGE_RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
|
|
@ -502,7 +493,7 @@ nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass)
|
|||
device_class->connection_type_check_compatible = NM_SETTING_MACVLAN_SETTING_NAME;
|
||||
device_class->link_types = NM_DEVICE_DEFINE_LINK_TYPES (NM_LINK_TYPE_MACVLAN, NM_LINK_TYPE_MACVTAP);
|
||||
|
||||
device_class->act_stage1_prepare = act_stage1_prepare;
|
||||
device_class->act_stage1_prepare_set_hwaddr_ethernet = TRUE;
|
||||
device_class->check_connection_compatible = check_connection_compatible;
|
||||
device_class->complete_connection = complete_connection;
|
||||
device_class->create_and_realize = create_and_realize;
|
||||
|
|
|
|||
|
|
@ -481,15 +481,6 @@ update_connection (NMDevice *device, NMConnection *connection)
|
|||
}
|
||||
}
|
||||
|
||||
static NMActStageReturn
|
||||
act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
||||
{
|
||||
if (!nm_device_hw_addr_set_cloned (device, nm_device_get_applied_connection (device), FALSE))
|
||||
return NM_ACT_STAGE_RETURN_FAILURE;
|
||||
|
||||
return NM_ACT_STAGE_RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
|
|
@ -614,7 +605,7 @@ nm_device_vxlan_class_init (NMDeviceVxlanClass *klass)
|
|||
device_class->complete_connection = complete_connection;
|
||||
device_class->get_generic_capabilities = get_generic_capabilities;
|
||||
device_class->update_connection = update_connection;
|
||||
device_class->act_stage1_prepare = act_stage1_prepare;
|
||||
device_class->act_stage1_prepare_set_hwaddr_ethernet = TRUE;
|
||||
device_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired;
|
||||
|
||||
obj_properties[PROP_ID] =
|
||||
|
|
|
|||
|
|
@ -6536,6 +6536,15 @@ activate_stage1_device_prepare (NMDevice *self)
|
|||
if (!nm_device_sys_iface_state_is_external_or_assume (self)) {
|
||||
NMDeviceClass *klass = NM_DEVICE_GET_CLASS (self);
|
||||
|
||||
if (klass->act_stage1_prepare_set_hwaddr_ethernet) {
|
||||
if (!nm_device_hw_addr_set_cloned (self,
|
||||
nm_device_get_applied_connection (self),
|
||||
FALSE)) {
|
||||
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_CONFIG_FAILED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (klass->act_stage1_prepare) {
|
||||
NMDeviceStateReason failure_reason = NM_DEVICE_STATE_REASON_NONE;
|
||||
|
||||
|
|
|
|||
|
|
@ -470,6 +470,9 @@ typedef struct _NMDeviceClass {
|
|||
* a device or for external activations. In this case, act_stage2_config() must
|
||||
* take care not to touch the device's configuration. */
|
||||
bool act_stage2_config_also_for_external_or_assume:1;
|
||||
|
||||
bool act_stage1_prepare_set_hwaddr_ethernet:1;
|
||||
|
||||
} NMDeviceClass;
|
||||
|
||||
typedef void (*NMDeviceAuthRequestFunc) (NMDevice *device,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue