From patchwork Wed Aug 7 10:08:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peer, Ilan" X-Patchwork-Id: 265470 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) by ozlabs.org (Postfix) with ESMTP id 644FB2C00DA for ; Wed, 7 Aug 2013 21:06:57 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 250B417C0BC; Wed, 7 Aug 2013 07:06:55 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vOuCGqLN2fQK; Wed, 7 Aug 2013 07:06:54 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 6F30E17C045; Wed, 7 Aug 2013 07:06:46 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 3DE7E17C045 for ; Wed, 7 Aug 2013 07:06:45 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gKqwc3ri5RvH for ; Wed, 7 Aug 2013 07:06:39 -0400 (EDT) Received: from mga03.intel.com (mga03.intel.com [143.182.124.21]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 733FD17C03C for ; Wed, 7 Aug 2013 07:06:37 -0400 (EDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by azsmga101.ch.intel.com with ESMTP; 07 Aug 2013 04:06:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.89,832,1367996400"; d="scan'208";a="377424377" Received: from ipeer-e6430-1.jer.intel.com ([10.12.217.166]) by fmsmga001.fm.intel.com with ESMTP; 07 Aug 2013 04:06:31 -0700 From: Ilan Peer To: hostap@lists.shmoo.com Subject: [PATCH] nl80211: Do not change type to station on P2P interfaces Date: Wed, 7 Aug 2013 13:08:38 +0300 Message-Id: <1375870125-27991-2-git-send-email-ilan.peer@intel.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1375870125-27991-1-git-send-email-ilan.peer@intel.com> References: <1375870125-27991-1-git-send-email-ilan.peer@intel.com> X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.11 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com 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 --- src/drivers/driver.h | 10 ++++++---- src/drivers/driver_nl80211.c | 19 +++++++++++++++---- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/drivers/driver.h b/src/drivers/driver.h index d78bdd0..a440166 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -2161,8 +2161,9 @@ struct wpa_driver_ops { * Returns: 0 on success, -1 on failure (or if not supported) * * This optional function can be used to disable AP mode related - * configuration and change the driver mode to station mode to allow - * normal station operations like scanning to be completed. + * configuration. If the interface was not dynamically added, + * change the driver mode to station mode to allow normal station + * operations like scanning to be completed. */ int (*deinit_ap)(void *priv); @@ -2171,8 +2172,9 @@ struct wpa_driver_ops { * @priv: Private driver interface data * Returns: 0 on success, -1 on failure (or if not supported) * - * This optional function can be used to disable P2P client mode. It - * can be used to change the interface type back to station mode. + * This optional function can be used to disable P2P client mode. If the + * interface was not dynamically added, change the interface type back + * to station mode. */ int (*deinit_p2p_cli)(void *priv); diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 2f30cda..5737338 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -197,6 +197,7 @@ struct i802_bss { u8 addr[ETH_ALEN]; int freq; + int if_dynamic; void *ctx; struct nl_handle *nl_preq, *nl_mgmt; @@ -4010,15 +4011,14 @@ wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv) #endif /* HOSTAPD */ struct i802_bss *bss = &drv->first_bss; int send_rfkill_event = 0; - int dynamic_if; drv->ifindex = if_nametoindex(bss->ifname); bss->ifindex = drv->ifindex; bss->wdev_id = drv->global->if_add_wdevid; bss->wdev_id_set = drv->global->if_add_wdevid_set; - dynamic_if = drv->ifindex == drv->global->if_add_ifindex; - dynamic_if = dynamic_if || drv->global->if_add_wdevid_set; + bss->if_dynamic = drv->ifindex == drv->global->if_add_ifindex; + bss->if_dynamic = bss->if_dynamic || drv->global->if_add_wdevid_set; drv->global->if_add_wdevid_set = 0; if (wpa_driver_nl80211_capa(drv)) @@ -4028,7 +4028,7 @@ wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv) bss->ifname, drv->phyname); #ifndef HOSTAPD - if (dynamic_if) + if (bss->if_dynamic) nlmode = nl80211_get_ifmode(bss); /* @@ -9530,6 +9530,12 @@ static int wpa_driver_nl80211_deinit_ap(void *priv) if (!is_ap_interface(drv->nlmode)) return -1; 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); } @@ -9552,6 +9558,11 @@ static int wpa_driver_nl80211_deinit_p2p_cli(void *priv) struct wpa_driver_nl80211_data *drv = bss->drv; if (drv->nlmode != NL80211_IFTYPE_P2P_CLIENT) 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); }