selftests/bpf: Use bpf_tracing.h instead of bpf_tcp_helpers.h
authorMartin KaFai Lau <martin.lau@kernel.org>
Sat, 4 May 2024 00:50:45 +0000 (17:50 -0700)
committerAndrii Nakryiko <andrii@kernel.org>
Mon, 6 May 2024 20:40:24 +0000 (13:40 -0700)
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.

Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20240504005045.848376-1-martin.lau@linux.dev
tools/testing/selftests/bpf/progs/timer.c
tools/testing/selftests/bpf/progs/timer_failure.c
tools/testing/selftests/bpf/progs/timer_mim.c
tools/testing/selftests/bpf/progs/timer_mim_reject.c

index f615da97df26382f4dd758015dd0aaf2cd359614..4c677c001258a4c05cd570ec52363d49d8eea169 100644 (file)
@@ -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 {
index 0996c2486f056295d1d1dcc7ce51742e84772ec2..5a2e9dabf1c6cd868fb7830197ec3154af8ff29c 100644 (file)
@@ -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";
 
index 2fee7ab105ef5268d46201ed0fb6169449c15ecd..50ebc3f6852229cd35294d18582b9600fba2c206 100644 (file)
@@ -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 {
index 5d648e3d8a41c94f1738c0a89420ddb11d7b2f73..dd3f1ed6d6e62cfa951f9f16321f228d2b8fc8f2 100644 (file)
@@ -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 {