All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: linux-wireless@vger.kernel.org
Subject: [RFC 4/4] mac80211: count authorized stations per BSS
Date: Tue, 13 Dec 2011 21:07:21 +0100	[thread overview]
Message-ID: <20111213201449.989844540@sipsolutions.net> (raw)
In-Reply-To: 20111213200717.465896579@sipsolutions.net

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

Currently, each AP interface will send multicast
traffic if any interface has a station entry even
if that station entry is allocated only. With the
new station state management we can easily fix it
by adding a counter that counts each authorized
station only and send multicast traffic only when
the correct interface has at least one authorized
station.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 net/mac80211/debugfs_netdev.c |    2 ++
 net/mac80211/ieee80211_i.h    |    1 +
 net/mac80211/sta_info.c       |   14 +++++++++-----
 net/mac80211/tx.c             |   19 ++++++++-----------
 4 files changed, 20 insertions(+), 16 deletions(-)

--- a/net/mac80211/debugfs_netdev.c	2011-12-13 20:30:53.000000000 +0100
+++ b/net/mac80211/debugfs_netdev.c	2011-12-13 20:31:16.000000000 +0100
@@ -321,6 +321,7 @@ static ssize_t ieee80211_if_parse_tkip_m
 __IEEE80211_IF_FILE_W(tkip_mic_test);
 
 /* AP attributes */
+IEEE80211_IF_FILE(num_sta_authorized, u.ap.num_sta_authorized, ATOMIC);
 IEEE80211_IF_FILE(num_sta_ps, u.ap.num_sta_ps, ATOMIC);
 IEEE80211_IF_FILE(dtim_count, u.ap.dtim_count, DEC);
 
@@ -458,6 +459,7 @@ static void add_ap_files(struct ieee8021
 	DEBUGFS_ADD(rc_rateidx_mask_2ghz);
 	DEBUGFS_ADD(rc_rateidx_mask_5ghz);
 
+	DEBUGFS_ADD(num_sta_authorized);
 	DEBUGFS_ADD(num_sta_ps);
 	DEBUGFS_ADD(dtim_count);
 	DEBUGFS_ADD(num_buffered_multicast);
--- a/net/mac80211/ieee80211_i.h	2011-12-13 20:30:53.000000000 +0100
+++ b/net/mac80211/ieee80211_i.h	2011-12-13 20:31:16.000000000 +0100
@@ -243,6 +243,7 @@ struct ieee80211_if_ap {
 	u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)];
 	struct sk_buff_head ps_bc_buf;
 	atomic_t num_sta_ps; /* number of stations in PS mode */
+	atomic_t num_sta_authorized; /* number of authorized stations */
 	int dtim_count;
 	bool dtim_bc_mc;
 };
--- a/net/mac80211/sta_info.c	2011-12-13 20:31:16.000000000 +0100
+++ b/net/mac80211/sta_info.c	2011-12-13 20:31:16.000000000 +0100
@@ -1542,17 +1542,21 @@ int sta_info_move_state_checked(struct s
 			return -EINVAL;
 		break;
 	case IEEE80211_STA_ASSOC:
-		if (sta->sta_state == IEEE80211_STA_AUTH)
+		if (sta->sta_state == IEEE80211_STA_AUTH) {
 			set_bit(WLAN_STA_ASSOC, &sta->_flags);
-		else if (sta->sta_state == IEEE80211_STA_AUTHORIZED)
+		} else if (sta->sta_state == IEEE80211_STA_AUTHORIZED) {
+			if (sta->sdata->vif.type == NL80211_IFTYPE_AP)
+				atomic_dec(&sta->sdata->u.ap.num_sta_authorized);
 			clear_bit(WLAN_STA_AUTHORIZED, &sta->_flags);
-		else
+		} else
 			return -EINVAL;
 		break;
 	case IEEE80211_STA_AUTHORIZED:
-		if (sta->sta_state == IEEE80211_STA_ASSOC)
+		if (sta->sta_state == IEEE80211_STA_ASSOC) {
+			if (sta->sdata->vif.type == NL80211_IFTYPE_AP)
+				atomic_inc(&sta->sdata->u.ap.num_sta_authorized);
 			set_bit(WLAN_STA_AUTHORIZED, &sta->_flags);
-		else
+		} else
 			return -EINVAL;
 		break;
 	default:
--- a/net/mac80211/tx.c	2011-12-13 20:30:53.000000000 +0100
+++ b/net/mac80211/tx.c	2011-12-13 20:31:16.000000000 +0100
@@ -304,17 +304,14 @@ ieee80211_tx_h_check_assoc(struct ieee80
 			I802_DEBUG_INC(tx->local->tx_handlers_drop_not_assoc);
 			return TX_DROP;
 		}
-	} else {
-		if (unlikely(ieee80211_is_data(hdr->frame_control) &&
-			     tx->local->num_sta == 0 &&
-			     tx->sdata->vif.type != NL80211_IFTYPE_ADHOC)) {
-			/*
-			 * No associated STAs - no need to send multicast
-			 * frames.
-			 */
-			return TX_DROP;
-		}
-		return TX_CONTINUE;
+	} else if (unlikely(tx->sdata->vif.type == NL80211_IFTYPE_AP &&
+			    ieee80211_is_data(hdr->frame_control) &&
+			    !atomic_read(&tx->sdata->u.ap.num_sta_authorized))) {
+		/*
+		 * No associated STAs - no need to send multicast
+		 * frames.
+		 */
+		return TX_DROP;
 	}
 
 	return TX_CONTINUE;



      parent reply	other threads:[~2011-12-13 20:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-13 20:07 [RFC 0/4] refactor station state management Johannes Berg
2011-12-13 20:07 ` [RFC 1/4] mac80211: use station mutex in configuration Johannes Berg
2011-12-13 20:07 ` [RFC 2/4] mac80211: refactor station state transitions Johannes Berg
2011-12-14  0:29   ` Thomas Pedersen
2011-12-14  8:22     ` Johannes Berg
2011-12-13 20:07 ` [RFC 3/4] mac80211: unwind station state on destroy Johannes Berg
2011-12-13 20:07 ` Johannes Berg [this message]

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=20111213201449.989844540@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.