device: rename device-state-reason argument to out_failure_reason

This argument is only relevant when the NMActStageReturn argument
indicates NM_ACT_STAGE_RETURN_FAILURE. In all other cases it is ignored.

Rename the argument to make the meaning clearer. The argument is passed
through several layers of code, it isn't obvious that this argument only
matters for the failure case. Also, the distinct name makes it easier
to distinguish from other uses of the "reason" name.

While at it, do some drive-by cleanup:

  - use g_return_*() instead of g_assert() to have a more graceful
    assertion.
  - functions like dhcp4_start() don't need to return a failure reason.
    Most callers don't care, and the caller who does can determine the
    proper reason.
  - allow omitting the out-argument via NM_SET_OUT().
This commit is contained in:
Thomas Haller
2017-02-22 17:04:00 +01:00
parent d5911fc551
commit 437c12fc89
21 changed files with 347 additions and 401 deletions

View File

@@ -329,12 +329,12 @@ nas_update_cb (gpointer user_data)
static NMActStageReturn static NMActStageReturn
br2684_create_iface (NMDeviceAdsl *self, br2684_create_iface (NMDeviceAdsl *self,
NMSettingAdsl *s_adsl, NMSettingAdsl *s_adsl,
NMDeviceStateReason *out_reason) NMDeviceStateReason *out_failure_reason)
{ {
NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (self); NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (self);
struct atm_newif_br2684 ni; struct atm_newif_br2684 ni;
int err, fd, errsv; nm_auto_close int fd = -1;
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE; int err, errsv;
guint num = 0; guint num = 0;
g_return_val_if_fail (s_adsl != NULL, FALSE); g_return_val_if_fail (s_adsl != NULL, FALSE);
@@ -348,7 +348,7 @@ br2684_create_iface (NMDeviceAdsl *self,
if (fd < 0) { if (fd < 0) {
errsv = errno; errsv = errno;
_LOGE (LOGD_ADSL, "failed to open ATM control socket (%d)", errsv); _LOGE (LOGD_ADSL, "failed to open ATM control socket (%d)", errsv);
*out_reason = NM_DEVICE_STATE_REASON_BR2684_FAILED; NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_BR2684_FAILED);
return NM_ACT_STAGE_RETURN_FAILURE; return NM_ACT_STAGE_RETURN_FAILURE;
} }
@@ -374,39 +374,36 @@ br2684_create_iface (NMDeviceAdsl *self,
priv->nas_update_count = 0; priv->nas_update_count = 0;
priv->nas_update_id = g_timeout_add (100, nas_update_cb, self); priv->nas_update_id = g_timeout_add (100, nas_update_cb, self);
ret = NM_ACT_STAGE_RETURN_POSTPONE; return NM_ACT_STAGE_RETURN_POSTPONE;
break; }
} else if (errno != EEXIST) { if (errno != EEXIST) {
errsv = errno; errsv = errno;
_LOGW (LOGD_ADSL, "failed to create br2684 interface (%d)", errsv); _LOGW (LOGD_ADSL, "failed to create br2684 interface (%d)", errsv);
*out_reason = NM_DEVICE_STATE_REASON_BR2684_FAILED;
break; break;
} }
} }
close (fd); NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_BR2684_FAILED);
return ret; return NM_ACT_STAGE_RETURN_FAILURE;
} }
static NMActStageReturn static NMActStageReturn
act_stage2_config (NMDevice *device, NMDeviceStateReason *out_reason) act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
{ {
NMDeviceAdsl *self = NM_DEVICE_ADSL (device); NMDeviceAdsl *self = NM_DEVICE_ADSL (device);
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE; NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
NMSettingAdsl *s_adsl; NMSettingAdsl *s_adsl;
const char *protocol; const char *protocol;
g_assert (out_reason);
s_adsl = nm_connection_get_setting_adsl (nm_device_get_applied_connection (device)); s_adsl = nm_connection_get_setting_adsl (nm_device_get_applied_connection (device));
g_assert (s_adsl); g_return_val_if_fail (s_adsl, NM_ACT_STAGE_RETURN_FAILURE);
protocol = nm_setting_adsl_get_protocol (s_adsl); protocol = nm_setting_adsl_get_protocol (s_adsl);
_LOGD (LOGD_ADSL, "using ADSL protocol '%s'", protocol); _LOGD (LOGD_ADSL, "using ADSL protocol '%s'", protocol);
if (g_strcmp0 (protocol, NM_SETTING_ADSL_PROTOCOL_PPPOE) == 0) { if (g_strcmp0 (protocol, NM_SETTING_ADSL_PROTOCOL_PPPOE) == 0) {
/* PPPoE needs RFC2684 bridging before we can do PPP over it */ /* PPPoE needs RFC2684 bridging before we can do PPP over it */
ret = br2684_create_iface (self, s_adsl, out_reason); ret = br2684_create_iface (self, s_adsl, out_failure_reason);
} else if (g_strcmp0 (protocol, NM_SETTING_ADSL_PROTOCOL_PPPOA) == 0) { } else if (g_strcmp0 (protocol, NM_SETTING_ADSL_PROTOCOL_PPPOA) == 0) {
/* PPPoA doesn't need anything special */ /* PPPoA doesn't need anything special */
ret = NM_ACT_STAGE_RETURN_SUCCESS; ret = NM_ACT_STAGE_RETURN_SUCCESS;
@@ -451,20 +448,19 @@ ppp_ip4_config (NMPPPManager *ppp_manager,
static NMActStageReturn static NMActStageReturn
act_stage3_ip4_config_start (NMDevice *device, act_stage3_ip4_config_start (NMDevice *device,
NMIP4Config **out_config, NMIP4Config **out_config,
NMDeviceStateReason *reason) NMDeviceStateReason *out_failure_reason)
{ {
NMDeviceAdsl *self = NM_DEVICE_ADSL (device); NMDeviceAdsl *self = NM_DEVICE_ADSL (device);
NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (self); NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (self);
NMSettingAdsl *s_adsl; NMSettingAdsl *s_adsl;
NMActRequest *req; NMActRequest *req;
GError *err = NULL; GError *err = NULL;
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
const char *ppp_iface; const char *ppp_iface;
req = nm_device_get_act_request (device); req = nm_device_get_act_request (device);
g_assert (req); g_return_val_if_fail (req, NM_ACT_STAGE_RETURN_FAILURE);
s_adsl = (NMSettingAdsl *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_ADSL); s_adsl = (NMSettingAdsl *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_ADSL);
g_assert (s_adsl); g_return_val_if_fail (s_adsl, NM_ACT_STAGE_RETURN_FAILURE);
/* PPPoE uses the NAS interface, not the ATM interface */ /* PPPoE uses the NAS interface, not the ATM interface */
if (g_strcmp0 (nm_setting_adsl_get_protocol (s_adsl), NM_SETTING_ADSL_PROTOCOL_PPPOE) == 0) { if (g_strcmp0 (nm_setting_adsl_get_protocol (s_adsl), NM_SETTING_ADSL_PROTOCOL_PPPOE) == 0) {
@@ -478,27 +474,26 @@ act_stage3_ip4_config_start (NMDevice *device,
} }
priv->ppp_manager = nm_ppp_manager_create (ppp_iface, &err); priv->ppp_manager = nm_ppp_manager_create (ppp_iface, &err);
if ( priv->ppp_manager if ( !priv->ppp_manager
&& nm_ppp_manager_start (priv->ppp_manager, req, || !nm_ppp_manager_start (priv->ppp_manager, req,
nm_setting_adsl_get_username (s_adsl), nm_setting_adsl_get_username (s_adsl),
30, 0, &err)) { 30, 0, &err)) {
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_STATE_CHANGED,
G_CALLBACK (ppp_state_changed),
self);
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_IP4_CONFIG,
G_CALLBACK (ppp_ip4_config),
self);
ret = NM_ACT_STAGE_RETURN_POSTPONE;
} else {
_LOGW (LOGD_ADSL, "PPP failed to start: %s", err->message); _LOGW (LOGD_ADSL, "PPP failed to start: %s", err->message);
g_error_free (err); g_error_free (err);
g_clear_object (&priv->ppp_manager); g_clear_object (&priv->ppp_manager);
*reason = NM_DEVICE_STATE_REASON_PPP_START_FAILED; NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_PPP_START_FAILED);
return NM_ACT_STAGE_RETURN_FAILURE;
} }
return ret; g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_STATE_CHANGED,
G_CALLBACK (ppp_state_changed),
self);
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_IP4_CONFIG,
G_CALLBACK (ppp_ip4_config),
self);
return NM_ACT_STAGE_RETURN_POSTPONE;
} }
static void static void

View File

@@ -99,7 +99,7 @@ G_DEFINE_TYPE (NMDeviceBt, nm_device_bt, NM_TYPE_DEVICE)
/*****************************************************************************/ /*****************************************************************************/
static gboolean modem_stage1 (NMDeviceBt *self, NMModem *modem, NMDeviceStateReason *reason); static gboolean modem_stage1 (NMDeviceBt *self, NMModem *modem, NMDeviceStateReason *out_failure_reason);
/*****************************************************************************/ /*****************************************************************************/
@@ -430,17 +430,18 @@ modem_auth_result (NMModem *modem, GError *error, gpointer user_data)
{ {
NMDevice *device = NM_DEVICE (user_data); NMDevice *device = NM_DEVICE (user_data);
NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE ((NMDeviceBt *) device); NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE ((NMDeviceBt *) device);
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
if (error) { if (error) {
nm_device_state_changed (device, nm_device_state_changed (device,
NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_FAILED,
NM_DEVICE_STATE_REASON_NO_SECRETS); NM_DEVICE_STATE_REASON_NO_SECRETS);
} else { } else {
NMDeviceStateReason failure_reason = NM_DEVICE_STATE_REASON_NONE;
/* Otherwise, on success for GSM/CDMA secrets we need to schedule modem stage1 again */ /* Otherwise, on success for GSM/CDMA secrets we need to schedule modem stage1 again */
g_return_if_fail (nm_device_get_state (device) == NM_DEVICE_STATE_NEED_AUTH); g_return_if_fail (nm_device_get_state (device) == NM_DEVICE_STATE_NEED_AUTH);
if (!modem_stage1 (NM_DEVICE_BT (device), priv->modem, &reason)) if (!modem_stage1 (NM_DEVICE_BT (device), priv->modem, &failure_reason))
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, reason); nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, failure_reason);
} }
} }
@@ -460,12 +461,12 @@ modem_prepare_result (NMModem *modem,
if (success) { if (success) {
NMActRequest *req; NMActRequest *req;
NMActStageReturn ret; NMActStageReturn ret;
NMDeviceStateReason stage2_reason = NM_DEVICE_STATE_REASON_NONE; NMDeviceStateReason failure_reason = NM_DEVICE_STATE_REASON_NONE;
req = nm_device_get_act_request (device); req = nm_device_get_act_request (device);
g_assert (req); g_return_if_fail (req);
ret = nm_modem_act_stage2_config (modem, req, &stage2_reason); ret = nm_modem_act_stage2_config (modem, req, &failure_reason);
switch (ret) { switch (ret) {
case NM_ACT_STAGE_RETURN_POSTPONE: case NM_ACT_STAGE_RETURN_POSTPONE:
break; break;
@@ -474,7 +475,7 @@ modem_prepare_result (NMModem *modem,
break; break;
case NM_ACT_STAGE_RETURN_FAILURE: case NM_ACT_STAGE_RETURN_FAILURE:
default: default:
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, stage2_reason); nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, failure_reason);
break; break;
} }
} else { } else {
@@ -541,17 +542,15 @@ data_port_changed_cb (NMModem *modem, GParamSpec *pspec, gpointer user_data)
} }
static gboolean static gboolean
modem_stage1 (NMDeviceBt *self, NMModem *modem, NMDeviceStateReason *reason) modem_stage1 (NMDeviceBt *self, NMModem *modem, NMDeviceStateReason *out_failure_reason)
{ {
NMActRequest *req; NMActRequest *req;
NMActStageReturn ret; NMActStageReturn ret;
g_return_val_if_fail (reason != NULL, FALSE);
req = nm_device_get_act_request (NM_DEVICE (self)); req = nm_device_get_act_request (NM_DEVICE (self));
g_assert (req); g_return_val_if_fail (req, FALSE);
ret = nm_modem_act_stage1_prepare (modem, req, reason); ret = nm_modem_act_stage1_prepare (modem, req, out_failure_reason);
switch (ret) { switch (ret) {
case NM_ACT_STAGE_RETURN_POSTPONE: case NM_ACT_STAGE_RETURN_POSTPONE:
case NM_ACT_STAGE_RETURN_SUCCESS: case NM_ACT_STAGE_RETURN_SUCCESS:
@@ -639,7 +638,7 @@ component_added (NMDevice *device, GObject *component)
const gchar *modem_control_port; const gchar *modem_control_port;
char *base; char *base;
NMDeviceState state; NMDeviceState state;
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE; NMDeviceStateReason failure_reason = NM_DEVICE_STATE_REASON_NONE;
if (!NM_IS_MODEM (component)) if (!NM_IS_MODEM (component))
return FALSE; return FALSE;
@@ -694,8 +693,8 @@ component_added (NMDevice *device, GObject *component)
g_signal_connect (modem, "notify::" NM_MODEM_DATA_PORT, G_CALLBACK (data_port_changed_cb), self); g_signal_connect (modem, "notify::" NM_MODEM_DATA_PORT, G_CALLBACK (data_port_changed_cb), self);
/* Kick off the modem connection */ /* Kick off the modem connection */
if (!modem_stage1 (self, modem, &reason)) if (!modem_stage1 (self, modem, &failure_reason))
nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_FAILED, reason); nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_FAILED, failure_reason);
return TRUE; return TRUE;
} }
@@ -836,14 +835,15 @@ bt_connect_timeout (gpointer user_data)
} }
static NMActStageReturn static NMActStageReturn
act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
{ {
NMDeviceBt *self = NM_DEVICE_BT (device); NMDeviceBt *self = NM_DEVICE_BT (device);
NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (self); NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (self);
NMConnection *connection; NMConnection *connection;
connection = nm_device_get_applied_connection (device); connection = nm_device_get_applied_connection (device);
g_assert (connection); g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
priv->bt_type = get_connection_bt_type (connection); priv->bt_type = get_connection_bt_type (connection);
if (priv->bt_type == NM_BT_CAPABILITY_NONE) { if (priv->bt_type == NM_BT_CAPABILITY_NONE) {
// FIXME: set a reason code // FIXME: set a reason code
@@ -851,7 +851,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
} }
if (priv->bt_type == NM_BT_CAPABILITY_DUN && !priv->mm_running) { if (priv->bt_type == NM_BT_CAPABILITY_DUN && !priv->mm_running) {
*reason = NM_DEVICE_STATE_REASON_MODEM_MANAGER_UNAVAILABLE; NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_MODEM_MANAGER_UNAVAILABLE);
return NM_ACT_STAGE_RETURN_FAILURE; return NM_ACT_STAGE_RETURN_FAILURE;
} }
@@ -862,8 +862,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
priv->bt_type & (NM_BT_CAPABILITY_DUN | NM_BT_CAPABILITY_NAP), priv->bt_type & (NM_BT_CAPABILITY_DUN | NM_BT_CAPABILITY_NAP),
bluez_connect_cb, g_object_ref (device)); bluez_connect_cb, g_object_ref (device));
if (priv->timeout_id) nm_clear_g_source (&priv->timeout_id);
g_source_remove (priv->timeout_id);
priv->timeout_id = g_timeout_add_seconds (30, bt_connect_timeout, device); priv->timeout_id = g_timeout_add_seconds (30, bt_connect_timeout, device);
return NM_ACT_STAGE_RETURN_POSTPONE; return NM_ACT_STAGE_RETURN_POSTPONE;
@@ -872,38 +871,34 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
static NMActStageReturn static NMActStageReturn
act_stage3_ip4_config_start (NMDevice *device, act_stage3_ip4_config_start (NMDevice *device,
NMIP4Config **out_config, NMIP4Config **out_config,
NMDeviceStateReason *reason) NMDeviceStateReason *out_failure_reason)
{ {
NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE ((NMDeviceBt *) device); NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE ((NMDeviceBt *) device);
NMActStageReturn ret;
if (priv->bt_type == NM_BT_CAPABILITY_DUN) { if (priv->bt_type == NM_BT_CAPABILITY_DUN) {
ret = nm_modem_stage3_ip4_config_start (priv->modem, return nm_modem_stage3_ip4_config_start (priv->modem,
device, device,
NM_DEVICE_CLASS (nm_device_bt_parent_class), NM_DEVICE_CLASS (nm_device_bt_parent_class),
reason); out_failure_reason);
} else }
ret = NM_DEVICE_CLASS (nm_device_bt_parent_class)->act_stage3_ip4_config_start (device, out_config, reason);
return ret; return NM_DEVICE_CLASS (nm_device_bt_parent_class)->act_stage3_ip4_config_start (device, out_config, out_failure_reason);
} }
static NMActStageReturn static NMActStageReturn
act_stage3_ip6_config_start (NMDevice *device, act_stage3_ip6_config_start (NMDevice *device,
NMIP6Config **out_config, NMIP6Config **out_config,
NMDeviceStateReason *reason) NMDeviceStateReason *out_failure_reason)
{ {
NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE ((NMDeviceBt *) device); NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE ((NMDeviceBt *) device);
NMActStageReturn ret;
if (priv->bt_type == NM_BT_CAPABILITY_DUN) { if (priv->bt_type == NM_BT_CAPABILITY_DUN) {
ret = nm_modem_stage3_ip6_config_start (priv->modem, return nm_modem_stage3_ip6_config_start (priv->modem,
nm_device_get_act_request (device), nm_device_get_act_request (device),
reason); out_failure_reason);
} else }
ret = NM_DEVICE_CLASS (nm_device_bt_parent_class)->act_stage3_ip6_config_start (device, out_config, reason);
return ret; return NM_DEVICE_CLASS (nm_device_bt_parent_class)->act_stage3_ip6_config_start (device, out_config, out_failure_reason);
} }
static void static void

