Commit 437c12fc authored by Thomas Haller's avatar Thomas Haller
Browse files

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().
parent d5911fc5
......@@ -329,12 +329,12 @@ nas_update_cb (gpointer user_data)
static NMActStageReturn
br2684_create_iface (NMDeviceAdsl *self,
NMSettingAdsl *s_adsl,
NMDeviceStateReason *out_reason)
NMDeviceStateReason *out_failure_reason)
{
NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (self);
struct atm_newif_br2684 ni;
int err, fd, errsv;
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
nm_auto_close int fd = -1;
int err, errsv;
guint num = 0;
g_return_val_if_fail (s_adsl != NULL, FALSE);
......@@ -348,7 +348,7 @@ br2684_create_iface (NMDeviceAdsl *self,
if (fd < 0) {
errsv = errno;
_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;
}
......@@ -374,39 +374,36 @@ br2684_create_iface (NMDeviceAdsl *self,
priv->nas_update_count = 0;
priv->nas_update_id = g_timeout_add (100, nas_update_cb, self);
ret = NM_ACT_STAGE_RETURN_POSTPONE;
break;
} else if (errno != EEXIST) {
return NM_ACT_STAGE_RETURN_POSTPONE;
}
if (errno != EEXIST) {
errsv = errno;
_LOGW (LOGD_ADSL, "failed to create br2684 interface (%d)", errsv);
*out_reason = NM_DEVICE_STATE_REASON_BR2684_FAILED;
break;
}
}
close (fd);
return ret;
NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_BR2684_FAILED);
return NM_ACT_STAGE_RETURN_FAILURE;
}
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);
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
NMSettingAdsl *s_adsl;
const char *protocol;
g_assert (out_reason);
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);
_LOGD (LOGD_ADSL, "using ADSL protocol '%s'", protocol);
if (g_strcmp0 (protocol, NM_SETTING_ADSL_PROTOCOL_PPPOE) == 0) {
/* 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) {
/* PPPoA doesn't need anything special */
ret = NM_ACT_STAGE_RETURN_SUCCESS;
......@@ -451,20 +448,19 @@ ppp_ip4_config (NMPPPManager *ppp_manager,
static NMActStageReturn
act_stage3_ip4_config_start (NMDevice *device,
NMIP4Config **out_config,
NMDeviceStateReason *reason)
NMDeviceStateReason *out_failure_reason)
{
NMDeviceAdsl *self = NM_DEVICE_ADSL (device);
NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (self);
NMSettingAdsl *s_adsl;
NMActRequest *req;
GError *err = NULL;
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
const char *ppp_iface;
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);
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 */
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);
if ( priv->ppp_manager
&& nm_ppp_manager_start (priv->ppp_manager, req,
nm_setting_adsl_get_username (s_adsl),
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 {
if ( !priv->ppp_manager
|| !nm_ppp_manager_start (priv->ppp_manager, req,
nm_setting_adsl_get_username (s_adsl),
30, 0, &err)) {
_LOGW (LOGD_ADSL, "PPP failed to start: %s", err->message);
g_error_free (err);
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
......
......@@ -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);
NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE ((NMDeviceBt *) device);
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
if (error) {
nm_device_state_changed (device,
NM_DEVICE_STATE_FAILED,
NM_DEVICE_STATE_REASON_NO_SECRETS);
} else {
NMDeviceStateReason failure_reason = NM_DEVICE_STATE_REASON_NONE;
/* 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);
if (!modem_stage1 (NM_DEVICE_BT (device), priv->modem, &reason))
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, reason);
if (!modem_stage1 (NM_DEVICE_BT (device), priv->modem, &failure_reason))
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, failure_reason);
}
}
......@@ -460,12 +461,12 @@ modem_prepare_result (NMModem *modem,
if (success) {
NMActRequest *req;
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);
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) {
case NM_ACT_STAGE_RETURN_POSTPONE:
break;
......@@ -474,7 +475,7 @@ modem_prepare_result (NMModem *modem,
break;
case NM_ACT_STAGE_RETURN_FAILURE:
default:
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, stage2_reason);
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, failure_reason);
break;
}
} else {
......@@ -541,17 +542,15 @@ data_port_changed_cb (NMModem *modem, GParamSpec *pspec, gpointer user_data)
}
static gboolean
modem_stage1 (NMDeviceBt *self, NMModem *modem, NMDeviceStateReason *reason)
modem_stage1 (NMDeviceBt *self, NMModem *modem, NMDeviceStateReason *out_failure_reason)
{
NMActRequest *req;
NMActStageReturn ret;
g_return_val_if_fail (reason != NULL, FALSE);
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) {
case NM_ACT_STAGE_RETURN_POSTPONE:
case NM_ACT_STAGE_RETURN_SUCCESS:
......@@ -639,7 +638,7 @@ component_added (NMDevice *device, GObject *component)
const gchar *modem_control_port;
char *base;
NMDeviceState state;
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
NMDeviceStateReason failure_reason = NM_DEVICE_STATE_REASON_NONE;
if (!NM_IS_MODEM (component))
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);
/* Kick off the modem connection */
if (!modem_stage1 (self, modem, &reason))
nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_FAILED, reason);
if (!modem_stage1 (self, modem, &failure_reason))
nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_FAILED, failure_reason);
return TRUE;
}
......@@ -836,14 +835,15 @@ bt_connect_timeout (gpointer user_data)
}
static NMActStageReturn
act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
{
NMDeviceBt *self = NM_DEVICE_BT (device);
NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (self);
NMConnection *connection;
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);
if (priv->bt_type == NM_BT_CAPABILITY_NONE) {
// 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) {
*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;
}
......@@ -862,8 +862,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
priv->bt_type & (NM_BT_CAPABILITY_DUN | NM_BT_CAPABILITY_NAP),
bluez_connect_cb, g_object_ref (device));
if (priv->timeout_id)
g_source_remove (priv->timeout_id);
nm_clear_g_source (&priv->timeout_id);
priv->timeout_id = g_timeout_add_seconds (30, bt_connect_timeout, device);
return NM_ACT_STAGE_RETURN_POSTPONE;
......@@ -872,38 +871,34 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
static NMActStageReturn
act_stage3_ip4_config_start (NMDevice *device,
NMIP4Config **out_config,
NMDeviceStateReason *reason)
NMDeviceStateReason *out_failure_reason)
{
NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE ((NMDeviceBt *) device);
NMActStageReturn ret;
if (priv->bt_type == NM_BT_CAPABILITY_DUN) {
ret = nm_modem_stage3_ip4_config_start (priv->modem,
device,
NM_DEVICE_CLASS (nm_device_bt_parent_class),
reason);
} else
ret = NM_DEVICE_CLASS (nm_device_bt_parent_class)->act_stage3_ip4_config_start (device, out_config, reason);
return nm_modem_stage3_ip4_config_start (priv->modem,
device,
NM_DEVICE_CLASS (nm_device_bt_parent_class),
out_failure_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
act_stage3_ip6_config_start (NMDevice *device,
NMIP6Config **out_config,
NMDeviceStateReason *reason)
NMDeviceStateReason *out_failure_reason)
{
NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE ((NMDeviceBt *) device);
NMActStageReturn ret;
if (priv->bt_type == NM_BT_CAPABILITY_DUN) {
ret = nm_modem_stage3_ip6_config_start (priv->modem,
nm_device_get_act_request (device),
reason);
} else
ret = NM_DEVICE_CLASS (nm_device_bt_parent_class)->act_stage3_ip6_config_start (device, out_config, reason);
return nm_modem_stage3_ip6_config_start (priv->modem,
nm_device_get_act_request (device),
out_failure_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
......
......@@ -363,21 +363,19 @@ apply_bonding_config (NMDevice *device)
}
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;
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, reason);
ret = NM_DEVICE_CLASS (nm_device_bond_parent_class)->act_stage1_prepare (dev, out_failure_reason);
if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
return ret;
/* Interface must be down to set bond options */
nm_device_take_down (dev, TRUE);
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);
nm_device_bring_up (dev, TRUE, &no_firmware);
......
......@@ -305,14 +305,14 @@ master_update_slave_connection (NMDevice *device,
}
static NMActStageReturn
act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
{
NMActStageReturn ret;
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)
return ret;
......
......@@ -874,15 +874,13 @@ pppoe_reconnect_delay (gpointer user_data)
}
static NMActStageReturn
act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *out_failure_reason)
{
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (dev);
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
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, reason);
ret = NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->act_stage1_prepare (dev, out_failure_reason);
if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
return ret;
......@@ -916,7 +914,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
}
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);
NMConnection *connection;
......@@ -925,11 +923,12 @@ nm_8021x_stage2_config (NMDeviceEthernet *self, NMDeviceStateReason *reason)
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
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);
if (!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;
}
......@@ -947,7 +946,7 @@ nm_8021x_stage2_config (NMDeviceEthernet *self, NMDeviceStateReason *reason)
ret = handle_auth_or_fail (self, req, FALSE);
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 {
_LOGI (LOGD_DEVICE | LOGD_ETHER,
"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))
ret = NM_ACT_STAGE_RETURN_POSTPONE;
else
*reason = NM_DEVICE_STATE_REASON_CONFIG_FAILED;
NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_CONFIG_FAILED);
}
return ret;
......@@ -998,43 +997,42 @@ ppp_ip4_config (NMPPPManager *ppp_manager,
}
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);
NMSettingPppoe *s_pppoe;
NMActRequest *req;
GError *err = NULL;
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
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);
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)),
&err);
if ( priv->ppp_manager
&& nm_ppp_manager_start (priv->ppp_manager, req,
nm_setting_pppoe_get_username (s_pppoe),
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 {
if ( !priv->ppp_manager
|| !nm_ppp_manager_start (priv->ppp_manager, req,
nm_setting_pppoe_get_username (s_pppoe),
30, 0, &err)) {
_LOGW (LOGD_DEVICE, "PPPoE failed to start: %s", err->message);
g_error_free (err);
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
act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
{
NMDeviceEthernet *self = (NMDeviceEthernet *) device;
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;
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,
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_signal_handler (device, &priv->dcb_carrier_id);
......@@ -1278,7 +1274,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
NM_TYPE_SETTING_802_1X);
if (security) {
/* 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 */
if (nm_platform_link_is_connected (NM_PLATFORM_GET, nm_device_get_ifindex (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;
}
} else {
......@@ -1337,21 +1333,19 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
static NMActStageReturn
act_stage3_ip4_config_start (NMDevice *device,
NMIP4Config **out_config,
NMDeviceStateReason *reason)
NMDeviceStateReason *out_failure_reason)
{
NMSettingConnection *s_con;
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));
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);
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
......
......@@ -75,7 +75,7 @@ get_generic_capabilities (NMDevice *device)
}
static NMActStageReturn
act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *out_failure_reason)
{
nm_auto_close int dirfd = -1;
NMActStageReturn ret;
......@@ -84,14 +84,12 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
const char *transport_mode;
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, reason);
ret = NM_DEVICE_CLASS (nm_device_infiniband_parent_class)->act_stage1_prepare (dev, out_failure_reason);
if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
return ret;
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);
......@@ -100,7 +98,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
if (!strcmp (transport_mode, "datagram"))
return NM_ACT_STAGE_RETURN_SUCCESS;
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;
}
}
......@@ -111,7 +109,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
nm_device_bring_up (dev, TRUE, &no_firmware);
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;
}
......
......@@ -585,7 +585,7 @@ supplicant_interface_init (NMDeviceMacsec *self)
}
static NMActStageReturn
act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
{
NMDeviceMacsec *self = NM_DEVICE_MACSEC (device);
NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE (self);
......@@ -594,7 +594,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
const char *setting_name;
connection = nm_device_get_applied_connection (NM_DEVICE (self));
g_assert (connection);