diff options
author | Eric Dumazet <edumazet@google.com> | 2024-05-03 21:20:58 +0200 |
---|---|---|
committer | Paolo Abeni <pabeni@redhat.com> | 2024-05-07 11:14:50 +0200 |
commit | 979aad40da9217d5e907ee4ad7c7f0dc555944a7 (patch) | |
tree | 61e37a750c356f85ebbe4530fd8c82f231673414 /net/core | |
parent | rtnetlink: do not depend on RTNL in rtnl_fill_proto_down() (diff) | |
download | linux-979aad40da9217d5e907ee4ad7c7f0dc555944a7.tar.xz linux-979aad40da9217d5e907ee4ad7c7f0dc555944a7.zip |
rtnetlink: do not depend on RTNL in rtnl_xdp_prog_skb()
dev->xdp_prog is protected by RCU, we can lift RTNL requirement
from rtnl_xdp_prog_skb().
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/rtnetlink.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index dfdd08006fae..41eb8bca5305 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -1477,13 +1477,15 @@ static int rtnl_fill_link_ifmap(struct sk_buff *skb, static u32 rtnl_xdp_prog_skb(struct net_device *dev) { const struct bpf_prog *generic_xdp_prog; + u32 res = 0; - ASSERT_RTNL(); + rcu_read_lock(); + generic_xdp_prog = rcu_dereference(dev->xdp_prog); + if (generic_xdp_prog) + res = generic_xdp_prog->aux->id; + rcu_read_unlock(); - generic_xdp_prog = rtnl_dereference(dev->xdp_prog); - if (!generic_xdp_prog) - return 0; - return generic_xdp_prog->aux->id; + return res; } static u32 rtnl_xdp_prog_drv(struct net_device *dev) |