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>
This commit is contained in:
Eric Dumazet 2024-05-03 19:20:58 +00:00 committed by Paolo Abeni
parent 6890ab31d1
commit 979aad40da
1 changed files with 7 additions and 5 deletions

View File

@ -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)