Skip to content

Commit 229c3b4

Browse files
tohojoAlexei Starovoitov
authored andcommitted
bpftool: Use consistent include paths for libbpf
Fix bpftool 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: Andrii Nakryiko <andriin@fb.com> Link: https://lore.kernel.org/bpf/157952560684.1683545.4765181397974997027.stgit@toke.dk
1 parent 3e68914 commit 229c3b4

17 files changed

Lines changed: 35 additions & 35 deletions

File tree

‎tools/bpf/bpftool/Documentation/bpftool-gen.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ and global variables.
196196
#define __EXAMPLE_SKEL_H__
197197

198198
#include <stdlib.h>
199-
#include <libbpf.h>
199+
#include <bpf/libbpf.h>
200200

201201
struct example {
202202
struct bpf_object_skeleton *skeleton;

‎tools/bpf/bpftool/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ CFLAGS += -DPACKAGE='"bpftool"' -D__EXPORTED_HEADERS__ \
4545
-I$(srctree)/kernel/bpf/ \
4646
-I$(srctree)/tools/include \
4747
-I$(srctree)/tools/include/uapi \
48-
-I$(srctree)/tools/lib/bpf \
48+
-I$(srctree)/tools/lib \
4949
-I$(srctree)/tools/perf
5050
CFLAGS += -DBPFTOOL_VERSION='"$(BPFTOOL_VERSION)"'
5151
ifneq ($(EXTRA_CFLAGS),)

‎tools/bpf/bpftool/btf.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
#include <stdio.h>
99
#include <string.h>
1010
#include <unistd.h>
11-
#include <bpf.h>
12-
#include <libbpf.h>
11+
#include <bpf/bpf.h>
12+
#include <bpf/btf.h>
13+
#include <bpf/libbpf.h>
1314
#include <linux/btf.h>
1415
#include <linux/hashtable.h>
1516
#include <sys/types.h>
1617
#include <sys/stat.h>
1718
#include <unistd.h>
1819

19-
#include "btf.h"
2020
#include "json_writer.h"
2121
#include "main.h"
2222

@@ -532,7 +532,7 @@ static int do_dump(int argc, char **argv)
532532
if (IS_ERR(btf)) {
533533
err = PTR_ERR(btf);
534534
btf = NULL;
535-
p_err("failed to load BTF from %s: %s",
535+
p_err("failed to load BTF from %s: %s",
536536
*argv, strerror(err));
537537
goto done;
538538
}

‎tools/bpf/bpftool/btf_dumper.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
#include <linux/bitops.h>
99
#include <linux/btf.h>
1010
#include <linux/err.h>
11+
#include <bpf/btf.h>
1112

12-
#include "btf.h"
1313
#include "json_writer.h"
1414
#include "main.h"
1515

‎tools/bpf/bpftool/cgroup.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <sys/types.h>
1515
#include <unistd.h>
1616

17-
#include <bpf.h>
17+
#include <bpf/bpf.h>
1818

1919
#include "main.h"
2020

‎tools/bpf/bpftool/common.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
#include <sys/stat.h>
2121
#include <sys/vfs.h>
2222

23-
#include <bpf.h>
24-
#include <libbpf.h> /* libbpf_num_possible_cpus */
23+
#include <bpf/bpf.h>
24+
#include <bpf/libbpf.h> /* libbpf_num_possible_cpus */
2525

2626
#include "main.h"
2727

‎tools/bpf/bpftool/feature.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
#include <linux/filter.h>
1313
#include <linux/limits.h>
1414

15-
#include <bpf.h>
16-
#include <libbpf.h>
15+
#include <bpf/bpf.h>
16+
#include <bpf/libbpf.h>
1717
#include <zlib.h>
1818

1919
#include "main.h"

‎tools/bpf/bpftool/gen.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
#include <stdio.h>
1313
#include <string.h>
1414
#include <unistd.h>
15-
#include <bpf.h>
16-
#include <libbpf.h>
15+
#include <bpf/bpf.h>
16+
#include <bpf/libbpf.h>
1717
#include <sys/types.h>
1818
#include <sys/stat.h>
1919
#include <sys/mman.h>
2020
#include <unistd.h>
21+
#include <bpf/btf.h>
2122

22-
#include "btf.h"
23-
#include "libbpf_internal.h"
23+
#include "bpf/libbpf_internal.h"
2424
#include "json_writer.h"
2525
#include "main.h"
2626

@@ -333,7 +333,7 @@ static int do_skeleton(int argc, char **argv)
333333
#define %2$s \n\
334334
\n\
335335
#include <stdlib.h> \n\
336-
#include <libbpf.h> \n\
336+
#include <bpf/libbpf.h> \n\
337337
\n\
338338
struct %1$s { \n\
339339
struct bpf_object_skeleton *skeleton; \n\

‎tools/bpf/bpftool/jit_disasm.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include <dis-asm.h>
2525
#include <sys/stat.h>
2626
#include <limits.h>
27-
#include <libbpf.h>
27+
#include <bpf/libbpf.h>
2828

2929
#include "json_writer.h"
3030
#include "main.h"

‎tools/bpf/bpftool/main.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#include <stdlib.h>
1010
#include <string.h>
1111

12-
#include <bpf.h>
13-
#include <libbpf.h>
12+
#include <bpf/bpf.h>
13+
#include <bpf/libbpf.h>
1414

1515
#include "main.h"
1616

0 commit comments

Comments
 (0)