netdev: Fix disconnect event coming out of order

mac80211 drivers seem to send the disconnect event which is triggered by
CMD_DISCONNECT prior to the CMD_DISCONNECT response.  However, some
drivers, namely brcmfmac, send the response first and then send the
disconnect event.  This confused iwd when a connection was immediately
triggered after a disconnection (network switch operation).

Fix this by making sure that connected variable isn't set until the
connect event is actually processed, and ignore disconnect events which
come after CMD_DISCONNECT has alredy succeeded.
This commit is contained in:
Denis Kenzior 2020-02-14 16:01:04 -06:00
parent df64dd443e
commit 53ea9adfb5
1 changed files with 3 additions and 2 deletions

View File

@ -2055,6 +2055,8 @@ static void netdev_cmd_connect_cb(struct l_genl_msg *msg, void *user_data)
/* Wait for connect event */
if (l_genl_msg_get_error(msg) >= 0) {
netdev->connected = true;
if (netdev->event_filter)
netdev->event_filter(netdev,
NETDEV_EVENT_ASSOCIATING,
@ -2397,7 +2399,6 @@ static int netdev_connect_common(struct netdev *netdev,
netdev->event_filter = event_filter;
netdev->connect_cb = cb;
netdev->user_data = user_data;
netdev->connected = true;
netdev->handshake = hs;
netdev->sm = sm;
netdev->frequency = bss->frequency;
@ -2432,7 +2433,7 @@ int netdev_connect(struct netdev *netdev, struct scan_bss *bss,
netdev->type != NL80211_IFTYPE_P2P_CLIENT)
return -ENOTSUP;
if (netdev->connected)
if (netdev->connected || netdev->connect_cmd_id)
return -EISCONN;
switch (hs->akm_suite) {