Open FrelDX opened 2 years ago
[root@node01 xdp_dump]# clang -v clang version 5.0.1 (tags/RELEASE_501/final) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /opt/rh/llvm-toolset-7/root/usr/bin Found candidate GCC installation: /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7 Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.2 Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.5 Selected GCC installation: /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7 Candidate multilib: .;@m64 Candidate multilib: 32;@m32 Selected multilib: .;@m64 [root@node01 xdp_dump]# go version go version go1.15.14 linux/amd64 [root@node01 xdp_dump]# uname -a Linux node01 5.4.171-1.el7.elrepo.x86_64 #1 SMP Mon Jan 10 18:01:24 EST 2022 x86_64 x86_64 x86_64 GNU/Linux [root@node01 xdp_dump]#
Sounds like your clang
compiler is way old, try newer one?
https://github.com/dropbox/goebpf/tree/master/examples/xdp/xdp_dump
In this example, only TCP related data will be obtained. Is there an example of obtaining IP layer or Ethernet layer data
There is no such example. But you can modify this one a bit, move these lines https://github.com/dropbox/goebpf/blob/8a0799ae57d68d133a8b1e0127bf95d464384e23/examples/xdp/xdp_dump/ebpf_prog/xdp_dump.c#L127-L128 Up to somewhere https://github.com/dropbox/goebpf/blob/8a0799ae57d68d133a8b1e0127bf95d464384e23/examples/xdp/xdp_dump/ebpf_prog/xdp_dump.c#L80-L86
When I move the code to the specified location according to what you said, an error is reported, It seems that there are variables that are not defined, I don't understand C language. Can you give me a complete code
use of undeclared identifier evt
[root@node01 xdp_dump]# go build
github.com/dropbox/goebpf
In file included from ../../../map.go:13:0: ./bpf_helpers.h:957:15: error: expected declaration specifiers or '...' before 'sizeof' static_assert(sizeof(u8) == 1, "wrong_u8_size"); ^ ./bpf_helpers.h:957:34: error: expected declaration specifiers or '...' before string constant static_assert(sizeof(u8) == 1, "wrong_u8_size"); ^ ./bpf_helpers.h:958:15: error: expected declaration specifiers or '...' before 'sizeof' static_assert(sizeof(u16) == 2, "wrong_u16_size"); ^ ./bpf_helpers.h:958:35: error: expected declaration specifiers or '...' before string constant static_assert(sizeof(u16) == 2, "wrong_u16_size"); ^ ./bpf_helpers.h:959:15: error: expected declaration specifiers or '...' before 'sizeof' static_assert(sizeof(u32) == 4, "wrong_u32_size"); ^ ./bpf_helpers.h:959:35: error: expected declaration specifiers or '...' before string constant static_assert(sizeof(u32) == 4, "wrong_u32_size"); ^ ./bpf_helpers.h:960:15: error: expected declaration specifiers or '...' before 'sizeof' static_assert(sizeof(u64) == 8, "wrong_u64_size"); ^ ./bpf_helpers.h:960:35: error: expected declaration specifiers or '...' before string constant static_assert(sizeof(u64) == 8, "wrong_u64_size"); ^ [root@node01 xdp_dump]#