Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't run xdp_dump #60

Open
FrelDX opened this issue Jan 15, 2022 · 6 comments
Open

can't run xdp_dump #60

FrelDX opened this issue Jan 15, 2022 · 6 comments

Comments

@FrelDX
Copy link

FrelDX commented Jan 15, 2022

[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]#

@FrelDX
Copy link
Author

FrelDX commented Jan 15, 2022

[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]#

@belyalov
Copy link
Contributor

Sounds like your clang compiler is way old, try newer one?

@FrelDX
Copy link
Author

FrelDX commented Jan 17, 2022

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

@belyalov
Copy link
Contributor

There is no such example.
But you can modify this one a bit, move these lines

__u64 flags = BPF_F_CURRENT_CPU | (packet_size << 32);
bpf_perf_event_output(ctx, &perfmap, flags, &evt, sizeof(evt));

Up to somewhere
// L2
struct ethhdr *ether = data;
if (data + sizeof(*ether) > data_end) {
return XDP_ABORTED;
}
// L3

@FrelDX
Copy link
Author

FrelDX commented Jan 20, 2022

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

@FrelDX
Copy link
Author

FrelDX commented Jan 20, 2022

use of undeclared identifier evt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants