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.
This commit is contained in:
Beniamino Galvani 2020-05-19 21:26:53 +02:00 committed by Thomas Haller
parent 9cbab5d3e7
commit eff0e0d123
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
2 changed files with 16 additions and 11 deletions

View file

@ -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;

View file

@ -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;