OSDN Git Service

mac80211: Use linked list instead of rhashtable walk for mesh tables
authorHerbert Xu <herbert@gondor.apana.org.au>
Thu, 14 Feb 2019 14:03:24 +0000 (22:03 +0800)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 15 Feb 2019 12:10:10 +0000 (13:10 +0100)
commitb4c3fbe6360178dc2181b7b43b7ae793a192b282
tree5b62cf077f62b4123e7f8117b7ad4e7cb82b7351
parentf9bcc9f3ee4fbbe8f11dfec76745476f5780517e
mac80211: Use linked list instead of rhashtable walk for mesh tables

The mesh table code walks over hash tables for two purposes.  First of
all it's used as part of a netlink dump process, but it is also used
for looking up entries to delete using criteria other than the hash
key.

The second purpose is directly contrary to the design specification
of rhashtable walks.  It is only meant for use by netlink dumps.

This is because rhashtable is resizable and you cannot obtain a
stable walk over it during a resize process.

In fact mesh's use of rhashtable for dumping is bogus too.  Rather
than using rhashtable walk's iterator to keep track of the current
position, it always converts the current position to an integer
which defeats the purpose of the iterator.

Therefore this patch converts all uses of rhashtable walk into a
simple linked list.

This patch also adds a new spin lock to protect the hash table
insertion/removal as well as the walk list modifications.  In fact
the previous code was buggy as the removals can race with each
other, potentially resulting in a double-free.

Cc: stable@vger.kernel.org
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/mesh.h
net/mac80211/mesh_pathtbl.c