View File

@@ -363,21 +363,19 @@ apply_bonding_config (NMDevice *device)
} }
static NMActStageReturn static NMActStageReturn
act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *out_failure_reason)
{ {
NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS; NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS;
gboolean no_firmware = FALSE; gboolean no_firmware = FALSE;
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE); ret = NM_DEVICE_CLASS (nm_device_bond_parent_class)->act_stage1_prepare (dev, out_failure_reason);
ret = NM_DEVICE_CLASS (nm_device_bond_parent_class)->act_stage1_prepare (dev, reason);
if (ret != NM_ACT_STAGE_RETURN_SUCCESS) if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
return ret; return ret;
/* Interface must be down to set bond options */ /* Interface must be down to set bond options */
nm_device_take_down (dev, TRUE); nm_device_take_down (dev, TRUE);
ret = apply_bonding_config (dev); ret = apply_bonding_config (dev);
if (ret) if (ret != NM_ACT_STAGE_RETURN_FAILURE)
ret = nm_device_hw_addr_set_cloned (dev, nm_device_get_applied_connection (dev), FALSE); ret = nm_device_hw_addr_set_cloned (dev, nm_device_get_applied_connection (dev), FALSE);
nm_device_bring_up (dev, TRUE, &no_firmware); nm_device_bring_up (dev, TRUE, &no_firmware);

View File

@@ -305,14 +305,14 @@ master_update_slave_connection (NMDevice *device,
} }
static NMActStageReturn static NMActStageReturn
act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
{ {
NMActStageReturn ret; NMActStageReturn ret;
NMConnection *connection = nm_device_get_applied_connection (device); NMConnection *connection = nm_device_get_applied_connection (device);
g_assert (connection); g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
ret = NM_DEVICE_CLASS (nm_device_bridge_parent_class)->act_stage1_prepare (device, reason); ret = NM_DEVICE_CLASS (nm_device_bridge_parent_class)->act_stage1_prepare (device, out_failure_reason);
if (ret != NM_ACT_STAGE_RETURN_SUCCESS) if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
return ret; return ret;

View File

@@ -874,15 +874,13 @@ pppoe_reconnect_delay (gpointer user_data)
} }
static NMActStageReturn static NMActStageReturn
act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *out_failure_reason)
{ {
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (dev); NMDeviceEthernet *self = NM_DEVICE_ETHERNET (dev);
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
NMActStageReturn ret; NMActStageReturn ret;
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE); ret = NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->act_stage1_prepare (dev, out_failure_reason);
ret = NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->act_stage1_prepare (dev, reason);
if (ret != NM_ACT_STAGE_RETURN_SUCCESS) if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
return ret; return ret;
@@ -916,7 +914,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
} }
static NMActStageReturn static NMActStageReturn
nm_8021x_stage2_config (NMDeviceEthernet *self, NMDeviceStateReason *reason) nm_8021x_stage2_config (NMDeviceEthernet *self, NMDeviceStateReason *out_failure_reason)
{ {
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
NMConnection *connection; NMConnection *connection;
@@ -925,11 +923,12 @@ nm_8021x_stage2_config (NMDeviceEthernet *self, NMDeviceStateReason *reason)
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE; NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
connection = nm_device_get_applied_connection (NM_DEVICE (self)); connection = nm_device_get_applied_connection (NM_DEVICE (self));
g_assert (connection); g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
security = nm_connection_get_setting_802_1x (connection); security = nm_connection_get_setting_802_1x (connection);
if (!security) { if (!security) {
_LOGE (LOGD_DEVICE, "Invalid or missing 802.1X security"); _LOGE (LOGD_DEVICE, "Invalid or missing 802.1X security");
*reason = NM_DEVICE_STATE_REASON_CONFIG_FAILED; NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_CONFIG_FAILED);
return ret; return ret;
} }
@@ -947,7 +946,7 @@ nm_8021x_stage2_config (NMDeviceEthernet *self, NMDeviceStateReason *reason)
ret = handle_auth_or_fail (self, req, FALSE); ret = handle_auth_or_fail (self, req, FALSE);
if (ret != NM_ACT_STAGE_RETURN_POSTPONE) if (ret != NM_ACT_STAGE_RETURN_POSTPONE)
*reason = NM_DEVICE_STATE_REASON_NO_SECRETS; NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_NO_SECRETS);
} else { } else {
_LOGI (LOGD_DEVICE | LOGD_ETHER, _LOGI (LOGD_DEVICE | LOGD_ETHER,
"Activation: (ethernet) connection '%s' requires no security. No secrets needed.", "Activation: (ethernet) connection '%s' requires no security. No secrets needed.",
@@ -956,7 +955,7 @@ nm_8021x_stage2_config (NMDeviceEthernet *self, NMDeviceStateReason *reason)
if (supplicant_interface_init (self)) if (supplicant_interface_init (self))
ret = NM_ACT_STAGE_RETURN_POSTPONE; ret = NM_ACT_STAGE_RETURN_POSTPONE;
else else
*reason = NM_DEVICE_STATE_REASON_CONFIG_FAILED; NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_CONFIG_FAILED);
} }
return ret; return ret;
@@ -998,43 +997,42 @@ ppp_ip4_config (NMPPPManager *ppp_manager,
} }
static NMActStageReturn static NMActStageReturn
pppoe_stage3_ip4_config_start (NMDeviceEthernet *self, NMDeviceStateReason *reason) pppoe_stage3_ip4_config_start (NMDeviceEthernet *self, NMDeviceStateReason *out_failure_reason)
{ {
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
NMSettingPppoe *s_pppoe; NMSettingPppoe *s_pppoe;
NMActRequest *req; NMActRequest *req;
GError *err = NULL; GError *err = NULL;
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
req = nm_device_get_act_request (NM_DEVICE (self)); req = nm_device_get_act_request (NM_DEVICE (self));
g_assert (req); g_return_val_if_fail (req, NM_ACT_STAGE_RETURN_FAILURE);
s_pppoe = (NMSettingPppoe *) nm_device_get_applied_setting ((NMDevice *) self, NM_TYPE_SETTING_PPPOE); s_pppoe = (NMSettingPppoe *) nm_device_get_applied_setting ((NMDevice *) self, NM_TYPE_SETTING_PPPOE);
g_assert (s_pppoe); g_return_val_if_fail (s_pppoe, NM_ACT_STAGE_RETURN_FAILURE);
priv->ppp_manager = nm_ppp_manager_create (nm_device_get_iface (NM_DEVICE (self)), priv->ppp_manager = nm_ppp_manager_create (nm_device_get_iface (NM_DEVICE (self)),
&err); &err);
if ( priv->ppp_manager
&& nm_ppp_manager_start (priv->ppp_manager, req, if ( !priv->ppp_manager
nm_setting_pppoe_get_username (s_pppoe), || !nm_ppp_manager_start (priv->ppp_manager, req,
30, 0, &err)) { nm_setting_pppoe_get_username (s_pppoe),
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_STATE_CHANGED, 30, 0, &err)) {
G_CALLBACK (ppp_state_changed),
self);
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_IP4_CONFIG,
G_CALLBACK (ppp_ip4_config),
self);
ret = NM_ACT_STAGE_RETURN_POSTPONE;
} else {
_LOGW (LOGD_DEVICE, "PPPoE failed to start: %s", err->message); _LOGW (LOGD_DEVICE, "PPPoE failed to start: %s", err->message);
g_error_free (err); g_error_free (err);
g_clear_object (&priv->ppp_manager); g_clear_object (&priv->ppp_manager);
*reason = NM_DEVICE_STATE_REASON_PPP_START_FAILED; NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_PPP_START_FAILED);
return NM_ACT_STAGE_RETURN_FAILURE;
} }
return ret; g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_STATE_CHANGED,
G_CALLBACK (ppp_state_changed),
self);
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_IP4_CONFIG,
G_CALLBACK (ppp_ip4_config),
self);
return NM_ACT_STAGE_RETURN_POSTPONE;
} }
/*****************************************************************************/ /*****************************************************************************/
@@ -1249,7 +1247,7 @@ found:
/*****************************************************************************/ /*****************************************************************************/
static NMActStageReturn static NMActStageReturn
act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
{ {
NMDeviceEthernet *self = (NMDeviceEthernet *) device; NMDeviceEthernet *self = (NMDeviceEthernet *) device;
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
@@ -1258,11 +1256,9 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS; NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS;
NMSettingDcb *s_dcb; NMSettingDcb *s_dcb;
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
s_con = NM_SETTING_CONNECTION (nm_device_get_applied_setting (device, s_con = NM_SETTING_CONNECTION (nm_device_get_applied_setting (device,
NM_TYPE_SETTING_CONNECTION)); NM_TYPE_SETTING_CONNECTION));
g_assert (s_con); g_return_val_if_fail (s_con, NM_ACT_STAGE_RETURN_FAILURE);
nm_clear_g_source (&priv->dcb_timeout_id); nm_clear_g_source (&priv->dcb_timeout_id);
nm_clear_g_signal_handler (device, &priv->dcb_carrier_id); nm_clear_g_signal_handler (device, &priv->dcb_carrier_id);
@@ -1278,7 +1274,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
NM_TYPE_SETTING_802_1X); NM_TYPE_SETTING_802_1X);
if (security) { if (security) {
/* FIXME: for now 802.1x is mutually exclusive with DCB */ /* FIXME: for now 802.1x is mutually exclusive with DCB */
return nm_8021x_stage2_config (self, reason); return nm_8021x_stage2_config (self, out_failure_reason);
} }
} }
@@ -1290,7 +1286,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
/* lldpad really really wants the carrier to be up */ /* lldpad really really wants the carrier to be up */
if (nm_platform_link_is_connected (NM_PLATFORM_GET, nm_device_get_ifindex (device))) { if (nm_platform_link_is_connected (NM_PLATFORM_GET, nm_device_get_ifindex (device))) {
if (!dcb_enable (device)) { if (!dcb_enable (device)) {
*reason = NM_DEVICE_STATE_REASON_DCB_FCOE_FAILED; NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_DCB_FCOE_FAILED);
return NM_ACT_STAGE_RETURN_FAILURE; return NM_ACT_STAGE_RETURN_FAILURE;
} }
} else { } else {
@@ -1337,21 +1333,19 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
static NMActStageReturn static NMActStageReturn
act_stage3_ip4_config_start (NMDevice *device, act_stage3_ip4_config_start (NMDevice *device,
NMIP4Config **out_config, NMIP4Config **out_config,
NMDeviceStateReason *reason) NMDeviceStateReason *out_failure_reason)
{ {
NMSettingConnection *s_con; NMSettingConnection *s_con;
const char *connection_type; const char *connection_type;
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
s_con = NM_SETTING_CONNECTION (nm_device_get_applied_setting (device, NM_TYPE_SETTING_CONNECTION)); s_con = NM_SETTING_CONNECTION (nm_device_get_applied_setting (device, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con); g_return_val_if_fail (s_con, NM_ACT_STAGE_RETURN_FAILURE);
connection_type = nm_setting_connection_get_connection_type (s_con); connection_type = nm_setting_connection_get_connection_type (s_con);
if (!strcmp (connection_type, NM_SETTING_PPPOE_SETTING_NAME)) if (!strcmp (connection_type, NM_SETTING_PPPOE_SETTING_NAME))
return pppoe_stage3_ip4_config_start (NM_DEVICE_ETHERNET (device), reason); return pppoe_stage3_ip4_config_start (NM_DEVICE_ETHERNET (device), out_failure_reason);
return NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->act_stage3_ip4_config_start (device, out_config, reason); return NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->act_stage3_ip4_config_start (device, out_config, out_failure_reason);
} }
static guint32 static guint32

View File

@@ -75,7 +75,7 @@ get_generic_capabilities (NMDevice *device)
} }
static NMActStageReturn static NMActStageReturn
act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *out_failure_reason)
{ {
nm_auto_close int dirfd = -1; nm_auto_close int dirfd = -1;
NMActStageReturn ret; NMActStageReturn ret;
@@ -84,14 +84,12 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
const char *transport_mode; const char *transport_mode;
gboolean ok, no_firmware = FALSE; gboolean ok, no_firmware = FALSE;
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE); ret = NM_DEVICE_CLASS (nm_device_infiniband_parent_class)->act_stage1_prepare (dev, out_failure_reason);
ret = NM_DEVICE_CLASS (nm_device_infiniband_parent_class)->act_stage1_prepare (dev, reason);
if (ret != NM_ACT_STAGE_RETURN_SUCCESS) if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
return ret; return ret;
s_infiniband = (NMSettingInfiniband *) nm_device_get_applied_setting (dev, NM_TYPE_SETTING_INFINIBAND); s_infiniband = (NMSettingInfiniband *) nm_device_get_applied_setting (dev, NM_TYPE_SETTING_INFINIBAND);
g_assert (s_infiniband); g_return_val_if_fail (s_infiniband, NM_ACT_STAGE_RETURN_FAILURE);
transport_mode = nm_setting_infiniband_get_transport_mode (s_infiniband); transport_mode = nm_setting_infiniband_get_transport_mode (s_infiniband);
@@ -100,7 +98,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
if (!strcmp (transport_mode, "datagram")) if (!strcmp (transport_mode, "datagram"))
return NM_ACT_STAGE_RETURN_SUCCESS; return NM_ACT_STAGE_RETURN_SUCCESS;
else { else {
*reason = NM_DEVICE_STATE_REASON_INFINIBAND_MODE; NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_INFINIBAND_MODE);
return NM_ACT_STAGE_RETURN_FAILURE; return NM_ACT_STAGE_RETURN_FAILURE;
} }
} }
@@ -111,7 +109,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
nm_device_bring_up (dev, TRUE, &no_firmware); nm_device_bring_up (dev, TRUE, &no_firmware);
if (!ok) { if (!ok) {
*reason = NM_DEVICE_STATE_REASON_CONFIG_FAILED; NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_CONFIG_FAILED);
return NM_ACT_STAGE_RETURN_FAILURE; return NM_ACT_STAGE_RETURN_FAILURE;
} }

View File

@@ -585,7 +585,7 @@ supplicant_interface_init (NMDeviceMacsec *self)
} }
static NMActStageReturn static NMActStageReturn
act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
{ {
NMDeviceMacsec *self = NM_DEVICE_MACSEC (device); NMDeviceMacsec *self = NM_DEVICE_MACSEC (device);
NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE (self); NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE (self);
@@ -594,7 +594,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
const char *setting_name; const char *setting_name;
connection = nm_device_get_applied_connection (NM_DEVICE (self)); connection = nm_device_get_applied_connection (NM_DEVICE (self));
g_assert (connection); g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
if (!priv->supplicant.mgr) if (!priv->supplicant.mgr)
priv->supplicant.mgr = g_object_ref (nm_supplicant_manager_get ()); priv->supplicant.mgr = g_object_ref (nm_supplicant_manager_get ());
@@ -610,7 +610,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
ret = handle_auth_or_fail (self, req, FALSE); ret = handle_auth_or_fail (self, req, FALSE);
if (ret != NM_ACT_STAGE_RETURN_POSTPONE) if (ret != NM_ACT_STAGE_RETURN_POSTPONE)
*reason = NM_DEVICE_STATE_REASON_NO_SECRETS; NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_NO_SECRETS);
} else { } else {
_LOGI (LOGD_DEVICE | LOGD_ETHER, _LOGI (LOGD_DEVICE | LOGD_ETHER,
"Activation: connection '%s' requires no security. No secrets needed.", "Activation: connection '%s' requires no security. No secrets needed.",
@@ -619,7 +619,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
if (supplicant_interface_init (self)) if (supplicant_interface_init (self))
ret = NM_ACT_STAGE_RETURN_POSTPONE; ret = NM_ACT_STAGE_RETURN_POSTPONE;
else else
*reason = NM_DEVICE_STATE_REASON_CONFIG_FAILED; NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_CONFIG_FAILED);
} }
return ret; return ret;

View File

