station: Give network a connection failed hint

Right now, if the connection fails, then network always thinks that the
password should be re-asked.  Loosen this to only do so if the
connection failed at least in the handshake phase.  If the connection
failed due to Association / Authentication timeout, it is likely that
something is wrong with the AP and it can't respond.
This commit is contained in:
Denis Kenzior 2020-06-12 15:21:39 -05:00
parent e70b252e19
commit 254cefcc96
3 changed files with 10 additions and 6 deletions

View File

@ -595,13 +595,13 @@ close_settings:
return ret; return ret;
} }
void network_connect_failed(struct network *network) void network_connect_failed(struct network *network, bool in_handshake)
{ {
/* /*
* Connection failed, if PSK try asking for the passphrase * Connection failed during the handshake phase. If PSK try asking
* once more * for the passphrase once more
*/ */
if (network_get_security(network) == SECURITY_PSK) { if (network_get_security(network) == SECURITY_PSK && in_handshake) {
network->update_psk = false; network->update_psk = false;
network->ask_passphrase = true; network->ask_passphrase = true;
} }

View File

@ -53,7 +53,7 @@ const struct network_info *network_get_info(const struct network *network);
void network_set_info(struct network *network, struct network_info *info); void network_set_info(struct network *network, struct network_info *info);
int network_autoconnect(struct network *network, struct scan_bss *bss); int network_autoconnect(struct network *network, struct scan_bss *bss);
void network_connect_failed(struct network *network); void network_connect_failed(struct network *network, bool in_handshake);
bool network_bss_add(struct network *network, struct scan_bss *bss); bool network_bss_add(struct network *network, struct scan_bss *bss);
bool network_bss_list_isempty(struct network *network); bool network_bss_list_isempty(struct network *network);
void network_bss_list_clear(struct network *network); void network_bss_list_clear(struct network *network);

View File

@ -2343,7 +2343,11 @@ static void station_connect_cb(struct netdev *netdev, enum netdev_result result,
if (result != NETDEV_RESULT_OK) { if (result != NETDEV_RESULT_OK) {
if (result != NETDEV_RESULT_ABORTED) { if (result != NETDEV_RESULT_ABORTED) {
network_connect_failed(station->connected_network); bool in_handshake =
result == NETDEV_RESULT_HANDSHAKE_FAILED;
network_connect_failed(station->connected_network,
in_handshake);
station_disassociated(station); station_disassociated(station);
} }