device: add mechanism to invoke act_stage2_config() function also for external/assume case

Usually, for external/assume we skip calling act_stage2_config().

Add a flag that allows the device to indicate that it always wants
to be called. This is useful, if the device wants to do some initialization
also for external/assume cases.
This commit is contained in:
Thomas Haller 2019-02-10 14:01:23 +01:00
parent b45b087bbe
commit c3751a25a1
2 changed files with 10 additions and 2 deletions

View file

@ -6486,6 +6486,7 @@ static void
activate_stage2_device_config (NMDevice *self)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
NMDeviceClass *klass;
NMActStageReturn ret;
gboolean no_firmware = FALSE;
CList *iter;
@ -6513,10 +6514,12 @@ activate_stage2_device_config (NMDevice *self)
}
}
if (!nm_device_sys_iface_state_is_external_or_assume (self)) {
klass = NM_DEVICE_GET_CLASS (self);
if ( klass->act_stage2_config_also_for_external_or_assume
|| !nm_device_sys_iface_state_is_external_or_assume (self)) {
NMDeviceStateReason failure_reason = NM_DEVICE_STATE_REASON_NONE;
ret = NM_DEVICE_GET_CLASS (self)->act_stage2_config (self, &failure_reason);
ret = klass->act_stage2_config (self, &failure_reason);
if (ret == NM_ACT_STAGE_RETURN_POSTPONE)
return;
if (ret != NM_ACT_STAGE_RETURN_SUCCESS) {

View file

@ -456,6 +456,11 @@ typedef struct _NMDeviceClass {
guint32 (* get_dhcp_timeout) (NMDevice *self,
int addr_family);
/* Controls, whether to call act_stage2_config() callback also for assuming
* 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;
} NMDeviceClass;
typedef void (*NMDeviceAuthRequestFunc) (NMDevice *device,