Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 6910d7d3867a ("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

authored by

Toke Høiland-Jørgensen and committed by
Alexei Starovoitov
229c3b47 3e689141

+35 -35
+1 -1
tools/bpf/bpftool/Documentation/bpftool-gen.rst
··· 196 196 #define __EXAMPLE_SKEL_H__ 197 197 198 198 #include <stdlib.h> 199 - #include <libbpf.h> 199 + #include <bpf/libbpf.h> 200 200 201 201 struct example { 202 202 struct bpf_object_skeleton *skeleton;
+1 -1
tools/bpf/bpftool/Makefile
··· 45 45 -I$(srctree)/kernel/bpf/ \ 46 46 -I$(srctree)/tools/include \ 47 47 -I$(srctree)/tools/include/uapi \ 48 - -I$(srctree)/tools/lib/bpf \ 48 + -I$(srctree)/tools/lib \ 49 49 -I$(srctree)/tools/perf 50 50 CFLAGS += -DBPFTOOL_VERSION='"$(BPFTOOL_VERSION)"' 51 51 ifneq ($(EXTRA_CFLAGS),)
+4 -4
tools/bpf/bpftool/btf.c
··· 8 8 #include <stdio.h> 9 9 #include <string.h> 10 10 #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> 13 14 #include <linux/btf.h> 14 15 #include <linux/hashtable.h> 15 16 #include <sys/types.h> 16 17 #include <sys/stat.h> 17 18 #include <unistd.h> 18 19 19 - #include "btf.h" 20 20 #include "json_writer.h" 21 21 #include "main.h" 22 22 ··· 532 532 if (IS_ERR(btf)) { 533 533 err = PTR_ERR(btf); 534 534 btf = NULL; 535 - p_err("failed to load BTF from %s: %s", 535 + p_err("failed to load BTF from %s: %s", 536 536 *argv, strerror(err)); 537 537 goto done; 538 538 }
+1 -1
tools/bpf/bpftool/btf_dumper.c
··· 8 8 #include <linux/bitops.h> 9 9 #include <linux/btf.h> 10 10 #include <linux/err.h> 11 + #include <bpf/btf.h> 11 12 12 - #include "btf.h" 13 13 #include "json_writer.h" 14 14 #include "main.h" 15 15
+1 -1
tools/bpf/bpftool/cgroup.c
··· 14 14 #include <sys/types.h> 15 15 #include <unistd.h> 16 16 17 - #include <bpf.h> 17 + #include <bpf/bpf.h> 18 18 19 19 #include "main.h" 20 20
+2 -2
tools/bpf/bpftool/common.c
··· 20 20 #include <sys/stat.h> 21 21 #include <sys/vfs.h> 22 22 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 */ 25 25 26 26 #include "main.h" 27 27
+2 -2
tools/bpf/bpftool/feature.c
··· 12 12 #include <linux/filter.h> 13 13 #include <linux/limits.h> 14 14 15 - #include <bpf.h> 16 - #include <libbpf.h> 15 + #include <bpf/bpf.h> 16 + #include <bpf/libbpf.h> 17 17 #include <zlib.h> 18 18 19 19 #include "main.h"
+5 -5
tools/bpf/bpftool/gen.c
··· 12 12 #include <stdio.h> 13 13 #include <string.h> 14 14 #include <unistd.h> 15 - #include <bpf.h> 16 - #include <libbpf.h> 15 + #include <bpf/bpf.h> 16 + #include <bpf/libbpf.h> 17 17 #include <sys/types.h> 18 18 #include <sys/stat.h> 19 19 #include <sys/mman.h> 20 20 #include <unistd.h> 21 + #include <bpf/btf.h> 21 22 22 - #include "btf.h" 23 - #include "libbpf_internal.h" 23 + #include "bpf/libbpf_internal.h" 24 24 #include "json_writer.h" 25 25 #include "main.h" 26 26 ··· 333 333 #define %2$s \n\ 334 334 \n\ 335 335 #include <stdlib.h> \n\ 336 - #include <libbpf.h> \n\ 336 + #include <bpf/libbpf.h> \n\ 337 337 \n\ 338 338 struct %1$s { \n\ 339 339 struct bpf_object_skeleton *skeleton; \n\
+1 -1
tools/bpf/bpftool/jit_disasm.c
··· 24 24 #include <dis-asm.h> 25 25 #include <sys/stat.h> 26 26 #include <limits.h> 27 - #include <libbpf.h> 27 + #include <bpf/libbpf.h> 28 28 29 29 #include "json_writer.h" 30 30 #include "main.h"
+2 -2
tools/bpf/bpftool/main.c
··· 9 9 #include <stdlib.h> 10 10 #include <string.h> 11 11 12 - #include <bpf.h> 13 - #include <libbpf.h> 12 + #include <bpf/bpf.h> 13 + #include <bpf/libbpf.h> 14 14 15 15 #include "main.h" 16 16
+2 -2
tools/bpf/bpftool/map.c
··· 15 15 #include <sys/types.h> 16 16 #include <sys/stat.h> 17 17 18 - #include <bpf.h> 18 + #include <bpf/bpf.h> 19 + #include <bpf/btf.h> 19 20 20 - #include "btf.h" 21 21 #include "json_writer.h" 22 22 #include "main.h" 23 23
+2 -2
tools/bpf/bpftool/map_perf_ring.c
··· 6 6 */ 7 7 #include <errno.h> 8 8 #include <fcntl.h> 9 - #include <libbpf.h> 9 + #include <bpf/libbpf.h> 10 10 #include <poll.h> 11 11 #include <signal.h> 12 12 #include <stdbool.h> ··· 21 21 #include <sys/mman.h> 22 22 #include <sys/syscall.h> 23 23 24 - #include <bpf.h> 24 + #include <bpf/bpf.h> 25 25 #include <perf-sys.h> 26 26 27 27 #include "main.h"
+4 -4
tools/bpf/bpftool/net.c
··· 7 7 #include <stdlib.h> 8 8 #include <string.h> 9 9 #include <unistd.h> 10 - #include <libbpf.h> 10 + #include <bpf/bpf.h> 11 + #include <bpf/libbpf.h> 11 12 #include <net/if.h> 12 13 #include <linux/if.h> 13 14 #include <linux/rtnetlink.h> ··· 17 16 #include <sys/stat.h> 18 17 #include <sys/types.h> 19 18 20 - #include <bpf.h> 21 - #include <nlattr.h> 22 - #include "libbpf_internal.h" 19 + #include "bpf/nlattr.h" 20 + #include "bpf/libbpf_internal.h" 23 21 #include "main.h" 24 22 #include "netlink_dumper.h" 25 23
+1 -1
tools/bpf/bpftool/perf.c
··· 13 13 #include <unistd.h> 14 14 #include <ftw.h> 15 15 16 - #include <bpf.h> 16 + #include <bpf/bpf.h> 17 17 18 18 #include "main.h" 19 19
+3 -3
tools/bpf/bpftool/prog.c
··· 17 17 #include <linux/err.h> 18 18 #include <linux/sizes.h> 19 19 20 - #include <bpf.h> 21 - #include <btf.h> 22 - #include <libbpf.h> 20 + #include <bpf/bpf.h> 21 + #include <bpf/btf.h> 22 + #include <bpf/libbpf.h> 23 23 24 24 #include "cfg.h" 25 25 #include "main.h"
+1 -1
tools/bpf/bpftool/xlated_dumper.c
··· 7 7 #include <stdlib.h> 8 8 #include <string.h> 9 9 #include <sys/types.h> 10 - #include <libbpf.h> 10 + #include <bpf/libbpf.h> 11 11 12 12 #include "disasm.h" 13 13 #include "json_writer.h"