2008-12-29 16:25:27

by Ville Nuorvala

[permalink] [raw]
Subject: [PATCH] mac80211: Add IWSPY support to mac80211 stack

The IWSPY ioctls and netlink events were supported in the old ieee80211
stack. This patch adds them to mac80211.

Signed-off-by: Ville Nuorvala <[email protected]>
---
net/mac80211/ieee80211_i.h | 3 +++
net/mac80211/iface.c | 3 +++
net/mac80211/rx.c | 38 ++++++++++++++++++++++++++++++++++++++
net/mac80211/wext.c | 8 ++++----
4 files changed, 48 insertions(+), 4 deletions(-)

diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 117718b..cdfbea5 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -431,6 +431,9 @@ struct ieee80211_sub_if_data {
u32 mntr_flags;
} u;

+ struct iw_public_data wireless_data;
+ struct iw_spy_data spy_data;
+
#ifdef CONFIG_MAC80211_DEBUGFS
struct dentry *debugfsdir;
union {
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 2c7a87d..128e374 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -778,6 +778,9 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
/* setup type-dependent data */
ieee80211_setup_sdata(sdata, type);

+ sdata->wireless_data.spy_data = &sdata->spy_data;
+ ndev->wireless_data = &sdata->wireless_data;
+
ret = register_netdevice(ndev);
if (ret)
goto fail;
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 384cb3b..f73e245 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1926,6 +1926,41 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata,
return 1;
}

+static void ieee80211_rx_qual_report(struct ieee80211_sub_if_data *sdata,
+ struct ieee80211_hdr *hdr,
+ struct ieee80211_rx_status *status)
+
+{
+#ifdef IW_WIRELESS_SPY /* defined in iw_handler.h */
+ /* If spy monitoring on */
+ if (sdata->spy_data.spy_number > 0) {
+ struct iw_quality wstats;
+
+ wstats.updated = 0;
+ if (status->signal != 0) {
+ wstats.level = status->signal;
+ wstats.updated |= IW_QUAL_LEVEL_UPDATED;
+ } else
+ wstats.updated |= IW_QUAL_LEVEL_INVALID;
+
+ if (status->noise != 0) {
+ wstats.noise = status->noise;
+ wstats.updated |= IW_QUAL_NOISE_UPDATED;
+ } else
+ wstats.updated |= IW_QUAL_NOISE_INVALID;
+
+ if (status->qual != 0) {
+ wstats.qual = status->qual;
+ wstats.updated |= IW_QUAL_QUAL_UPDATED;
+ } else
+ wstats.updated |= IW_QUAL_QUAL_INVALID;
+
+ /* Update spy records */
+ wireless_spy_update(sdata->dev, hdr->addr2, &wstats);
+ }
+#endif /* IW_WIRELESS_SPY */
+}
+
/*
* This is the actual Rx frames handler. as it blongs to Rx path it must
* be called with rcu_read_lock protection.
@@ -1988,6 +2023,9 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
if (!prepares)
continue;

+ /* update signal quality parameters */
+ ieee80211_rx_qual_report(sdata, hdr, status);
+
/*
* frame is destined for this interface, but if it's not
* also for the previous one we handle that after the
diff --git a/net/mac80211/wext.c b/net/mac80211/wext.c
index 48fc6b9..8056fdd 100644
--- a/net/mac80211/wext.c
+++ b/net/mac80211/wext.c
@@ -1084,10 +1084,10 @@ static const iw_handler ieee80211_handler[] =
(iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
(iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
(iw_handler) NULL /* kernel code */, /* SIOCGIWSTATS */
- (iw_handler) NULL, /* SIOCSIWSPY */
- (iw_handler) NULL, /* SIOCGIWSPY */
- (iw_handler) NULL, /* SIOCSIWTHRSPY */
- (iw_handler) NULL, /* SIOCGIWTHRSPY */
+ (iw_handler) iw_handler_set_spy, /* SIOCSIWSPY */
+ (iw_handler) iw_handler_get_spy, /* SIOCGIWSPY */
+ (iw_handler) iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
+ (iw_handler) iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
(iw_handler) ieee80211_ioctl_siwap, /* SIOCSIWAP */
(iw_handler) ieee80211_ioctl_giwap, /* SIOCGIWAP */
(iw_handler) ieee80211_ioctl_siwmlme, /* SIOCSIWMLME */
--
1.6.0.6



2008-12-29 16:28:48

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] mac80211: Add IWSPY support to mac80211 stack

On Mon, 2008-12-29 at 18:25 +0200, Ville Nuorvala wrote:
> The IWSPY ioctls and netlink events were supported in the old ieee80211
> stack. This patch adds them to mac80211.

missing very long explanation as to why this is needed

As far as I can tell, nobody uses iwspy support or could possibly want
it the way it is done.

johannes


Attachments:
signature.asc (836.00 B)
This is a digitally signed message part

2008-12-29 21:06:44

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] mac80211: Add IWSPY support to mac80211 stack

On Mon, 2008-12-29 at 20:23 +0200, Ville Nuorvala wrote:

> to my knowledge it is currently the only way to get a realtime
> indication that the wireless link quality has changed, please correct
> me if I'm wrong.

You should be able to obtain information out of nl80211 about the AP
you're currently associated with, namely via listing the stations.
Currently you can only get rate information, but that's a feature, since
the "quality" information "defined" by wext is anything but defined.

