diff mbox

[RFC] cfg80211: report monitor interface channel via wext when possible

Message ID 1295655098-17534-1-git-send-email-fercerpav@gmail.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Paul Fertser Jan. 22, 2011, 12:11 a.m. UTC
None
diff mbox

Patch

diff --git a/net/wireless/chan.c b/net/wireless/chan.c
index 17cd0c0..869e764 100644
--- a/net/wireless/chan.c
+++ b/net/wireless/chan.c
@@ -81,6 +81,7 @@  int cfg80211_set_freq(struct cfg80211_registered_device *rdev,
 		      enum nl80211_channel_type channel_type)
 {
 	struct ieee80211_channel *chan;
+	struct wireless_dev *passed_wdev = wdev;
 	int result;
 
 	if (wdev && wdev->iftype == NL80211_IFTYPE_MONITOR)
@@ -128,8 +129,8 @@  int cfg80211_set_freq(struct cfg80211_registered_device *rdev,
 	if (result)
 		return result;
 
-	if (wdev)
-		wdev->channel = chan;
+	if (passed_wdev)
+		passed_wdev->channel = chan;
 
 	return 0;
 }
diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c
index 3e5dbd4..aa637e6 100644
--- a/net/wireless/wext-compat.c
+++ b/net/wireless/wext-compat.c
@@ -819,6 +819,8 @@  int cfg80211_wext_giwfreq(struct net_device *dev,
 			  struct iw_freq *freq, char *extra)
 {
 	struct wireless_dev *wdev = dev->ieee80211_ptr;
+	struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
+	int result;
 
 	switch (wdev->iftype) {
 	case NL80211_IFTYPE_STATION:
@@ -828,6 +830,16 @@  int cfg80211_wext_giwfreq(struct net_device *dev,
 	default:
 		if (!wdev->channel)
 			return -EINVAL;
+		/* The actual working channel might have been changed, verify it
+		 * by re-setting pretending we want to set channel for a monitor
+		 * interface */
+		result = rdev->ops->set_channel(&rdev->wiphy, NULL,
+						wdev->channel,
+						NL80211_CHAN_NO_HT);
+		if (result) {
+			wdev->channel = NULL;
+			return -EINVAL;
+		}
 		freq->m = wdev->channel->center_freq;
 		freq->e = 6;
 		return 0;