aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorKuniyuki Iwashima <kuniyu@google.com>2025-07-16 22:08:12 +0000
committerJakub Kicinski <kuba@kernel.org>2025-07-17 16:25:20 -0700
commitd539d8fbd8fcf64a1492c51f5ee99aaa8a8dc9ab (patch)
treedda874417e9d21e8e3bc0358a02b31da5401c9ea /include
parentneighbour: Annotate neigh_table.phash_buckets and pneigh_entry.next with __rcu. (diff)
downloadlinux-d539d8fbd8fcf64a1492c51f5ee99aaa8a8dc9ab.tar.gz
linux-d539d8fbd8fcf64a1492c51f5ee99aaa8a8dc9ab.zip
neighbour: Free pneigh_entry after RCU grace period.
We will convert RTM_GETNEIGH to RCU. neigh_get() looks up pneigh_entry by pneigh_lookup() and passes it to pneigh_fill_info(). Then, we must ensure that the entry is alive till pneigh_fill_info() completes, but read_lock_bh(&tbl->lock) in pneigh_lookup() does not guarantee that. Also, we will convert all readers of tbl->phash_buckets[] to RCU. Let's use call_rcu() to free pneigh_entry and update phash_buckets[] and ->next by rcu_assign_pointer(). pneigh_ifdown_and_unlock() uses list_head to avoid overwriting ->next and moving RCU iterators to another list. pndisc_destructor() (only IPv6 ndisc uses this) uses a mutex, so it is not delayed to call_rcu(), where we cannot sleep. This is fine because the mcast code works with RCU and ipv6_dev_mc_dec() frees mcast objects after RCU grace period. While at it, we change the return type of pneigh_ifdown_and_unlock() to void. Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Link: https://patch.msgid.link/20250716221221.442239-8-kuniyu@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include')
-rw-r--r--include/net/neighbour.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index 1ddc44a04200..6d7f9aa53a7a 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -180,6 +180,10 @@ struct pneigh_entry {
possible_net_t net;
struct net_device *dev;
netdevice_tracker dev_tracker;
+ union {
+ struct list_head free_node;
+ struct rcu_head rcu;
+ };
u32 flags;
u8 protocol;
bool permanent;