> Such a feature can be used as an early indication that the link is
> going down, and may help prepare a vertical IP layer handover to for
> example 3G or just another WLAN interface. The predictive nature of
> the event allows you (most of the time) to set up the other link
> before the WLAN link is down, which allows a make-before-break
> handover without packet loss. In fact such events are described in the
> IEEE 802.21 Media Independent Handover document. Ideally these events
> might be produced by the 802.11 firmware or at least somewhere lower
> in the stack, but lacking that, it can at least be emulated by the
> IWSPY interface. Also, as an added bonus for using IWSPY, you can
> choose the trigger signal levels yourself and don't have to rely on
> any preset levels chosen by the device manufacturer.

I really really don't like the iwspy interface, it also requires that
you explicitly monitor the AP you're associated to etc. IMHO any such
tool needs something that is more reliable and predictable than iwspy.

> I'm not bringing any new functionality to the wireless stack, I'm just
> reintroducing a feature that got lost when the wireless stack was
> changed.

For good measure, if you ask me!

> Sure a pure netlink interface without any ugly IOCTL hacks would be
> nice, but last time I checked the documentation for nl80211 and
> cfg80211 was nonexistent, and even driver_nl80211.c straight from the
> hostap GIT repository uses WEXT IOCTLs internally for several
> different purposes. To me at least it seems like the nl80211 interface
> is still far from ready. As my resources are currently very limited, I
> don't have time to implement the necessary netlink API and userspace
> tools at the moment. The logical conclusion for me was therefore to
> just use the old WEXT interface for now.

Then can you afford to keep porting the iwspy hack? I really don't want
to see this in the tree, especially not since the implementation is ugly
too by implementing purely wext stuff in the core mac80211 code.

johannes


Attachments:
signature.asc (836.00 B)
This is a digitally signed message part

2008-12-29 18:23:40

by Ville Nuorvala

[permalink] [raw]
Subject: Re: [PATCH] mac80211: Add IWSPY support to mac80211 stack

On Mon, Dec 29, 2008 at 6:29 PM, Johannes Berg
<[email protected]> wrote:
> On Mon, 2008-12-29 at 18:25 +0200, Ville Nuorvala wrote:
>> The IWSPY ioctls and netlink events were supported in the old ieee80211
>> stack. This patch adds them to mac80211.
>
> missing very long explanation as to why this is needed

Hello Johannes,

to my knowledge it is currently the only way to get a realtime
indication that the wireless link quality has changed, please correct
me if I'm wrong.

Such a feature can be used as an early indication that the link is
going down, and may help prepare a vertical IP layer handover to for
example 3G or just another WLAN interface. The predictive nature of
the event allows you (most of the time) to set up the other link
before the WLAN link is down, which allows a make-before-break
handover without packet loss. In fact such events are described in the
IEEE 802.21 Media Independent Handover document. Ideally these events
might be produced by the 802.11 firmware or at least somewhere lower
in the stack, but lacking that, it can at least be emulated by the
IWSPY interface. Also, as an added bonus for using IWSPY, you can
choose the trigger signal levels yourself and don't have to rely on
any preset levels chosen by the device manufacturer.

> As far as I can tell, nobody uses iwspy support or could possibly want
> it the way it is done.

The IOCTL interface is horrible, but it's already there and there is a
tool that supports it; iwspy.

I'm not bringing any new functionality to the wireless stack, I'm just
reintroducing a feature that got lost when the wireless stack was
changed.

Sure a pure netlink interface without any ugly IOCTL hacks would be
nice, but last time I checked the documentation for nl80211 and
cfg80211 was nonexistent, and even driver_nl80211.c straight from the
hostap GIT repository uses WEXT IOCTLs internally for several
different purposes. To me at least it seems like the nl80211 interface
is still far from ready. As my resources are currently very limited, I
don't have time to implement the necessary netlink API and userspace
tools at the moment. The logical conclusion for me was therefore to
just use the old WEXT interface for now.

Regards,
Ville

2009-01-09 12:13:09

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH] mac80211: Add IWSPY support to mac80211 stack

"Ville Nuorvala" <[email protected]> writes:

> On Mon, Dec 29, 2008 at 6:29 PM, Johannes Berg
> <[email protected]> wrote:
>> On Mon, 2008-12-29 at 18:25 +0200, Ville Nuorvala wrote:
>>> The IWSPY ioctls and netlink events were supported in the old ieee80211
>>> stack. This patch adds them to mac80211.
>>
>> missing very long explanation as to why this is needed
>
> Hello Johannes,
>
> to my knowledge it is currently the only way to get a realtime
> indication that the wireless link quality has changed, please correct
> me if I'm wrong.

Last fall there was a discussion about roaming in mac80211:

http://markmail.org/message/ml4bjiyd6a26he6x

So we are working on support for quality events, just a bit slowly :/

> Such a feature can be used as an early indication that the link is
> going down, and may help prepare a vertical IP layer handover to for
> example 3G or just another WLAN interface.

I didn't even think about vertical handovers, thanks for pointing it
out. I will keep this in mind.

>> As far as I can tell, nobody uses iwspy support or could possibly want
>> it the way it is done.
>
> The IOCTL interface is horrible, but it's already there and there is a
> tool that supports it; iwspy.
>
> I'm not bringing any new functionality to the wireless stack, I'm just
> reintroducing a feature that got lost when the wireless stack was
> changed.

I'm with Johannes here, let's forget iwspy and do it properly with
nl80211.

--
Kalle Valo