Linux wireless drivers development
 help / color / mirror / Atom feed
From: "John W. Linville" <linville@tuxdriver.com>
To: linux-wireless@vger.kernel.org
Cc: Johannes Berg <johannes@sipsolutions.net>,
	Gilboa Davara <gilboad@gmail.com>,
	"John W. Linville" <linville@tuxdriver.com>
Subject: [PATCH] cfg80211: allow channel change on monitor i/f if no active i/f present
Date: Mon,  3 Oct 2011 16:23:33 -0400	[thread overview]
Message-ID: <1317673413-1467-1-git-send-email-linville@tuxdriver.com> (raw)

This is the latest attempt to address the long-standing complaint from
the aircrack-ng folks about being unable to change the channel on
monitor interfaces.  This version checks for the existance of other
"active" interfaces and refuses the channel change if they are present.

	https://bugzilla.redhat.com/show_bug.cgi?id=654344

Signed-off-by: John W. Linville <linville@tuxdriver.com>
---
 net/wireless/chan.c |   29 +++++++++++++++++++++++++++--
 1 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/net/wireless/chan.c b/net/wireless/chan.c
index 17cd0c0..d4add34 100644
--- a/net/wireless/chan.c
+++ b/net/wireless/chan.c
@@ -81,10 +81,32 @@ int cfg80211_set_freq(struct cfg80211_registered_device *rdev,
 		      enum nl80211_channel_type channel_type)
 {
 	struct ieee80211_channel *chan;
-	int result;
+	int result, active_intf_present = 0;
+	struct wireless_dev *mon_wdev = NULL;
+
+	if (wdev && wdev->iftype == NL80211_IFTYPE_MONITOR) {
+		mon_wdev = wdev;
+
+		ASSERT_RDEV_LOCK(rdev);
+
+		/* rdev->devlist_mtx locked by callers */
+		list_for_each_entry(wdev, &rdev->netdev_list, list) {
+			if (wdev && wdev != mon_wdev &&
+			    (wdev->iftype == NL80211_IFTYPE_ADHOC ||
+			     wdev->iftype == NL80211_IFTYPE_AP ||
+			     wdev->iftype == NL80211_IFTYPE_AP_VLAN ||
+			     wdev->iftype == NL80211_IFTYPE_MESH_POINT ||
+			     wdev->iftype == NL80211_IFTYPE_P2P_GO)) {
+				active_intf_present = 1;
+				break;
+			}
+		}
+
+		if (active_intf_present)
+			return -EINVAL;
 
-	if (wdev && wdev->iftype == NL80211_IFTYPE_MONITOR)
 		wdev = NULL;
+	}
 
 	if (wdev) {
 		ASSERT_WDEV_LOCK(wdev);
@@ -131,5 +153,8 @@ int cfg80211_set_freq(struct cfg80211_registered_device *rdev,
 	if (wdev)
 		wdev->channel = chan;
 
+	if (mon_wdev)
+		mon_wdev->channel = chan;
+
 	return 0;
 }
-- 
1.7.4.4


             reply	other threads:[~2011-10-03 20:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-03 20:23 John W. Linville [this message]
2011-10-04  6:37 ` [PATCH] cfg80211: allow channel change on monitor i/f if no active i/f present Johannes Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1317673413-1467-1-git-send-email-linville@tuxdriver.com \
    --to=linville@tuxdriver.com \
    --cc=gilboad@gmail.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox