linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 1/2] mac80211: iterate over vif using RCU
@ 2013-12-10 16:39 Antonio Quartulli
  2013-12-10 16:39 ` [RFC 2/2] mac80211: Use RCU to handle local->key_list Antonio Quartulli
  2013-12-10 17:05 ` [RFC 1/2] mac80211: iterate over vif using RCU Eliad Peller
  0 siblings, 2 replies; 6+ messages in thread
From: Antonio Quartulli @ 2013-12-10 16:39 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless, Antonio Quartulli

From: Antonio Quartulli <antonio@open-mesh.com>

I need to invoke ieee80211_iter_keys() from a periodic worker in a driver and
therefore I would prefer to get rid of any of locks to avoid problems.
These two patches try to use rcu lock to protect the iteration, but I'd like to
get a feedback before sending this stuff as a patch :-)

Moreover, why do we use list_for_each_entry_safe() is ieee80211_iter_keys() if
the list cannot be altered (pointer to key is not passed to iter() so we should
be sure that nobody is going to invoke list_del())?

Cheers,


In ieee80211_iter_keys the local->interfaces list is
accessed for reading only. RCU can be used instead
of pretending to be under RTNL lock.

This can simplify future users of this function.

Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
---
 net/mac80211/key.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/mac80211/key.c b/net/mac80211/key.c
index 3e51dd7..04c885a 100644
--- a/net/mac80211/key.c
+++ b/net/mac80211/key.c
@@ -550,8 +550,6 @@ void ieee80211_iter_keys(struct ieee80211_hw *hw,
 	struct ieee80211_key *key, *tmp;
 	struct ieee80211_sub_if_data *sdata;
 
-	ASSERT_RTNL();
-
 	mutex_lock(&local->key_mtx);
 	if (vif) {
 		sdata = vif_to_sdata(vif);
@@ -560,12 +558,14 @@ void ieee80211_iter_keys(struct ieee80211_hw *hw,
 			     key->sta ? &key->sta->sta : NULL,
 			     &key->conf, iter_data);
 	} else {
-		list_for_each_entry(sdata, &local->interfaces, list)
+		rcu_read_lock();
+		list_for_each_entry_rcu(sdata, &local->interfaces, list)
 			list_for_each_entry_safe(key, tmp,
 						 &sdata->key_list, list)
 				iter(hw, &sdata->vif,
 				     key->sta ? &key->sta->sta : NULL,
 				     &key->conf, iter_data);
+		rcu_read_unlock();
 	}
 	mutex_unlock(&local->key_mtx);
 }
-- 
1.8.5.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-12-10 17:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-10 16:39 [RFC 1/2] mac80211: iterate over vif using RCU Antonio Quartulli
2013-12-10 16:39 ` [RFC 2/2] mac80211: Use RCU to handle local->key_list Antonio Quartulli
2013-12-10 17:05 ` [RFC 1/2] mac80211: iterate over vif using RCU Eliad Peller
2013-12-10 17:08   ` Antonio Quartulli
2013-12-10 17:23     ` Eliad Peller
2013-12-10 17:34       ` Antonio Quartulli

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).