@@ -474,13 +474,11 @@ update_connection (NMDevice *device, NMConnection *connection)
} }
static NMActStageReturn static NMActStageReturn
act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *out_failure_reason)
{ {
NMActStageReturn ret; NMActStageReturn ret;
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE); ret = NM_DEVICE_CLASS (nm_device_macvlan_parent_class)->act_stage1_prepare (dev, out_failure_reason);
ret = NM_DEVICE_CLASS (nm_device_macvlan_parent_class)->act_stage1_prepare (dev, reason);
if (ret != NM_ACT_STAGE_RETURN_SUCCESS) if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
return ret; return ret;

View File

@@ -291,15 +291,13 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
} }
static NMActStageReturn static NMActStageReturn
act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
{ {
NMDeviceTun *self = NM_DEVICE_TUN (device); NMDeviceTun *self = NM_DEVICE_TUN (device);
NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE (self); NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE (self);
NMActStageReturn ret; NMActStageReturn ret;
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE); ret = NM_DEVICE_CLASS (nm_device_tun_parent_class)->act_stage1_prepare (device, out_failure_reason);
ret = NM_DEVICE_CLASS (nm_device_tun_parent_class)->act_stage1_prepare (device, reason);
if (ret != NM_ACT_STAGE_RETURN_SUCCESS) if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
return ret; return ret;

View File

@@ -522,15 +522,13 @@ update_connection (NMDevice *device, NMConnection *connection)
} }
static NMActStageReturn static NMActStageReturn
act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
{ {
NMDevice *parent_device; NMDevice *parent_device;
NMSettingVlan *s_vlan; NMSettingVlan *s_vlan;
NMActStageReturn ret; NMActStageReturn ret;
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE); ret = NM_DEVICE_CLASS (nm_device_vlan_parent_class)->act_stage1_prepare (device, out_failure_reason);
ret = NM_DEVICE_CLASS (nm_device_vlan_parent_class)->act_stage1_prepare (device, reason);
if (ret != NM_ACT_STAGE_RETURN_SUCCESS) if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
return ret; return ret;

View File

@@ -496,13 +496,11 @@ update_connection (NMDevice *device, NMConnection *connection)
} }
static NMActStageReturn static NMActStageReturn
act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
{ {
NMActStageReturn ret; NMActStageReturn ret;
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE); ret = NM_DEVICE_CLASS (nm_device_vxlan_parent_class)->act_stage1_prepare (device, out_failure_reason);
ret = NM_DEVICE_CLASS (nm_device_vxlan_parent_class)->act_stage1_prepare (device, reason);
if (ret != NM_ACT_STAGE_RETURN_SUCCESS) if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
return ret; return ret;

View File

@@ -459,7 +459,7 @@ static gboolean nm_device_set_ip4_config (NMDevice *self,
guint32 default_route_metric, guint32 default_route_metric,
gboolean commit, gboolean commit,
gboolean routes_full_sync, gboolean routes_full_sync,
NMDeviceStateReason *reason); NMDeviceStateReason *out_reason);
static gboolean ip4_config_merge_and_apply (NMDevice *self, static gboolean ip4_config_merge_and_apply (NMDevice *self,
NMIP4Config *config, NMIP4Config *config,
gboolean commit, gboolean commit,
@@ -469,7 +469,7 @@ static gboolean nm_device_set_ip6_config (NMDevice *self,
NMIP6Config *config, NMIP6Config *config,
gboolean commit, gboolean commit,
gboolean routes_full_sync, gboolean routes_full_sync,
NMDeviceStateReason *reason); NMDeviceStateReason *out_reason);
static gboolean ip6_config_merge_and_apply (NMDevice *self, static gboolean ip6_config_merge_and_apply (NMDevice *self,
gboolean commit, gboolean commit,
NMDeviceStateReason *out_reason); NMDeviceStateReason *out_reason);
@@ -498,8 +498,8 @@ static gboolean queued_ip4_config_change (gpointer user_data);
static gboolean queued_ip6_config_change (gpointer user_data); static gboolean queued_ip6_config_change (gpointer user_data);
static void ip_check_ping_watch_cb (GPid pid, gint status, gpointer user_data); static void ip_check_ping_watch_cb (GPid pid, gint status, gpointer user_data);
static gboolean ip_config_valid (NMDeviceState state); static gboolean ip_config_valid (NMDeviceState state);
static NMActStageReturn dhcp4_start (NMDevice *self, NMConnection *connection, NMDeviceStateReason *reason); static NMActStageReturn dhcp4_start (NMDevice *self, NMConnection *connection);
static gboolean dhcp6_start (NMDevice *self, gboolean wait_for_ll, NMDeviceStateReason *reason); static gboolean dhcp6_start (NMDevice *self, gboolean wait_for_ll);
static void nm_device_start_ip_check (NMDevice *self); static void nm_device_start_ip_check (NMDevice *self);
static void realize_start_setup (NMDevice *self, const NMPlatformLink *plink); static void realize_start_setup (NMDevice *self, const NMPlatformLink *plink);
static void _commit_mtu (NMDevice *self, const NMIP4Config *config); static void _commit_mtu (NMDevice *self, const NMIP4Config *config);
@@ -4220,7 +4220,7 @@ lldp_rx_enabled (NMDevice *self)
} }
static NMActStageReturn static NMActStageReturn
act_stage1_prepare (NMDevice *self, NMDeviceStateReason *reason) act_stage1_prepare (NMDevice *self, NMDeviceStateReason *out_failure_reason)
{ {
return NM_ACT_STAGE_RETURN_SUCCESS; return NM_ACT_STAGE_RETURN_SUCCESS;
} }
@@ -4236,7 +4236,7 @@ activate_stage1_device_prepare (NMDevice *self)
{ {
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS; NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS;
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE; NMDeviceStateReason failure_reason = NM_DEVICE_STATE_REASON_NONE;
NMActiveConnection *active = NM_ACTIVE_CONNECTION (priv->act_request); NMActiveConnection *active = NM_ACTIVE_CONNECTION (priv->act_request);
_set_ip_state (self, AF_INET, IP_NONE); _set_ip_state (self, AF_INET, IP_NONE);
@@ -4250,14 +4250,14 @@ activate_stage1_device_prepare (NMDevice *self)
/* Assumed connections were already set up outside NetworkManager */ /* Assumed connections were already set up outside NetworkManager */
if (!nm_active_connection_get_assumed (active)) { if (!nm_active_connection_get_assumed (active)) {
ret = NM_DEVICE_GET_CLASS (self)->act_stage1_prepare (self, &reason); ret = NM_DEVICE_GET_CLASS (self)->act_stage1_prepare (self, &failure_reason);
if (ret == NM_ACT_STAGE_RETURN_POSTPONE) { if (ret == NM_ACT_STAGE_RETURN_POSTPONE) {
return; return;
} else if (ret == NM_ACT_STAGE_RETURN_FAILURE) { } else if (ret == NM_ACT_STAGE_RETURN_FAILURE) {
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason); nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, failure_reason);
return; return;
} }
g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS); g_return_if_fail (ret == NM_ACT_STAGE_RETURN_SUCCESS);
} }
nm_device_activate_schedule_stage2_device_config (self); nm_device_activate_schedule_stage2_device_config (self);
@@ -4284,9 +4284,8 @@ nm_device_activate_schedule_stage1_device_prepare (NMDevice *self)
} }
static NMActStageReturn static NMActStageReturn
act_stage2_config (NMDevice *self, NMDeviceStateReason *reason) act_stage2_config (NMDevice *self, NMDeviceStateReason *out_failure_reason)
{ {
/* Nothing to do */
return NM_ACT_STAGE_RETURN_SUCCESS; return NM_ACT_STAGE_RETURN_SUCCESS;
} }
@@ -4302,7 +4301,6 @@ activate_stage2_device_config (NMDevice *self)
{ {
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
NMActStageReturn ret; NMActStageReturn ret;
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
gboolean no_firmware = FALSE; gboolean no_firmware = FALSE;
NMActiveConnection *active = NM_ACTIVE_CONNECTION (priv->act_request); NMActiveConnection *active = NM_ACTIVE_CONNECTION (priv->act_request);
GSList *iter; GSList *iter;
@@ -4311,6 +4309,8 @@ activate_stage2_device_config (NMDevice *self)
/* Assumed connections were already set up outside NetworkManager */ /* Assumed connections were already set up outside NetworkManager */
if (!nm_active_connection_get_assumed (active)) { if (!nm_active_connection_get_assumed (active)) {
NMDeviceStateReason failure_reason = NM_DEVICE_STATE_REASON_NONE;
if (!nm_device_bring_up (self, FALSE, &no_firmware)) { if (!nm_device_bring_up (self, FALSE, &no_firmware)) {
if (no_firmware) if (no_firmware)
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_FIRMWARE_MISSING); nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_FIRMWARE_MISSING);
@@ -4319,11 +4319,11 @@ activate_stage2_device_config (NMDevice *self)
return; return;
} }
ret = NM_DEVICE_GET_CLASS (self)->act_stage2_config (self, &reason); ret = NM_DEVICE_GET_CLASS (self)->act_stage2_config (self, &failure_reason);
if (ret == NM_ACT_STAGE_RETURN_POSTPONE) if (ret == NM_ACT_STAGE_RETURN_POSTPONE)
return; return;
else if (ret == NM_ACT_STAGE_RETURN_FAILURE) { else if (ret == NM_ACT_STAGE_RETURN_FAILURE) {
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason); nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, failure_reason);
return; return;
} }
g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS); g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS);
@@ -4828,7 +4828,7 @@ ipv4ll_timeout_cb (gpointer user_data)
} }
static NMActStageReturn static NMActStageReturn
ipv4ll_start (NMDevice *self, NMDeviceStateReason *reason) ipv4ll_start (NMDevice *self)
{ {
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
const struct ether_addr *addr; const struct ether_addr *addr;
@@ -4840,55 +4840,51 @@ ipv4ll_start (NMDevice *self, NMDeviceStateReason *reason)
r = sd_ipv4ll_new (&priv->ipv4ll); r = sd_ipv4ll_new (&priv->ipv4ll);
if (r < 0) { if (r < 0) {
_LOGE (LOGD_AUTOIP4, "IPv4LL: new() failed with error %d", r); _LOGE (LOGD_AUTOIP4, "IPv4LL: new() failed with error %d", r);
goto fail; return NM_ACT_STAGE_RETURN_FAILURE;
} }
r = sd_ipv4ll_attach_event (priv->ipv4ll, NULL, 0); r = sd_ipv4ll_attach_event (priv->ipv4ll, NULL, 0);
if (r < 0) { if (r < 0) {
_LOGE (LOGD_AUTOIP4, "IPv4LL: attach_event() failed with error %d", r); _LOGE (LOGD_AUTOIP4, "IPv4LL: attach_event() failed with error %d", r);
goto fail; return NM_ACT_STAGE_RETURN_FAILURE;
} }
ifindex = nm_device_get_ip_ifindex (self); ifindex = nm_device_get_ip_ifindex (self);
addr = nm_platform_link_get_address (NM_PLATFORM_GET, ifindex, &addr_len); addr = nm_platform_link_get_address (NM_PLATFORM_GET, ifindex, &addr_len);
if (!addr || addr_len != ETH_ALEN) { if (!addr || addr_len != ETH_ALEN) {
_LOGE (LOGD_AUTOIP4, "IPv4LL: can't retrieve hardware address"); _LOGE (LOGD_AUTOIP4, "IPv4LL: can't retrieve hardware address");
goto fail; return NM_ACT_STAGE_RETURN_FAILURE;
} }
r = sd_ipv4ll_set_mac (priv->ipv4ll, addr); r = sd_ipv4ll_set_mac (priv->ipv4ll, addr);
if (r < 0) { if (r < 0) {
_LOGE (LOGD_AUTOIP4, "IPv4LL: set_mac() failed with error %d", r); _LOGE (LOGD_AUTOIP4, "IPv4LL: set_mac() failed with error %d", r);
goto fail; return NM_ACT_STAGE_RETURN_FAILURE;
} }
r = sd_ipv4ll_set_ifindex (priv->ipv4ll, ifindex); r = sd_ipv4ll_set_ifindex (priv->ipv4ll, ifindex);
if (r < 0) { if (r < 0) {
_LOGE (LOGD_AUTOIP4, "IPv4LL: set_ifindex() failed with error %d", r); _LOGE (LOGD_AUTOIP4, "IPv4LL: set_ifindex() failed with error %d", r);
goto fail; return NM_ACT_STAGE_RETURN_FAILURE;
} }
r = sd_ipv4ll_set_callback (priv->ipv4ll, nm_device_handle_ipv4ll_event, self); r = sd_ipv4ll_set_callback (priv->ipv4ll, nm_device_handle_ipv4ll_event, self);
if (r < 0) { if (r < 0) {
_LOGE (LOGD_AUTOIP4, "IPv4LL: set_callback() failed with error %d", r); _LOGE (LOGD_AUTOIP4, "IPv4LL: set_callback() failed with error %d", r);
goto fail; return NM_ACT_STAGE_RETURN_FAILURE;
} }
r = sd_ipv4ll_start (priv->ipv4ll); r = sd_ipv4ll_start (priv->ipv4ll);
if (r < 0) { if (r < 0) {
_LOGE (LOGD_AUTOIP4, "IPv4LL: start() failed with error %d", r); _LOGE (LOGD_AUTOIP4, "IPv4LL: start() failed with error %d", r);
goto fail; return NM_ACT_STAGE_RETURN_FAILURE;
} }
_LOGI (LOGD_DEVICE | LOGD_AUTOIP4, "IPv4LL: started"); _LOGI (LOGD_DEVICE | LOGD_AUTOIP4, "IPv4LL: started");
/* Start a timeout to bound the address attempt */ /* Start a timeout to bound the address attempt */
priv->ipv4ll_timeout = g_timeout_add_seconds (20, ipv4ll_timeout_cb, self); priv->ipv4ll_timeout = g_timeout_add_seconds (20, ipv4ll_timeout_cb, self);
return NM_ACT_STAGE_RETURN_POSTPONE; return NM_ACT_STAGE_RETURN_POSTPONE;
fail:
*reason = NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED;
return NM_ACT_STAGE_RETURN_FAILURE;
} }
/*****************************************************************************/ /*****************************************************************************/
@@ -5215,11 +5211,9 @@ END_ADD_DEFAULT_ROUTE:
static gboolean static gboolean
dhcp4_lease_change (NMDevice *self, NMIP4Config *config) dhcp4_lease_change (NMDevice *self, NMIP4Config *config)
{ {
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE; g_return_val_if_fail (config, FALSE);
g_return_val_if_fail (config != NULL, FALSE); if (!ip4_config_merge_and_apply (self, config, TRUE, NULL)) {
if (!ip4_config_merge_and_apply (self, config, TRUE, &reason)) {
_LOGW (LOGD_DHCP4, "failed to update IPv4 config for DHCP change."); _LOGW (LOGD_DHCP4, "failed to update IPv4 config for DHCP change.");
return FALSE; return FALSE;
} }
@@ -5243,7 +5237,6 @@ dhcp4_restart_cb (gpointer user_data)
{ {
NMDevice *self = user_data; NMDevice *self = user_data;
NMDevicePrivate *priv; NMDevicePrivate *priv;
NMDeviceStateReason reason;
NMConnection *connection; NMConnection *connection;
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE); g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
@@ -5252,7 +5245,7 @@ dhcp4_restart_cb (gpointer user_data)
priv->dhcp4.restart_id = 0; priv->dhcp4.restart_id = 0;
connection = nm_device_get_applied_connection (self); connection = nm_device_get_applied_connection (self);
if (dhcp4_start (self, connection, &reason) == NM_ACT_STAGE_RETURN_FAILURE) if (dhcp4_start (self, connection) == NM_ACT_STAGE_RETURN_FAILURE)
dhcp_schedule_restart (self, AF_INET, NULL); dhcp_schedule_restart (self, AF_INET, NULL);
return FALSE; return FALSE;
@@ -5408,8 +5401,7 @@ dhcp4_get_timeout (NMDevice *self, NMSettingIP4Config *s_ip4)
static NMActStageReturn static NMActStageReturn
dhcp4_start (NMDevice *self, dhcp4_start (NMDevice *self,
NMConnection *connection, NMConnection *connection)
NMDeviceStateReason *reason)
{ {
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip4;
@@ -5448,10 +5440,8 @@ dhcp4_start (NMDevice *self,
if (tmp) if (tmp)
g_byte_array_free (tmp, TRUE); g_byte_array_free (tmp, TRUE);
if (!priv->dhcp4.client) { if (!priv->dhcp4.client)
*reason = NM_DEVICE_STATE_REASON_DHCP_START_FAILED;
return NM_ACT_STAGE_RETURN_FAILURE; return NM_ACT_STAGE_RETURN_FAILURE;
}
priv->dhcp4.state_sigid = g_signal_connect (priv->dhcp4.client, priv->dhcp4.state_sigid = g_signal_connect (priv->dhcp4.client,
NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED, NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED,
@@ -5468,8 +5458,6 @@ gboolean
nm_device_dhcp4_renew (NMDevice *self, gboolean release) nm_device_dhcp4_renew (NMDevice *self, gboolean release)
{ {
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
NMActStageReturn ret;
NMDeviceStateReason reason;
NMConnection *connection; NMConnection *connection;
g_return_val_if_fail (priv->dhcp4.client != NULL, FALSE); g_return_val_if_fail (priv->dhcp4.client != NULL, FALSE);
@@ -5480,12 +5468,10 @@ nm_device_dhcp4_renew (NMDevice *self, gboolean release)
dhcp4_cleanup (self, CLEANUP_TYPE_DECONFIGURE, release); dhcp4_cleanup (self, CLEANUP_TYPE_DECONFIGURE, release);
connection = nm_device_get_applied_connection (self); connection = nm_device_get_applied_connection (self);
g_assert (connection); g_return_val_if_fail (connection, FALSE);
/* Start DHCP again on the interface */ /* Start DHCP again on the interface */
ret = dhcp4_start (self, connection, &reason); return dhcp4_start (self, connection) != NM_ACT_STAGE_RETURN_FAILURE;
return (ret != NM_ACT_STAGE_RETURN_FAILURE);
} }
/*****************************************************************************/ /*****************************************************************************/
@@ -5534,17 +5520,15 @@ reserve_shared_ip (NMDevice *self, NMSettingIPConfig *s_ip4, NMPlatformIP4Addres
} }
static NMIP4Config * static NMIP4Config *
shared4_new_config (NMDevice *self, NMConnection *connection, NMDeviceStateReason *reason) shared4_new_config (NMDevice *self, NMConnection *connection)
{ {
NMIP4Config *config = NULL; NMIP4Config *config = NULL;
NMPlatformIP4Address address; NMPlatformIP4Address address;
g_return_val_if_fail (self != NULL, NULL); g_return_val_if_fail (self != NULL, NULL);
if (!reserve_shared_ip (self, nm_connection_get_setting_ip4_config (connection), &address)) { if (!reserve_shared_ip (self, nm_connection_get_setting_ip4_config (connection), &address))
*reason = NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE;
return NULL; return NULL;
}
config = nm_ip4_config_new (nm_device_get_ip_ifindex (self)); config = nm_ip4_config_new (nm_device_get_ip_ifindex (self));
address.addr_source = NM_IP_CONFIG_SOURCE_SHARED; address.addr_source = NM_IP_CONFIG_SOURCE_SHARED;
@@ -5661,7 +5645,7 @@ ip4_requires_slaves (NMConnection *connection)
static NMActStageReturn static NMActStageReturn
act_stage3_ip4_config_start (NMDevice *self, act_stage3_ip4_config_start (NMDevice *self,
NMIP4Config **out_config, NMIP4Config **out_config,
NMDeviceStateReason *reason) NMDeviceStateReason *out_failure_reason)
{ {
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
NMConnection *connection; NMConnection *connection;
@@ -5670,10 +5654,8 @@ act_stage3_ip4_config_start (NMDevice *self,
GSList *slaves; GSList *slaves;
gboolean ready_slaves; gboolean ready_slaves;
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
connection = nm_device_get_applied_connection (self); connection = nm_device_get_applied_connection (self);
g_assert (connection); g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
if ( connection_ip4_method_requires_carrier (connection, NULL) if ( connection_ip4_method_requires_carrier (connection, NULL)
&& priv->is_master && priv->is_master
@@ -5702,11 +5684,15 @@ act_stage3_ip4_config_start (NMDevice *self,
priv->dhcp4.num_tries_left = DHCP_NUM_TRIES_MAX; priv->dhcp4.num_tries_left = DHCP_NUM_TRIES_MAX;
/* Start IPv4 addressing based on the method requested */ /* Start IPv4 addressing based on the method requested */
if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0) if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0) {
ret = dhcp4_start (self, connection, reason); ret = dhcp4_start (self, connection);
else if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL) == 0) if (ret == NM_ACT_STAGE_RETURN_FAILURE)
ret = ipv4ll_start (self, reason); NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_DHCP_START_FAILED);
else if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) == 0) { } else if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL) == 0) {
ret = ipv4ll_start (self);
if (ret == NM_ACT_STAGE_RETURN_FAILURE)
NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED);
} else if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) == 0) {
NMIP4Config **configs, *config; NMIP4Config **configs, *config;
config = nm_ip4_config_new (nm_device_get_ip_ifindex (self)); config = nm_ip4_config_new (nm_device_get_ip_ifindex (self));
@@ -5720,12 +5706,14 @@ act_stage3_ip4_config_start (NMDevice *self,
ret = NM_ACT_STAGE_RETURN_POSTPONE; ret = NM_ACT_STAGE_RETURN_POSTPONE;
} else if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED) == 0) { } else if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED) == 0) {
if (out_config) { if (out_config) {
*out_config = shared4_new_config (self, connection, reason); *out_config = shared4_new_config (self, connection);
if (*out_config) { if (*out_config) {
priv->dnsmasq_manager = nm_dnsmasq_manager_new (nm_device_get_ip_iface (self)); priv->dnsmasq_manager = nm_dnsmasq_manager_new (nm_device_get_ip_iface (self));
ret = NM_ACT_STAGE_RETURN_SUCCESS; ret = NM_ACT_STAGE_RETURN_SUCCESS;
} else } else {
NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
ret = NM_ACT_STAGE_RETURN_FAILURE; ret = NM_ACT_STAGE_RETURN_FAILURE;
}
} else } else
g_return_val_if_reached (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) } else if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) == 0)
@@ -5980,7 +5968,6 @@ dhcp6_lease_change (NMDevice *self)
{ {
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
NMSettingsConnection *settings_connection; NMSettingsConnection *settings_connection;
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
if (priv->dhcp6.ip6_config == NULL) { if (priv->dhcp6.ip6_config == NULL) {
_LOGW (LOGD_DHCP6, "failed to get DHCPv6 config for rebind"); _LOGW (LOGD_DHCP6, "failed to get DHCPv6 config for rebind");
@@ -5993,7 +5980,7 @@ dhcp6_lease_change (NMDevice *self)
g_assert (settings_connection); g_assert (settings_connection);
/* Apply the updated config */ /* Apply the updated config */
if (!ip6_config_merge_and_apply (self, TRUE, &reason)) { if (!ip6_config_merge_and_apply (self, TRUE, NULL)) {
_LOGW (LOGD_DHCP6, "failed to update IPv6 config in response to DHCP event"); _LOGW (LOGD_DHCP6, "failed to update IPv6 config in response to DHCP event");
return FALSE; return FALSE;
} }
@@ -6014,14 +6001,13 @@ dhcp6_restart_cb (gpointer user_data)
{ {
NMDevice *self = user_data; NMDevice *self = user_data;
NMDevicePrivate *priv; NMDevicePrivate *priv;
NMDeviceStateReason reason;
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE); g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
priv = NM_DEVICE_GET_PRIVATE (self); priv = NM_DEVICE_GET_PRIVATE (self);
priv->dhcp6.restart_id = 0; priv->dhcp6.restart_id = 0;
if (!dhcp6_start (self, FALSE, &reason)) if (!dhcp6_start (self, FALSE))
dhcp_schedule_restart (self, AF_INET6, NULL); dhcp_schedule_restart (self, AF_INET6, NULL);
return FALSE; return FALSE;
@@ -6272,7 +6258,7 @@ dhcp6_start_with_link_ready (NMDevice *self, NMConnection *connection)
} }
static gboolean static gboolean
dhcp6_start (NMDevice *self, gboolean wait_for_ll, NMDeviceStateReason *reason) dhcp6_start (NMDevice *self, gboolean wait_for_ll)
{ {
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
NMConnection *connection; NMConnection *connection;
@@ -6306,10 +6292,8 @@ dhcp6_start (NMDevice *self, gboolean wait_for_ll, NMDeviceStateReason *reason)
g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS); g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS);
} }
if (!dhcp6_start_with_link_ready (self, connection)) { if (!dhcp6_start_with_link_ready (self, connection))
NM_SET_OUT (reason, NM_DEVICE_STATE_REASON_DHCP_START_FAILED);
return FALSE; return FALSE;
}
return TRUE; return TRUE;
} }
@@ -6327,7 +6311,7 @@ nm_device_dhcp6_renew (NMDevice *self, gboolean release)
dhcp6_cleanup (self, CLEANUP_TYPE_DECONFIGURE, release); dhcp6_cleanup (self, CLEANUP_TYPE_DECONFIGURE, release);
/* Start DHCP again on the interface */ /* Start DHCP again on the interface */
return dhcp6_start (self, FALSE, NULL); return dhcp6_start (self, FALSE);
} }
/*****************************************************************************/ /*****************************************************************************/
@@ -6894,14 +6878,13 @@ ndisc_config_changed (NMNDisc *ndisc, const NMNDiscData *rdata, guint changed_in
priv->dhcp6.mode = rdata->dhcp_level; priv->dhcp6.mode = rdata->dhcp_level;
if (priv->dhcp6.mode != NM_NDISC_DHCP_LEVEL_NONE) { if (priv->dhcp6.mode != NM_NDISC_DHCP_LEVEL_NONE) {
NMDeviceStateReason reason;
_LOGD (LOGD_DEVICE | LOGD_DHCP6, _LOGD (LOGD_DEVICE | LOGD_DHCP6,
"Activation: Stage 3 of 5 (IP Configure Start) starting DHCPv6" "Activation: Stage 3 of 5 (IP Configure Start) starting DHCPv6"
" as requested by IPv6 router..."); " as requested by IPv6 router...");
if (!dhcp6_start (self, FALSE, &reason)) { if (!dhcp6_start (self, FALSE)) {
if (priv->dhcp6.mode == NM_NDISC_DHCP_LEVEL_MANAGED) { if (priv->dhcp6.mode == NM_NDISC_DHCP_LEVEL_MANAGED) {
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason); nm_device_state_changed (self, NM_DEVICE_STATE_FAILED,
NM_DEVICE_STATE_REASON_DHCP_START_FAILED);
return; return;
} }
} }
@@ -7267,7 +7250,7 @@ ip6_requires_slaves (NMConnection *connection)
static NMActStageReturn static NMActStageReturn
act_stage3_ip6_config_start (NMDevice *self, act_stage3_ip6_config_start (NMDevice *self,
NMIP6Config **out_config, NMIP6Config **out_config,
NMDeviceStateReason *reason) NMDeviceStateReason *out_failure_reason)
{ {
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE; NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
@@ -7278,10 +7261,8 @@ act_stage3_ip6_config_start (NMDevice *self,
GSList *slaves; GSList *slaves;
gboolean ready_slaves; gboolean ready_slaves;
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
connection = nm_device_get_applied_connection (self); connection = nm_device_get_applied_connection (self);
g_assert (connection); g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
if ( connection_ip6_method_requires_carrier (connection, NULL) if ( connection_ip6_method_requires_carrier (connection, NULL)
&& priv->is_master && priv->is_master
@@ -7356,7 +7337,7 @@ act_stage3_ip6_config_start (NMDevice *self,
ret = linklocal6_start (self); ret = linklocal6_start (self);
} else if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) == 0) { } else if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) == 0) {
priv->dhcp6.mode = NM_NDISC_DHCP_LEVEL_MANAGED; priv->dhcp6.mode = NM_NDISC_DHCP_LEVEL_MANAGED;
if (!dhcp6_start (self, TRUE, reason)) { if (!dhcp6_start (self, TRUE)) {
/* IPv6 might be disabled; allow IPv4 to proceed */ /* IPv6 might be disabled; allow IPv4 to proceed */
ret = NM_ACT_STAGE_RETURN_IP_FAIL; ret = NM_ACT_STAGE_RETURN_IP_FAIL;
} else } else
@@ -7397,13 +7378,13 @@ nm_device_activate_stage3_ip4_start (NMDevice *self)
{ {
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
NMActStageReturn ret; NMActStageReturn ret;
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE; NMDeviceStateReason failure_reason = NM_DEVICE_STATE_REASON_NONE;
NMIP4Config *ip4_config = NULL; NMIP4Config *ip4_config = NULL;
g_assert (priv->ip4_state == IP_WAIT); g_assert (priv->ip4_state == IP_WAIT);
_set_ip_state (self, AF_INET, IP_CONF); _set_ip_state (self, AF_INET, IP_CONF);
ret = NM_DEVICE_GET_CLASS (self)->act_stage3_ip4_config_start (self, &ip4_config, &reason); ret = NM_DEVICE_GET_CLASS (self)->act_stage3_ip4_config_start (self, &ip4_config, &failure_reason);
if (ret == NM_ACT_STAGE_RETURN_SUCCESS) { if (ret == NM_ACT_STAGE_RETURN_SUCCESS) {
if (!ip4_config) if (!ip4_config)
ip4_config = nm_ip4_config_new (nm_device_get_ip_ifindex (self)); ip4_config = nm_ip4_config_new (nm_device_get_ip_ifindex (self));
@@ -7413,7 +7394,7 @@ nm_device_activate_stage3_ip4_start (NMDevice *self)
_set_ip_state (self, AF_INET, IP_DONE); _set_ip_state (self, AF_INET, IP_DONE);
check_ip_state (self, FALSE); check_ip_state (self, FALSE);
} else if (ret == NM_ACT_STAGE_RETURN_FAILURE) { } else if (ret == NM_ACT_STAGE_RETURN_FAILURE) {
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason); nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, failure_reason);
return FALSE; return FALSE;
} else if (ret == NM_ACT_STAGE_RETURN_IP_FAIL) { } else if (ret == NM_ACT_STAGE_RETURN_IP_FAIL) {
/* Activation not wanted */ /* Activation not wanted */
@@ -7438,13 +7419,13 @@ nm_device_activate_stage3_ip6_start (NMDevice *self)
{ {
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
NMActStageReturn ret; NMActStageReturn ret;
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE; NMDeviceStateReason failure_reason = NM_DEVICE_STATE_REASON_NONE;
NMIP6Config *ip6_config = NULL; NMIP6Config *ip6_config = NULL;
g_assert (priv->ip6_state == IP_WAIT); g_assert (priv->ip6_state == IP_WAIT);
_set_ip_state (self, AF_INET6, IP_CONF); _set_ip_state (self, AF_INET6, IP_CONF);
ret = NM_DEVICE_GET_CLASS (self)->act_stage3_ip6_config_start (self, &ip6_config, &reason); ret = NM_DEVICE_GET_CLASS (self)->act_stage3_ip6_config_start (self, &ip6_config, &failure_reason);
if (ret == NM_ACT_STAGE_RETURN_SUCCESS) { if (ret == NM_ACT_STAGE_RETURN_SUCCESS) {
if (!ip6_config) if (!ip6_config)
ip6_config = nm_ip6_config_new (nm_device_get_ip_ifindex (self)); ip6_config = nm_ip6_config_new (nm_device_get_ip_ifindex (self));
@@ -7458,7 +7439,7 @@ nm_device_activate_stage3_ip6_start (NMDevice *self)
_set_ip_state (self, AF_INET6, IP_DONE); _set_ip_state (self, AF_INET6, IP_DONE);
check_ip_state (self, FALSE); check_ip_state (self, FALSE);
} else if (ret == NM_ACT_STAGE_RETURN_FAILURE) { } else if (ret == NM_ACT_STAGE_RETURN_FAILURE) {
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason); nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, failure_reason);
return FALSE; return FALSE;
} else if (ret == NM_ACT_STAGE_RETURN_IP_FAIL) { } else if (ret == NM_ACT_STAGE_RETURN_IP_FAIL) {
/* Activation not wanted */ /* Activation not wanted */
@@ -7632,10 +7613,10 @@ nm_device_activate_schedule_stage3_ip_config_start (NMDevice *self)
} }
static NMActStageReturn static NMActStageReturn
act_stage4_ip4_config_timeout (NMDevice *self, NMDeviceStateReason *reason) act_stage4_ip4_config_timeout (NMDevice *self, NMDeviceStateReason *out_failure_reason)
{ {
if (!get_ip_config_may_fail (self, AF_INET)) { if (!get_ip_config_may_fail (self, AF_INET)) {
*reason = NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE; NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
return NM_ACT_STAGE_RETURN_FAILURE; return NM_ACT_STAGE_RETURN_FAILURE;
} }
return NM_ACT_STAGE_RETURN_SUCCESS; return NM_ACT_STAGE_RETURN_SUCCESS;
@@ -7651,13 +7632,13 @@ static void
activate_stage4_ip4_config_timeout (NMDevice *self) activate_stage4_ip4_config_timeout (NMDevice *self)
{ {
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE; NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE; NMDeviceStateReason failure_reason = NM_DEVICE_STATE_REASON_NONE;
ret = NM_DEVICE_GET_CLASS (self)->act_stage4_ip4_config_timeout (self, &reason); ret = NM_DEVICE_GET_CLASS (self)->act_stage4_ip4_config_timeout (self, &failure_reason);
if (ret == NM_ACT_STAGE_RETURN_POSTPONE) if (ret == NM_ACT_STAGE_RETURN_POSTPONE)
return; return;
else if (ret == NM_ACT_STAGE_RETURN_FAILURE) { else if (ret == NM_ACT_STAGE_RETURN_FAILURE) {
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason); nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, failure_reason);
return; return;
} }
g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS); g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS);
@@ -7687,10 +7668,10 @@ nm_device_activate_schedule_ip4_config_timeout (NMDevice *self)
} }
static NMActStageReturn static NMActStageReturn
act_stage4_ip6_config_timeout (NMDevice *self, NMDeviceStateReason *reason) act_stage4_ip6_config_timeout (NMDevice *self, NMDeviceStateReason *out_failure_reason)
{ {
if (!get_ip_config_may_fail (self, AF_INET6)) { if (!get_ip_config_may_fail (self, AF_INET6)) {
*reason = NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE; NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
return NM_ACT_STAGE_RETURN_FAILURE; return NM_ACT_STAGE_RETURN_FAILURE;
} }
@@ -7707,13 +7688,13 @@ static void
activate_stage4_ip6_config_timeout (NMDevice *self) activate_stage4_ip6_config_timeout (NMDevice *self)
{ {
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE; NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE; NMDeviceStateReason failure_reason = NM_DEVICE_STATE_REASON_NONE;
ret = NM_DEVICE_GET_CLASS (self)->act_stage4_ip6_config_timeout (self, &reason); ret = NM_DEVICE_GET_CLASS (self)->act_stage4_ip6_config_timeout (self, &failure_reason);
if (ret == NM_ACT_STAGE_RETURN_POSTPONE) if (ret == NM_ACT_STAGE_RETURN_POSTPONE)
return; return;
if (ret == NM_ACT_STAGE_RETURN_FAILURE) { if (ret == NM_ACT_STAGE_RETURN_FAILURE) {
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason); nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, failure_reason);
return; return;
} }
g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS); g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS);
@@ -9201,7 +9182,7 @@ nm_device_set_ip4_config (NMDevice *self,
guint32 default_route_metric, guint32 default_route_metric,
gboolean commit, gboolean commit,
gboolean routes_full_sync, gboolean routes_full_sync,
NMDeviceStateReason *reason) NMDeviceStateReason *out_reason)
{ {
NMDevicePrivate *priv; NMDevicePrivate *priv;
NMIP4Config *old_config = NULL; NMIP4Config *old_config = NULL;
@@ -9297,9 +9278,7 @@ nm_device_set_ip4_config (NMDevice *self,
nm_device_queue_recheck_assume (self); nm_device_queue_recheck_assume (self);
} }
if (reason) NM_SET_OUT (out_reason, reason_local);
*reason = reason_local;
return success; return success;
} }
@@ -9371,7 +9350,7 @@ nm_device_set_ip6_config (NMDevice *self,
NMIP6Config *new_config, NMIP6Config *new_config,
gboolean commit, gboolean commit,
gboolean routes_full_sync, gboolean routes_full_sync,
NMDeviceStateReason *reason) NMDeviceStateReason *out_reason)
{ {
NMDevicePrivate *priv; NMDevicePrivate *priv;
NMIP6Config *old_config = NULL; NMIP6Config *old_config = NULL;
@@ -9461,9 +9440,7 @@ nm_device_set_ip6_config (NMDevice *self,
ndisc_set_router_config (priv->ndisc, self); ndisc_set_router_config (priv->ndisc, self);
} }
if (reason) NM_SET_OUT (out_reason, reason_local);
*reason = reason_local;
return success; return success;
} }

