commit 2b0b5d417344c2af74fee588a6d2e4952d8bf210
parent 11f42e2476e39ad3ff97f3be598823ed048eb229
Author: Denis Kenzior <denkenz@gmail.com>
Date: Fri, 28 May 2021 22:39:05 -0500
netdev: Check ifi_flags in netdev_connect/disconnect
Also, set the flags appropriately when removing the netdev object. This
prevents callers from accidentally starting any actions that will simply
fail.
Diffstat:
1 file changed, 8 insertions(+), 0 deletions(-)
diff --git a/src/netdev.c b/src/netdev.c
@@ -802,6 +802,8 @@ static void netdev_free(void *data)
l_debug("Freeing netdev %s[%d]", netdev->name, netdev->index);
+ netdev->ifi_flags &= ~IFF_UP;
+
if (netdev->events_ready)
WATCHLIST_NOTIFY(&netdev_watches, netdev_watch_func_t,
netdev, NETDEV_WATCH_EVENT_DEL);
@@ -3293,6 +3295,9 @@ int netdev_connect(struct netdev *netdev, struct scan_bss *bss,
struct eapol_sm *sm = NULL;
bool is_rsn = hs->supplicant_ie != NULL;
+ if (!(netdev->ifi_flags & IFF_UP))
+ return -ENETDOWN;
+
if (netdev->type != NL80211_IFTYPE_STATION &&
netdev->type != NL80211_IFTYPE_P2P_CLIENT)
return -ENOTSUP;
@@ -3367,6 +3372,9 @@ int netdev_disconnect(struct netdev *netdev,
struct l_genl_msg *disconnect;
bool send_disconnect = true;
+ if (!(netdev->ifi_flags & IFF_UP))
+ return -ENETDOWN;
+
if (netdev->type != NL80211_IFTYPE_STATION &&
netdev->type != NL80211_IFTYPE_P2P_CLIENT)
return -ENOTSUP;