netdev: move failure point out of netdev_connect_common
The only point of failure in netdev_connect_common was setting up the handshake type. Moving this outside of netdev_connect_common makes the code flow much better in netdev_{connect,reassociate} as nothing needs to be reset upon failure.
This commit is contained in:
parent
eb968c9098
commit
b543bf76f1
37
src/netdev.c
37
src/netdev.c
|
@ -3364,6 +3364,9 @@ static int netdev_handshake_state_setup_connection_type(
|
||||||
bool softmac = wiphy_supports_cmds_auth_assoc(wiphy);
|
bool softmac = wiphy_supports_cmds_auth_assoc(wiphy);
|
||||||
bool canroam = wiphy_supports_firmware_roam(wiphy);
|
bool canroam = wiphy_supports_firmware_roam(wiphy);
|
||||||
|
|
||||||
|
if (hs->supplicant_ie == NULL)
|
||||||
|
goto softmac;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sanity check that any FT AKMs are set only on softmac or on
|
* Sanity check that any FT AKMs are set only on softmac or on
|
||||||
* devices that support firmware roam
|
* devices that support firmware roam
|
||||||
|
@ -3442,7 +3445,7 @@ offload_1x:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int netdev_connect_common(struct netdev *netdev,
|
static void netdev_connect_common(struct netdev *netdev,
|
||||||
struct scan_bss *bss,
|
struct scan_bss *bss,
|
||||||
struct scan_bss *prev_bss,
|
struct scan_bss *prev_bss,
|
||||||
struct handshake_state *hs,
|
struct handshake_state *hs,
|
||||||
|
@ -3458,13 +3461,8 @@ static int netdev_connect_common(struct netdev *netdev,
|
||||||
bool is_rsn = hs->supplicant_ie != NULL;
|
bool is_rsn = hs->supplicant_ie != NULL;
|
||||||
const uint8_t *prev_bssid = prev_bss ? prev_bss->addr : NULL;
|
const uint8_t *prev_bssid = prev_bss ? prev_bss->addr : NULL;
|
||||||
|
|
||||||
if (!is_rsn) {
|
if (!is_rsn)
|
||||||
nhs->type = CONNECTION_TYPE_SOFTMAC;
|
|
||||||
goto build_cmd_connect;
|
goto build_cmd_connect;
|
||||||
}
|
|
||||||
|
|
||||||
if (netdev_handshake_state_setup_connection_type(hs) < 0)
|
|
||||||
return -ENOTSUP;
|
|
||||||
|
|
||||||
if (nhs->type != CONNECTION_TYPE_SOFTMAC)
|
if (nhs->type != CONNECTION_TYPE_SOFTMAC)
|
||||||
goto build_cmd_connect;
|
goto build_cmd_connect;
|
||||||
|
@ -3533,8 +3531,6 @@ build_cmd_connect:
|
||||||
|
|
||||||
wiphy_radio_work_insert(netdev->wiphy, &netdev->work, 1,
|
wiphy_radio_work_insert(netdev->wiphy, &netdev->work, 1,
|
||||||
&connect_work_ops);
|
&connect_work_ops);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int netdev_connect(struct netdev *netdev, struct scan_bss *bss,
|
int netdev_connect(struct netdev *netdev, struct scan_bss *bss,
|
||||||
|
@ -3554,9 +3550,14 @@ int netdev_connect(struct netdev *netdev, struct scan_bss *bss,
|
||||||
if (netdev->connected || netdev->connect_cmd_id || netdev->work.id)
|
if (netdev->connected || netdev->connect_cmd_id || netdev->work.id)
|
||||||
return -EISCONN;
|
return -EISCONN;
|
||||||
|
|
||||||
return netdev_connect_common(netdev, bss, NULL, hs, vendor_ies,
|
if (netdev_handshake_state_setup_connection_type(hs) < 0)
|
||||||
|
return -ENOTSUP;
|
||||||
|
|
||||||
|
netdev_connect_common(netdev, bss, NULL, hs, vendor_ies,
|
||||||
num_vendor_ies, event_filter, cb,
|
num_vendor_ies, event_filter, cb,
|
||||||
user_data);
|
user_data);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void disconnect_idle(struct l_idle *idle, void *user_data)
|
static void disconnect_idle(struct l_idle *idle, void *user_data)
|
||||||
|
@ -3646,24 +3647,24 @@ int netdev_reassociate(struct netdev *netdev, struct scan_bss *target_bss,
|
||||||
{
|
{
|
||||||
struct handshake_state *old_hs;
|
struct handshake_state *old_hs;
|
||||||
struct eapol_sm *old_sm;
|
struct eapol_sm *old_sm;
|
||||||
int ret;
|
|
||||||
|
|
||||||
old_sm = netdev->sm;
|
old_sm = netdev->sm;
|
||||||
old_hs = netdev->handshake;
|
old_hs = netdev->handshake;
|
||||||
|
|
||||||
ret = netdev_connect_common(netdev, target_bss, orig_bss, hs, NULL, 0,
|
if (netdev_handshake_state_setup_connection_type(hs) < 0)
|
||||||
event_filter, cb, user_data);
|
return -ENOTSUP;
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (netdev->ap)
|
|
||||||
memcpy(netdev->ap->prev_bssid, orig_bss->addr, ETH_ALEN);
|
|
||||||
|
|
||||||
netdev->associated = false;
|
netdev->associated = false;
|
||||||
netdev->operational = false;
|
netdev->operational = false;
|
||||||
netdev->connected = false;
|
netdev->connected = false;
|
||||||
netdev->in_reassoc = true;
|
netdev->in_reassoc = true;
|
||||||
|
|
||||||
|
netdev_connect_common(netdev, target_bss, orig_bss, hs, NULL, 0,
|
||||||
|
event_filter, cb, user_data);
|
||||||
|
|
||||||
|
if (netdev->ap)
|
||||||
|
memcpy(netdev->ap->prev_bssid, orig_bss->addr, ETH_ALEN);
|
||||||
|
|
||||||
netdev_rssi_polling_update(netdev);
|
netdev_rssi_polling_update(netdev);
|
||||||
|
|
||||||
if (old_sm)
|
if (old_sm)
|
||||||
|
|
Loading…
Reference in New Issue