From patchwork Mon Jun 3 06:39:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 2650891 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 2C342DF24C for ; Mon, 3 Jun 2013 07:04:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751392Ab3FCHEd (ORCPT ); Mon, 3 Jun 2013 03:04:33 -0400 Received: from diserzione.investici.org ([82.221.99.153]:37497 "EHLO diserzione.investici.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750861Ab3FCHEc (ORCPT ); Mon, 3 Jun 2013 03:04:32 -0400 X-Greylist: delayed 1361 seconds by postgrey-1.27 at vger.kernel.org; Mon, 03 Jun 2013 03:04:32 EDT Received: from [82.221.99.153] (diserzione [82.221.99.153]) (Authenticated sender: ordex@autistici.org) by localhost (Postfix) with ESMTPSA id 4CCC8181349; Mon, 3 Jun 2013 06:41:50 +0000 (UTC) X-DKIM: Sendmail DKIM Filter v2.8.2 diserzione.investici.org 4CCC8181349 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1370241711; bh=Ioc4dU065GTC2L/rpwmso3mY3dm+uNtJMLvCu3FdM8I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=c9hWsP8lj9+NIEiB3MWVrDa/uy8ZFjiinT6YXvlbKX659eGid+uqQnIudiH4go7fP nXN/JqV8GKdWx9B9WZmxh2wf59Q2ZFH8oHokk4Rv9pZuza9pDUxD2UWD00+xLuCrTy DBGJu28ZXCBnrQAbi9tINVnbS/mq+EHYgE481ZEY= From: Antonio Quartulli To: Johannes Berg Cc: linux-wireless@vger.kernel.org, Antonio Quartulli Subject: [PATCH 2/2] mac80211: in mgmt_tx use the current channel if none has been specified Date: Mon, 3 Jun 2013 08:39:47 +0200 Message-Id: <1370241587-2609-2-git-send-email-ordex@autistici.org> X-Mailer: git-send-email 1.8.1.5 In-Reply-To: <1370241587-2609-1-git-send-email-ordex@autistici.org> References: <1370241587-2609-1-git-send-email-ordex@autistici.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Antonio Quartulli In mgmt_tx, if no channel has been specified via cfg80211, use the current one. If the interface requires offchan (because disconnected or for other reasons) then fail. Signed-off-by: Antonio Quartulli --- net/mac80211/cfg.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 9034da1..e6e41c7 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -2836,6 +2836,13 @@ static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, return -EOPNOTSUPP; } + /* + * configurations requiring offchan cannot work if no channel has been + * specified + */ + if (need_offchan && !chan) + return -EINVAL; + mutex_lock(&local->mtx); /* Check if the operating channel is the requested channel */ @@ -2845,6 +2852,10 @@ static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, rcu_read_lock(); chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); + /* if no channel was specified, use the current one */ + if (chanctx_conf && !chan) + chan = chanctx_conf->def.chan; + if (chanctx_conf) need_offchan = chan != chanctx_conf->def.chan; else @@ -2852,6 +2863,12 @@ static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, rcu_read_unlock(); } + /* at this point a channel should have been chosen */ + if (!chan) { + ret = -EINVAL; + goto out_unlock; + } + if (need_offchan && !offchan) { ret = -EBUSY; goto out_unlock;