mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-21 03:32:42 +01:00
netdev: Finalize disconnects on device removal
When device is removed or otherwise freed, netdev_connect callbacks are invoked. Treat disconnects similarly
This commit is contained in:
parent
29387e012a
commit
92a51805c4
21
src/netdev.c
21
src/netdev.c
@ -68,6 +68,7 @@ struct netdev {
|
|||||||
uint32_t pairwise_set_key_cmd_id;
|
uint32_t pairwise_set_key_cmd_id;
|
||||||
uint32_t group_new_key_cmd_id;
|
uint32_t group_new_key_cmd_id;
|
||||||
uint32_t connect_cmd_id;
|
uint32_t connect_cmd_id;
|
||||||
|
uint32_t disconnect_cmd_id;
|
||||||
|
|
||||||
struct l_queue *watches;
|
struct l_queue *watches;
|
||||||
uint32_t next_watch_id;
|
uint32_t next_watch_id;
|
||||||
@ -315,6 +316,15 @@ static void netdev_free(void *data)
|
|||||||
netdev->user_data);
|
netdev->user_data);
|
||||||
|
|
||||||
netdev_connect_free(netdev);
|
netdev_connect_free(netdev);
|
||||||
|
} else if (netdev->disconnect_cmd_id) {
|
||||||
|
l_genl_family_cancel(nl80211, netdev->disconnect_cmd_id);
|
||||||
|
netdev->disconnect_cmd_id = 0;
|
||||||
|
|
||||||
|
if (netdev->disconnect_cb)
|
||||||
|
netdev->disconnect_cb(netdev, true, netdev->user_data);
|
||||||
|
|
||||||
|
netdev->disconnect_cb = NULL;
|
||||||
|
netdev->user_data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
device_remove(netdev->device);
|
device_remove(netdev->device);
|
||||||
@ -486,7 +496,7 @@ static void netdev_cmd_deauthenticate_cb(struct l_genl_msg *msg,
|
|||||||
bool r;
|
bool r;
|
||||||
|
|
||||||
if (!netdev->disconnect_cb)
|
if (!netdev->disconnect_cb)
|
||||||
return;
|
goto done;
|
||||||
|
|
||||||
if (l_genl_msg_get_error(msg) < 0)
|
if (l_genl_msg_get_error(msg) < 0)
|
||||||
r = false;
|
r = false;
|
||||||
@ -494,6 +504,9 @@ static void netdev_cmd_deauthenticate_cb(struct l_genl_msg *msg,
|
|||||||
r = true;
|
r = true;
|
||||||
|
|
||||||
netdev->disconnect_cb(netdev, r, netdev->user_data);
|
netdev->disconnect_cb(netdev, r, netdev->user_data);
|
||||||
|
netdev->disconnect_cb = NULL;
|
||||||
|
done:
|
||||||
|
netdev->user_data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct l_genl_msg *netdev_build_cmd_deauthenticate(struct netdev *netdev,
|
static struct l_genl_msg *netdev_build_cmd_deauthenticate(struct netdev *netdev,
|
||||||
@ -1194,8 +1207,10 @@ int netdev_disconnect(struct netdev *netdev,
|
|||||||
|
|
||||||
deauthenticate = netdev_build_cmd_deauthenticate(netdev,
|
deauthenticate = netdev_build_cmd_deauthenticate(netdev,
|
||||||
MPDU_REASON_CODE_DEAUTH_LEAVING);
|
MPDU_REASON_CODE_DEAUTH_LEAVING);
|
||||||
if (!l_genl_family_send(nl80211, deauthenticate,
|
netdev->disconnect_cmd_id = l_genl_family_send(nl80211, deauthenticate,
|
||||||
netdev_cmd_deauthenticate_cb, netdev, NULL)) {
|
netdev_cmd_deauthenticate_cb, netdev, NULL);
|
||||||
|
|
||||||
|
if (!netdev->disconnect_cmd_id) {
|
||||||
l_genl_msg_unref(deauthenticate);
|
l_genl_msg_unref(deauthenticate);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user