]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Refactor BPF_PROG_RUN into a function
authorAndrii Nakryiko <andrii@kernel.org>
Sun, 15 Aug 2021 07:05:54 +0000 (00:05 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Mon, 16 Aug 2021 22:45:07 +0000 (00:45 +0200)
commitd648591e46c9a49172b32259a3f1be2a4f8a147b
tree9006ce2d61e9cd8c9fa353e5cff61d5f6da09031
parenta7f50ca670bfd1ab5dfe3587b9121324d1c77866
bpf: Refactor BPF_PROG_RUN into a function

Turn BPF_PROG_RUN into a proper always inlined function. No functional and
performance changes are intended, but it makes it much easier to understand
what's going on with how BPF programs are actually get executed. It's more
obvious what types and callbacks are expected. Also extra () around input
parameters can be dropped, as well as `__` variable prefixes intended to avoid
naming collisions, which makes the code simpler to read and write.

This refactoring also highlighted one extra issue. BPF_PROG_RUN is both
a macro and an enum value (BPF_PROG_RUN == BPF_PROG_TEST_RUN). Turning
BPF_PROG_RUN into a function causes naming conflict compilation error. So
rename BPF_PROG_RUN into lower-case bpf_prog_run(), similar to
bpf_prog_run_xdp(), bpf_prog_run_pin_on_cpu(), etc. All existing callers of
BPF_PROG_RUN, the macro, are switched to bpf_prog_run() explicitly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20210815070609.987780-2-andrii@kernel.org
20 files changed:
Documentation/networking/filter.rst
drivers/media/rc/bpf-lirc.c
drivers/net/ppp/ppp_generic.c
drivers/net/team/team_mode_loadbalance.c
include/linux/bpf.h
include/linux/filter.h
kernel/bpf/bpf_iter.c
kernel/bpf/cgroup.c
kernel/bpf/core.c
kernel/bpf/trampoline.c
kernel/bpf/verifier.c
kernel/events/core.c
kernel/trace/bpf_trace.c
lib/test_bpf.c
net/bpf/test_run.c
net/core/filter.c
net/core/ptp_classifier.c
net/netfilter/xt_bpf.c
net/sched/act_bpf.c
net/sched/cls_bpf.c