]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit - net/packet/af_packet.c
bpf: refactor bpf_prog_get and type check into helper
authorDaniel Borkmann <daniel@iogearbox.net>
Thu, 30 Jun 2016 15:24:44 +0000 (17:24 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 1 Jul 2016 20:00:47 +0000 (16:00 -0400)
commit113214be7f6c98dd6d0435e4765aea8dea91662c
tree31d2c41c7af6991401c3aff11e7ade3317b4a614
parent1aacde3d22c42281236155c1ef6d7a5aa32a826b
bpf: refactor bpf_prog_get and type check into helper

Since bpf_prog_get() and program type check is used in a couple of places,
refactor this into a small helper function that we can make use of. Since
the non RO prog->aux part is not used in performance critical paths and a
program destruction via RCU is rather very unlikley when doing the put, we
shouldn't have an issue just doing the bpf_prog_get() + prog->type != type
check, but actually not taking the ref at all (due to being in fdget() /
fdput() section of the bpf fd) is even cleaner and makes the diff smaller
as well, so just go for that. Callsites are changed to make use of the new
helper where possible.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/bpf.h
kernel/bpf/syscall.c
net/core/filter.c
net/kcm/kcmsock.c
net/packet/af_packet.c
net/sched/act_bpf.c
net/sched/cls_bpf.c