linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: John Linville <linville@tuxdriver.com>
Cc: linux-wireless@vger.kernel.org
Subject: [PATCH 11/12] mac80211: send unexpected 4addr event
Date: Fri, 04 Nov 2011 11:18:20 +0100	[thread overview]
Message-ID: <20111104101945.533357720@sipsolutions.net> (raw)
In-Reply-To: 20111104101809.711636760@sipsolutions.net

From: Johannes Berg <johannes.berg@intel.com>

Implement the cfg80211 notification but only send
one event per associated station to avoid having
tons of events if the station thinks it should be
allowed to use 4addr frames but it isn't.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 net/mac80211/rx.c       |   24 +++++++++++++++++-------
 net/mac80211/sta_info.h |    8 ++++++++
 2 files changed, 25 insertions(+), 7 deletions(-)

--- a/net/mac80211/rx.c	2011-11-03 14:17:00.000000000 +0100
+++ b/net/mac80211/rx.c	2011-11-03 14:25:14.000000000 +0100
@@ -1330,15 +1330,20 @@ ieee80211_rx_h_sta_process(struct ieee80
 
 		/*
 		 * If we receive a 4-addr nullfunc frame from a STA
-		 * that was not moved to a 4-addr STA vlan yet, drop
-		 * the frame to the monitor interface, to make sure
-		 * that hostapd sees it
+		 * that was not moved to a 4-addr STA vlan yet send
+		 * the event to userspace and for older hostapd drop
+		 * the frame to the monitor interface.
 		 */
 		if (ieee80211_has_a4(hdr->frame_control) &&
 		    (rx->sdata->vif.type == NL80211_IFTYPE_AP ||
 		     (rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
-		      !rx->sdata->u.vlan.sta)))
+		      !rx->sdata->u.vlan.sta))) {
+			if (!test_and_set_sta_flag(sta, WLAN_STA_4ADDR_EVENT))
+				cfg80211_rx_unexpected_4addr_frame(
+					rx->sdata->dev, sta->sta.addr,
+					GFP_ATOMIC);
 			return RX_DROP_MONITOR;
+		}
 		/*
 		 * Update counter and free packet here to avoid
 		 * counting this as a dropped packed.
@@ -2017,12 +2022,17 @@ ieee80211_rx_h_data(struct ieee80211_rx_
 		return RX_DROP_MONITOR;
 
 	/*
-	 * Allow the cooked monitor interface of an AP to see 4-addr frames so
-	 * that a 4-addr station can be detected and moved into a separate VLAN
+	 * Send unexpected-4addr-frame event to hostapd. For older versions,
+	 * also drop the frame to cooked monitor interfaces.
 	 */
 	if (ieee80211_has_a4(hdr->frame_control) &&
-	    sdata->vif.type == NL80211_IFTYPE_AP)
+	    sdata->vif.type == NL80211_IFTYPE_AP) {
+		if (rx->sta &&
+		    !test_and_set_sta_flag(rx->sta, WLAN_STA_4ADDR_EVENT))
+			cfg80211_rx_unexpected_4addr_frame(
+				rx->sdata->dev, rx->sta->sta.addr, GFP_ATOMIC);
 		return RX_DROP_MONITOR;
+	}
 
 	err = __ieee80211_data_to_8023(rx, &port_control);
 	if (unlikely(err))
--- a/net/mac80211/sta_info.h	2011-11-03 13:48:28.000000000 +0100
+++ b/net/mac80211/sta_info.h	2011-11-03 14:20:15.000000000 +0100
@@ -52,6 +52,7 @@
  *	unblocks the station.
  * @WLAN_STA_SP: Station is in a service period, so don't try to
  *	reply to other uAPSD trigger frames or PS-Poll.
+ * @WLAN_STA_4ADDR_EVENT: 4-addr event was already sent for this frame.
  */
 enum ieee80211_sta_info_flags {
 	WLAN_STA_AUTH,
@@ -71,6 +72,7 @@ enum ieee80211_sta_info_flags {
 	WLAN_STA_TDLS_PEER_AUTH,
 	WLAN_STA_UAPSD,
 	WLAN_STA_SP,
+	WLAN_STA_4ADDR_EVENT,
 };
 
 #define STA_TID_NUM 16
@@ -390,6 +392,12 @@ static inline int test_and_clear_sta_fla
 	return test_and_clear_bit(flag, &sta->_flags);
 }
 
+static inline int test_and_set_sta_flag(struct sta_info *sta,
+					enum ieee80211_sta_info_flags flag)
+{
+	return test_and_set_bit(flag, &sta->_flags);
+}
+
 void ieee80211_assign_tid_tx(struct sta_info *sta, int tid,
 			     struct tid_ampdu_tx *tid_tx);
 



  parent reply	other threads:[~2011-11-04 10:21 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-04 10:18 [PATCH 00/12] monitor-less AP mode part 1 Johannes Berg
2011-11-04 10:18 ` [PATCH 01/12] mac80211: add helper to free TX skb Johannes Berg
2011-11-04 10:18 ` [PATCH 02/12] mac80211: add support for control port protocol in AP mode Johannes Berg
2011-11-04 10:18 ` [PATCH 03/12] nl80211: allow subscribing to unexpected class3 frames Johannes Berg
2011-11-04 10:18 ` [PATCH 04/12] mac80211: support spurious class3 event Johannes Berg
2011-11-04 10:18 ` [PATCH 05/12] nl80211: advertise device AP SME Johannes Berg
2011-11-07  8:29   ` Arik Nemtsov
2011-11-07  8:49     ` Johannes Berg
2011-11-07 11:39   ` [PATCH v3 " Johannes Berg
2011-11-04 10:18 ` [PATCH 06/12] nl80211: add API to probe a client Johannes Berg
2011-11-04 10:18 ` [PATCH 07/12] mac80211: support client probe Johannes Berg
2011-11-04 10:18 ` [PATCH 08/12] cfg80211: allow registering to beacons Johannes Berg
2011-11-04 10:18 ` [PATCH 09/12] mac80211: report OBSS beacons Johannes Berg
2011-11-04 10:18 ` [PATCH 10/12] cfg80211: add event for unexpected 4addr frames Johannes Berg
2011-11-04 10:18 ` Johannes Berg [this message]
2011-11-04 10:18 ` [PATCH 12/12] cfg80211/mac80211: allow management TX to not wait for ACK Johannes Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111104101945.533357720@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).