summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2020-05-19 21:26:53 +0200
committerThomas Haller <thaller@redhat.com>2020-05-27 15:49:02 +0200
commiteff0e0d1233d834403accad29cb7ec05ea4f915b (patch)
treef62631a767f97eb550ba5e5321c9dadca01af116
parent9cbab5d3e77b4e8827b606d377ad8fcb2ddb262f (diff)
downloadNetworkManager-eff0e0d1233d834403accad29cb7ec05ea4f915b.tar.gz
device: add mechanism to call stage1 for external or assumed devices
Usually stage1 is skipped for external or assumed devices. Add a mechanism to call stage1 for all devices, similarly to what was already done for stage2.
-rw-r--r--src/devices/nm-device.c22
-rw-r--r--src/devices/nm-device.h5
2 files changed, 16 insertions, 11 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index e6fe97493a..dc46d3f7cc 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -6960,6 +6960,7 @@ activate_stage1_device_prepare (NMDevice *self)
NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS;
NMActiveConnection *active;
NMActiveConnection *master;
+ NMDeviceClass *klass;
priv->v4_route_table_initialized = FALSE;
priv->v6_route_table_initialized = FALSE;
@@ -7033,18 +7034,21 @@ activate_stage1_device_prepare (NMDevice *self)
}
/* Assumed connections were already set up outside NetworkManager */
- if (!nm_device_sys_iface_state_is_external_or_assume (self)) {
- NMDeviceClass *klass = NM_DEVICE_GET_CLASS (self);
+ 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_set_hwaddr_ethernet
+ && !nm_device_sys_iface_state_is_external_or_assume (self)) {
+ 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_also_for_external_or_assume
+ || !nm_device_sys_iface_state_is_external_or_assume (self)) {
+ nm_assert (!klass->act_stage1_prepare_also_for_external_or_assume || klass->act_stage1_prepare);
if (klass->act_stage1_prepare) {
NMDeviceStateReason failure_reason = NM_DEVICE_STATE_REASON_NONE;
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index 8d51c707dd..fa6559fd60 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -445,9 +445,10 @@ typedef struct _NMDeviceClass {
gboolean (* set_platform_mtu) (NMDevice *self, guint32 mtu);
- /* Controls, whether to call act_stage2_config() callback also for assuming
- * a device or for external activations. In this case, act_stage2_config() must
+ /* Control whether to call stage1 and stage2 callbacks also for assuming
+ * a device or for external activations. In this case, the callback must
* take care not to touch the device's configuration. */
+ bool act_stage1_prepare_also_for_external_or_assume:1;
bool act_stage2_config_also_for_external_or_assume:1;
bool act_stage1_prepare_set_hwaddr_ethernet:1;