From 2f2a5707557a603b16b5d85fb5a91e9098fd3e1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20=C3=85strand?= Date: Thu, 11 Mar 2021 21:58:48 +0100 Subject: [PATCH] nl80211: Restore station mode on deinit only if station when started With the earlier code, a mesh interface was changed to station after deinit. Signed-off-by: Peter Astrand --- src/drivers/driver_nl80211.c | 9 +++++---- src/drivers/driver_nl80211.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index c2721ae37..a67bef9a3 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -2839,8 +2839,8 @@ wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv, set_addr))) return -1; - if (first && nl80211_get_ifmode(bss) == NL80211_IFTYPE_AP) - drv->start_mode_ap = 1; + if (first && nl80211_get_ifmode(bss) == NL80211_IFTYPE_STATION) + drv->start_mode_sta = 1; if (drv->hostapd || bss->static_ap) nlmode = NL80211_IFTYPE_AP; @@ -3005,7 +3005,7 @@ static void wpa_driver_nl80211_deinit(struct i802_bss *bss) } if (drv->nlmode != NL80211_IFTYPE_P2P_DEVICE) { - if (!drv->hostapd || !drv->start_mode_ap) + if (drv->start_mode_sta) wpa_driver_nl80211_set_mode(bss, NL80211_IFTYPE_STATION); nl80211_mgmt_unsubscribe(bss, "deinit"); @@ -10550,7 +10550,8 @@ static int wpa_driver_nl80211_leave_mesh(void *priv) "nl80211: mesh leave request send successfully"); } - if (wpa_driver_nl80211_set_mode(drv->first_bss, + if (drv->start_mode_sta && + wpa_driver_nl80211_set_mode(drv->first_bss, NL80211_IFTYPE_STATION)) { wpa_printf(MSG_INFO, "nl80211: Failed to set interface into station mode"); diff --git a/src/drivers/driver_nl80211.h b/src/drivers/driver_nl80211.h index 945015bf2..9d61c1d69 100644 --- a/src/drivers/driver_nl80211.h +++ b/src/drivers/driver_nl80211.h @@ -149,7 +149,7 @@ struct wpa_driver_nl80211_data { unsigned int ignore_next_local_disconnect:1; unsigned int ignore_next_local_deauth:1; unsigned int hostapd:1; - unsigned int start_mode_ap:1; + unsigned int start_mode_sta:1; unsigned int start_iface_up:1; unsigned int test_use_roc_tx:1; unsigned int ignore_deauth_event:1;