View File

@@ -283,19 +283,19 @@ typedef struct {
GError **error); GError **error);
NMActStageReturn (* act_stage1_prepare) (NMDevice *self, NMActStageReturn (* act_stage1_prepare) (NMDevice *self,
NMDeviceStateReason *reason); NMDeviceStateReason *out_failure_reason);
NMActStageReturn (* act_stage2_config) (NMDevice *self, NMActStageReturn (* act_stage2_config) (NMDevice *self,
NMDeviceStateReason *reason); NMDeviceStateReason *out_failure_reason);
NMActStageReturn (* act_stage3_ip4_config_start) (NMDevice *self, NMActStageReturn (* act_stage3_ip4_config_start) (NMDevice *self,
NMIP4Config **out_config, NMIP4Config **out_config,
NMDeviceStateReason *reason); NMDeviceStateReason *out_failure_reason);
NMActStageReturn (* act_stage3_ip6_config_start) (NMDevice *self, NMActStageReturn (* act_stage3_ip6_config_start) (NMDevice *self,
NMIP6Config **out_config, NMIP6Config **out_config,
NMDeviceStateReason *reason); NMDeviceStateReason *out_failure_reason);
NMActStageReturn (* act_stage4_ip4_config_timeout) (NMDevice *self, NMActStageReturn (* act_stage4_ip4_config_timeout) (NMDevice *self,
NMDeviceStateReason *reason); NMDeviceStateReason *out_failure_reason);
NMActStageReturn (* act_stage4_ip6_config_timeout) (NMDevice *self, NMActStageReturn (* act_stage4_ip6_config_timeout) (NMDevice *self,
NMDeviceStateReason *reason); NMDeviceStateReason *out_failure_reason);
void (* ip4_config_pre_commit) (NMDevice *self, NMIP4Config *config); void (* ip4_config_pre_commit) (NMDevice *self, NMIP4Config *config);

View File

