Skip to content

Commit 4439548

Browse files
bcopelandjmberg-intel
authored andcommitted
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 <[email protected]> Signed-off-by: Johannes Berg <[email protected]>
1 parent 2bdaf38 commit 4439548

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

net/mac80211/mesh_pathtbl.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,10 @@ static int mesh_table_grow(struct mesh_table *oldtbl,
177177
return -ENOMEM;
178178
}
179179

180-
static u32 mesh_table_hash(const u8 *addr, struct ieee80211_sub_if_data *sdata,
181-
struct mesh_table *tbl)
180+
static u32 mesh_table_hash(const u8 *addr, struct mesh_table *tbl)
182181
{
183-
/* Use last four bytes of hw addr and interface index as hash index */
184-
return jhash_2words(*(u32 *)(addr+2), sdata->dev->ifindex,
185-
tbl->hash_rnd) & tbl->hash_mask;
182+
/* Use last four bytes of hw addr as hash index */
183+
return jhash_1word(*(u32 *)(addr+2), tbl->hash_rnd) & tbl->hash_mask;
186184
}
187185

188186

@@ -331,7 +329,7 @@ static struct mesh_path *mpath_lookup(struct mesh_table *tbl, const u8 *dst,
331329
struct hlist_head *bucket;
332330
struct mpath_node *node;
333331

334-
bucket = &tbl->hash_buckets[mesh_table_hash(dst, sdata, tbl)];
332+
bucket = &tbl->hash_buckets[mesh_table_hash(dst, tbl)];
335333
hlist_for_each_entry_rcu(node, bucket, list) {
336334
mpath = node->mpath;
337335
if (ether_addr_equal(dst, mpath->dst)) {
@@ -538,7 +536,7 @@ struct mesh_path *mesh_path_add(struct ieee80211_sub_if_data *sdata,
538536
read_lock_bh(&sdata->u.mesh.pathtbl_resize_lock);
539537
tbl = resize_dereference_mesh_paths(sdata);
540538

541-
hash_idx = mesh_table_hash(dst, sdata, tbl);
539+
hash_idx = mesh_table_hash(dst, tbl);
542540
bucket = &tbl->hash_buckets[hash_idx];
543541

544542
spin_lock(&tbl->hashwlock[hash_idx]);
@@ -687,7 +685,7 @@ int mpp_path_add(struct ieee80211_sub_if_data *sdata,
687685

688686
tbl = resize_dereference_mpp_paths(sdata);
689687

690-
hash_idx = mesh_table_hash(dst, sdata, tbl);
688+
hash_idx = mesh_table_hash(dst, tbl);
691689
bucket = &tbl->hash_buckets[hash_idx];
692690

693691
spin_lock(&tbl->hashwlock[hash_idx]);
@@ -905,7 +903,7 @@ static int table_path_del(struct mesh_table __rcu *rcu_tbl,
905903
int err = 0;
906904

907905
tbl = resize_dereference_paths(sdata, rcu_tbl);
908-
hash_idx = mesh_table_hash(addr, sdata, tbl);
906+
hash_idx = mesh_table_hash(addr, tbl);
909907
bucket = &tbl->hash_buckets[hash_idx];
910908

911909
spin_lock(&tbl->hashwlock[hash_idx]);
@@ -1107,7 +1105,7 @@ static int mesh_path_node_copy(struct hlist_node *p, struct mesh_table *newtbl)
11071105
node = hlist_entry(p, struct mpath_node, list);
11081106
mpath = node->mpath;
11091107
new_node->mpath = mpath;
1110-
hash_idx = mesh_table_hash(mpath->dst, mpath->sdata, newtbl);
1108+
hash_idx = mesh_table_hash(mpath->dst, newtbl);
11111109
hlist_add_head(&new_node->list,
11121110
&newtbl->hash_buckets[hash_idx]);
11131111
return 0;

0 commit comments

Comments
 (0)