Skip to content

Commit 8e6d9ae

Browse files
Martin KaFai Lauanakryiko
authored andcommitted
selftests/bpf: Use bpf_tracing.h instead of bpf_tcp_helpers.h
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
1 parent a9e7715 commit 8e6d9ae

4 files changed

Lines changed: 5 additions & 4 deletions

File tree

tools/testing/selftests/bpf/progs/timer.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
/* Copyright (c) 2021 Facebook */
33
#include <linux/bpf.h>
44
#include <time.h>
5+
#include <stdbool.h>
56
#include <errno.h>
67
#include <bpf/bpf_helpers.h>
7-
#include "bpf_tcp_helpers.h"
8+
#include <bpf/bpf_tracing.h>
89

910
char _license[] SEC("license") = "GPL";
1011
struct hmap_elem {

tools/testing/selftests/bpf/progs/timer_failure.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#include <time.h>
66
#include <errno.h>
77
#include <bpf/bpf_helpers.h>
8+
#include <bpf/bpf_tracing.h>
89
#include "bpf_misc.h"
9-
#include "bpf_tcp_helpers.h"
1010

1111
char _license[] SEC("license") = "GPL";
1212

tools/testing/selftests/bpf/progs/timer_mim.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <time.h>
55
#include <errno.h>
66
#include <bpf/bpf_helpers.h>
7-
#include "bpf_tcp_helpers.h"
7+
#include <bpf/bpf_tracing.h>
88

99
char _license[] SEC("license") = "GPL";
1010
struct hmap_elem {

tools/testing/selftests/bpf/progs/timer_mim_reject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <time.h>
55
#include <errno.h>
66
#include <bpf/bpf_helpers.h>
7-
#include "bpf_tcp_helpers.h"
7+
#include <bpf/bpf_tracing.h>
88

99
char _license[] SEC("license") = "GPL";
1010
struct hmap_elem {

0 commit comments

Comments
 (0)