device: various code cleanups in devices

Mostly just cleanups, there should be no significant change in behavior.
This commit is contained in:
Thomas Haller
2020-02-27 16:45:16 +01:00
parent 607a22b900
commit aa991916dc
12 changed files with 193 additions and 216 deletions

View File

@@ -228,7 +228,8 @@ link_changed_cb (NMPlatform *platform,
/* This only gets called for PPPoE connections and "nas" interfaces */ /* This only gets called for PPPoE connections and "nas" interfaces */
if (priv->nas_ifindex > 0 && ifindex == priv->nas_ifindex) { if ( priv->nas_ifindex > 0
&& ifindex == priv->nas_ifindex) {
/* NAS device went away for some reason; kill the connection */ /* NAS device went away for some reason; kill the connection */
_LOGD (LOGD_ADSL, "br2684 interface disappeared"); _LOGD (LOGD_ADSL, "br2684 interface disappeared");
nm_device_state_changed (device, nm_device_state_changed (device,
@@ -273,11 +274,17 @@ nas_update_cb (gpointer user_data)
NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (self); NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (self);
NMDevice *device = NM_DEVICE (self); NMDevice *device = NM_DEVICE (self);
g_assert (priv->nas_ifname); nm_assert (priv->nas_ifname);
priv->nas_update_count++; priv->nas_update_count++;
if (priv->nas_update_count > 10) { nm_assert (priv->nas_ifindex <= 0);
priv->nas_ifindex = nm_platform_link_get_ifindex (nm_device_get_platform (device), priv->nas_ifname);
if (priv->nas_ifindex <= 0) {
if (priv->nas_update_count <= 10) {
/* Keep waiting for it to appear */
return G_SOURCE_CONTINUE;
}
priv->nas_update_id = 0; priv->nas_update_id = 0;
_LOGW (LOGD_ADSL, "failed to find br2684 interface %s ifindex after timeout", priv->nas_ifname); _LOGW (LOGD_ADSL, "failed to find br2684 interface %s ifindex after timeout", priv->nas_ifname);
nm_device_state_changed (device, nm_device_state_changed (device,
@@ -286,31 +293,22 @@ nas_update_cb (gpointer user_data)
return G_SOURCE_REMOVE; return G_SOURCE_REMOVE;
} }
g_warn_if_fail (priv->nas_ifindex < 0);
priv->nas_ifindex = nm_platform_link_get_ifindex (nm_device_get_platform (device), priv->nas_ifname);
if (priv->nas_ifindex < 0) {
/* Keep waiting for it to appear */
return G_SOURCE_CONTINUE;
}
priv->nas_update_id = 0; priv->nas_update_id = 0;
_LOGD (LOGD_ADSL, "using br2684 iface '%s' index %d", priv->nas_ifname, priv->nas_ifindex); _LOGD (LOGD_ADSL, "using br2684 iface '%s' index %d", priv->nas_ifname, priv->nas_ifindex);
if (pppoe_vcc_config (self)) { if (!pppoe_vcc_config (self)) {
nm_device_activate_schedule_stage3_ip_config_start (device);
} else {
nm_device_state_changed (device, nm_device_state_changed (device,
NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_FAILED,
NM_DEVICE_STATE_REASON_BR2684_FAILED); NM_DEVICE_STATE_REASON_BR2684_FAILED);
return G_SOURCE_REMOVE;
} }
nm_device_activate_schedule_stage3_ip_config_start (device);
return G_SOURCE_REMOVE; return G_SOURCE_REMOVE;
} }
static NMActStageReturn static gboolean
br2684_create_iface (NMDeviceAdsl *self, br2684_create_iface (NMDeviceAdsl *self)
NMSettingAdsl *s_adsl,
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;
@@ -318,19 +316,14 @@ br2684_create_iface (NMDeviceAdsl *self,
int err, errsv; int err, errsv;
guint num = 0; guint num = 0;
g_return_val_if_fail (s_adsl != NULL, FALSE); if (nm_clear_g_source (&priv->nas_update_id))
nm_assert_not_reached ();
if (priv->nas_update_id) {
g_warn_if_fail (priv->nas_update_id == 0);
nm_clear_g_source (&priv->nas_update_id);
}
fd = socket (PF_ATMPVC, SOCK_DGRAM | SOCK_CLOEXEC, ATM_AAL5); fd = socket (PF_ATMPVC, SOCK_DGRAM | SOCK_CLOEXEC, ATM_AAL5);
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);
NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_BR2684_FAILED); return FALSE;
return NM_ACT_STAGE_RETURN_FAILURE;
} }
memset (&ni, 0, sizeof (ni)); memset (&ni, 0, sizeof (ni));
@@ -343,36 +336,32 @@ br2684_create_iface (NMDeviceAdsl *self,
* cannot return that name to us. Since we want to know the name right * cannot return that name to us. Since we want to know the name right
* away, just brute-force it. * away, just brute-force it.
*/ */
while (num < 10000) { while (TRUE) {
memset (&ni.ifname, 0, sizeof (ni.ifname)); memset (&ni.ifname, 0, sizeof (ni.ifname));
g_snprintf (ni.ifname, sizeof (ni.ifname), "nas%d", num++); g_snprintf (ni.ifname, sizeof (ni.ifname), "nas%u", num++);
err = ioctl (fd, ATM_NEWBACKENDIF, &ni); err = ioctl (fd, ATM_NEWBACKENDIF, &ni);
if (err == 0) { if (err != 0) {
g_free (priv->nas_ifname); errsv = errno;
priv->nas_ifname = g_strdup (ni.ifname); if (errsv == EEXIST)
_LOGD (LOGD_ADSL, "waiting for br2684 iface '%s' to appear", priv->nas_ifname); continue;
priv->nas_update_count = 0;
priv->nas_update_id = g_timeout_add (100, nas_update_cb, self);
return NM_ACT_STAGE_RETURN_POSTPONE;
}
errsv = errno;
if (errsv != EEXIST) {
_LOGW (LOGD_ADSL, "failed to create br2684 interface (%d)", errsv); _LOGW (LOGD_ADSL, "failed to create br2684 interface (%d)", errsv);
break; return FALSE;
} }
}
NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_BR2684_FAILED); nm_utils_strdup_reset (&priv->nas_ifname, ni.ifname);
return NM_ACT_STAGE_RETURN_FAILURE; _LOGD (LOGD_ADSL, "waiting for br2684 iface '%s' to appear", priv->nas_ifname);
priv->nas_update_count = 0;
priv->nas_update_id = g_timeout_add (100, nas_update_cb, self);
return TRUE;
}
} }
static NMActStageReturn static NMActStageReturn
act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_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;
NMSettingAdsl *s_adsl; NMSettingAdsl *s_adsl;
const char *protocol; const char *protocol;
@@ -383,16 +372,22 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
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 (nm_streq0 (protocol, NM_SETTING_ADSL_PROTOCOL_PPPOA)) {
/* PPPoE needs RFC2684 bridging before we can do PPP over it */
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 */ /* PPPoA doesn't need anything special */
ret = NM_ACT_STAGE_RETURN_SUCCESS; return NM_ACT_STAGE_RETURN_SUCCESS;
} else }
_LOGW (LOGD_ADSL, "unhandled ADSL protocol '%s'", protocol);
return ret; if (nm_streq0 (protocol, NM_SETTING_ADSL_PROTOCOL_PPPOE)) {
/* PPPoE needs RFC2684 bridging before we can do PPP over it */
if (!br2684_create_iface (self)) {
NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_BR2684_FAILED);
return NM_ACT_STAGE_RETURN_FAILURE;
}
return NM_ACT_STAGE_RETURN_POSTPONE;
}
_LOGW (LOGD_ADSL, "unhandled ADSL protocol '%s'", protocol);
return NM_ACT_STAGE_RETURN_SUCCESS;
} }
static void static void
@@ -460,8 +455,8 @@ act_stage3_ip4_config_start (NMDevice *device,
g_return_val_if_fail (s_adsl, NM_ACT_STAGE_RETURN_FAILURE); 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 (nm_streq0 (nm_setting_adsl_get_protocol (s_adsl), NM_SETTING_ADSL_PROTOCOL_PPPOE)) {
g_assert (priv->nas_ifname); nm_assert (priv->nas_ifname);
ppp_iface = priv->nas_ifname; ppp_iface = priv->nas_ifname;
_LOGD (LOGD_ADSL, "starting PPPoE on br2684 interface %s", priv->nas_ifname); _LOGD (LOGD_ADSL, "starting PPPoE on br2684 interface %s", priv->nas_ifname);
@@ -540,8 +535,8 @@ adsl_cleanup (NMDeviceAdsl *self)
* so it gets leaked. It does get destroyed when it's no longer in use, * so it gets leaked. It does get destroyed when it's no longer in use,
* but we have no control over that. * but we have no control over that.
*/ */
priv->nas_ifindex = -1; priv->nas_ifindex = 0;
g_clear_pointer (&priv->nas_ifname, g_free); nm_clear_g_free (&priv->nas_ifname);
} }
static void static void

