2012-06-19 21:59:41

by Will Hawkins

[permalink] [raw]
Subject: [PATCH 0/3 v4] mac80211: add support for userspace to handle auth frames on adhoc ifaces

Hello!

I am sending along 3 patches to add support for user space applications
to register for authentication frames on adhoc interfaces. These are
revisions to a previous patch that I submitted to accomplish the same
thing.

Patch 1/3 adds support for tracking whether userspace applications
are registered for authentication frames received by an adhoc
interface. This count is used in Patch 2/3 to determine
if an "open system" authentication frame is sent when a new
station joins an adhoc network.

Patch 2/3 adds support for checking the registration count
before sending out "open system" authentication frames when a
new station joins an adhoc network. If there are no userspace
applications registered for the authentication frames then
an "open system" authentication frame is broadcast.

Patch 3/3 sets the necessary flags to allow userspace
applications to register for authentication frames on adhoc interfaces.
frames.

As I've said before, I'm still new to this process so I look forward to
your feedback on improving.

Will

Will Hawkins (3):
mac80211: Track auth frame registrations on IBSS ifaces
mac80211: Check auth frame registration count
mac80211: Allow userspace application to register for authentication
frames

net/mac80211/cfg.c | 10 ++++++++++
net/mac80211/ibss.c | 2 +-
net/mac80211/ieee80211_i.h | 1 +
net/mac80211/main.c | 4 +++-
4 files changed, 15 insertions(+), 2 deletions(-)

--
1.7.9.5




2012-06-20 15:12:11

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 1/3] mac80211: Track auth frame registrations on IBSS ifaces

On Wed, 2012-06-20 at 11:00 -0400, Will Hawkins wrote:

> >> Just trying to make sure that it doesn't go negative. I am protecting
> >> against unmatched unregisters.
> >
> > reg is a bool, did you mean "if (ifibss->auth_frame_registrations > 0)"?
>
> Yes, of course I did. :-) Not sure how I missed that.
>
> >
> > in any case, you don't really have to care about unmatched unregisters
> > as cfg80211 tracks all of them anyway.
>
> I will take that check out entirely and resubmit.
>
> Is it proper protocol to resubmit this particular part of the patch or
> the entire set?

You can resend just this one patch as a reply to the original if you
wish, or the entire series (it's short, if it was 20 patches I'd ask you
not to do that :-) )

johannes


2012-06-20 18:02:28

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 0/3 v4] mac80211: add support for userspace to handle auth frames on adhoc ifaces

On Tue, 2012-06-19 at 17:59 -0400, Will Hawkins wrote:
> Hello!
>
> I am sending along 3 patches to add support for user space applications
> to register for authentication frames on adhoc interfaces. These are
> revisions to a previous patch that I submitted to accomplish the same
> thing.
>
> Patch 1/3 adds support for tracking whether userspace applications
> are registered for authentication frames received by an adhoc
> interface. This count is used in Patch 2/3 to determine
> if an "open system" authentication frame is sent when a new
> station joins an adhoc network.
>
> Patch 2/3 adds support for checking the registration count
> before sending out "open system" authentication frames when a
> new station joins an adhoc network. If there are no userspace
> applications registered for the authentication frames then
> an "open system" authentication frame is broadcast.
>
> Patch 3/3 sets the necessary flags to allow userspace
> applications to register for authentication frames on adhoc interfaces.
> frames.

