OpenCloudOS / nettrace

nettrace is a eBPF-based tool to trace network packet and diagnose network problem.
Other
337 stars 82 forks source link

Compilation errors on the 4.14.141 kernel version #127

Closed ioworker0 closed 1 month ago

ioworker0 commented 1 month ago

Hi @menglongdong

Sorry to bother you again :(

When attempting to compile this tool on the 4.14.141 kernel version, I encountered the following errors:

$ make -C $(pwd) COMPAT=1 all

make: Entering directory '/tmp1/nettrace'
make -C src all
make[1]: Entering directory '/tmp1/nettrace/src'
python3 gen_trace.py > trace_group.c
python3 gen_trace.py probe > progs/kprobe_trace.h
ln -s vmlinux_header.h kheaders.h
clang -O2 -c -S -Wall -fno-asynchronous-unwind-tables       \
-Wno-incompatible-pointer-types-discards-qualifiers     \
progs/kprobe.c -emit-llvm -Wno-unknown-attributes -I./ -I/tmp1/nettrace/shared/bpf/ -g -DBPF_NO_GLOBAL_DATA -DNO_BTF -DINLINE_MODE -D__F_STACK_TRACE -D__KERN_VER=4.14.141 -D__KERN_MAJOR=4 -Wno-unused-function -Wno-compare-distinct-pointer-types -Wuninitialized -D__TARGET_ARCH_x86 -DBPF_NO_PRESERVE_ACCESS_INDEX -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/12/include -I/lib/modules/4.14.141/build//arch/x86/include -I/lib/modules/4.14.141/build//arch/x86/include/generated -I/lib/modules/4.14.141/build//include -I/lib/modules/4.14.141/build//arch/x86/include/uapi -I/lib/modules/4.14.141/build//arch/x86/include/generated/uapi -I/lib/modules/4.14.141/build//include/uapi -I/lib/modules/4.14.141/build//include/generated/uapi -include /lib/modules/4.14.141/build//include/linux/kconfig.h -I/usr/include/ -D__KERNEL__ -Wno-unused-value -Wno-pointer-sign -Wno-compare-distinct-pointer-types -Wno-gnu-variable-sized-type-not-at-end -Wno-address-of-packed-member -Wno-tautological-compare -Wno-unknown-warning-option -Wno-frame-address -D__F_SK_PRPTOCOL_LEGACY -Xclang   \
-disable-llvm-passes -o - |                     \
opt -O2 -mtriple=bpf-pc-linux |                 \
llvm-dis |                          \
llc -march=bpf -filetype=obj -o progs/kprobe.o
In file included from progs/kprobe.c:3:
In file included from /usr/include/bpf/bpf_helpers.h:11:
/usr/include/bpf/bpf_helper_defs.h:327:15: error: redefinition of 'bpf_tail_call' as different kind of symbol
static long (*bpf_tail_call)(void *ctx, void *prog_array_map, __u32 index) = (void *) 12;
              ^
/lib/modules/4.14.141/build//include/linux/bpf.h:236:5: note: previous definition is here
u64 bpf_tail_call(u64 ctx, u64 r2, u64 index, u64 r4, u64 r5);
    ^
In file included from progs/kprobe.c:3:
In file included from /usr/include/bpf/bpf_helpers.h:11:
/usr/include/bpf/bpf_helper_defs.h:763:15: error: redefinition of 'bpf_get_stackid' as different kind of symbol
static long (*bpf_get_stackid)(void *ctx, void *map, __u64 flags) = (void *) 27;
              ^
/lib/modules/4.14.141/build//include/linux/bpf.h:237:5: note: previous definition is here
u64 bpf_get_stackid(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5);
    ^
In file included from progs/kprobe.c:94:
progs/core.c:57:60: error: too few arguments to function call, expected 5, have 3
        info->e->stack_id = bpf_get_stackid(info->ctx, &m_stack, 0);
                            ~~~~~~~~~~~~~~~                       ^
/lib/modules/4.14.141/build//include/linux/bpf.h:237:5: note: 'bpf_get_stackid' declared here
u64 bpf_get_stackid(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5);
    ^
3 errors generated.
make[1]: *** [../common.mk:112: progs/kprobe.o] Error 1
make[1]: Leaving directory '/tmp1/nettrace/src'
make: *** [Makefile:24: all] Error 2
make: Leaving directory '/tmp1/nettrace'

It's always tough when we want eBPF tools to be compatible with as many kernel versions as possible ;)

menglongdong commented 1 month ago

Looks like BUG of 4.14. It defines some functions, which have the same name to the BPF helpers. I did some adjust for it in the MR.

ioworker0 commented 1 month ago

Looks like BUG of 4.14. It defines some functions, which have the same name to the BPF helpers. I did some adjust for it in the MR.

Awesome, bro ~

I really appreciate your nice work!