View File

@@ -561,40 +561,38 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
NMDeviceBridge *self = NM_DEVICE_BRIDGE (device); NMDeviceBridge *self = NM_DEVICE_BRIDGE (device);
NMConnection *connection; NMConnection *connection;
NMSettingBluetooth *s_bt; NMSettingBluetooth *s_bt;
gs_free_error GError *error = NULL;
connection = nm_device_get_applied_connection (device); connection = nm_device_get_applied_connection (device);
s_bt = _nm_connection_get_setting_bluetooth_for_nap (connection); s_bt = _nm_connection_get_setting_bluetooth_for_nap (connection);
if (s_bt) { if (!s_bt)
gs_free_error GError *error = NULL; return NM_ACT_STAGE_RETURN_SUCCESS;
if (!nm_bt_vtable_network_server) { if (!nm_bt_vtable_network_server) {
_LOGD (LOGD_DEVICE, "bluetooth NAP server failed because bluetooth plugin not available"); _LOGD (LOGD_DEVICE, "bluetooth NAP server failed because bluetooth plugin not available");
*out_failure_reason = NM_DEVICE_STATE_REASON_BT_FAILED; *out_failure_reason = NM_DEVICE_STATE_REASON_BT_FAILED;
return NM_ACT_STAGE_RETURN_FAILURE; return NM_ACT_STAGE_RETURN_FAILURE;
}
if (self->bt_cancellable)
return NM_ACT_STAGE_RETURN_POSTPONE;
self->bt_cancellable = g_cancellable_new ();
if (!nm_bt_vtable_network_server->register_bridge (nm_bt_vtable_network_server,
nm_setting_bluetooth_get_bdaddr (s_bt),
device,
self->bt_cancellable,
_bt_register_bridge_cb,
device,
&error)) {
_LOGD (LOGD_DEVICE, "bluetooth NAP server failed to register bridge: %s", error->message);
*out_failure_reason = NM_DEVICE_STATE_REASON_BT_FAILED;
return NM_ACT_STAGE_RETURN_FAILURE;
}
self->bt_registered = TRUE;
return NM_ACT_STAGE_RETURN_POSTPONE;
} }
return NM_ACT_STAGE_RETURN_SUCCESS; if (self->bt_cancellable)
return NM_ACT_STAGE_RETURN_POSTPONE;
self->bt_cancellable = g_cancellable_new ();
if (!nm_bt_vtable_network_server->register_bridge (nm_bt_vtable_network_server,
nm_setting_bluetooth_get_bdaddr (s_bt),
device,
self->bt_cancellable,
_bt_register_bridge_cb,
device,
&error)) {
_LOGD (LOGD_DEVICE, "bluetooth NAP server failed to register bridge: %s", error->message);
*out_failure_reason = NM_DEVICE_STATE_REASON_BT_FAILED;
return NM_ACT_STAGE_RETURN_FAILURE;
}
self->bt_registered = TRUE;
return NM_ACT_STAGE_RETURN_POSTPONE;
} }
static void static void