Applied all three. I looked at the code in patch 1 and decided to rework
the code there a little bit to make the flow depend on the frame type,
please check. I also reworded commit messages a bit (mostly to make it
clearer that it's all about IBSS.)

Thanks!

I'd like to see your userspace application btw :-)

johannes


2012-06-20 14:40:39

by Will Hawkins

[permalink] [raw]
Subject: Re: [PATCH 1/3] mac80211: Track auth frame registrations on IBSS ifaces



On 06/20/2012 01:32 AM, Johannes Berg wrote:
> On Tue, 2012-06-19 at 17:59 -0400, Will Hawkins wrote:
>> Track userspace registrations for authentication
>> frames received on an IBSS interface. This field
>> will be used to decide whether or not to send
>> "open system" authentication frames when a new
>> station joins an adhoc network.
>>
>> Signed-off-by: Will Hawkins <[email protected]>
>> ---
>> net/mac80211/cfg.c | 10 ++++++++++
>> net/mac80211/ieee80211_i.h | 1 +
>> 2 files changed, 11 insertions(+)
>>
>> diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
>> index 498c94e..e00a696 100644
>> --- a/net/mac80211/cfg.c
>> +++ b/net/mac80211/cfg.c
>> @@ -2486,6 +2486,16 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
>> u16 frame_type, bool reg)
>> {
>> struct ieee80211_local *local = wiphy_priv(wiphy);
>> + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
>> +
>> + if (sdata->vif.type == NL80211_IFTYPE_ADHOC &&
>> + (frame_type == (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH))) {
>> + struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
>> + if (reg)
>> + ifibss->auth_frame_registrations++;
>> + else if (reg > 0)
>> + ifibss->auth_frame_registrations--;
>
> The "if (reg > 0)" here doesn't seem to make sense?

Just trying to make sure that it doesn't go negative. I am protecting
against unmatched unregisters.

Will

>
> johannes
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>

2012-06-19 21:59:43

by Will Hawkins

[permalink] [raw]
Subject: [PATCH 3/3] mac80211: Allow userspace application to register for authentication frames

Set the necessary flags to allow user space
applications to register for authentication frames
on adhoc interfaces. This is useful for
situations where userspace applications want
to control key negotiation between stations.

Signed-off-by: Will Hawkins <[email protected]>
---
net/mac80211/main.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index d81c178..4467162 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -455,7 +455,9 @@ static const struct ieee80211_txrx_stypes
ieee80211_default_mgmt_stypes[NUM_NL80211_IFTYPES] = {
[NL80211_IFTYPE_ADHOC] = {
.tx = 0xffff,
- .rx = BIT(IEEE80211_STYPE_ACTION >> 4),
+ .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
+ BIT(IEEE80211_STYPE_AUTH >> 4) |
+ BIT(IEEE80211_STYPE_DEAUTH >> 4),
},
[NL80211_IFTYPE_STATION] = {
.tx = 0xffff,
--
1.7.9.5



2012-06-20 15:52:03

by Will Hawkins

[permalink] [raw]
Subject: [PATCH 1/3 v5] mac80211: Track auth frame registrations on IBSS ifaces

Track userspace registrations for authentication
frames received on an IBSS interface. This field
will be used to decide whether or not to send
"open system" authentication frames when a new
station joins an adhoc network.

Signed-off-by: Will Hawkins <[email protected]>
---
net/mac80211/cfg.c | 10 ++++++++++
net/mac80211/ieee80211_i.h | 1 +
2 files changed, 11 insertions(+)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 498c94e..d623ce9 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -2486,6 +2486,16 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
u16 frame_type, bool reg)
{
struct ieee80211_local *local = wiphy_priv(wiphy);
+ struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+
+ if (sdata->vif.type == NL80211_IFTYPE_ADHOC &&
+ (frame_type == (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH))) {
+ struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
+ if (reg)
+ ifibss->auth_frame_registrations++;
+ else
+ ifibss->auth_frame_registrations--;
+ }

if (frame_type != (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ))
return;
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index e6cbf5b..599f9fd 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -508,6 +508,7 @@ struct ieee80211_if_ibss {
bool privacy;

bool control_port;
+ unsigned int auth_frame_registrations;

u8 bssid[ETH_ALEN] __aligned(2);
u8 ssid[IEEE80211_MAX_SSID_LEN];
--
1.7.9.5



2012-06-20 15:00:14

by Will Hawkins

[permalink] [raw]
Subject: Re: [PATCH 1/3] mac80211: Track auth frame registrations on IBSS ifaces



On 06/20/2012 10:43 AM, Johannes Berg wrote:
> On Wed, 2012-06-20 at 10:40 -0400, Will Hawkins wrote:
>>
>> On 06/20/2012 01:32 AM, Johannes Berg wrote:
>>> On Tue, 2012-06-19 at 17:59 -0400, Will Hawkins wrote:
>>>> Track userspace registrations for authentication
>>>> frames received on an IBSS interface. This field
>>>> will be used to decide whether or not to send
>>>> "open system" authentication frames when a new
>>>> station joins an adhoc network.
>>>>
>>>> Signed-off-by: Will Hawkins <[email protected]>
>>>> ---
>>>> net/mac80211/cfg.c | 10 ++++++++++
>>>> net/mac80211/ieee80211_i.h | 1 +
>>>> 2 files changed, 11 insertions(+)
>>>>
>>>> diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
>>>> index 498c94e..e00a696 100644
>>>> --- a/net/mac80211/cfg.c
>>>> +++ b/net/mac80211/cfg.c
>>>> @@ -2486,6 +2486,16 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
>>>> u16 frame_type, bool reg)
>>>> {
>>>> struct ieee80211_local *local = wiphy_priv(wiphy);
>>>> + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
>>>> +
>>>> + if (sdata->vif.type == NL80211_IFTYPE_ADHOC &&
>>>> + (frame_type == (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH))) {
>>>> + struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
>>>> + if (reg)
>>>> + ifibss->auth_frame_registrations++;
>>>> + else if (reg > 0)
>>>> + ifibss->auth_frame_registrations--;
>>>
>>> The "if (reg > 0)" here doesn't seem to make sense?
>>
>> Just trying to make sure that it doesn't go negative. I am protecting
>> against unmatched unregisters.
>
> reg is a bool, did you mean "if (ifibss->auth_frame_registrations > 0)"?

Yes, of course I did. :-) Not sure how I missed that.

>
> in any case, you don't really have to care about unmatched unregisters
> as cfg80211 tracks all of them anyway.

I will take that check out entirely and resubmit.

Is it proper protocol to resubmit this particular part of the patch or
the entire set?

Thanks for your eagle eyes!

Will
>
> johannes
>
>

2012-06-20 14:43:13

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 1/3] mac80211: Track auth frame registrations on IBSS ifaces

On Wed, 2012-06-20 at 10:40 -0400, Will Hawkins wrote:
>
> On 06/20/2012 01:32 AM, Johannes Berg wrote:
> > On Tue, 2012-06-19 at 17:59 -0400, Will Hawkins wrote:
> >> Track userspace registrations for authentication
> >> frames received on an IBSS interface. This field
> >> will be used to decide whether or not to send
> >> "open system" authentication frames when a new
> >> station joins an adhoc network.
> >>
> >> Signed-off-by: Will Hawkins <[email protected]>
> >> ---
> >> net/mac80211/cfg.c | 10 ++++++++++
> >> net/mac80211/ieee80211_i.h | 1 +
> >> 2 files changed, 11 insertions(+)
> >>
> >> diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
> >> index 498c94e..e00a696 100644
> >> --- a/net/mac80211/cfg.c
> >> +++ b/net/mac80211/cfg.c
> >> @@ -2486,6 +2486,16 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
> >> u16 frame_type, bool reg)
> >> {
> >> struct ieee80211_local *local = wiphy_priv(wiphy);
> >> + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
> >> +
> >> + if (sdata->vif.type == NL80211_IFTYPE_ADHOC &&
> >> + (frame_type == (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH))) {
> >> + struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
> >> + if (reg)
> >> + ifibss->auth_frame_registrations++;
> >> + else if (reg > 0)
> >> + ifibss->auth_frame_registrations--;
> >
> > The "if (reg > 0)" here doesn't seem to make sense?
>
> Just trying to make sure that it doesn't go negative. I am protecting
> against unmatched unregisters.

reg is a bool, did you mean "if (ifibss->auth_frame_registrations > 0)"?

in any case, you don't really have to care about unmatched unregisters
as cfg80211 tracks all of them anyway.

johannes


2012-06-19 21:59:41

by Will Hawkins

[permalink] [raw]
Subject: [PATCH 1/3] mac80211: Track auth frame registrations on IBSS ifaces

Track userspace registrations for authentication
frames received on an IBSS interface. This field
will be used to decide whether or not to send
"open system" authentication frames when a new
station joins an adhoc network.

Signed-off-by: Will Hawkins <[email protected]>
---
net/mac80211/cfg.c | 10 ++++++++++
net/mac80211/ieee80211_i.h | 1 +
2 files changed, 11 insertions(+)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 498c94e..e00a696 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -2486,6 +2486,16 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
u16 frame_type, bool reg)
{
struct ieee80211_local *local = wiphy_priv(wiphy);
+ struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+
+ if (sdata->vif.type == NL80211_IFTYPE_ADHOC &&
+ (frame_type == (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH))) {
+ struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
+ if (reg)
+ ifibss->auth_frame_registrations++;
+ else if (reg > 0)
+ ifibss->auth_frame_registrations--;
+ }

if (frame_type != (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ))
return;
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index e6cbf5b..599f9fd 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -508,6 +508,7 @@ struct ieee80211_if_ibss {
bool privacy;

bool control_port;
+ unsigned int auth_frame_registrations;

u8 bssid[ETH_ALEN] __aligned(2);
u8 ssid[IEEE80211_MAX_SSID_LEN];
--
1.7.9.5



2012-06-19 21:59:42

by Will Hawkins

[permalink] [raw]
Subject: [PATCH 2/3] mac80211: Check auth frame registration count

Check the auth frame registration count before sending
"open system" authentication messages when a new station
registers on a particular adhoc network. This
stops a station from sending out multiple authentication
messages with different authentication algorithms.

Signed-off-by: Will Hawkins <[email protected]>
---
net/mac80211/ibss.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index 725cb4b..ff46ff4 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -279,7 +279,7 @@ static struct sta_info *ieee80211_ibss_finish_sta(struct sta_info *sta,
/* If it fails, maybe we raced another insertion? */
if (sta_info_insert_rcu(sta))
return sta_info_get(sdata, addr);
- if (auth) {
+ if (auth && !sdata->u.ibss.auth_frame_registrations) {
ibss_vdbg("TX Auth SA=%pM DA=%pM BSSID=%pM (auth_transaction=1)\n",
sdata->vif.addr, sdata->u.ibss.bssid, addr);
ieee80211_send_auth(sdata, 1, WLAN_AUTH_OPEN, NULL, 0,
--
1.7.9.5



2012-06-20 05:32:54

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 1/3] mac80211: Track auth frame registrations on IBSS ifaces

On Tue, 2012-06-19 at 17:59 -0400, Will Hawkins wrote:
> Track userspace registrations for authentication
> frames received on an IBSS interface. This field
> will be used to decide whether or not to send
> "open system" authentication frames when a new
> station joins an adhoc network.
>
> Signed-off-by: Will Hawkins <[email protected]>
> ---
> net/mac80211/cfg.c | 10 ++++++++++
> net/mac80211/ieee80211_i.h | 1 +
> 2 files changed, 11 insertions(+)
>
> diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
> index 498c94e..e00a696 100644
> --- a/net/mac80211/cfg.c
> +++ b/net/mac80211/cfg.c
> @@ -2486,6 +2486,16 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
> u16 frame_type, bool reg)
> {
> struct ieee80211_local *local = wiphy_priv(wiphy);
> + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
> +
> + if (sdata->vif.type == NL80211_IFTYPE_ADHOC &&
> + (frame_type == (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH))) {
> + struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
> + if (reg)
> + ifibss->auth_frame_registrations++;
> + else if (reg > 0)
> + ifibss->auth_frame_registrations--;

The "if (reg > 0)" here doesn't seem to make sense?

johannes