Skip to content

Commit 7cf245a

Browse files
tohojoAlexei Starovoitov
authored andcommitted
samples/bpf: Use consistent include paths for libbpf
Fix all files in samples/bpf to include libbpf header files with the bpf/ prefix, to be consistent with external users of the library. Also ensure that all includes of exported libbpf header files (those that are exported on 'make install' of the library) use bracketed includes instead of quoted. To make sure no new files are introduced that doesn't include the bpf/ prefix in its include, remove tools/lib/bpf from the include path entirely, and use tools/lib instead. Fixes: 6910d7d ("selftests/bpf: Ensure bpf_helper_defs.h are taken from selftests dir") Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Jesper Dangaard Brouer <brouer@redhat.com> Acked-by: Andrii Nakryiko <andriin@fb.com> Link: https://lore.kernel.org/bpf/157952560911.1683545.8795966751309534150.stgit@toke.dk
1 parent 521fe8b commit 7cf245a

83 files changed

Lines changed: 112 additions & 113 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎samples/bpf/Makefile‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ TPROGS_CFLAGS += -Wmissing-prototypes
184184
TPROGS_CFLAGS += -Wstrict-prototypes
185185

186186
TPROGS_CFLAGS += -I$(objtree)/usr/include
187-
TPROGS_CFLAGS += -I$(srctree)/tools/lib/bpf/
188187
TPROGS_CFLAGS += -I$(srctree)/tools/testing/selftests/bpf/
189188
TPROGS_CFLAGS += -I$(srctree)/tools/lib/
190189
TPROGS_CFLAGS += -I$(srctree)/tools/include
@@ -305,7 +304,7 @@ $(obj)/%.o: $(src)/%.c
305304
@echo " CLANG-bpf " $@
306305
$(Q)$(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(BPF_EXTRA_CFLAGS) \
307306
-I$(obj) -I$(srctree)/tools/testing/selftests/bpf/ \
308-
-I$(srctree)/tools/lib/bpf/ \
307+
-I$(srctree)/tools/lib/ \
309308
-D__KERNEL__ -D__BPF_TRACING__ -Wno-unused-value -Wno-pointer-sign \
310309
-D__TARGET_ARCH_$(SRCARCH) -Wno-compare-distinct-pointer-types \
311310
-Wno-gnu-variable-sized-type-not-at-end \

‎samples/bpf/cpustat_kern.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <linux/version.h>
44
#include <linux/ptrace.h>
55
#include <uapi/linux/bpf.h>
6-
#include "bpf_helpers.h"
6+
#include <bpf/bpf_helpers.h>
77

88
/*
99
* The CPU number, cstate number and pstate number are based

‎samples/bpf/fds_example.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include <bpf/bpf.h>
1616

17-
#include "libbpf.h"
17+
#include <bpf/libbpf.h>
1818
#include "bpf_insn.h"
1919
#include "sock_example.h"
2020

‎samples/bpf/hbm.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
#include "cgroup_helpers.h"
5151
#include "hbm.h"
5252
#include "bpf_util.h"
53-
#include "bpf.h"
54-
#include "libbpf.h"
53+
#include <bpf/bpf.h>
54+
#include <bpf/libbpf.h>
5555

5656
bool outFlag = true;
5757
int minRate = 1000; /* cgroup rate limit in Mbps */

‎samples/bpf/hbm_kern.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
#include <uapi/linux/pkt_cls.h>
2323
#include <net/ipv6.h>
2424
#include <net/inet_ecn.h>
25-
#include "bpf_endian.h"
26-
#include "bpf_helpers.h"
25+
#include <bpf/bpf_endian.h>
26+
#include <bpf/bpf_helpers.h>
2727
#include "hbm.h"
2828

2929
#define DROP_PKT 0

‎samples/bpf/ibumad_kern.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#define KBUILD_MODNAME "ibumad_count_pkts_by_class"
1414
#include <uapi/linux/bpf.h>
1515

16-
#include "bpf_helpers.h"
16+
#include <bpf/bpf_helpers.h>
1717

1818

1919
struct bpf_map_def SEC("maps") read_count = {

‎samples/bpf/ibumad_user.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
#include "bpf_load.h"
2727
#include "bpf_util.h"
28-
#include "libbpf.h"
28+
#include <bpf/libbpf.h>
2929

3030
static void dump_counts(int fd)
3131
{

‎samples/bpf/lathist_kern.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <linux/version.h>
99
#include <linux/ptrace.h>
1010
#include <uapi/linux/bpf.h>
11-
#include "bpf_helpers.h"
11+
#include <bpf/bpf_helpers.h>
1212

1313
#define MAX_ENTRIES 20
1414
#define MAX_CPU 4

‎samples/bpf/lwt_len_hist_kern.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <uapi/linux/if_ether.h>
1515
#include <uapi/linux/ip.h>
1616
#include <uapi/linux/in.h>
17-
#include "bpf_helpers.h"
17+
#include <bpf/bpf_helpers.h>
1818

1919
# define printk(fmt, ...) \
2020
({ \

‎samples/bpf/map_perf_test_kern.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
#include <linux/netdevice.h>
99
#include <linux/version.h>
1010
#include <uapi/linux/bpf.h>
11-
#include "bpf_helpers.h"
11+
#include <bpf/bpf_helpers.h>
1212
#include "bpf_legacy.h"
13-
#include "bpf_tracing.h"
13+
#include <bpf/bpf_tracing.h>
1414

1515
#define MAX_ENTRIES 1000
1616
#define MAX_NR_CPUS 1024

0 commit comments

Comments
 (0)