Skip to contentSkip to conversation

mac80211: add support for userspace to handle auth frames on adhoc ifaces

PATCH Superseded Will Hawkins 2 participants 11 messages Jun 19, 2012 – Jun 20, 2012 mac80211

lore
Share & tools
lore
#0 lore raw

v4 cover 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(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v4 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.

---
 net/mac80211/cfg.c         |   10 ++++++++++
 net/mac80211/ieee80211_i.h |    1 +
 2 files changed, 11 insertions(+)
net/mac80211/cfg.c +10 -0
index 498c94e..e00a696 100644
@@ -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;
net/mac80211/ieee80211_i.h +1 -0
index e6cbf5b..599f9fd 100644
@@ -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];
Signature · 1 line
1.7.9.5
maintainer
#2 lore raw

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

Quoted 19 lines · Will Hawkins

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.

---
 net/mac80211/cfg.c         |   10 ++++++++++
 net/mac80211/ieee80211_i.h |    1 +
 2 files changed, 11 insertions(+)
net/mac80211/cfg.c +0 -0
index 498c94e..e00a696 100644
@@ -2486,6 +2486,16 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
 					  u16 frame_type, bool reg)
 {

net/mac80211/cfg.c static void ieee80211_mgmt_frame_register(struct wiphy *wiphy, · line 2497

Quoted 10 lines
net/mac80211/cfg.c +9 -0
 	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

#3 lore raw

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

Quoted 24 lines · Johannes Berg
Quoted 23 lines · Will Hawkins

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.

---
 net/mac80211/cfg.c         |   10 ++++++++++
 net/mac80211/ieee80211_i.h |    1 +
 2 files changed, 11 insertions(+)
net/mac80211/cfg.c +3 -0
index 498c94e..e00a696 100644
@@ -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 && 
Quoted 8 lines

net/mac80211/cfg.c static void ieee80211_mgmt_frame_register(struct wiphy *wiphy, · line 2497

Quoted 6 lines
net/mac80211/cfg.c +6 -0
+	    (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

Quoted 8 lines

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

maintainer
#4 lore raw

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

Quoted 35 lines · Will Hawkins
Quoted 24 lines · Johannes Berg
Quoted 23 lines · Will Hawkins

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.

---
 net/mac80211/cfg.c         |   10 ++++++++++
 net/mac80211/ieee80211_i.h |    1 +
 2 files changed, 11 insertions(+)
net/mac80211/cfg.c +3 -0
index 498c94e..e00a696 100644
@@ -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 && 
Quoted 8 lines

net/mac80211/cfg.c static void ieee80211_mgmt_frame_register(struct wiphy *wiphy, · line 2497

Quoted 6 lines
net/mac80211/cfg.c +6 -0
+	    (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?

Quoted 2 lines

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

#5 lore raw

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

Quoted 36 lines · Johannes Berg
Quoted 35 lines · Will Hawkins
Quoted 32 lines · Johannes Berg
Quoted 19 lines · Will Hawkins

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.

---
 net/mac80211/cfg.c         |   10 ++++++++++
 net/mac80211/ieee80211_i.h |    1 +
 2 files changed, 11 insertions(+)
net/mac80211/cfg.c +0 -0
index 498c94e..e00a696 100644
@@ -2486,6 +2486,16 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
 					  u16 frame_type, bool reg)
 {

net/mac80211/cfg.c static void ieee80211_mgmt_frame_register(struct wiphy *wiphy, · line 2497

Quoted 10 lines
net/mac80211/cfg.c +9 -0
 	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?

Quoted 4 lines
Quoted 2 lines

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.

Quoted 3 lines

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

Quoted 4 lines

johannes

maintainer
#6 lore raw

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

Quoted 8 lines · Will Hawkins
Quoted 4 lines
Quoted 2 lines

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.

Quoted 1 line
Quoted 7 lines
Quoted 2 lines

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

#7 lore raw

PATCH v4 2/3 mac80211: Check auth frame registration count

In reply to Will Hawkins

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.

---
 net/mac80211/ibss.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/ibss.c +1 -1
index 725cb4b..ff46ff4 100644
@@ -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,
Signature · 1 line
1.7.9.5
#8 lore raw

PATCH v4 3/3 mac80211: Allow userspace application to register for authentication frames

In reply to Will Hawkins

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.

---
 net/mac80211/main.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/mac80211/main.c +3 -1
index d81c178..4467162 100644
@@ -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,
Signature · 1 line
1.7.9.5
#9 lore raw

PATCH v5 1/3 mac80211: Track auth frame registrations on IBSS ifaces

In reply to Will Hawkins

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.

---
 net/mac80211/cfg.c         |   10 ++++++++++
 net/mac80211/ieee80211_i.h |    1 +
 2 files changed, 11 insertions(+)
net/mac80211/cfg.c +10 -0
index 498c94e..d623ce9 100644
@@ -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;
net/mac80211/ieee80211_i.h +1 -0
index e6cbf5b..599f9fd 100644
@@ -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];
Signature · 1 line
1.7.9.5
maintainer
#10 lore raw
In reply to Will Hawkins
Quoted 19 lines · Will Hawkins

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.

Quoted 3 lines

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