* [PATCH] cfg80211: allow channel change on monitor i/f if no active i/f present
@ 2011-10-03 20:23 John W. Linville
2011-10-04 6:37 ` Johannes Berg
0 siblings, 1 reply; 2+ messages in thread
From: John W. Linville @ 2011-10-03 20:23 UTC (permalink / raw)
To: linux-wireless; +Cc: Johannes Berg, Gilboa Davara, John W. Linville
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
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] cfg80211: allow channel change on monitor i/f if no active i/f present
2011-10-03 20:23 [PATCH] cfg80211: allow channel change on monitor i/f if no active i/f present John W. Linville
@ 2011-10-04 6:37 ` Johannes Berg
0 siblings, 0 replies; 2+ messages in thread
From: Johannes Berg @ 2011-10-04 6:37 UTC (permalink / raw)
To: John W. Linville; +Cc: linux-wireless, Gilboa Davara
On Mon, 2011-10-03 at 16:23 -0400, John W. Linville wrote:
> 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
Thanks for working on this.
> @@ -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;
> + }
This really isn't the problem though, mac80211 will correctly treat
monitor interfaces already, and drivers are pretty much expected to do
the same thing.
> @@ -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;
This is the issue, it doesn't work. I'm finally getting to a point where
I'm not sure I care any more though, if the people who user monitor mode
are happy with this patch and don't care about getting the wrong results
then who am I to complain?
Maybe you should respin this patch with just the last bit. The checking
above is pretty much useless. Also please add *huge* warnings to it that
this *will* give the wrong results.
Alternatively, it could be fixed up properly, but I think to do that we
need a cfg80211 get_channel op to ask mac80211 what channel it really is
using. Not that this will help much once we go multi-channel :-)
johannes
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-10-04 6:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-03 20:23 [PATCH] cfg80211: allow channel change on monitor i/f if no active i/f present John W. Linville
2011-10-04 6:37 ` Johannes Berg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox