From 7b20f57239f8fbee2467599b562bbe6ded331a9c Mon Sep 17 00:00:00 2001 From: Andrew Zaborowski Date: Mon, 26 Sep 2016 18:55:38 +0200 Subject: [PATCH] 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. --- src/network.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/network.c b/src/network.c index 1e0de2fe..08377a65 100644 --- a/src/network.c +++ b/src/network.c @@ -150,8 +150,6 @@ bool network_connected(struct network *network) * Write an empty settings file to keep track of the * last connected time. This will also make iwd autoconnect * 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)) return false; @@ -217,9 +215,18 @@ static const double rankmod_table[] = { bool network_rankmod(const struct network *network, double *rankmod) { - int n = network_find_rank_index(network->info); + int n; 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) return false;