From patchwork Mon Apr 22 14:06:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 238542 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "maxx.shmoo.com", Issuer "CA Cert Signing Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 0AF8E2C0128 for ; Tue, 23 Apr 2013 00:07:16 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 420099C18C; Mon, 22 Apr 2013 10:07:13 -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 mrySjaX30nzj; Mon, 22 Apr 2013 10:07:12 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id E64859C198; Mon, 22 Apr 2013 10:07:08 -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 47C449C198 for ; Mon, 22 Apr 2013 10:07:07 -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 46yUqQ+N2NrW for ; Mon, 22 Apr 2013 10:07:02 -0400 (EDT) Received: from sipsolutions.net (he.sipsolutions.net [78.46.109.217]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (Client did not present a certificate) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id 7B3E79C18C for ; Mon, 22 Apr 2013 10:07:02 -0400 (EDT) Received: by sipsolutions.net with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1UUHOW-0006Js-23; Mon, 22 Apr 2013 16:07:00 +0200 From: Johannes Berg To: hostap@lists.shmoo.com Subject: [PATCH] nl80211: explicitly pass mode setting when initialising interface Date: Mon, 22 Apr 2013 16:06:54 +0200 Message-Id: <1366639614-5466-1-git-send-email-johannes@sipsolutions.net> X-Mailer: git-send-email 1.8.0 Cc: Johannes Berg 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 From: Johannes Berg 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 --- 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; }