[PATCH] nl80211: explicitly pass mode setting when initialising interface

Johannes Berg johannes
Mon Apr 22 07:06:54 PDT 2013


From: Johannes Berg <johannes.berg at intel.com>

When wpa_driver_nl80211_finish_drv_init() is called, require the
caller to explicitly give the new nlmode, or NL80211_IFTYPE_UNSPECIFIED
if it shouldn't be changed.

Change-Id: Ifd46ae9c7e353d4d3e18988e4dd6cd267d647163
Signed-hostap: Johannes Berg <johannes.berg at intel.com>
---
 src/drivers/driver_nl80211.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 3b0dba4..88956d9 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -299,7 +299,8 @@ static void wpa_driver_nl80211_scan_timeout(void *eloop_ctx,
 static int wpa_driver_nl80211_set_mode(struct i802_bss *bss,
 				       enum nl80211_iftype nlmode);
 static int
-wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv);
+wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv,
+				   enum nl80211_iftype nlmode);
 static int wpa_driver_nl80211_mlme(struct wpa_driver_nl80211_data *drv,
 				   const u8 *addr, int cmd, u16 reason_code,
 				   int local_state_change);
@@ -859,7 +860,10 @@ static int wpa_driver_nl80211_own_ifindex(struct wpa_driver_nl80211_data *drv,
 		drv->first_bss.ifindex = if_nametoindex(drv->first_bss.ifname);
 		wpa_printf(MSG_DEBUG, "nl80211: Update ifindex for a removed "
 			   "interface");
-		wpa_driver_nl80211_finish_drv_init(drv);
+		wpa_driver_nl80211_finish_drv_init(drv,
+			drv->ifindex != drv->global->if_add_ifindex ?
+				NL80211_IFTYPE_STATION :
+				NL80211_IFTYPE_UNSPECIFIED);
 		return 1;
 	}
 
@@ -3314,7 +3318,10 @@ static void * wpa_driver_nl80211_init(void *ctx, const char *ifname,
 		os_free(rcfg);
 	}
 
-	if (wpa_driver_nl80211_finish_drv_init(drv))
+	if (wpa_driver_nl80211_finish_drv_init(drv,
+			drv->ifindex != drv->global->if_add_ifindex ?
+				NL80211_IFTYPE_STATION :
+				NL80211_IFTYPE_UNSPECIFIED);
 		goto failed;
 
 	drv->eapol_tx_sock = socket(PF_PACKET, SOCK_DGRAM, 0);
@@ -3609,7 +3616,8 @@ static void wpa_driver_nl80211_send_rfkill(void *eloop_ctx, void *timeout_ctx)
 
 
 static int
-wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv)
+wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv,
+				   enum nl80211_iftype nlmode)
 {
 	struct i802_bss *bss = &drv->first_bss;
 	int send_rfkill_event = 0;
@@ -3623,10 +3631,10 @@ wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv)
 	 * dynamically added interface (e.g., P2P) that was already configured
 	 * with proper iftype.
 	 */
-	if (drv->ifindex != drv->global->if_add_ifindex &&
-	    wpa_driver_nl80211_set_mode(bss, NL80211_IFTYPE_STATION) < 0) {
+	if (nlmode != NL80211_IFTYPE_UNSPECIFIED &&
+	    wpa_driver_nl80211_set_mode(bss, nlmode) < 0) {
 		wpa_printf(MSG_ERROR, "nl80211: Could not configure driver to "
-			   "use managed mode");
+			   "use mode %d", nlmode);
 		return -1;
 	}
 
-- 
1.8.0




More information about the Hostap mailing list