Skip to content

Commit

Permalink
mac80211: mesh: don't hash sdata in mpath tables
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
bcopeland authored and jmberg-intel committed Apr 5, 2016
1 parent 2bdaf38 commit 4439548
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions net/mac80211/mesh_pathtbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,10 @@ static int mesh_table_grow(struct mesh_table *oldtbl,
return -ENOMEM;
}

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


Expand Down Expand Up @@ -331,7 +329,7 @@ static struct mesh_path *mpath_lookup(struct mesh_table *tbl, const u8 *dst,
struct hlist_head *bucket;
struct mpath_node *node;

bucket = &tbl->hash_buckets[mesh_table_hash(dst, sdata, tbl)];
bucket = &tbl->hash_buckets[mesh_table_hash(dst, tbl)];
hlist_for_each_entry_rcu(node, bucket, list) {
mpath = node->mpath;
if (ether_addr_equal(dst, mpath->dst)) {
Expand Down Expand Up @@ -538,7 +536,7 @@ struct mesh_path *mesh_path_add(struct ieee80211_sub_if_data *sdata,
read_lock_bh(&sdata->u.mesh.pathtbl_resize_lock);
tbl = resize_dereference_mesh_paths(sdata);

hash_idx = mesh_table_hash(dst, sdata, tbl);
hash_idx = mesh_table_hash(dst, tbl);
bucket = &tbl->hash_buckets[hash_idx];

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

tbl = resize_dereference_mpp_paths(sdata);

hash_idx = mesh_table_hash(dst, sdata, tbl);
hash_idx = mesh_table_hash(dst, tbl);
bucket = &tbl->hash_buckets[hash_idx];

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

tbl = resize_dereference_paths(sdata, rcu_tbl);
hash_idx = mesh_table_hash(addr, sdata, tbl);
hash_idx = mesh_table_hash(addr, tbl);
bucket = &tbl->hash_buckets[hash_idx];

spin_lock(&tbl->hashwlock[hash_idx]);
Expand Down Expand Up @@ -1107,7 +1105,7 @@ static int mesh_path_node_copy(struct hlist_node *p, struct mesh_table *newtbl)
node = hlist_entry(p, struct mpath_node, list);
mpath = node->mpath;
new_node->mpath = mpath;
hash_idx = mesh_table_hash(mpath->dst, mpath->sdata, newtbl);
hash_idx = mesh_table_hash(mpath->dst, newtbl);
hlist_add_head(&new_node->list,
&newtbl->hash_buckets[hash_idx]);
return 0;
Expand Down

0 comments on commit 4439548

Please sign in to comment.