diff options
| author | Eric Dumazet <edumazet@google.com> | 2025-02-05 18:51:09 +0300 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-02-21 15:57:20 +0300 |
| commit | 81f369b67006951d88345bca035340fb1b61ed1d (patch) | |
| tree | dcc49d6ae0776110ed2457d3049acd697540dc37 /include/linux | |
| parent | 4cfecb7fc742888bf31bd49cfa16dd6eb42641e6 (diff) | |
| download | linux-81f369b67006951d88345bca035340fb1b61ed1d.tar.xz | |
net: add dev_net_rcu() helper
[ Upstream commit 482ad2a4ace2740ca0ff1cbc8f3c7f862f3ab507 ]
dev->nd_net can change, readers should either
use rcu_read_lock() or RTNL.
We currently use a generic helper, dev_net() with
no debugging support. We probably have many hidden bugs.
Add dev_net_rcu() helper for callers using rcu_read_lock()
protection.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Link: https://patch.msgid.link/20250205155120.1676781-2-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Stable-dep-of: 71b8471c93fa ("ipv4: use RCU protection in ipv4_default_advmss()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/netdevice.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 8b5121eb8757..95ee88dfe0b9 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2594,6 +2594,12 @@ struct net *dev_net(const struct net_device *dev) } static inline +struct net *dev_net_rcu(const struct net_device *dev) +{ + return read_pnet_rcu(&dev->nd_net); +} + +static inline void dev_net_set(struct net_device *dev, struct net *net) { write_pnet(&dev->nd_net, net); |