View File

@@ -734,7 +734,7 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface,
supplicant_iface_state_is_completed (self, new_state); supplicant_iface_state_is_completed (self, new_state);
} }
static NMActStageReturn static gboolean
handle_auth_or_fail (NMDeviceEthernet *self, handle_auth_or_fail (NMDeviceEthernet *self,
NMActRequest *req, NMActRequest *req,
gboolean new_secrets) gboolean new_secrets)
@@ -743,7 +743,7 @@ handle_auth_or_fail (NMDeviceEthernet *self,
NMConnection *applied_connection; NMConnection *applied_connection;
if (!nm_device_auth_retries_try_next (NM_DEVICE (self))) if (!nm_device_auth_retries_try_next (NM_DEVICE (self)))
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);
@@ -753,7 +753,7 @@ handle_auth_or_fail (NMDeviceEthernet *self,
setting_name = nm_connection_need_secrets (applied_connection, NULL); setting_name = nm_connection_need_secrets (applied_connection, NULL);
if (!setting_name) { if (!setting_name) {
_LOGI (LOGD_DEVICE, "Cleared secrets, but setting didn't need any secrets."); _LOGI (LOGD_DEVICE, "Cleared secrets, but setting didn't need any secrets.");
return NM_ACT_STAGE_RETURN_FAILURE; return FALSE;
} }
_LOGI (LOGD_DEVICE | LOGD_ETHER, "Activation: (ethernet) asking for new secrets"); _LOGI (LOGD_DEVICE | LOGD_ETHER, "Activation: (ethernet) asking for new secrets");
@@ -768,7 +768,7 @@ handle_auth_or_fail (NMDeviceEthernet *self,
wired_secrets_get_secrets (self, setting_name, wired_secrets_get_secrets (self, setting_name,
NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION
| (new_secrets ? NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW : 0)); | (new_secrets ? NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW : 0));
return NM_ACT_STAGE_RETURN_POSTPONE; return TRUE;
} }
static gboolean static gboolean
@@ -800,7 +800,7 @@ supplicant_connection_timeout_cb (gpointer user_data)
if (nm_settings_connection_get_timestamp (connection, &timestamp)) if (nm_settings_connection_get_timestamp (connection, &timestamp))
new_secrets = !timestamp; new_secrets = !timestamp;
if (handle_auth_or_fail (self, req, new_secrets) == NM_ACT_STAGE_RETURN_FAILURE) { if (!handle_auth_or_fail (self, req, new_secrets)) {
wired_auth_cond_fail (self, NM_DEVICE_STATE_REASON_NO_SECRETS); wired_auth_cond_fail (self, NM_DEVICE_STATE_REASON_NO_SECRETS);
return G_SOURCE_REMOVE; return G_SOURCE_REMOVE;
} }
@@ -1003,7 +1003,6 @@ supplicant_check_secrets_needed (NMDeviceEthernet *self, NMDeviceStateReason *ou
NMConnection *connection; NMConnection *connection;
NMSetting8021x *security; NMSetting8021x *security;
const char *setting_name; const char *setting_name;
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_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE); g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
@@ -1012,7 +1011,7 @@ supplicant_check_secrets_needed (NMDeviceEthernet *self, NMDeviceStateReason *ou
if (!security) { if (!security) {
_LOGE (LOGD_DEVICE, "Invalid or missing 802.1X security"); _LOGE (LOGD_DEVICE, "Invalid or missing 802.1X security");
NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_CONFIG_FAILED); NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_CONFIG_FAILED);
return ret; return NM_ACT_STAGE_RETURN_FAILURE;
} }
if (!priv->supplicant.mgr) if (!priv->supplicant.mgr)
@@ -1027,10 +1026,11 @@ supplicant_check_secrets_needed (NMDeviceEthernet *self, NMDeviceStateReason *ou
"Activation: (ethernet) connection '%s' has security, but secrets are required.", "Activation: (ethernet) connection '%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_POSTPONE)
NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_NO_SECRETS); NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_NO_SECRETS);
return ret; return NM_ACT_STAGE_RETURN_FAILURE;
}
return NM_ACT_STAGE_RETURN_POSTPONE;
} }
_LOGI (LOGD_DEVICE | LOGD_ETHER, _LOGI (LOGD_DEVICE | LOGD_ETHER,
@@ -1056,35 +1056,19 @@ carrier_changed (NMSupplicantInterface *iface,
NMDeviceStateReason reason; NMDeviceStateReason reason;
NMActStageReturn ret; NMActStageReturn ret;
if (nm_device_has_carrier (NM_DEVICE (self))) { if (!nm_device_has_carrier (NM_DEVICE (self)))
_LOGD (LOGD_DEVICE | LOGD_ETHER, "got carrier, initializing supplicant"); return;
nm_clear_g_signal_handler (self, &priv->carrier_id);
ret = supplicant_check_secrets_needed (self, &reason); _LOGD (LOGD_DEVICE | LOGD_ETHER, "got carrier, initializing supplicant");
if (ret == NM_ACT_STAGE_RETURN_FAILURE) { nm_clear_g_signal_handler (self, &priv->carrier_id);
nm_device_state_changed (NM_DEVICE (self), ret = supplicant_check_secrets_needed (self, &reason);
NM_DEVICE_STATE_FAILED, if (ret == NM_ACT_STAGE_RETURN_FAILURE) {
reason); nm_device_state_changed (NM_DEVICE (self),
} NM_DEVICE_STATE_FAILED,
reason);
} }
} }
static NMActStageReturn
nm_8021x_stage2_config (NMDeviceEthernet *self, NMDeviceStateReason *out_failure_reason)
{
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
if (!nm_device_has_carrier (NM_DEVICE (self))) {
_LOGD (LOGD_DEVICE | LOGD_ETHER, "delay supplicant initialization until carrier goes up");
priv->carrier_id = g_signal_connect (self,
"notify::" NM_DEVICE_CARRIER,
G_CALLBACK (carrier_changed),
self);
return NM_ACT_STAGE_RETURN_POSTPONE;
}
return supplicant_check_secrets_needed (self, out_failure_reason);
}
/*****************************************************************************/ /*****************************************************************************/
/* PPPoE */ /* PPPoE */
@@ -1388,7 +1372,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
NMSettingConnection *s_con; NMSettingConnection *s_con;
const char *connection_type; const char *connection_type;
NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS; gboolean do_postpone = FALSE;
NMSettingDcb *s_dcb; NMSettingDcb *s_dcb;
s_con = nm_device_get_applied_setting (device, NM_TYPE_SETTING_CONNECTION); s_con = nm_device_get_applied_setting (device, NM_TYPE_SETTING_CONNECTION);
@@ -1402,14 +1386,23 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
* process opens the port up for normal traffic. * process opens the port up for normal traffic.
*/ */
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_WIRED_SETTING_NAME)) { if (nm_streq (connection_type, NM_SETTING_WIRED_SETTING_NAME)) {
NMSetting8021x *security; NMSetting8021x *security;
security = nm_device_get_applied_setting (device, NM_TYPE_SETTING_802_1X); security = nm_device_get_applied_setting (device, 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, out_failure_reason); if (!nm_device_has_carrier (NM_DEVICE (self))) {
_LOGD (LOGD_DEVICE | LOGD_ETHER, "delay supplicant initialization until carrier goes up");
priv->carrier_id = g_signal_connect (self,
"notify::" NM_DEVICE_CARRIER,
G_CALLBACK (carrier_changed),
self);
return NM_ACT_STAGE_RETURN_POSTPONE;
}
return supplicant_check_secrets_needed (self, out_failure_reason);
} }
} }
@@ -1431,7 +1424,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
} }
priv->dcb_handle_carrier_changes = TRUE; priv->dcb_handle_carrier_changes = TRUE;
ret = NM_ACT_STAGE_RETURN_POSTPONE; do_postpone = TRUE;
} }
/* PPPoE setup */ /* PPPoE setup */
@@ -1441,11 +1434,13 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
s_ppp = nm_device_get_applied_setting (device, NM_TYPE_SETTING_PPP); s_ppp = nm_device_get_applied_setting (device, NM_TYPE_SETTING_PPP);
if (s_ppp) { if (s_ppp) {
guint32 mtu = 0, mru = 0, mxu; guint32 mtu;
guint32 mru;
guint32 mxu;
mtu = nm_setting_ppp_get_mtu (s_ppp); mtu = nm_setting_ppp_get_mtu (s_ppp);
mru = nm_setting_ppp_get_mru (s_ppp); mru = nm_setting_ppp_get_mru (s_ppp);
mxu = mru > mtu ? mru : mtu; mxu = MAX (mru, mtu);
if (mxu) { if (mxu) {
_LOGD (LOGD_PPP, "set MTU to %u (PPP interface MRU %u, MTU %u)", _LOGD (LOGD_PPP, "set MTU to %u (PPP interface MRU %u, MTU %u)",
mxu + PPPOE_ENCAP_OVERHEAD, mru, mtu); mxu + PPPOE_ENCAP_OVERHEAD, mru, mtu);
@@ -1456,7 +1451,9 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
} }
} }
return ret; return do_postpone
? NM_ACT_STAGE_RETURN_POSTPONE
: NM_ACT_STAGE_RETURN_SUCCESS;
} }
static NMActStageReturn static NMActStageReturn

