linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Kazior <michal.kazior@tieto.com>
To: linux-wireless@vger.kernel.org
Cc: johannes@sipsolutions.net, Michal Kazior <michal.kazior@tieto.com>
Subject: [PATCH 2/3] mac80211: use csa counter offsets instead of csa_active
Date: Thu, 22 May 2014 15:28:13 +0200	[thread overview]
Message-ID: <1400765294-14732-3-git-send-email-michal.kazior@tieto.com> (raw)
In-Reply-To: <1400765294-14732-1-git-send-email-michal.kazior@tieto.com>

vif->csa_active is protected by mutexes only. This
means it is unreliable to depend on it on codeflow
in non-sleepable beacon and CSA code. There was no
guarantee to have vif->csa_active update be
visible before beacons are updated on SMP systems.

Using csa counter offsets which are embedded in
beacon struct (and thus are protected with single
RCU assignment) is much safer.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
---
 net/mac80211/tx.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 7d96a27..eeeafeb 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -2536,6 +2536,9 @@ bool ieee80211_csa_is_complete(struct ieee80211_vif *vif)
 		goto out;
 	}
 
+	if (!beacon->csa_counter_offset[0])
+		goto out;
+
 	if (WARN_ON_ONCE(beacon->csa_counter_offset[0] > beacon_data_len))
 		goto out;
 
@@ -2580,7 +2583,7 @@ __ieee80211_beacon_get(struct ieee80211_hw *hw,
 
 		beacon = rcu_dereference(ap->beacon);
 		if (beacon) {
-			if (sdata->vif.csa_active) {
+			if (beacon->csa_counter_offset[0]) {
 				if (!is_template)
 					ieee80211_csa_update_counter(vif);
 
@@ -2626,7 +2629,7 @@ __ieee80211_beacon_get(struct ieee80211_hw *hw,
 		if (!beacon)
 			goto out;
 
-		if (sdata->vif.csa_active) {
+		if (beacon->csa_counter_offset[0]) {
 			if (!is_template)
 				ieee80211_csa_update_counter(vif);
 
@@ -2651,7 +2654,7 @@ __ieee80211_beacon_get(struct ieee80211_hw *hw,
 		if (!beacon)
 			goto out;
 
-		if (sdata->vif.csa_active) {
+		if (beacon->csa_counter_offset[0]) {
 			if (!is_template)
 				/* TODO: For mesh csa_counter is in TU, so
 				 * decrementing it by one isn't correct, but
-- 
1.8.5.3


  parent reply	other threads:[~2014-05-22 13:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-22 13:28 [PATCH 0/3] mac80211: fix csa counters Michal Kazior
2014-05-22 13:28 ` [PATCH 1/3] mac80211: move csa counters from sdata to beacon/presp Michal Kazior
2014-05-22 13:43   ` Johannes Berg
2014-05-22 13:53     ` Michal Kazior
2014-05-22 14:37       ` Johannes Berg
2014-05-22 14:38         ` Johannes Berg
2014-05-22 13:28 ` Michal Kazior [this message]
2014-05-22 13:45   ` [PATCH 2/3] mac80211: use csa counter offsets instead of csa_active Johannes Berg
2014-05-22 13:59     ` Michal Kazior
2014-05-22 14:38       ` Johannes Berg
2014-05-22 13:28 ` [PATCH 3/3] mac80211: make csa_currnet_counter atomic Michal Kazior
2014-05-22 13:50   ` Johannes Berg
2014-05-22 14:03     ` Michal Kazior
2014-05-22 14:36       ` 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=1400765294-14732-3-git-send-email-michal.kazior@tieto.com \
    --to=michal.kazior@tieto.com \
    --cc=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 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).