diff options
author | Johannes Berg <johannes.berg@intel.com> | 2015-02-13 21:55:15 +0100 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2015-04-01 10:06:26 +0200 |
commit | 7bedd0cfad4e122bc0ddaf3fc955a38c88c95d35 (patch) | |
tree | f156540ff672dec031e81a64fc60796dd34ea867 /net/mac80211/rx.c | |
parent | 9911674fcf1f239ff3c87e56177c4826e33dfd95 (diff) | |
download | op-kernel-dev-7bedd0cfad4e122bc0ddaf3fc955a38c88c95d35.zip op-kernel-dev-7bedd0cfad4e122bc0ddaf3fc955a38c88c95d35.tar.gz |
mac80211: use rhashtable for station table
We currently have a hand-rolled table with 256 entries and are
using the last byte of the MAC address as the hash. This hash
is obviously very fast, but collisions are easily created and
we waste a lot of space in the common case of just connecting
as a client to an AP where we just have a single station. The
other common case of an AP is also suboptimal due to the size
of the hash table and the ease of causing collisions.
Convert all of this to use rhashtable with jhash, which gives
us the advantage of a far better hash function (with random
perturbation to avoid hash collision attacks) and of course
that the hash table grows and shrinks dynamically with chain
length, improving both cases above.
Use a specialised hash function (using jhash, but with fixed
length) to achieve better compiler optimisation as suggested
by Sergey Ryazanov.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211/rx.c')
-rw-r--r-- | net/mac80211/rx.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 4f7b922c..5b60bcf 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -3423,7 +3423,8 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, __le16 fc; struct ieee80211_rx_data rx; struct ieee80211_sub_if_data *prev; - struct sta_info *sta, *tmp, *prev_sta; + struct sta_info *sta, *prev_sta; + struct rhash_head *tmp; int err = 0; fc = ((struct ieee80211_hdr *)skb->data)->frame_control; @@ -3458,9 +3459,13 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, ieee80211_scan_rx(local, skb); if (ieee80211_is_data(fc)) { + const struct bucket_table *tbl; + prev_sta = NULL; - for_each_sta_info(local, hdr->addr2, sta, tmp) { + tbl = rht_dereference_rcu(local->sta_hash.tbl, &local->sta_hash); + + for_each_sta_info(local, tbl, hdr->addr2, sta, tmp) { if (!prev_sta) { prev_sta = sta; continue; |