From 067aa5036355fe436e45bd8debcc84e439a92762 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 31 Aug 2016 20:01:12 +0200 Subject: [PATCH] device: add new result NM_ACT_STAGE_RETURN_IP_DONE for ip config activation This is like NM_ACT_STAGE_RETURN_SUCCESS, except it should only set the IP state without commiting an NMIP[46]Config instance. --- src/devices/nm-device-private.h | 4 +++ src/devices/nm-device.c | 53 ++++++++++++++++----------------- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/src/devices/nm-device-private.h b/src/devices/nm-device-private.h index 0274431bb9..927dc8c46c 100644 --- a/src/devices/nm-device-private.h +++ b/src/devices/nm-device-private.h @@ -31,6 +31,10 @@ enum NMActStageReturn { NM_ACT_STAGE_RETURN_SUCCESS, /* Activation stage done */ NM_ACT_STAGE_RETURN_POSTPONE, /* Long-running operation in progress */ NM_ACT_STAGE_RETURN_IP_WAIT, /* IP config stage is waiting (state IP_WAIT) */ + NM_ACT_STAGE_RETURN_IP_DONE, /* IP config stage is done (state IP_DONE), + For the ip-config stage, this is similar to + NM_ACT_STAGE_RETURN_SUCCESS, except that no + IP config should be commited. */ NM_ACT_STAGE_RETURN_IP_FAIL, /* IP config stage failed (state IP_FAIL), activation may proceed */ }; diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index de20e18d14..743202eb90 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -5427,12 +5427,15 @@ act_stage3_ip4_config_start (NMDevice *self, ipv4_dad_start (self, configs, ipv4_manual_method_apply); ret = NM_ACT_STAGE_RETURN_POSTPONE; } else if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED) == 0) { - *out_config = shared4_new_config (self, connection, reason); - if (*out_config) { - priv->dnsmasq_manager = nm_dnsmasq_manager_new (nm_device_get_ip_iface (self)); - ret = NM_ACT_STAGE_RETURN_SUCCESS; + if (out_config) { + *out_config = shared4_new_config (self, connection, reason); + if (*out_config) { + priv->dnsmasq_manager = nm_dnsmasq_manager_new (nm_device_get_ip_iface (self)); + ret = NM_ACT_STAGE_RETURN_SUCCESS; + } else + ret = NM_ACT_STAGE_RETURN_FAILURE; } else - ret = NM_ACT_STAGE_RETURN_FAILURE; + g_return_val_if_reached (NM_ACT_STAGE_RETURN_FAILURE); } else if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) == 0) { apply_mtu_from_config (self); /* Nothing else to do... */ @@ -6795,8 +6798,6 @@ act_stage3_ip6_config_start (NMDevice *self, } else ret = NM_ACT_STAGE_RETURN_POSTPONE; } else if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL) == 0) { - /* New blank config */ - *out_config = nm_ip6_config_new (nm_device_get_ip_ifindex (self)); ret = NM_ACT_STAGE_RETURN_SUCCESS; } else _LOGW (LOGD_IP6, "unhandled IPv6 config method '%s'; will fail", method); @@ -6842,14 +6843,13 @@ nm_device_activate_stage3_ip4_start (NMDevice *self) _set_ip_state (self, AF_INET, IP_CONF); ret = NM_DEVICE_GET_CLASS (self)->act_stage3_ip4_config_start (self, &ip4_config, &reason); if (ret == NM_ACT_STAGE_RETURN_SUCCESS) { - if (!ip4_config) { - /* Early finish, nothing more to do */ - _set_ip_state (self, AF_INET, IP_DONE); - check_ip_done (self); - } else { - nm_device_activate_schedule_ip4_config_result (self, ip4_config); - g_object_unref (ip4_config); - } + if (!ip4_config) + ip4_config = nm_ip4_config_new (nm_device_get_ip_ifindex (self)); + nm_device_activate_schedule_ip4_config_result (self, ip4_config); + g_object_unref (ip4_config); + } else if (ret == NM_ACT_STAGE_RETURN_IP_DONE) { + _set_ip_state (self, AF_INET, IP_DONE); + check_ip_done (self); } else if (ret == NM_ACT_STAGE_RETURN_FAILURE) { nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason); return FALSE; @@ -6884,18 +6884,17 @@ nm_device_activate_stage3_ip6_start (NMDevice *self) _set_ip_state (self, AF_INET6, IP_CONF); ret = NM_DEVICE_GET_CLASS (self)->act_stage3_ip6_config_start (self, &ip6_config, &reason); if (ret == NM_ACT_STAGE_RETURN_SUCCESS) { - if (!ip6_config) { - /* Early finish, nothing more to do */ - _set_ip_state (self, AF_INET6, IP_DONE); - check_ip_done (self); - } else { - /* Here we get a static IPv6 config, like for Shared where it's - * autogenerated or from modems where it comes from ModemManager. - */ - g_warn_if_fail (priv->ac_ip6_config == NULL); - priv->ac_ip6_config = ip6_config; - nm_device_activate_schedule_ip6_config_result (self); - } + if (!ip6_config) + ip6_config = nm_ip6_config_new (nm_device_get_ip_ifindex (self)); + /* Here we get a static IPv6 config, like for Shared where it's + * autogenerated or from modems where it comes from ModemManager. + */ + g_warn_if_fail (priv->ac_ip6_config == NULL); + priv->ac_ip6_config = ip6_config; + nm_device_activate_schedule_ip6_config_result (self); + } else if (ret == NM_ACT_STAGE_RETURN_IP_DONE) { + _set_ip_state (self, AF_INET6, IP_DONE); + check_ip_done (self); } else if (ret == NM_ACT_STAGE_RETURN_FAILURE) { nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason); return FALSE;