aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211
diff options
context:
space:
mode:
authorBob Copeland <me@bobcopeland.com>2016-02-28 20:03:57 -0500
committerJohannes Berg <johannes.berg@intel.com>2016-04-05 04:56:31 -0400
commit443954815b63b36f09623d74170520e6554f5fac (patch)
tree816f927aafbd58c5770bc10f744bd7091cead53c /net/mac80211
parent2bdaf386f99c4a82788812e583ff59c6714ae4d6 (diff)
mac80211: mesh: don't hash sdata in mpath tables
Now that the sdata pointer is the same for all entries of a path table, hashing it is pointless, so hash only the address. Signed-off-by: Bob Copeland <me@bobcopeland.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211')
-rw-r--r--net/mac80211/mesh_pathtbl.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c
index 0508b37b0471..fc3cc350df8c 100644
--- a/net/mac80211/mesh_pathtbl.c
+++ b/net/mac80211/mesh_pathtbl.c
@@ -177,12 +177,10 @@ errcopy:
177 return -ENOMEM; 177 return -ENOMEM;
178} 178}
179 179
180static u32 mesh_table_hash(const u8 *addr, struct ieee80211_sub_if_data *sdata, 180static u32 mesh_table_hash(const u8 *addr, struct mesh_table *tbl)
181 struct mesh_table *tbl)
182{ 181{
183 /* Use last four bytes of hw addr and interface index as hash index */ 182 /* Use last four bytes of hw addr as hash index */
184 return jhash_2words(*(u32 *)(addr+2), sdata->dev->ifindex, 183 return jhash_1word(*(u32 *)(addr+2), tbl->hash_rnd) & tbl->hash_mask;
185 tbl->hash_rnd) & tbl->hash_mask;
186} 184}
187 185
188 186
@@ -331,7 +329,7 @@ static struct mesh_path *mpath_lookup(struct mesh_table *tbl, const u8 *dst,
331 struct hlist_head *bucket; 329 struct hlist_head *bucket;
332 struct mpath_node *node; 330 struct mpath_node *node;
333 331
334 bucket = &tbl->hash_buckets[mesh_table_hash(dst, sdata, tbl)]; 332 bucket = &tbl->hash_buckets[mesh_table_hash(dst, tbl)];
335 hlist_for_each_entry_rcu(node, bucket, list) { 333 hlist_for_each_entry_rcu(node, bucket, list) {
336 mpath = node->mpath; 334 mpath = node->mpath;
337 if (ether_addr_equal(dst, mpath->dst)) { 335 if (ether_addr_equal(dst, mpath->dst)) {
@@ -538,7 +536,7 @@ struct mesh_path *mesh_path_add(struct ieee80211_sub_if_data *sdata,
538 read_lock_bh(&sdata->u.mesh.pathtbl_resize_lock); 536 read_lock_bh(&sdata->u.mesh.pathtbl_resize_lock);
539 tbl = resize_dereference_mesh_paths(sdata); 537 tbl = resize_dereference_mesh_paths(sdata);
540 538
541 hash_idx = mesh_table_hash(dst, sdata, tbl); 539 hash_idx = mesh_table_hash(dst, tbl);
542 bucket = &tbl->hash_buckets[hash_idx]; 540 bucket = &tbl->hash_buckets[hash_idx];
543 541
544 spin_lock(&tbl->hashwlock[hash_idx]); 542 spin_lock(&tbl->hashwlock[hash_idx]);
@@ -687,7 +685,7 @@ int mpp_path_add(struct ieee80211_sub_if_data *sdata,
687 685
688 tbl = resize_dereference_mpp_paths(sdata); 686 tbl = resize_dereference_mpp_paths(sdata);
689 687
690 hash_idx = mesh_table_hash(dst, sdata, tbl); 688 hash_idx = mesh_table_hash(dst, tbl);
691 bucket = &tbl->hash_buckets[hash_idx]; 689 bucket = &tbl->hash_buckets[hash_idx];
692 690
693 spin_lock(&tbl->hashwlock[hash_idx]); 691 spin_lock(&tbl->hashwlock[hash_idx]);
@@ -905,7 +903,7 @@ static int table_path_del(struct mesh_table __rcu *rcu_tbl,
905 int err = 0; 903 int err = 0;
906 904
907 tbl = resize_dereference_paths(sdata, rcu_tbl); 905 tbl = resize_dereference_paths(sdata, rcu_tbl);
908 hash_idx = mesh_table_hash(addr, sdata, tbl); 906 hash_idx = mesh_table_hash(addr, tbl);
909 bucket = &tbl->hash_buckets[hash_idx]; 907 bucket = &tbl->hash_buckets[hash_idx];
910 908
911 spin_lock(&tbl->hashwlock[hash_idx]); 909 spin_lock(&tbl->hashwlock[hash_idx]);
@@ -1107,7 +1105,7 @@ static int mesh_path_node_copy(struct hlist_node *p, struct mesh_table *newtbl)
1107 node = hlist_entry(p, struct mpath_node, list); 1105 node = hlist_entry(p, struct mpath_node, list);
1108 mpath = node->mpath; 1106 mpath = node->mpath;
1109 new_node->mpath = mpath; 1107 new_node->mpath = mpath;
1110 hash_idx = mesh_table_hash(mpath->dst, mpath->sdata, newtbl); 1108 hash_idx = mesh_table_hash(mpath->dst, newtbl);
1111 hlist_add_head(&new_node->list, 1109 hlist_add_head(&new_node->list,
1112 &newtbl->hash_buckets[hash_idx]); 1110 &newtbl->hash_buckets[hash_idx]);
1113 return 0; 1111 return 0;