selftests/bpf: Use vmlinux.h in socket_cookie_prog.c
authorFlorent Revest <revest@chromium.org>
Wed, 10 Feb 2021 11:14:05 +0000 (12:14 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 12 Feb 2021 01:44:41 +0000 (17:44 -0800)
commit6cd4dcc3fb8198fff6e6c2d7c622f78649fa2474
tree90e01695280e38a54a9f8dd9ddc0d37e6de3fcdf
parent61f8c9c8f3c8fb60722f0f3168d1a546dbf8a3d4
selftests/bpf: Use vmlinux.h in socket_cookie_prog.c

When migrating from the bpf.h's to the vmlinux.h's definition of struct
bps_sock, an interesting LLVM behavior happened. LLVM started producing
two fetches of ctx->sk in the sockops program this means that the
verifier could not keep track of the NULL-check on ctx->sk. Therefore,
we need to extract ctx->sk in a variable before checking and
dereferencing it.

Signed-off-by: Florent Revest <revest@chromium.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: KP Singh <kpsingh@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20210210111406.785541-4-revest@chromium.org
tools/testing/selftests/bpf/progs/socket_cookie_prog.c