OSDN Git Service

selftests/bpf: Stop using static variables for passing data to/from user-space
authorAndrii Nakryiko <andrii@kernel.org>
Fri, 7 May 2021 05:41:15 +0000 (22:41 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 11 May 2021 22:07:17 +0000 (15:07 -0700)
commit256eab48e70c0eaf5b1b9af83c0588491986c7de
tree31f258d11a2de49f180040ebc7f74100c331993c
parentfdbf5ddeb855a80831af2e5bb9db9218926e6789
selftests/bpf: Stop using static variables for passing data to/from user-space

In preparation of skipping emitting static variables in BPF skeletons, switch
all current selftests uses of static variables to pass data between BPF and
user-space to use global variables.

All non-read-only `static volatile` variables become just plain global
variables by dropping `static volatile` part.

Read-only `static volatile const` variables, though, still require `volatile`
modifier, otherwise compiler will ignore whatever values are set from
user-space.

Few static linker tests are using name-conflicting static variables to
validate that static linker still properly handles static variables and
doesn't trip up on name conflicts.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210507054119.270888-4-andrii@kernel.org
19 files changed:
tools/testing/selftests/bpf/prog_tests/send_signal.c
tools/testing/selftests/bpf/prog_tests/skeleton.c
tools/testing/selftests/bpf/prog_tests/static_linked.c
tools/testing/selftests/bpf/progs/bpf_iter_test_kern4.c
tools/testing/selftests/bpf/progs/kfree_skb.c
tools/testing/selftests/bpf/progs/tailcall3.c
tools/testing/selftests/bpf/progs/tailcall4.c
tools/testing/selftests/bpf/progs/tailcall5.c
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf2.c
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf4.c
tools/testing/selftests/bpf/progs/test_check_mtu.c
tools/testing/selftests/bpf/progs/test_cls_redirect.c
tools/testing/selftests/bpf/progs/test_global_func_args.c
tools/testing/selftests/bpf/progs/test_rdonly_maps.c
tools/testing/selftests/bpf/progs/test_skeleton.c
tools/testing/selftests/bpf/progs/test_snprintf_single.c
tools/testing/selftests/bpf/progs/test_sockmap_listen.c
tools/testing/selftests/bpf/progs/test_static_linked1.c
tools/testing/selftests/bpf/progs/test_static_linked2.c