nl80211: Do not change type to station on P2P interfaces

It is possible that when trying to remove a dynamically added interface,
changing its type to station mode is not possible (since the kernel does
not support so in its interface combinations).

Since P2P interfaces are always dynamically added, avoid changing their
type to station in the deinit_ap() and deinit_p2p_client() nl80211
callbacks, assuming that the interface is about to be removed.

Signed-hostap: Ilan Peer <ilan.peer@intel.com>
This commit is contained in:
Ilan Peer 2013-08-25 10:20:54 +03:00 committed by Jouni Malinen
parent e0591c3cfe
commit 60b13c2017
2 changed files with 26 additions and 8 deletions

View file

@ -2161,8 +2161,9 @@ struct wpa_driver_ops {
* Returns: 0 on success, -1 on failure (or if not supported) * Returns: 0 on success, -1 on failure (or if not supported)
* *
* This optional function can be used to disable AP mode related * This optional function can be used to disable AP mode related
* configuration and change the driver mode to station mode to allow * configuration. If the interface was not dynamically added,
* normal station operations like scanning to be completed. * change the driver mode to station mode to allow normal station
* operations like scanning to be completed.
*/ */
int (*deinit_ap)(void *priv); int (*deinit_ap)(void *priv);
@ -2171,8 +2172,9 @@ struct wpa_driver_ops {
* @priv: Private driver interface data * @priv: Private driver interface data
* Returns: 0 on success, -1 on failure (or if not supported) * Returns: 0 on success, -1 on failure (or if not supported)
* *
* This optional function can be used to disable P2P client mode. It * This optional function can be used to disable P2P client mode. If the
* can be used to change the interface type back to station mode. * interface was not dynamically added, change the interface type back
* to station mode.
*/ */
int (*deinit_p2p_cli)(void *priv); int (*deinit_p2p_cli)(void *priv);

View file

@ -197,6 +197,7 @@ struct i802_bss {
u8 addr[ETH_ALEN]; u8 addr[ETH_ALEN];
int freq; int freq;
int if_dynamic;
void *ctx; void *ctx;
struct nl_handle *nl_preq, *nl_mgmt; struct nl_handle *nl_preq, *nl_mgmt;
@ -4012,15 +4013,14 @@ wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv)
#endif /* HOSTAPD */ #endif /* HOSTAPD */
struct i802_bss *bss = &drv->first_bss; struct i802_bss *bss = &drv->first_bss;
int send_rfkill_event = 0; int send_rfkill_event = 0;
int dynamic_if;
drv->ifindex = if_nametoindex(bss->ifname); drv->ifindex = if_nametoindex(bss->ifname);
bss->ifindex = drv->ifindex; bss->ifindex = drv->ifindex;
bss->wdev_id = drv->global->if_add_wdevid; bss->wdev_id = drv->global->if_add_wdevid;
bss->wdev_id_set = drv->global->if_add_wdevid_set; bss->wdev_id_set = drv->global->if_add_wdevid_set;
dynamic_if = drv->ifindex == drv->global->if_add_ifindex; bss->if_dynamic = drv->ifindex == drv->global->if_add_ifindex;
dynamic_if = dynamic_if || drv->global->if_add_wdevid_set; bss->if_dynamic = bss->if_dynamic || drv->global->if_add_wdevid_set;
drv->global->if_add_wdevid_set = 0; drv->global->if_add_wdevid_set = 0;
if (wpa_driver_nl80211_capa(drv)) if (wpa_driver_nl80211_capa(drv))
@ -4030,7 +4030,7 @@ wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv)
bss->ifname, drv->phyname); bss->ifname, drv->phyname);
#ifndef HOSTAPD #ifndef HOSTAPD
if (dynamic_if) if (bss->if_dynamic)
nlmode = nl80211_get_ifmode(bss); nlmode = nl80211_get_ifmode(bss);
/* /*
@ -9540,6 +9540,14 @@ static int wpa_driver_nl80211_deinit_ap(void *priv)
if (!is_ap_interface(drv->nlmode)) if (!is_ap_interface(drv->nlmode))
return -1; return -1;
wpa_driver_nl80211_del_beacon(drv); wpa_driver_nl80211_del_beacon(drv);
/*
* If the P2P GO interface was dynamically added, then it is
* possible that the interface change to station is not possible.
*/
if (drv->nlmode == NL80211_IFTYPE_P2P_GO && bss->if_dynamic)
return 0;
return wpa_driver_nl80211_set_mode(priv, NL80211_IFTYPE_STATION); return wpa_driver_nl80211_set_mode(priv, NL80211_IFTYPE_STATION);
} }
@ -9562,6 +9570,14 @@ static int wpa_driver_nl80211_deinit_p2p_cli(void *priv)
struct wpa_driver_nl80211_data *drv = bss->drv; struct wpa_driver_nl80211_data *drv = bss->drv;
if (drv->nlmode != NL80211_IFTYPE_P2P_CLIENT) if (drv->nlmode != NL80211_IFTYPE_P2P_CLIENT)
return -1; return -1;
/*
* If the P2P Client interface was dynamically added, then it is
* possible that the interface change to station is not possible.
*/
if (bss->if_dynamic)
return 0;
return wpa_driver_nl80211_set_mode(priv, NL80211_IFTYPE_STATION); return wpa_driver_nl80211_set_mode(priv, NL80211_IFTYPE_STATION);
} }