@@ -580,7 +580,7 @@ teamd_start (NMDevice *device, NMSettingTeam *s_team)
} }
static NMActStageReturn static NMActStageReturn
act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
{ {
NMDeviceTeam *self = NM_DEVICE_TEAM (device); NMDeviceTeam *self = NM_DEVICE_TEAM (device);
NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (self); NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (self);
@@ -589,14 +589,12 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
NMSettingTeam *s_team; NMSettingTeam *s_team;
const char *cfg; const char *cfg;
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE); ret = NM_DEVICE_CLASS (nm_device_team_parent_class)->act_stage1_prepare (device, out_failure_reason);
ret = NM_DEVICE_CLASS (nm_device_team_parent_class)->act_stage1_prepare (device, reason);
if (ret != NM_ACT_STAGE_RETURN_SUCCESS) if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
return ret; return ret;
s_team = (NMSettingTeam *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_TEAM); s_team = (NMSettingTeam *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_TEAM);
g_assert (s_team); g_return_val_if_fail (s_team, NM_ACT_STAGE_RETURN_FAILURE);
if (priv->tdc) { if (priv->tdc) {
/* If the existing teamd config is the same as we're about to use, /* If the existing teamd config is the same as we're about to use,
@@ -614,7 +612,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
_LOGD (LOGD_TEAM, "existing teamd config mismatch; killing existing via teamdctl"); _LOGD (LOGD_TEAM, "existing teamd config mismatch; killing existing via teamdctl");
if (!teamd_kill (self, NULL, &error)) { if (!teamd_kill (self, NULL, &error)) {
_LOGW (LOGD_TEAM, "existing teamd config mismatch; failed to kill existing teamd: %s", error->message); _LOGW (LOGD_TEAM, "existing teamd config mismatch; failed to kill existing teamd: %s", error->message);
*reason = NM_DEVICE_STATE_REASON_TEAMD_CONTROL_FAILED; NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_TEAMD_CONTROL_FAILED);
return NM_ACT_STAGE_RETURN_FAILURE; return NM_ACT_STAGE_RETURN_FAILURE;
} }
} }

View File

@@ -163,14 +163,14 @@ complete_connection (NMDevice *device,
/*****************************************************************************/ /*****************************************************************************/
static NMActStageReturn static NMActStageReturn
act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
{ {
NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (device); NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (device);
NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (self); NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (self);
NMActStageReturn ret; NMActStageReturn ret;
gboolean scanning; gboolean scanning;
ret = NM_DEVICE_CLASS (nm_device_olpc_mesh_parent_class)->act_stage1_prepare (device, reason); ret = NM_DEVICE_CLASS (nm_device_olpc_mesh_parent_class)->act_stage1_prepare (device, out_failure_reason);
if (ret != NM_ACT_STAGE_RETURN_SUCCESS) if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
return ret; return ret;
@@ -209,7 +209,7 @@ _mesh_set_channel (NMDeviceOlpcMesh *self, guint32 channel)
} }
static NMActStageReturn static NMActStageReturn
act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
{ {
NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (device); NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (device);
NMConnection *connection; NMConnection *connection;
@@ -219,10 +219,10 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
const char *anycast_addr; const char *anycast_addr;
connection = nm_device_get_applied_connection (device); connection = nm_device_get_applied_connection (device);
g_assert (connection); g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
s_mesh = nm_connection_get_setting_olpc_mesh (connection); s_mesh = nm_connection_get_setting_olpc_mesh (connection);
g_assert (s_mesh); g_return_val_if_fail (s_mesh, NM_ACT_STAGE_RETURN_FAILURE);
channel = nm_setting_olpc_mesh_get_channel (s_mesh); channel = nm_setting_olpc_mesh_get_channel (s_mesh);
if (channel != 0) if (channel != 0)

View File

@@ -2218,7 +2218,7 @@ supplicant_iface_notify_current_bss (NMSupplicantInterface *iface,
} }
} }
static NMActStageReturn static gboolean
handle_auth_or_fail (NMDeviceWifi *self, handle_auth_or_fail (NMDeviceWifi *self,
NMActRequest *req, NMActRequest *req,
gboolean new_secrets) gboolean new_secrets)
@@ -2226,35 +2226,34 @@ handle_auth_or_fail (NMDeviceWifi *self,
const char *setting_name; const char *setting_name;
guint32 tries; guint32 tries;
NMConnection *applied_connection; NMConnection *applied_connection;
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
g_return_val_if_fail (NM_IS_DEVICE_WIFI (self), NM_ACT_STAGE_RETURN_FAILURE); g_return_val_if_fail (NM_IS_DEVICE_WIFI (self), FALSE);
if (!req) { if (!req) {
req = nm_device_get_act_request (NM_DEVICE (self)); req = nm_device_get_act_request (NM_DEVICE (self));
g_return_val_if_fail (req, NM_ACT_STAGE_RETURN_FAILURE); g_return_val_if_fail (req, FALSE);
} }
applied_connection = nm_act_request_get_applied_connection (req); applied_connection = nm_act_request_get_applied_connection (req);
tries = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (applied_connection), wireless_secrets_tries_quark ())); tries = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (applied_connection), wireless_secrets_tries_quark ()));
if (tries > 3) if (tries > 3)
return NM_ACT_STAGE_RETURN_FAILURE; return FALSE;
nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_NONE); nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_NONE);
nm_act_request_clear_secrets (req); nm_act_request_clear_secrets (req);
setting_name = nm_connection_need_secrets (applied_connection, NULL); setting_name = nm_connection_need_secrets (applied_connection, NULL);
if (setting_name) { if (!setting_name) {
wifi_secrets_get_secrets (self, setting_name,
NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION
| (new_secrets ? NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW : 0));
g_object_set_qdata (G_OBJECT (applied_connection), wireless_secrets_tries_quark (), GUINT_TO_POINTER (++tries));
ret = NM_ACT_STAGE_RETURN_POSTPONE;
} else
_LOGW (LOGD_DEVICE, "Cleared secrets, but setting didn't need any secrets."); _LOGW (LOGD_DEVICE, "Cleared secrets, but setting didn't need any secrets.");
return FALSE;
}
return ret; wifi_secrets_get_secrets (self, setting_name,
NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION
| (new_secrets ? NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW : 0));
g_object_set_qdata (G_OBJECT (applied_connection), wireless_secrets_tries_quark (), GUINT_TO_POINTER (++tries));
return TRUE;
} }
/* /*
@@ -2323,7 +2322,7 @@ supplicant_connection_timeout_cb (gpointer user_data)
if (nm_settings_connection_get_timestamp (nm_act_request_get_settings_connection (req), &timestamp)) if (nm_settings_connection_get_timestamp (nm_act_request_get_settings_connection (req), &timestamp))
new_secrets = !timestamp; new_secrets = !timestamp;
if (handle_auth_or_fail (self, req, new_secrets) == NM_ACT_STAGE_RETURN_POSTPONE) if (handle_auth_or_fail (self, req, new_secrets))
_LOGW (LOGD_DEVICE | LOGD_WIFI, "Activation: (wifi) asking for new secrets"); _LOGW (LOGD_DEVICE | LOGD_WIFI, "Activation: (wifi) asking for new secrets");
else { else {
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, nm_device_state_changed (device, NM_DEVICE_STATE_FAILED,
@@ -2407,7 +2406,7 @@ error:
/*****************************************************************************/ /*****************************************************************************/
static NMActStageReturn static NMActStageReturn
act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
{ {
NMDeviceWifi *self = NM_DEVICE_WIFI (device); NMDeviceWifi *self = NM_DEVICE_WIFI (device);
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
@@ -2419,18 +2418,18 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
const char *mode; const char *mode;
const char *ap_path; const char *ap_path;
ret = NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage1_prepare (device, reason); ret = NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage1_prepare (device, out_failure_reason);
if (ret != NM_ACT_STAGE_RETURN_SUCCESS) if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
return ret; return ret;
req = nm_device_get_act_request (NM_DEVICE (self)); req = nm_device_get_act_request (NM_DEVICE (self));
g_return_val_if_fail (req != NULL, NM_ACT_STAGE_RETURN_FAILURE); g_return_val_if_fail (req, NM_ACT_STAGE_RETURN_FAILURE);
connection = nm_act_request_get_applied_connection (req); connection = nm_act_request_get_applied_connection (req);
g_return_val_if_fail (connection != NULL, NM_ACT_STAGE_RETURN_FAILURE); g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
s_wireless = nm_connection_get_setting_wireless (connection); s_wireless = nm_connection_get_setting_wireless (connection);
g_assert (s_wireless); g_return_val_if_fail (s_wireless, NM_ACT_STAGE_RETURN_FAILURE);
mode = nm_setting_wireless_get_mode (s_wireless); mode = nm_setting_wireless_get_mode (s_wireless);
if (g_strcmp0 (mode, NM_SETTING_WIRELESS_MODE_INFRA) == 0) if (g_strcmp0 (mode, NM_SETTING_WIRELESS_MODE_INFRA) == 0)
@@ -2451,7 +2450,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
*/ */
if (is_adhoc_wpa (connection)) { if (is_adhoc_wpa (connection)) {
_LOGW (LOGD_WIFI, "Ad-Hoc WPA disabled due to kernel bugs"); _LOGW (LOGD_WIFI, "Ad-Hoc WPA disabled due to kernel bugs");
*reason = NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED; NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED);
return NM_ACT_STAGE_RETURN_FAILURE; return NM_ACT_STAGE_RETURN_FAILURE;
} }
@@ -2563,7 +2562,7 @@ set_powersave (NMDevice *device)
} }
static NMActStageReturn static NMActStageReturn
act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
{ {
NMDeviceWifi *self = NM_DEVICE_WIFI (device); NMDeviceWifi *self = NM_DEVICE_WIFI (device);
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
@@ -2577,17 +2576,15 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
GError *error = NULL; GError *error = NULL;
guint timeout; guint timeout;
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
nm_clear_g_source (&priv->sup_timeout_id); nm_clear_g_source (&priv->sup_timeout_id);
nm_clear_g_source (&priv->link_timeout_id); nm_clear_g_source (&priv->link_timeout_id);
req = nm_device_get_act_request (device); req = nm_device_get_act_request (device);
g_assert (req); g_return_val_if_fail (req, NM_ACT_STAGE_RETURN_FAILURE);
ap = priv->current_ap; ap = priv->current_ap;
if (!ap) { if (!ap) {
*reason = NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED; NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED);
goto out; goto out;
} }
@@ -2604,9 +2601,12 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
"Activation: (wifi) access point '%s' has security, but secrets are required.", "Activation: (wifi) access point '%s' has security, but secrets are required.",
nm_connection_get_id (connection)); nm_connection_get_id (connection));
ret = handle_auth_or_fail (self, req, FALSE); if (handle_auth_or_fail (self, req, FALSE))
if (ret == NM_ACT_STAGE_RETURN_FAILURE) ret = NM_ACT_STAGE_RETURN_POSTPONE;
*reason = NM_DEVICE_STATE_REASON_NO_SECRETS; else {
NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_NO_SECRETS);
ret = NM_ACT_STAGE_RETURN_FAILURE;
}
goto out; goto out;
} }
@@ -2640,7 +2640,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
"Activation: (wifi) couldn't build wireless configuration: %s", "Activation: (wifi) couldn't build wireless configuration: %s",
error->message); error->message);
g_clear_error (&error); g_clear_error (&error);
*reason = NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED; NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED);
goto out; goto out;
} }
@@ -2675,14 +2675,15 @@ out:
static NMActStageReturn static NMActStageReturn
act_stage3_ip4_config_start (NMDevice *device, act_stage3_ip4_config_start (NMDevice *device,
NMIP4Config **out_config, NMIP4Config **out_config,
NMDeviceStateReason *reason) NMDeviceStateReason *out_failure_reason)
{ {
NMConnection *connection; NMConnection *connection;
NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip4;
const char *method = NM_SETTING_IP4_CONFIG_METHOD_AUTO; const char *method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
connection = nm_device_get_applied_connection (device); connection = nm_device_get_applied_connection (device);
g_assert (connection); g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
s_ip4 = nm_connection_get_setting_ip4_config (connection); s_ip4 = nm_connection_get_setting_ip4_config (connection);
if (s_ip4) if (s_ip4)
method = nm_setting_ip_config_get_method (s_ip4); method = nm_setting_ip_config_get_method (s_ip4);
@@ -2691,20 +2692,21 @@ act_stage3_ip4_config_start (NMDevice *device,
if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0) if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0)
nm_platform_wifi_indicate_addressing_running (NM_PLATFORM_GET, nm_device_get_ifindex (device), TRUE); nm_platform_wifi_indicate_addressing_running (NM_PLATFORM_GET, nm_device_get_ifindex (device), TRUE);
return NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage3_ip4_config_start (device, out_config, reason); return NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage3_ip4_config_start (device, out_config, out_failure_reason);
} }
static NMActStageReturn static NMActStageReturn
act_stage3_ip6_config_start (NMDevice *device, act_stage3_ip6_config_start (NMDevice *device,
NMIP6Config **out_config, NMIP6Config **out_config,
NMDeviceStateReason *reason) NMDeviceStateReason *out_failure_reason)
{ {
NMConnection *connection; NMConnection *connection;
NMSettingIPConfig *s_ip6; NMSettingIPConfig *s_ip6;
const char *method = NM_SETTING_IP6_CONFIG_METHOD_AUTO; const char *method = NM_SETTING_IP6_CONFIG_METHOD_AUTO;
connection = nm_device_get_applied_connection (device); connection = nm_device_get_applied_connection (device);
g_assert (connection); g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
s_ip6 = nm_connection_get_setting_ip6_config (connection); s_ip6 = nm_connection_get_setting_ip6_config (connection);
if (s_ip6) if (s_ip6)
method = nm_setting_ip_config_get_method (s_ip6); method = nm_setting_ip_config_get_method (s_ip6);
@@ -2714,7 +2716,7 @@ act_stage3_ip6_config_start (NMDevice *device,
strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) == 0) strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) == 0)
nm_platform_wifi_indicate_addressing_running (NM_PLATFORM_GET, nm_device_get_ifindex (device), TRUE); nm_platform_wifi_indicate_addressing_running (NM_PLATFORM_GET, nm_device_get_ifindex (device), TRUE);
return NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage3_ip6_config_start (device, out_config, reason); return NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage3_ip6_config_start (device, out_config, out_failure_reason);
} }
static guint32 static guint32
@@ -2771,7 +2773,7 @@ handle_ip_config_timeout (NMDeviceWifi *self,
NMConnection *connection, NMConnection *connection,
gboolean may_fail, gboolean may_fail,
gboolean *chain_up, gboolean *chain_up,
NMDeviceStateReason *reason) NMDeviceStateReason *out_failure_reason)
{ {
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE; NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
@@ -2779,7 +2781,7 @@ handle_ip_config_timeout (NMDeviceWifi *self,
if (NM_DEVICE_WIFI_GET_PRIVATE (self)->mode == NM_802_11_MODE_AP) { if (NM_DEVICE_WIFI_GET_PRIVATE (self)->mode == NM_802_11_MODE_AP) {
*chain_up = TRUE; *chain_up = TRUE;
return ret; return NM_ACT_STAGE_RETURN_FAILURE;
} }
/* If IP configuration times out and it's a static WEP connection, that /* If IP configuration times out and it's a static WEP connection, that
@@ -2795,12 +2797,13 @@ handle_ip_config_timeout (NMDeviceWifi *self,
"Activation: (wifi) could not get IP configuration for connection '%s'.", "Activation: (wifi) could not get IP configuration for connection '%s'.",
nm_connection_get_id (connection)); nm_connection_get_id (connection));
ret = handle_auth_or_fail (self, NULL, TRUE); if (handle_auth_or_fail (self, NULL, TRUE)) {
if (ret == NM_ACT_STAGE_RETURN_POSTPONE) {
_LOGI (LOGD_DEVICE | LOGD_WIFI, _LOGI (LOGD_DEVICE | LOGD_WIFI,
"Activation: (wifi) asking for new secrets"); "Activation: (wifi) asking for new secrets");
ret = NM_ACT_STAGE_RETURN_POSTPONE;
} else { } else {
*reason = NM_DEVICE_STATE_REASON_NO_SECRETS; NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_NO_SECRETS);
ret = NM_ACT_STAGE_RETURN_FAILURE;
} }
} else { } else {
/* Not static WEP or failure allowed; let superclass handle it */ /* Not static WEP or failure allowed; let superclass handle it */
@@ -2812,7 +2815,7 @@ handle_ip_config_timeout (NMDeviceWifi *self,
static NMActStageReturn static NMActStageReturn
act_stage4_ip4_config_timeout (NMDevice *device, NMDeviceStateReason *reason) act_stage4_ip4_config_timeout (NMDevice *device, NMDeviceStateReason *out_failure_reason)
{ {
NMConnection *connection; NMConnection *connection;
NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip4;
@@ -2820,20 +2823,20 @@ act_stage4_ip4_config_timeout (NMDevice *device, NMDeviceStateReason *reason)
NMActStageReturn ret; NMActStageReturn ret;
connection = nm_device_get_applied_connection (device); connection = nm_device_get_applied_connection (device);
g_assert (connection); g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
s_ip4 = nm_connection_get_setting_ip4_config (connection); s_ip4 = nm_connection_get_setting_ip4_config (connection);
may_fail = nm_setting_ip_config_get_may_fail (s_ip4); may_fail = nm_setting_ip_config_get_may_fail (s_ip4);
ret = handle_ip_config_timeout (NM_DEVICE_WIFI (device), connection, may_fail, &chain_up, reason); ret = handle_ip_config_timeout (NM_DEVICE_WIFI (device), connection, may_fail, &chain_up, out_failure_reason);
if (chain_up) if (chain_up)
ret = NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage4_ip4_config_timeout (device, reason); ret = NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage4_ip4_config_timeout (device, out_failure_reason);
return ret; return ret;
} }
static NMActStageReturn static NMActStageReturn
act_stage4_ip6_config_timeout (NMDevice *device, NMDeviceStateReason *reason) act_stage4_ip6_config_timeout (NMDevice *device, NMDeviceStateReason *out_failure_reason)
{ {
NMConnection *connection; NMConnection *connection;
NMSettingIPConfig *s_ip6; NMSettingIPConfig *s_ip6;
@@ -2841,14 +2844,14 @@ act_stage4_ip6_config_timeout (NMDevice *device, NMDeviceStateReason *reason)
NMActStageReturn ret; NMActStageReturn ret;
connection = nm_device_get_applied_connection (device); connection = nm_device_get_applied_connection (device);
g_assert (connection); g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
s_ip6 = nm_connection_get_setting_ip6_config (connection); s_ip6 = nm_connection_get_setting_ip6_config (connection);
may_fail = nm_setting_ip_config_get_may_fail (s_ip6); may_fail = nm_setting_ip_config_get_may_fail (s_ip6);
ret = handle_ip_config_timeout (NM_DEVICE_WIFI (device), connection, may_fail, &chain_up, reason); ret = handle_ip_config_timeout (NM_DEVICE_WIFI (device), connection, may_fail, &chain_up, out_failure_reason);
if (chain_up) if (chain_up)
ret = NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage4_ip6_config_timeout (device, reason); ret = NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage4_ip6_config_timeout (device, out_failure_reason);
return ret; return ret;
} }

View File

@@ -201,7 +201,7 @@ modem_ip6_config_result (NMModem *modem,
NMDeviceModem *self = NM_DEVICE_MODEM (user_data); NMDeviceModem *self = NM_DEVICE_MODEM (user_data);
NMDevice *device = NM_DEVICE (self); NMDevice *device = NM_DEVICE (self);
NMActStageReturn ret; NMActStageReturn ret;
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE; NMDeviceStateReason failure_reason = NM_DEVICE_STATE_REASON_NONE;
NMIP6Config *ignored = NULL; NMIP6Config *ignored = NULL;
gboolean got_config = !!config; gboolean got_config = !!config;
@@ -235,11 +235,11 @@ modem_ip6_config_result (NMModem *modem,
} }
/* Start SLAAC now that we have a link-local address from the modem */ /* Start SLAAC now that we have a link-local address from the modem */
ret = NM_DEVICE_CLASS (nm_device_modem_parent_class)->act_stage3_ip6_config_start (device, &ignored, &reason); ret = NM_DEVICE_CLASS (nm_device_modem_parent_class)->act_stage3_ip6_config_start (device, &ignored, &failure_reason);
g_assert (ignored == NULL); g_assert (ignored == NULL);
switch (ret) { switch (ret) {
case NM_ACT_STAGE_RETURN_FAILURE: case NM_ACT_STAGE_RETURN_FAILURE:
nm_device_ip_method_failed (device, AF_INET6, reason); nm_device_ip_method_failed (device, AF_INET6, failure_reason);
break; break;
case NM_ACT_STAGE_RETURN_IP_FAIL: case NM_ACT_STAGE_RETURN_IP_FAIL:
/* all done */ /* all done */
@@ -509,41 +509,41 @@ deactivate_async (NMDevice *self,
/*****************************************************************************/ /*****************************************************************************/
static NMActStageReturn static NMActStageReturn
act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
{ {
NMActStageReturn ret; NMActStageReturn ret;
NMActRequest *req; NMActRequest *req;
ret = NM_DEVICE_CLASS (nm_device_modem_parent_class)->act_stage1_prepare (device, reason); ret = NM_DEVICE_CLASS (nm_device_modem_parent_class)->act_stage1_prepare (device, out_failure_reason);
if (ret != NM_ACT_STAGE_RETURN_SUCCESS) if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
return ret; return ret;
req = nm_device_get_act_request (device); req = nm_device_get_act_request (device);
g_assert (req); g_return_val_if_fail (req, NM_ACT_STAGE_RETURN_FAILURE);
return nm_modem_act_stage1_prepare (NM_DEVICE_MODEM_GET_PRIVATE ((NMDeviceModem *) device)->modem, req, reason); return nm_modem_act_stage1_prepare (NM_DEVICE_MODEM_GET_PRIVATE ((NMDeviceModem *) device)->modem, req, out_failure_reason);
} }
static NMActStageReturn static NMActStageReturn
act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
{ {
NMActRequest *req; NMActRequest *req;
req = nm_device_get_act_request (device); req = nm_device_get_act_request (device);
g_assert (req); g_return_val_if_fail (req, NM_ACT_STAGE_RETURN_FAILURE);
return nm_modem_act_stage2_config (NM_DEVICE_MODEM_GET_PRIVATE ((NMDeviceModem *) device)->modem, req, reason); return nm_modem_act_stage2_config (NM_DEVICE_MODEM_GET_PRIVATE ((NMDeviceModem *) device)->modem, req, out_failure_reason);
} }
static NMActStageReturn static NMActStageReturn
act_stage3_ip4_config_start (NMDevice *device, act_stage3_ip4_config_start (NMDevice *device,
NMIP4Config **out_config, NMIP4Config **out_config,
NMDeviceStateReason *reason) NMDeviceStateReason *out_failure_reason)
{ {
return nm_modem_stage3_ip4_config_start (NM_DEVICE_MODEM_GET_PRIVATE ((NMDeviceModem *) device)->modem, return nm_modem_stage3_ip4_config_start (NM_DEVICE_MODEM_GET_PRIVATE ((NMDeviceModem *) device)->modem,
device, device,
NM_DEVICE_CLASS (nm_device_modem_parent_class), NM_DEVICE_CLASS (nm_device_modem_parent_class),
reason); out_failure_reason);
} }
static void static void
@@ -555,11 +555,11 @@ ip4_config_pre_commit (NMDevice *device, NMIP4Config *config)
static NMActStageReturn static NMActStageReturn
act_stage3_ip6_config_start (NMDevice *device, act_stage3_ip6_config_start (NMDevice *device,
NMIP6Config **out_config, NMIP6Config **out_config,
NMDeviceStateReason *reason) NMDeviceStateReason *out_failure_reason)
{ {
return nm_modem_stage3_ip6_config_start (NM_DEVICE_MODEM_GET_PRIVATE ((NMDeviceModem *) device)->modem, return nm_modem_stage3_ip6_config_start (NM_DEVICE_MODEM_GET_PRIVATE ((NMDeviceModem *) device)->modem,
nm_device_get_act_request (device), nm_device_get_act_request (device),
reason); out_failure_reason);
} }
static gboolean static gboolean

View File

@@ -581,7 +581,7 @@ connect_context_step (NMModemBroadband *self)
static NMActStageReturn static NMActStageReturn
act_stage1_prepare (NMModem *_self, act_stage1_prepare (NMModem *_self,
NMConnection *connection, NMConnection *connection,
NMDeviceStateReason *reason) NMDeviceStateReason *out_failure_reason)
{ {
NMModemBroadband *self = NM_MODEM_BROADBAND (_self); NMModemBroadband *self = NM_MODEM_BROADBAND (_self);
@@ -590,7 +590,7 @@ act_stage1_prepare (NMModem *_self,
self->_priv.simple_iface = mm_object_get_modem_simple (self->_priv.modem_object); self->_priv.simple_iface = mm_object_get_modem_simple (self->_priv.modem_object);
if (!self->_priv.simple_iface) { if (!self->_priv.simple_iface) {
_LOGW ("cannot access the Simple mobile broadband modem interface"); _LOGW ("cannot access the Simple mobile broadband modem interface");
*reason = NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED; NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED);
return NM_ACT_STAGE_RETURN_FAILURE; return NM_ACT_STAGE_RETURN_FAILURE;
} }
} }
@@ -944,7 +944,7 @@ out:
static NMActStageReturn static NMActStageReturn
static_stage3_ip4_config_start (NMModem *_self, static_stage3_ip4_config_start (NMModem *_self,
NMActRequest *req, NMActRequest *req,
NMDeviceStateReason *reason) NMDeviceStateReason *out_failure_reason)
{ {
NMModemBroadband *self = NM_MODEM_BROADBAND (_self); NMModemBroadband *self = NM_MODEM_BROADBAND (_self);
@@ -1050,7 +1050,7 @@ out:
} }
static NMActStageReturn static NMActStageReturn
stage3_ip6_config_request (NMModem *_self, NMDeviceStateReason *reason) stage3_ip6_config_request (NMModem *_self, NMDeviceStateReason *out_failure_reason)
{ {
NMModemBroadband *self = NM_MODEM_BROADBAND (_self); NMModemBroadband *self = NM_MODEM_BROADBAND (_self);

View File

@@ -922,27 +922,27 @@ out:
static NMActStageReturn static NMActStageReturn
static_stage3_ip4_config_start (NMModem *modem, static_stage3_ip4_config_start (NMModem *modem,
NMActRequest *req, NMActRequest *req,
NMDeviceStateReason *reason) NMDeviceStateReason *out_failure_reason)
{ {
NMModemOfono *self = NM_MODEM_OFONO (modem); NMModemOfono *self = NM_MODEM_OFONO (modem);
NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE (self); NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE (self);
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
GError *error = NULL; GError *error = NULL;
if (priv->ip4_config) { if (!priv->ip4_config) {
_LOGD ("IP4 config is done; setting modem_state -> CONNECTED"); _LOGD ("IP4 config not ready(?)");
g_signal_emit_by_name (self, NM_MODEM_IP4_CONFIG_RESULT, priv->ip4_config, error); return NM_ACT_STAGE_RETURN_FAILURE;
/* Signal listener takes ownership of the IP4Config */
priv->ip4_config = NULL;
nm_modem_set_state (NM_MODEM (self),
NM_MODEM_STATE_CONNECTED,
nm_modem_state_to_string (NM_MODEM_STATE_CONNECTED));
ret = NM_ACT_STAGE_RETURN_POSTPONE;
} }
return ret; _LOGD ("IP4 config is done; setting modem_state -> CONNECTED");
g_signal_emit_by_name (self, NM_MODEM_IP4_CONFIG_RESULT, priv->ip4_config, error);
/* Signal listener takes ownership of the IP4Config */
priv->ip4_config = NULL;
nm_modem_set_state (NM_MODEM (self),
NM_MODEM_STATE_CONNECTED,
nm_modem_state_to_string (NM_MODEM_STATE_CONNECTED));
return NM_ACT_STAGE_RETURN_POSTPONE;
} }
static void static void
@@ -1038,7 +1038,7 @@ create_connect_properties (NMConnection *connection)
static NMActStageReturn static NMActStageReturn
act_stage1_prepare (NMModem *modem, act_stage1_prepare (NMModem *modem,
NMConnection *connection, NMConnection *connection,
NMDeviceStateReason *reason) NMDeviceStateReason *out_failure_reason)
{ {
NMModemOfono *self = NM_MODEM_OFONO (modem); NMModemOfono *self = NM_MODEM_OFONO (modem);
NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE (self); NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE (self);
@@ -1047,7 +1047,7 @@ act_stage1_prepare (NMModem *modem,
context_id = nm_connection_get_id (connection); context_id = nm_connection_get_id (connection);
id = g_strsplit (context_id, "/", 0); id = g_strsplit (context_id, "/", 0);
g_assert (id[2]); g_return_val_if_fail (id[2], NM_ACT_STAGE_RETURN_FAILURE);
_LOGD ("trying %s %s", id[1], id[2]); _LOGD ("trying %s %s", id[1], id[2]);
@@ -1058,8 +1058,8 @@ act_stage1_prepare (NMModem *modem,
g_strfreev (id); g_strfreev (id);
if (!priv->context_path) { if (!priv->context_path) {
*reason = NM_DEVICE_STATE_REASON_GSM_APN_FAILED; NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_GSM_APN_FAILED);
return NM_ACT_STAGE_RETURN_FAILURE; return NM_ACT_STAGE_RETURN_FAILURE;
} }
if (priv->connect_properties) if (priv->connect_properties)
@@ -1073,7 +1073,7 @@ act_stage1_prepare (NMModem *modem,
do_context_activate (self); do_context_activate (self);
} else { } else {
_LOGW ("could not activate context: modem is not registered."); _LOGW ("could not activate context: modem is not registered.");
*reason = NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER; NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER);
return NM_ACT_STAGE_RETURN_FAILURE; return NM_ACT_STAGE_RETURN_FAILURE;
} }

View File

@@ -514,18 +514,16 @@ port_speed_is_zero (const char *port)
static NMActStageReturn static NMActStageReturn
ppp_stage3_ip_config_start (NMModem *self, ppp_stage3_ip_config_start (NMModem *self,
NMActRequest *req, NMActRequest *req,
NMDeviceStateReason *reason) NMDeviceStateReason *out_failure_reason)
{ {
NMModemPrivate *priv = NM_MODEM_GET_PRIVATE (self); NMModemPrivate *priv = NM_MODEM_GET_PRIVATE (self);
const char *ppp_name = NULL; const char *ppp_name = NULL;
GError *error = NULL; GError *error = NULL;
NMActStageReturn ret;
guint ip_timeout = 30; guint ip_timeout = 30;
guint baud_override = 0; guint baud_override = 0;
g_return_val_if_fail (NM_IS_MODEM (self), NM_ACT_STAGE_RETURN_FAILURE); g_return_val_if_fail (NM_IS_MODEM (self), NM_ACT_STAGE_RETURN_FAILURE);
g_return_val_if_fail (NM_IS_ACT_REQUEST (req), NM_ACT_STAGE_RETURN_FAILURE); g_return_val_if_fail (NM_IS_ACT_REQUEST (req), NM_ACT_STAGE_RETURN_FAILURE);
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
/* If we're already running PPP don't restart it; for example, if both /* If we're already running PPP don't restart it; for example, if both
* IPv4 and IPv6 are requested, IPv4 gets started first, but we use the * IPv4 and IPv6 are requested, IPv4 gets started first, but we use the
@@ -560,24 +558,10 @@ ppp_stage3_ip_config_start (NMModem *self,
baud_override = 57600; baud_override = 57600;
priv->ppp_manager = nm_ppp_manager_create (priv->data_port, &error); priv->ppp_manager = nm_ppp_manager_create (priv->data_port, &error);
if ( priv->ppp_manager
&& nm_ppp_manager_start (priv->ppp_manager, req, ppp_name,
ip_timeout, baud_override, &error)) {
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_STATE_CHANGED,
G_CALLBACK (ppp_state_changed),
self);
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_IP4_CONFIG,
G_CALLBACK (ppp_ip4_config),
self);
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_IP6_CONFIG,
G_CALLBACK (ppp_ip6_config),
self);
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_STATS,
G_CALLBACK (ppp_stats),
self);
ret = NM_ACT_STAGE_RETURN_POSTPONE; if ( !priv->ppp_manager
} else { || !nm_ppp_manager_start (priv->ppp_manager, req, ppp_name,
ip_timeout, baud_override, &error)) {
nm_log_err (LOGD_PPP, "(%s): error starting PPP: %s", nm_log_err (LOGD_PPP, "(%s): error starting PPP: %s",
nm_modem_get_uid (self), nm_modem_get_uid (self),
error->message); error->message);
@@ -585,11 +569,24 @@ ppp_stage3_ip_config_start (NMModem *self,
g_clear_object (&priv->ppp_manager); g_clear_object (&priv->ppp_manager);
*reason = NM_DEVICE_STATE_REASON_PPP_START_FAILED; NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_PPP_START_FAILED);
ret = NM_ACT_STAGE_RETURN_FAILURE; return NM_ACT_STAGE_RETURN_FAILURE;
} }
return ret; g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_STATE_CHANGED,
G_CALLBACK (ppp_state_changed),
self);
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_IP4_CONFIG,
G_CALLBACK (ppp_ip4_config),
self);
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_IP6_CONFIG,
G_CALLBACK (ppp_ip6_config),
self);
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_STATS,
G_CALLBACK (ppp_stats),
self);
return NM_ACT_STAGE_RETURN_POSTPONE;
} }
/*****************************************************************************/ /*****************************************************************************/
@@ -598,7 +595,7 @@ NMActStageReturn
nm_modem_stage3_ip4_config_start (NMModem *self, nm_modem_stage3_ip4_config_start (NMModem *self,
NMDevice *device, NMDevice *device,
NMDeviceClass *device_class, NMDeviceClass *device_class,
NMDeviceStateReason *reason) NMDeviceStateReason *out_failure_reason)
{ {
NMModemPrivate *priv; NMModemPrivate *priv;
NMActRequest *req; NMActRequest *req;
@@ -611,12 +608,13 @@ nm_modem_stage3_ip4_config_start (NMModem *self,
g_return_val_if_fail (NM_IS_MODEM (self), NM_ACT_STAGE_RETURN_FAILURE); g_return_val_if_fail (NM_IS_MODEM (self), NM_ACT_STAGE_RETURN_FAILURE);
g_return_val_if_fail (NM_IS_DEVICE (device), NM_ACT_STAGE_RETURN_FAILURE); g_return_val_if_fail (NM_IS_DEVICE (device), NM_ACT_STAGE_RETURN_FAILURE);
g_return_val_if_fail (NM_IS_DEVICE_CLASS (device_class), NM_ACT_STAGE_RETURN_FAILURE); g_return_val_if_fail (NM_IS_DEVICE_CLASS (device_class), NM_ACT_STAGE_RETURN_FAILURE);
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
req = nm_device_get_act_request (device); req = nm_device_get_act_request (device);
g_assert (req); g_return_val_if_fail (req, NM_ACT_STAGE_RETURN_FAILURE);
connection = nm_act_request_get_applied_connection (req); connection = nm_act_request_get_applied_connection (req);
g_assert (connection); g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP4_CONFIG); method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP4_CONFIG);
/* Only Disabled and Auto methods make sense for WWAN */ /* Only Disabled and Auto methods make sense for WWAN */
@@ -627,22 +625,22 @@ nm_modem_stage3_ip4_config_start (NMModem *self,
nm_log_warn (LOGD_MB | LOGD_IP4, nm_log_warn (LOGD_MB | LOGD_IP4,
"(%s): unhandled WWAN IPv4 method '%s'; will fail", "(%s): unhandled WWAN IPv4 method '%s'; will fail",
nm_modem_get_uid (self), method); nm_modem_get_uid (self), method);
*reason = NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE; NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
return NM_ACT_STAGE_RETURN_FAILURE; return NM_ACT_STAGE_RETURN_FAILURE;
} }
priv = NM_MODEM_GET_PRIVATE (self); priv = NM_MODEM_GET_PRIVATE (self);
switch (priv->ip4_method) { switch (priv->ip4_method) {
case NM_MODEM_IP_METHOD_PPP: case NM_MODEM_IP_METHOD_PPP:
ret = ppp_stage3_ip_config_start (self, req, reason); ret = ppp_stage3_ip_config_start (self, req, out_failure_reason);
break; break;
case NM_MODEM_IP_METHOD_STATIC: case NM_MODEM_IP_METHOD_STATIC:
nm_log_dbg (LOGD_MB, "MODEM_IP_METHOD_STATIC"); nm_log_dbg (LOGD_MB, "MODEM_IP_METHOD_STATIC");
ret = NM_MODEM_GET_CLASS (self)->static_stage3_ip4_config_start (self, req, reason); ret = NM_MODEM_GET_CLASS (self)->static_stage3_ip4_config_start (self, req, out_failure_reason);
break; break;
case NM_MODEM_IP_METHOD_AUTO: case NM_MODEM_IP_METHOD_AUTO:
nm_log_dbg (LOGD_MB, "MODEM_IP_METHOD_AUTO"); nm_log_dbg (LOGD_MB, "MODEM_IP_METHOD_AUTO");
ret = device_class->act_stage3_ip4_config_start (device, NULL, reason); ret = device_class->act_stage3_ip4_config_start (device, NULL, out_failure_reason);
break; break;
default: default:
nm_log_info (LOGD_MB, "(%s): IPv4 configuration disabled", nm_modem_get_uid (self)); nm_log_info (LOGD_MB, "(%s): IPv4 configuration disabled", nm_modem_get_uid (self));
@@ -712,30 +710,28 @@ nm_modem_emit_ip6_config_result (NMModem *self,
} }
static NMActStageReturn static NMActStageReturn
stage3_ip6_config_request (NMModem *self, NMDeviceStateReason *reason) stage3_ip6_config_request (NMModem *self, NMDeviceStateReason *out_failure_reason)
{ {
*reason = NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE; NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
return NM_ACT_STAGE_RETURN_FAILURE; return NM_ACT_STAGE_RETURN_FAILURE;
} }
NMActStageReturn NMActStageReturn
nm_modem_stage3_ip6_config_start (NMModem *self, nm_modem_stage3_ip6_config_start (NMModem *self,
NMActRequest *req, NMActRequest *req,
NMDeviceStateReason *reason) NMDeviceStateReason *out_failure_reason)
{ {
NMModemPrivate *priv; NMModemPrivate *priv;
NMActStageReturn ret; NMActStageReturn ret;
NMConnection *connection; NMConnection *connection;
const char *method; const char *method;
g_return_val_if_fail (self != NULL, NM_ACT_STAGE_RETURN_FAILURE);
g_return_val_if_fail (NM_IS_MODEM (self), NM_ACT_STAGE_RETURN_FAILURE); g_return_val_if_fail (NM_IS_MODEM (self), NM_ACT_STAGE_RETURN_FAILURE);
g_return_val_if_fail (req != NULL, NM_ACT_STAGE_RETURN_FAILURE);
g_return_val_if_fail (NM_IS_ACT_REQUEST (req), NM_ACT_STAGE_RETURN_FAILURE); g_return_val_if_fail (NM_IS_ACT_REQUEST (req), NM_ACT_STAGE_RETURN_FAILURE);
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
connection = nm_act_request_get_applied_connection (req); connection = nm_act_request_get_applied_connection (req);
g_assert (connection); g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP6_CONFIG); method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP6_CONFIG);
/* Only Ignore and Auto methods make sense for WWAN */ /* Only Ignore and Auto methods make sense for WWAN */
@@ -746,14 +742,14 @@ nm_modem_stage3_ip6_config_start (NMModem *self,
nm_log_warn (LOGD_MB | LOGD_IP6, nm_log_warn (LOGD_MB | LOGD_IP6,
"(%s): unhandled WWAN IPv6 method '%s'; will fail", "(%s): unhandled WWAN IPv6 method '%s'; will fail",
nm_modem_get_uid (self), method); nm_modem_get_uid (self), method);
*reason = NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE; NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
return NM_ACT_STAGE_RETURN_FAILURE; return NM_ACT_STAGE_RETURN_FAILURE;
} }
priv = NM_MODEM_GET_PRIVATE (self); priv = NM_MODEM_GET_PRIVATE (self);
switch (priv->ip6_method) { switch (priv->ip6_method) {
case NM_MODEM_IP_METHOD_PPP: case NM_MODEM_IP_METHOD_PPP:
ret = ppp_stage3_ip_config_start (self, req, reason); ret = ppp_stage3_ip_config_start (self, req, out_failure_reason);
break; break;
case NM_MODEM_IP_METHOD_STATIC: case NM_MODEM_IP_METHOD_STATIC:
case NM_MODEM_IP_METHOD_AUTO: case NM_MODEM_IP_METHOD_AUTO:
@@ -761,7 +757,7 @@ nm_modem_stage3_ip6_config_start (NMModem *self,
* which in the static case is the full config, and the DHCP/Auto case * which in the static case is the full config, and the DHCP/Auto case
* is just the IPv6LL address to use for SLAAC. * is just the IPv6LL address to use for SLAAC.
*/ */
ret = NM_MODEM_GET_CLASS (self)->stage3_ip6_config_request (self, reason); ret = NM_MODEM_GET_CLASS (self)->stage3_ip6_config_request (self, out_failure_reason);
break; break;
default: default:
nm_log_info (LOGD_MB, "(%s): IPv6 configuration disabled", nm_modem_get_uid (self)); nm_log_info (LOGD_MB, "(%s): IPv6 configuration disabled", nm_modem_get_uid (self));
@@ -874,16 +870,16 @@ nm_modem_get_secrets (NMModem *self,
static NMActStageReturn static NMActStageReturn
act_stage1_prepare (NMModem *modem, act_stage1_prepare (NMModem *modem,
NMConnection *connection, NMConnection *connection,
NMDeviceStateReason *reason) NMDeviceStateReason *out_failure_reason)
{ {
*reason = NM_DEVICE_STATE_REASON_UNKNOWN; NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_UNKNOWN);
return NM_ACT_STAGE_RETURN_FAILURE; return NM_ACT_STAGE_RETURN_FAILURE;
} }
NMActStageReturn NMActStageReturn
nm_modem_act_stage1_prepare (NMModem *self, nm_modem_act_stage1_prepare (NMModem *self,
NMActRequest *req, NMActRequest *req,
NMDeviceStateReason *reason) NMDeviceStateReason *out_failure_reason)
{ {
NMModemPrivate *priv = NM_MODEM_GET_PRIVATE (self); NMModemPrivate *priv = NM_MODEM_GET_PRIVATE (self);
gs_unref_ptrarray GPtrArray *hints = NULL; gs_unref_ptrarray GPtrArray *hints = NULL;
@@ -896,13 +892,13 @@ nm_modem_act_stage1_prepare (NMModem *self,
priv->act_request = g_object_ref (req); priv->act_request = g_object_ref (req);
connection = nm_act_request_get_applied_connection (req); connection = nm_act_request_get_applied_connection (req);
g_assert (connection); g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
setting_name = nm_connection_need_secrets (connection, &hints); setting_name = nm_connection_need_secrets (connection, &hints);
if (!setting_name) { if (!setting_name) {
/* Ready to connect */ /* Ready to connect */
g_assert (!hints); g_assert (!hints);
return NM_MODEM_GET_CLASS (self)->act_stage1_prepare (self, connection, reason); return NM_MODEM_GET_CLASS (self)->act_stage1_prepare (self, connection, out_failure_reason);
} }
/* Secrets required... */ /* Secrets required... */
@@ -926,7 +922,7 @@ nm_modem_act_stage1_prepare (NMModem *self,
NMActStageReturn NMActStageReturn
nm_modem_act_stage2_config (NMModem *self, nm_modem_act_stage2_config (NMModem *self,
NMActRequest *req, NMActRequest *req,
NMDeviceStateReason *reason) NMDeviceStateReason *out_failure_reason)
{ {
NMModemPrivate *priv = NM_MODEM_GET_PRIVATE (self); NMModemPrivate *priv = NM_MODEM_GET_PRIVATE (self);

View File

@@ -132,17 +132,17 @@ typedef struct {
NMActStageReturn (*act_stage1_prepare) (NMModem *modem, NMActStageReturn (*act_stage1_prepare) (NMModem *modem,
NMConnection *connection, NMConnection *connection,
NMDeviceStateReason *reason); NMDeviceStateReason *out_failure_reason);
NMActStageReturn (*static_stage3_ip4_config_start) (NMModem *self, NMActStageReturn (*static_stage3_ip4_config_start) (NMModem *self,
NMActRequest *req, NMActRequest *req,
NMDeviceStateReason *reason); NMDeviceStateReason *out_failure_reason);
/* Request the IP6 config; when the config returns the modem /* Request the IP6 config; when the config returns the modem
* subclass should emit the ip6_config_result signal. * subclass should emit the ip6_config_result signal.
*/ */
NMActStageReturn (*stage3_ip6_config_request) (NMModem *self, NMActStageReturn (*stage3_ip6_config_request) (NMModem *self,
NMDeviceStateReason *reason); NMDeviceStateReason *out_failure_reason);
void (*set_mm_enabled) (NMModem *self, gboolean enabled); void (*set_mm_enabled) (NMModem *self, gboolean enabled);
@@ -187,20 +187,20 @@ gboolean nm_modem_complete_connection (NMModem *self,
NMActStageReturn nm_modem_act_stage1_prepare (NMModem *modem, NMActStageReturn nm_modem_act_stage1_prepare (NMModem *modem,
NMActRequest *req, NMActRequest *req,
NMDeviceStateReason *reason); NMDeviceStateReason *out_failure_reason);
NMActStageReturn nm_modem_act_stage2_config (NMModem *modem, NMActStageReturn nm_modem_act_stage2_config (NMModem *modem,
NMActRequest *req, NMActRequest *req,
NMDeviceStateReason *reason); NMDeviceStateReason *out_failure_reason);
NMActStageReturn nm_modem_stage3_ip4_config_start (NMModem *modem, NMActStageReturn nm_modem_stage3_ip4_config_start (NMModem *modem,
NMDevice *device, NMDevice *device,
NMDeviceClass *device_class, NMDeviceClass *device_class,
NMDeviceStateReason *reason); NMDeviceStateReason *out_failure_reason);
NMActStageReturn nm_modem_stage3_ip6_config_start (NMModem *modem, NMActStageReturn nm_modem_stage3_ip6_config_start (NMModem *modem,
NMActRequest *req, NMActRequest *req,
NMDeviceStateReason *reason); NMDeviceStateReason *out_failure_reason);
void nm_modem_ip4_pre_commit (NMModem *modem, NMDevice *device, NMIP4Config *config); void nm_modem_ip4_pre_commit (NMModem *modem, NMDevice *device, NMIP4Config *config);