xdp-tutorial
xdp-tutorial copied to clipboard
compile error
Hi I have installed the dependencies. However, we I compile the basic01 tutorial, the following error with attached logs are seen. Any help is much appreciated.
Regards error.txt ,
here is the error shown: common_user_bpf_xdp.c: In function ‘load_bpf_object_file’: common_user_bpf_xdp.c:112:9: error: variable ‘prog_load_attr’ has initializer but incomplete type 112 | struct bpf_prog_load_attr prog_load_attr = { | ^~~~~~~~~~~~~~~~~~
Did you include the git submodule? Try running git submodule update --init
yes I have. I have followed the dependencies mentioned in the document. here is my kernel info as well. Linux VM1 5.15.0-1017-aws #21~20.04.1-Ubuntu SMP Fri Aug 5 11:44:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Behzad @.***> writes:
yes I have. I have followed the dependencies mentioned in the document. here is my kernel info as well. Linux VM1 5.15.0-1017-aws #21~20.04.1-Ubuntu SMP Fri Aug 5 11:44:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Hmm, did you update the libbpf submodule to a newer version than the one that's pinned in the tutorial repository, by any chance?
Hello, I am new in eBPF and I want to learn more about XDP.
I just tried to compile the code and I am having this error. I will paste the log.
I updated libbpf 0.7 to 0.8, LLVM 14. Also, I am using Linux Kernel 5.15.67
[omarerc@fedora` xdp-tutorial-2022-04-15-a24d425b]$ sh build.sh build
=== BUILD XDP SAMPLES...
make: Entering directory '/home/omarerc/Documents/project/xdp-tutorial-2022-04-15-a24d425b'
make -C basic01-xdp-pass
make[1]: Entering directory '/home/omarerc/Documents/project/xdp-tutorial-2022-04-15-a24d425b/basic01-xdp-pass'
make[2]: Entering directory '/home/omarerc/Documents/project/xdp-tutorial-2022-04-15-a24d425b/libbpf/src'
MKDIR staticobjs
CC staticobjs/bpf.o
CC staticobjs/btf.o
CC staticobjs/libbpf.o
CC staticobjs/libbpf_errno.o
CC staticobjs/netlink.o
CC staticobjs/nlattr.o
CC staticobjs/str_error.o
CC staticobjs/libbpf_probes.o
CC staticobjs/bpf_prog_linfo.o
CC staticobjs/xsk.o
CC staticobjs/btf_dump.o
CC staticobjs/hashmap.o
CC staticobjs/ringbuf.o
CC staticobjs/strset.o
CC staticobjs/linker.o
CC staticobjs/gen_loader.o
CC staticobjs/relo_core.o
AR libbpf.a
MKDIR sharedobjs
CC sharedobjs/bpf.o
CC sharedobjs/btf.o
CC sharedobjs/libbpf.o
CC sharedobjs/libbpf_errno.o
CC sharedobjs/netlink.o
CC sharedobjs/nlattr.o
CC sharedobjs/str_error.o
CC sharedobjs/libbpf_probes.o
CC sharedobjs/bpf_prog_linfo.o
CC sharedobjs/xsk.o
CC sharedobjs/btf_dump.o
CC sharedobjs/hashmap.o
CC sharedobjs/ringbuf.o
CC sharedobjs/strset.o
CC sharedobjs/linker.o
CC sharedobjs/gen_loader.o
CC sharedobjs/relo_core.o
CC libbpf.so.0.8.0
make[2]: Leaving directory '/home/omarerc/Documents/project/xdp-tutorial-2022-04-15-a24d425b/libbpf/src'
make[2]: Entering directory '/home/omarerc/Documents/project/xdp-tutorial-2022-04-15-a24d425b/libbpf/src'
INSTALL bpf.h libbpf.h btf.h libbpf_common.h libbpf_legacy.h xsk.h bpf_helpers.h bpf_helper_defs.h bpf_tracing.h bpf_endian.h bpf_core_read.h skel_internal.h libbpf_version.h
make[2]: Leaving directory '/home/omarerc/Documents/project/xdp-tutorial-2022-04-15-a24d425b/libbpf/src'
make -C ../common/
make[2]: Entering directory '/home/omarerc/Documents/project/xdp-tutorial-2022-04-15-a24d425b/common'
gcc -g -Wall -I../libbpf/src//build/usr/include/ -I../headers -c -o common_params.o common_params.c
gcc -g -Wall -I../libbpf/src//build/usr/include/ -I../headers -c -o common_user_bpf_xdp.o common_user_bpf_xdp.c
gcc -g -Wall -I../libbpf/src//build/usr/include/ -I../headers -c -o common_libbpf.o common_libbpf.c
make[2]: Leaving directory '/home/omarerc/Documents/project/xdp-tutorial-2022-04-15-a24d425b/common'
gcc -Wall -I../libbpf/src//build/usr/include/ -g -I../headers/ -L../libbpf/src/ -o xdp_pass_user ../common//common_params.o \
xdp_pass_user.c -l:libbpf.a -lelf -lz
/home/omarerc/Documents/project/llvm-bpf-14.0.6.Linux-x86_64/bin/clang -S \
-target bpf \
-D __BPF_TRACING__ \
-I../libbpf/src//build/usr/include/ -I../headers/ \
-Wall \
-Wno-unused-value \
-Wno-pointer-sign \
-Wno-compare-distinct-pointer-types \
-Werror \
-O2 -emit-llvm -c -g -o xdp_pass_kern.ll xdp_pass_kern.c
/home/omarerc/Documents/project/llvm-bpf-14.0.6.Linux-x86_64/bin/llc -march=bpf -filetype=obj -o xdp_pass_kern.o xdp_pass_kern.ll
make[1]: Leaving directory '/home/omarerc/Documents/project/xdp-tutorial-2022-04-15-a24d425b/basic01-xdp-pass'
make -C basic02-prog-by-name
make[1]: Entering directory '/home/omarerc/Documents/project/xdp-tutorial-2022-04-15-a24d425b/basic02-prog-by-name'
aarch64-openwrt-linux-gcc -Wall -I../libbpf/src//build/usr/include/ -g -I../headers/ -L../libbpf/src/ -o xdp_loader ../common//common_params.o ../common//common_user_bpf_xdp.o \
xdp_loader.c -l:libbpf.a -lelf -lz
/home/omarerc/Documents/project/openwrt-toolchain-mvebu-cortexa53_gcc-11.3.0_musl.Linux-x86_64/toolchain-aarch64_cortex-a53_gcc-11.3.0_musl/bin/../lib/gcc/aarch64-openwrt-linux-musl/11.3.0/../../../../aarch64-openwrt-linux-musl/bin/ld: ../common//common_params.o: Relocations in generic ELF (EM: 62)
/home/omarerc/Documents/project/openwrt-toolchain-mvebu-cortexa53_gcc-11.3.0_musl.Linux-x86_64/toolchain-aarch64_cortex-a53_gcc-11.3.0_musl/bin/../lib/gcc/aarch64-openwrt-linux-musl/11.3.0/../../../../aarch64-openwrt-linux-musl/bin/ld: ../common//common_params.o: Relocations in generic ELF (EM: 62)
/home/omarerc/Documents/project/openwrt-toolchain-mvebu-cortexa53_gcc-11.3.0_musl.Linux-x86_64/toolchain-aarch64_cortex-a53_gcc-11.3.0_musl/bin/../lib/gcc/aarch64-openwrt-linux-musl/11.3.0/../../../../aarch64-openwrt-linux-musl/bin/ld: ../common//common_params.o: Relocations in generic ELF (EM: 62)
/home/omarerc/Documents/project/openwrt-toolchain-mvebu-cortexa53_gcc-11.3.0_musl.Linux-x86_64/toolchain-aarch64_cortex-a53_gcc-11.3.0_musl/bin/../lib/gcc/aarch64-openwrt-linux-musl/11.3.0/../../../../aarch64-openwrt-linux-musl/bin/ld: ../common//common_params.o: Relocations in generic ELF (EM: 62)
/home/omarerc/Documents/project/openwrt-toolchain-mvebu-cortexa53_gcc-11.3.0_musl.Linux-x86_64/toolchain-aarch64_cortex-a53_gcc-11.3.0_musl/bin/../lib/gcc/aarch64-openwrt-linux-musl/11.3.0/../../../../aarch64-openwrt-linux-musl/bin/ld: ../common//common_params.o: Relocations in generic ELF (EM: 62)
/home/omarerc/Documents/project/openwrt-toolchain-mvebu-cortexa53_gcc-11.3.0_musl.Linux-x86_64/toolchain-aarch64_cortex-a53_gcc-11.3.0_musl/bin/../lib/gcc/aarch64-openwrt-linux-musl/11.3.0/../../../../aarch64-openwrt-linux-musl/bin/ld: ../common//common_params.o: Relocations in generic ELF (EM: 62)
/home/omarerc/Documents/project/openwrt-toolchain-mvebu-cortexa53_gcc-11.3.0_musl.Linux-x86_64/toolchain-aarch64_cortex-a53_gcc-11.3.0_musl/bin/../lib/gcc/aarch64-openwrt-linux-musl/11.3.0/../../../../aarch64-openwrt-linux-musl/bin/ld: ../common//common_params.o: error adding symbols: file in wrong format
collect2: error: ld returned 1 exit status
make[1]: *** [../common//common.mk:107: xdp_loader] Error 1
make[1]: Leaving directory '/home/omarerc/Documents/project/xdp-tutorial-2022-04-15-a24d425b/basic02-prog-by-name'
make: *** [Makefile:13: basic02-prog-by-name] Error 2
make: Leaving directory '/home/omarerc/Documents/project/xdp-tutorial-2022-04-15-a24d425b'
Omar Ramirez @.***> writes:
Hello, I am new in eBPF and I want to learn more about XDP.
I just tried to compile the code and I am having this error. I will paste the log.
I updated libbpf 0.7 to 0.8, LLVM 14. Also, I am using Linux Kernel 5.15.67
The tutorial only works with the particular git revision of libbpf that it's pinned to, so updating it is not going to work...
Thanks a lot for all this work done. Do you think there's any way that I can help to update the code? This is a really great resource to learn and share with the community.
Omar Ramirez @.***> writes:
Thanks a lot for all this work done. Do you think there's any way that I can help to update the code? This is a really great resource to learn and share with the community.
A PR to update the tutorial to the newer libbpf features/syntax would be awesome! It'll involve updating the libbpf submodule version, fixing up any compile errors caused by deprecates API usage, moving map definitions to the new BTF-based syntax, and updating all the tutorial text etc to match. I.e., it's not exactly a trivial undertaking which is why no one has done it yet... :(