Skip to content

Commit 9719c6b

Browse files
jrfastabborkmann
authored andcommitted
bpf, xdp: virtio_net use access ptr macro for xdp enable check
virtio_net currently relies on rcu critical section to access the xdp program in its xdp_xmit handler. However, the pointer to the xdp program is only used to do a NULL pointer comparison to determine if xdp is enabled or not. Use rcu_access_pointer() instead of rcu_dereference() to reflect this. Then later when we drop rcu_read critical section virtio_net will not need in special handling. Signed-off-by: John Fastabend <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Jesper Dangaard Brouer <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 42a84a8 commit 9719c6b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/net/virtio_net.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ static int virtnet_xdp_xmit(struct net_device *dev,
501501
/* Only allow ndo_xdp_xmit if XDP is loaded on dev, as this
502502
* indicate XDP resources have been successfully allocated.
503503
*/
504-
xdp_prog = rcu_dereference(rq->xdp_prog);
504+
xdp_prog = rcu_access_pointer(rq->xdp_prog);
505505
if (!xdp_prog)
506506
return -ENXIO;
507507

0 commit comments

Comments
 (0)