]> git.baikalelectronics.ru Git - kernel.git/commit
samples: bpf: Fix vmlinux.h generation for XDP samples
authorKumar Kartikeya Dwivedi <memxor@gmail.com>
Tue, 28 Sep 2021 05:46:08 +0000 (11:16 +0530)
committerAndrii Nakryiko <andrii@kernel.org>
Wed, 29 Sep 2021 00:21:35 +0000 (17:21 -0700)
commit8ee8fef41f16b19b7ecc8bb345eb77d3e90ceb9b
tree338b25807575e4387e3cfd7cb15763bd11452e61
parent607bc756d4b9353d3561c6b654503cda4890b7c4
samples: bpf: Fix vmlinux.h generation for XDP samples

Generate vmlinux.h only from the in-tree vmlinux, and remove enum
declarations that would cause a build failure in case of version
mismatches.

There are now two options when building the samples:
1. Compile the kernel to use in-tree vmlinux for vmlinux.h
2. Override VMLINUX_BTF for samples using something like this:
   make VMLINUX_BTF=/sys/kernel/btf/vmlinux -C samples/bpf

This change was tested with relative builds, e.g. cases like:
 * make O=build -C samples/bpf
 * make KBUILD_OUTPUT=build -C samples/bpf
 * make -C samples/bpf
 * cd samples/bpf && make

When a suitable VMLINUX_BTF is not found, the following message is
printed:
/home/kkd/src/linux/samples/bpf/Makefile:333: *** Cannot find a vmlinux
for VMLINUX_BTF at any of "  ./vmlinux", build the kernel or set
VMLINUX_BTF variable.  Stop.

Fixes: 0122aef2e677 (samples: bpf: Add vmlinux.h generation support)
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
Link: https://lore.kernel.org/bpf/20210928054608.1799021-1-memxor@gmail.com
samples/bpf/Makefile
samples/bpf/xdp_redirect_map_multi.bpf.c