From 886ffc2edb524f3ec874d85e8494ef9bd02887f8 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Thu, 22 Sep 2016 15:55:07 -0500 Subject: [PATCH] netdev: keep track of operational state We should not attempt to call connect_failed if we're have become operational. E.g. successfully associated, ran eapol if necessary and set operstate. --- src/netdev.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/netdev.c b/src/netdev.c index 00072455..1e76529d 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -75,6 +75,7 @@ struct netdev { uint32_t next_watch_id; bool connected : 1; + bool operational : 1; bool eapol_active : 1; bool rekey_offload_support : 1; }; @@ -280,6 +281,7 @@ static void netdev_connect_free(struct netdev *netdev) netdev->eapol_active = false; } + netdev->operational = false; netdev->connected = false; netdev->connect_cb = NULL; netdev->event_filter = NULL; @@ -562,6 +564,8 @@ static void netdev_operstate_cb(bool success, void *user_data) return; } + netdev->operational = true; + if (netdev->connect_cb) { netdev->connect_cb(netdev, NETDEV_RESULT_OK, netdev->user_data); netdev->connect_cb = NULL; @@ -1205,8 +1209,13 @@ int netdev_disconnect(struct netdev *netdev, if (netdev->disconnect_cmd_id) return -EINPROGRESS; - netdev->result = NETDEV_RESULT_ABORTED; - netdev_connect_failed(NULL, netdev); + /* Only perform this if we haven't successfully fully associated yet */ + if (!netdev->operational) { + netdev->result = NETDEV_RESULT_ABORTED; + netdev_connect_failed(NULL, netdev); + } else { + netdev_connect_free(netdev); + } deauthenticate = netdev_build_cmd_deauthenticate(netdev, MPDU_REASON_CODE_DEAUTH_LEAVING);