selftests/bpf: Use bpf_tracing.h instead of bpf_tcp_helpers.h
Subsystems (3)
Martin KaFai Lau
reviewerPATCH 1/1 selftests/bpf: Use bpf_tracing.h instead of bpf_tcp_helpers.h
From: Martin KaFai Lau <[email protected]>
The bpf programs that this patch changes require the BPF_PROG macro. The BPF_PROG macro is defined in the libbpf's bpf_tracing.h. Some tests include bpf_tcp_helpers.h which includes bpf_tracing.h. They don't need other things from bpf_tcp_helpers.h other than bpf_tracing.h. This patch simplifies it by directly including the bpf_tracing.h.
The motivation of this unnecessary code churn is to retire the bpf_tcp_helpers.h by directly using vmlinux.h. Right now, the main usage of the bpf_tcp_helpers.h is the partial kernel socket definitions (e.g. socket, sock, tcp_sock). While the test cases continue to grow, fields are kept adding to those partial socket definitions (e.g. the recent bpf_cc_cubic.c test which tried to extend bpf_tcp_helpers.c but eventually used the vmlinux.h instead).
The idea is to retire bpf_tcp_helpers.c and consistently use vmlinux.h for the tests that require the kernel sockets. This patch tackles the obvious tests that can directly use bpf_tracing.h instead of bpf_tcp_helpers.h.
--- tools/testing/selftests/bpf/progs/timer.c | 3 ++- tools/testing/selftests/bpf/progs/timer_failure.c | 2 +- tools/testing/selftests/bpf/progs/timer_mim.c | 2 +- tools/testing/selftests/bpf/progs/timer_mim_reject.c | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-)
tools/testing/selftests/bpf/progs/timer.c +2 -1
@@ -2,9 +2,10 @@/* Copyright (c) 2021 Facebook */ #include <linux/bpf.h> #include <time.h> +#include <stdbool.h> #include <errno.h> #include <bpf/bpf_helpers.h> -#include "bpf_tcp_helpers.h" +#include <bpf/bpf_tracing.h> char _license[] SEC("license") = "GPL";struct hmap_elem {
tools/testing/selftests/bpf/progs/timer_failure.c +1 -1
@@ -5,8 +5,8 @@#include <time.h> #include <errno.h> #include <bpf/bpf_helpers.h> +#include <bpf/bpf_tracing.h> #include "bpf_misc.h" -#include "bpf_tcp_helpers.h" char _license[] SEC("license") = "GPL";
tools/testing/selftests/bpf/progs/timer_mim.c +1 -1
@@ -4,7 +4,7 @@#include <time.h> #include <errno.h> #include <bpf/bpf_helpers.h> -#include "bpf_tcp_helpers.h" +#include <bpf/bpf_tracing.h> char _license[] SEC("license") = "GPL";struct hmap_elem {
tools/testing/selftests/bpf/progs/timer_mim_reject.c +1 -1
@@ -4,7 +4,7 @@#include <time.h> #include <errno.h> #include <bpf/bpf_helpers.h> -#include "bpf_tcp_helpers.h" +#include <bpf/bpf_tracing.h> char _license[] SEC("license") = "GPL";struct hmap_elem {
Signature · 1 line
2.43.0
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:
Quoted 10 lines · On Fri, 3 May 2024 17:50:45 -0700 you wrote:
From: Martin KaFai Lau <[email protected]>
The bpf programs that this patch changes require the
BPF_PROGmacro. TheBPF_PROGmacro is defined in the libbpf'sbpf_tracing.h. Some tests includebpf_tcp_helpers.hwhich includesbpf_tracing.h. They don't need other things frombpf_tcp_helpers.hother thanbpf_tracing.h. This patch simplifies it by directly including thebpf_tracing.h.[...]
Here is the summary with links:
- [bpf-next] selftests/bpf: Use bpf_tracing.h instead of bpf_tcp_helpers.h
https://git.kernel.org/bpf/bpf-next/c/8e6d9ae2e09f
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html