3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-30 06:02:39 +01:00

network: Fix autoconnect candidate logic

Fix autoconnect trying to connect to networks never used before as found
by Tim Kourt.  Update the comments to be consistent with the use of the
is_known field and the docs, in that a Known Network is any network that
has a config file in the iwd storage, and an autoconnect candidate is a
network that has been connected to before.
This commit is contained in:
Andrew Zaborowski 2016-09-26 18:55:38 +02:00 committed by Denis Kenzior
parent 0eea6ad4b7
commit 7b20f57239

View File

@ -150,8 +150,6 @@ bool network_connected(struct network *network)
* Write an empty settings file to keep track of the * Write an empty settings file to keep track of the
* last connected time. This will also make iwd autoconnect * last connected time. This will also make iwd autoconnect
* to this network in the future. * to this network in the future.
* Current policy is that network becomes a Known Network
* only on a successful connect.
*/ */
if (!network_settings_load(network)) if (!network_settings_load(network))
return false; return false;
@ -217,9 +215,18 @@ static const double rankmod_table[] = {
bool network_rankmod(const struct network *network, double *rankmod) bool network_rankmod(const struct network *network, double *rankmod)
{ {
int n = network_find_rank_index(network->info); int n;
int nmax; int nmax;
/*
* Current policy is that only networks successfully connected
* to at least once are autoconnectable. Known Networks that
* we have never connected to are not.
*/
if (!network->info->connected_time.tv_sec)
return false;
n = network_find_rank_index(network->info);
if (n == -1) if (n == -1)
return false; return false;