View File

@@ -511,7 +511,7 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface,
supplicant_iface_state_is_completed (self, new_state); supplicant_iface_state_is_completed (self, new_state);
} }
static NMActStageReturn static gboolean
handle_auth_or_fail (NMDeviceMacsec *self, handle_auth_or_fail (NMDeviceMacsec *self,
NMActRequest *req, NMActRequest *req,
gboolean new_secrets) gboolean new_secrets)
@@ -520,7 +520,7 @@ handle_auth_or_fail (NMDeviceMacsec *self,
NMConnection *applied_connection; NMConnection *applied_connection;
if (!nm_device_auth_retries_try_next (NM_DEVICE (self))) if (!nm_device_auth_retries_try_next (NM_DEVICE (self)))
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);
@@ -530,13 +530,13 @@ handle_auth_or_fail (NMDeviceMacsec *self,
setting_name = nm_connection_need_secrets (applied_connection, NULL); setting_name = nm_connection_need_secrets (applied_connection, NULL);
if (!setting_name) { if (!setting_name) {
_LOGI (LOGD_DEVICE, "Cleared secrets, but setting didn't need any secrets."); _LOGI (LOGD_DEVICE, "Cleared secrets, but setting didn't need any secrets.");
return NM_ACT_STAGE_RETURN_FAILURE; return FALSE;
} }
macsec_secrets_get_secrets (self, setting_name, macsec_secrets_get_secrets (self, setting_name,
NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION
| (new_secrets ? NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW : 0)); | (new_secrets ? NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW : 0));
return NM_ACT_STAGE_RETURN_POSTPONE; return TRUE;
} }
static gboolean static gboolean
@@ -571,7 +571,7 @@ supplicant_connection_timeout_cb (gpointer user_data)
if (nm_settings_connection_get_timestamp (connection, &timestamp)) if (nm_settings_connection_get_timestamp (connection, &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)) {
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_NO_SECRETS); nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_NO_SECRETS);
return G_SOURCE_REMOVE; return G_SOURCE_REMOVE;
} }
@@ -646,7 +646,6 @@ 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);
NMConnection *connection; NMConnection *connection;
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
NMDevice *parent; NMDevice *parent;
const char *setting_name; const char *setting_name;
int ifindex; int ifindex;
@@ -667,10 +666,12 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
"Activation: connection '%s' has security, but secrets are required.", "Activation: connection '%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_POSTPONE)
NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_NO_SECRETS); NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_NO_SECRETS);
return ret; return NM_ACT_STAGE_RETURN_FAILURE;
}
return NM_ACT_STAGE_RETURN_POSTPONE;
} }
_LOGI (LOGD_DEVICE | LOGD_ETHER, _LOGI (LOGD_DEVICE | LOGD_ETHER,

View File

@@ -137,11 +137,9 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
GError *error = NULL; GError *error = NULL;
req = nm_device_get_act_request (device); req = nm_device_get_act_request (device);
g_return_val_if_fail (req, NM_ACT_STAGE_RETURN_FAILURE); g_return_val_if_fail (req, NM_ACT_STAGE_RETURN_FAILURE);
s_pppoe = nm_device_get_applied_setting (device, NM_TYPE_SETTING_PPPOE); s_pppoe = nm_device_get_applied_setting (device, NM_TYPE_SETTING_PPPOE);
g_return_val_if_fail (s_pppoe, NM_ACT_STAGE_RETURN_FAILURE); g_return_val_if_fail (s_pppoe, NM_ACT_STAGE_RETURN_FAILURE);
g_clear_object (&priv->ip4_config); g_clear_object (&priv->ip4_config);
@@ -157,9 +155,12 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
} }
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_pppoe_get_username (s_pppoe), nm_setting_pppoe_get_username (s_pppoe),
30, 0, &error)) { 30,
0,
&error)) {
_LOGW (LOGD_DEVICE | LOGD_PPP, "PPPoE failed to start: %s", error->message); _LOGW (LOGD_DEVICE | LOGD_PPP, "PPPoE failed to start: %s", error->message);
g_error_free (error); g_error_free (error);
@@ -169,16 +170,18 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
return NM_ACT_STAGE_RETURN_FAILURE; return NM_ACT_STAGE_RETURN_FAILURE;
} }
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_STATE_CHANGED, g_signal_connect (priv->ppp_manager,
NM_PPP_MANAGER_SIGNAL_STATE_CHANGED,
G_CALLBACK (ppp_state_changed), G_CALLBACK (ppp_state_changed),
self); self);
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_IFINDEX_SET, g_signal_connect (priv->ppp_manager,
NM_PPP_MANAGER_SIGNAL_IFINDEX_SET,
G_CALLBACK (ppp_ifindex_set), G_CALLBACK (ppp_ifindex_set),
self); self);
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_IP4_CONFIG, g_signal_connect (priv->ppp_manager,
NM_PPP_MANAGER_SIGNAL_IP4_CONFIG,
G_CALLBACK (ppp_ip4_config), G_CALLBACK (ppp_ip4_config),
self); self);
return NM_ACT_STAGE_RETURN_POSTPONE; return NM_ACT_STAGE_RETURN_POSTPONE;
} }

