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.
This commit is contained in:
Thomas Haller 2016-08-31 20:01:12 +02:00
parent dd48472909
commit 067aa50363
2 changed files with 30 additions and 27 deletions

View file

@ -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 */
};

View file

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