]> git.baikalelectronics.ru Git - kernel.git/commit
bpf, xdp: drop rcu_read_lock from bpf_prog_run_xdp and move to caller
authorDaniel Borkmann <daniel@iogearbox.net>
Wed, 30 Nov 2016 21:16:06 +0000 (22:16 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 2 Dec 2016 16:06:24 +0000 (11:06 -0500)
commit0406f854f004ec258efcba3bf408d5f95ad2b382
treee531d50fe7b94cf8f4f56fdd3c2eff6555f6ef8b
parentc7d67e5b44a4c57bacb435e2cfa94a4bd8d0831f
bpf, xdp: drop rcu_read_lock from bpf_prog_run_xdp and move to caller

After 847015737e75 ("net/mlx4_en: protect ring->xdp_prog with rcu_read_lock"),
the rcu_read_lock() in bpf_prog_run_xdp() is superfluous, since callers
need to hold rcu_read_lock() already to make sure BPF program doesn't
get released in the background.

Thus, drop it from bpf_prog_run_xdp(), as it can otherwise be misleading.
Still keeping the bpf_prog_run_xdp() is useful as it allows for grepping
in XDP supported drivers and to keep the typecheck on the context intact.
For mlx4, this means we don't have a double rcu_read_lock() anymore. nfp can
just make use of bpf_prog_run_xdp(), too. For qede, just move rcu_read_lock()
out of the helper. When the driver gets atomic replace support, this will
move to call-sites eventually.

mlx5 needs actual fixing as it has the same issue as described already in
847015737e75 ("net/mlx4_en: protect ring->xdp_prog with rcu_read_lock"),
that is, we're under RCU bh at this time, BPF programs are released via
call_rcu(), and call_rcu() != call_rcu_bh(), so we need to properly mark
read side as programs can get xchg()'ed in mlx5e_xdp_set() without queue
reset.

Fixes: edaff77292b6 ("net/mlx5e: XDP fast RX drop bpf programs support")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
drivers/net/ethernet/netronome/nfp/nfp_net_common.c
drivers/net/ethernet/qlogic/qede/qede_main.c
include/linux/filter.h