View File

@@ -1522,28 +1522,26 @@ act_stage2_config (NMDevice *device,
} }
ret = link_config (NM_DEVICE_WIREGUARD (device), ret = link_config (NM_DEVICE_WIREGUARD (device),
"configure", "configure",
(sys_iface_state == NM_DEVICE_SYS_IFACE_STATE_ASSUME) (sys_iface_state == NM_DEVICE_SYS_IFACE_STATE_ASSUME)
? LINK_CONFIG_MODE_ASSUME ? LINK_CONFIG_MODE_ASSUME
: LINK_CONFIG_MODE_FULL, : LINK_CONFIG_MODE_FULL,
&failure_reason); &failure_reason);
if (sys_iface_state == NM_DEVICE_SYS_IFACE_STATE_ASSUME) { if (sys_iface_state == NM_DEVICE_SYS_IFACE_STATE_ASSUME) {
/* this never fails. */ /* this never fails. */
NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_NONE);
return NM_ACT_STAGE_RETURN_SUCCESS; return NM_ACT_STAGE_RETURN_SUCCESS;
} }
if (ret != NM_ACT_STAGE_RETURN_FAILURE) { if (ret == NM_ACT_STAGE_RETURN_FAILURE) {
NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_NONE); nm_device_state_changed (device,
return ret; NM_DEVICE_STATE_FAILED,
failure_reason);
NM_SET_OUT (out_failure_reason, failure_reason);
return NM_ACT_STAGE_RETURN_FAILURE;
} }
nm_device_state_changed (device, return ret;
NM_DEVICE_STATE_FAILED,
failure_reason);
NM_SET_OUT (out_failure_reason, failure_reason);
return NM_ACT_STAGE_RETURN_FAILURE;
} }
static NMIPConfig * static NMIPConfig *

