summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/prog_tests/sockopt_sk.c
diff options
context:
space:
mode:
authorYauheni Kaliuta <yauheni.kaliuta@redhat.com>2021-04-08 09:13:04 +0300
committerAndrii Nakryiko <andrii@kernel.org>2021-04-08 23:54:47 -0700
commit361d32028c7d52d28d7f0562193a2f4a41d10351 (patch)
tree863fbc4109bd7da906472b89b8713c4fb9e60199 /tools/testing/selftests/bpf/prog_tests/sockopt_sk.c
parentcad99cce133dd5377f22da1e75d7eb5c4b886d75 (diff)
selftests/bpf: Pass page size from userspace in sockopt_sk
Since there is no convenient way for bpf program to get PAGE_SIZE from inside of the kernel, pass the value from userspace. Zero-initialize the variable in bpf prog, otherwise it will cause problems on some versions of Clang. Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20210408061310.95877-3-yauheni.kaliuta@redhat.com
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/sockopt_sk.c')
-rw-r--r--tools/testing/selftests/bpf/prog_tests/sockopt_sk.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/sockopt_sk.c b/tools/testing/selftests/bpf/prog_tests/sockopt_sk.c
index 7274b12abe17..4b937e5dbaca 100644
--- a/tools/testing/selftests/bpf/prog_tests/sockopt_sk.c
+++ b/tools/testing/selftests/bpf/prog_tests/sockopt_sk.c
@@ -200,6 +200,8 @@ static void run_test(int cgroup_fd)
if (!ASSERT_OK_PTR(skel, "skel_load"))
goto cleanup;
+ skel->bss->page_size = getpagesize();
+
skel->links._setsockopt =
bpf_program__attach_cgroup(skel->progs._setsockopt, cgroup_fd);
if (!ASSERT_OK_PTR(skel->links._setsockopt, "setsockopt_link"))