View File

@@ -7067,10 +7067,11 @@ activate_stage2_device_config (NMDevice *self)
if (!nm_device_sys_iface_state_is_external_or_assume (self)) { if (!nm_device_sys_iface_state_is_external_or_assume (self)) {
if (!nm_device_bring_up (self, FALSE, &no_firmware)) { if (!nm_device_bring_up (self, FALSE, &no_firmware)) {
if (no_firmware) nm_device_state_changed (self,
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_FIRMWARE_MISSING); NM_DEVICE_STATE_FAILED,
else no_firmware
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_CONFIG_FAILED); ? NM_DEVICE_STATE_REASON_FIRMWARE_MISSING
: NM_DEVICE_STATE_REASON_CONFIG_FAILED);
return; return;
} }
} }

View File

@@ -567,7 +567,7 @@ is_connection_known_network (NMConnection *connection)
static gboolean static gboolean
is_ap_known_network (NMWifiAP *ap) is_ap_known_network (NMWifiAP *ap)
{ {
GDBusProxy *network_proxy; gs_unref_object GDBusProxy *network_proxy = NULL;
gs_unref_variant GVariant *known_network = NULL; gs_unref_variant GVariant *known_network = NULL;
network_proxy = nm_iwd_manager_get_dbus_interface (nm_iwd_manager_get (), network_proxy = nm_iwd_manager_get_dbus_interface (nm_iwd_manager_get (),
@@ -577,10 +577,7 @@ is_ap_known_network (NMWifiAP *ap)
return FALSE; return FALSE;
known_network = g_dbus_proxy_get_cached_property (network_proxy, "KnownNetwork"); known_network = g_dbus_proxy_get_cached_property (network_proxy, "KnownNetwork");
g_object_unref (network_proxy); return nm_g_variant_is_of_type (known_network, G_VARIANT_TYPE_OBJECT_PATH);
return known_network
&& g_variant_is_of_type (known_network, G_VARIANT_TYPE_OBJECT_PATH);
} }
static gboolean static gboolean
@@ -1773,29 +1770,25 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
{ {
NMDeviceIwd *self = NM_DEVICE_IWD (device); NMDeviceIwd *self = NM_DEVICE_IWD (device);
NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE (self); NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE (self);
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
NMActRequest *req; NMActRequest *req;
NMConnection *connection; NMConnection *connection;
NMSettingWireless *s_wireless; NMSettingWireless *s_wireless;
const char *mode; const char *mode;
req = nm_device_get_act_request (device); req = nm_device_get_act_request (device);
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);
s_wireless = nm_connection_get_setting_wireless (connection); s_wireless = nm_connection_get_setting_wireless (connection);
g_return_val_if_fail (s_wireless, NM_ACT_STAGE_RETURN_FAILURE); 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 (NM_IN_STRSET (mode, NULL, NM_SETTING_WIRELESS_MODE_INFRA)) { if (NM_IN_STRSET (mode, NULL, NM_SETTING_WIRELESS_MODE_INFRA)) {
GDBusProxy *network_proxy; gs_unref_object GDBusProxy *network_proxy = NULL;
NMWifiAP *ap = priv->current_ap; NMWifiAP *ap = priv->current_ap;
if (!ap) { if (!ap) {
NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED); NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED);
goto out; goto out_fail;
} }
/* 802.1x networks that are not IWD Known Networks will definitely /* 802.1x networks that are not IWD Known Networks will definitely
@@ -1809,7 +1802,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
nm_connection_get_id (connection)); nm_connection_get_id (connection));
NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_NO_SECRETS); NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_NO_SECRETS);
goto out; goto out_fail;
} }
network_proxy = nm_iwd_manager_get_dbus_interface (nm_iwd_manager_get (), network_proxy = nm_iwd_manager_get_dbus_interface (nm_iwd_manager_get (),
@@ -1820,7 +1813,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
"Activation: (wifi) could not get Network interface proxy for %s", "Activation: (wifi) could not get Network interface proxy for %s",
nm_ref_string_get_str (nm_wifi_ap_get_supplicant_path (ap))); nm_ref_string_get_str (nm_wifi_ap_get_supplicant_path (ap)));
NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED); NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED);
goto out; goto out_fail;
} }
if (!priv->cancellable) if (!priv->cancellable)
@@ -1833,12 +1826,15 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
NULL, G_DBUS_CALL_FLAGS_NONE, G_MAXINT, NULL, G_DBUS_CALL_FLAGS_NONE, G_MAXINT,
priv->cancellable, network_connect_cb, self); priv->cancellable, network_connect_cb, self);
g_object_unref (network_proxy); return NM_ACT_STAGE_RETURN_POSTPONE;
} else if (NM_IN_STRSET (mode, NM_SETTING_WIRELESS_MODE_AP, NM_SETTING_WIRELESS_MODE_ADHOC)) { }
if (NM_IN_STRSET (mode, NM_SETTING_WIRELESS_MODE_AP, NM_SETTING_WIRELESS_MODE_ADHOC)) {
NMSettingWirelessSecurity *s_wireless_sec; NMSettingWirelessSecurity *s_wireless_sec;
s_wireless_sec = nm_connection_get_setting_wireless_security (connection); s_wireless_sec = nm_connection_get_setting_wireless_security (connection);
if (s_wireless_sec && !nm_setting_wireless_security_get_psk (s_wireless_sec)) { if ( s_wireless_sec
&& !nm_setting_wireless_security_get_psk (s_wireless_sec)) {
/* PSK is missing from the settings, have to request it */ /* PSK is missing from the settings, have to request it */
wifi_secrets_cancel (self); wifi_secrets_cancel (self);
@@ -1853,16 +1849,15 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
nm_device_state_changed (device, NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_NONE); nm_device_state_changed (device, NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_NONE);
} else } else
act_set_mode (self); act_set_mode (self);
return NM_ACT_STAGE_RETURN_POSTPONE;
} }
/* We'll get stage3 started when the supplicant connects */ return NM_ACT_STAGE_RETURN_POSTPONE;
ret = NM_ACT_STAGE_RETURN_POSTPONE;
out: out_fail:
if (ret == NM_ACT_STAGE_RETURN_FAILURE) cleanup_association_attempt (self, FALSE);
cleanup_association_attempt (self, FALSE); return NM_ACT_STAGE_RETURN_FAILURE;
return ret;
} }
static guint32 static guint32

View File

@@ -189,10 +189,10 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
gboolean success; gboolean success;
s_mesh = nm_device_get_applied_setting (device, NM_TYPE_SETTING_OLPC_MESH); s_mesh = nm_device_get_applied_setting (device, NM_TYPE_SETTING_OLPC_MESH);
g_return_val_if_fail (s_mesh, NM_ACT_STAGE_RETURN_FAILURE); g_return_val_if_fail (s_mesh, NM_ACT_STAGE_RETURN_FAILURE);
ssid = nm_setting_olpc_mesh_get_ssid (s_mesh); ssid = nm_setting_olpc_mesh_get_ssid (s_mesh);
nm_device_take_down (NM_DEVICE (self), TRUE); nm_device_take_down (NM_DEVICE (self), TRUE);
success = nm_platform_mesh_set_ssid (nm_device_get_platform (device), success = nm_platform_mesh_set_ssid (nm_device_get_platform (device),
nm_device_get_ifindex (device), nm_device_get_ifindex (device),

View File

@@ -429,7 +429,6 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
connection = nm_device_get_applied_connection (device); connection = nm_device_get_applied_connection (device);
g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE); g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
nm_assert (NM_IS_SETTING_WIFI_P2P (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIFI_P2P))); nm_assert (NM_IS_SETTING_WIFI_P2P (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIFI_P2P)));
/* The prepare stage ensures that the peer has been found */ /* The prepare stage ensures that the peer has been found */
@@ -449,7 +448,8 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
/* TODO: Fix "pbc" being hardcoded here! */ /* TODO: Fix "pbc" being hardcoded here! */
nm_supplicant_interface_p2p_connect (priv->mgmt_iface, nm_supplicant_interface_p2p_connect (priv->mgmt_iface,
nm_wifi_p2p_peer_get_supplicant_path (peer), nm_wifi_p2p_peer_get_supplicant_path (peer),
"pbc", NULL); "pbc",
NULL);
/* Set up a timeout on the connect attempt */ /* Set up a timeout on the connect attempt */
if (priv->sup_timeout_id == 0) { if (priv->sup_timeout_id == 0) {

View File

@@ -2780,8 +2780,7 @@ 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);
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE; gs_unref_object NMSupplicantConfig *config = NULL;
NMSupplicantConfig *config = NULL;
NM80211Mode ap_mode; NM80211Mode ap_mode;
NMActRequest *req; NMActRequest *req;
NMWifiAP *ap; NMWifiAP *ap;
@@ -2801,15 +2800,14 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
ap = priv->current_ap; ap = priv->current_ap;
if (!ap) { if (!ap) {
NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED); NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED);
goto out; goto out_fail;
} }
ap_mode = nm_wifi_ap_get_mode (ap); ap_mode = nm_wifi_ap_get_mode (ap);
connection = nm_act_request_get_applied_connection (req); connection = nm_act_request_get_applied_connection (req);
g_assert (connection);
s_wireless = nm_connection_get_setting_wireless (connection); s_wireless = nm_connection_get_setting_wireless (connection);
g_assert (s_wireless); nm_assert (s_wireless);
/* If we need secrets, get them */ /* If we need secrets, get them */
setting_name = nm_connection_need_secrets (connection, NULL); setting_name = nm_connection_need_secrets (connection, NULL);
@@ -2818,13 +2816,12 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_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));
if (handle_auth_or_fail (self, req, FALSE)) if (!handle_auth_or_fail (self, req, FALSE)) {
ret = NM_ACT_STAGE_RETURN_POSTPONE;
else {
NM_SET_OUT (out_failure_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; goto out_fail;
} }
goto out;
return NM_ACT_STAGE_RETURN_POSTPONE;
} }
if (!wake_on_wlan_enable (self)) if (!wake_on_wlan_enable (self))
@@ -2857,17 +2854,19 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
/* Build up the supplicant configuration */ /* Build up the supplicant configuration */
config = build_supplicant_config (self, connection, nm_wifi_ap_get_freq (ap), &error); config = build_supplicant_config (self, connection, nm_wifi_ap_get_freq (ap), &error);
if (config == NULL) { if (!config) {
_LOGE (LOGD_DEVICE | LOGD_WIFI, _LOGE (LOGD_DEVICE | LOGD_WIFI,
"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);
NM_SET_OUT (out_failure_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_fail;
} }
nm_supplicant_interface_assoc (priv->sup_iface, config, nm_supplicant_interface_assoc (priv->sup_iface,
supplicant_iface_assoc_cb, self); config,
supplicant_iface_assoc_cb,
self);
/* Set up a timeout on the association attempt */ /* Set up a timeout on the association attempt */
timeout = nm_device_get_supplicant_timeout (NM_DEVICE (self)); timeout = nm_device_get_supplicant_timeout (NM_DEVICE (self));
@@ -2879,21 +2878,12 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
priv->periodic_source_id = g_timeout_add_seconds (6, periodic_update_cb, self); priv->periodic_source_id = g_timeout_add_seconds (6, periodic_update_cb, self);
/* We'll get stage3 started when the supplicant connects */ /* We'll get stage3 started when the supplicant connects */
ret = NM_ACT_STAGE_RETURN_POSTPONE; return NM_ACT_STAGE_RETURN_POSTPONE;
out: out_fail:
if (ret == NM_ACT_STAGE_RETURN_FAILURE) { cleanup_association_attempt (self, TRUE);
cleanup_association_attempt (self, TRUE); wake_on_wlan_restore (self);
wake_on_wlan_restore (self); return NM_ACT_STAGE_RETURN_FAILURE;
}
if (config) {
/* Supplicant interface object refs the config; we no longer care about
* it after this function.
*/
g_object_unref (config);
}
return ret;
} }
static NMActStageReturn static NMActStageReturn

View File

@@ -605,7 +605,6 @@ static NMActStageReturn
act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason) act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
{ {
nm_modem_act_stage2_config (NM_DEVICE_MODEM_GET_PRIVATE (device)->modem); nm_modem_act_stage2_config (NM_DEVICE_MODEM_GET_PRIVATE (device)->modem);
return NM_ACT_STAGE_RETURN_SUCCESS; return NM_ACT_STAGE_RETURN_SUCCESS;
} }