Comments (15)
Hi, could you please mention what version of clang and llc you are using? (llc --version
)
from bpf-samples.
Thank you for the pointer - i found out i have not done proper update-alternatives
, works good with llc 6.0. It compiles fine now.
I have one more question - just by following the docs - I was wondering if i am not missing something again ? -
./rss -i enp94s0np0
libbpf: Error in bpf_object__probe_name():Operation not permitted(1). Couldn't load basic 'r0 = 0' BPF program.
libbpf: failed to load object 'rss_kern.o'
Err: Cannot load file
For info - the interface is already in use - by Suricata.
I have 4.19.0-0.bpo.2-amd64 #1 SMP Debian 4.19.16-1~bpo9+1 (2019-02-07) x86_64 GNU/Linux
from bpf-samples.
This error is returned by libbpf that tries to load a very simple program, but not to attach it to the interface, so the status of the interface should not be related here.
Could it be something as simple as missing permissions? Are you launching the rss
executable as root?
from bpf-samples.
ok. Yes i am launching it as root.
root@suricata:/opt/bpf-samples/programmable_rss# whoami
root
root@suricata:/opt/bpf-samples/programmable_rss# ./rss -i enp94s0np0
libbpf: Error in bpf_object__probe_name():Operation not permitted(1). Couldn't load basic 'r0 = 0' BPF program.
libbpf: failed to load object 'rss_kern.o'
Err: Cannot load file
root@suricata:/opt/bpf-samples/programmable_rss#
from bpf-samples.
Hmm I cannot understand why this probe would fail.
One thing though, this bpf_object__probe_name()
is not in the libbpf version referenced by git submodule
, i.e. you should not have it in bpf-samples/libbpf/src/libbpf.c, it was added only recently. So I believe you installed libbpf on your machine, and the rss program picks that one instead of the one coming with this repo with git submodule
? Does that sound possible to you?
That wouldn't tell us why the probe fails, but at least it would explain why you get this error and I don't.
from bpf-samples.
yes - correct. That's why i mentioned it at the beginning - i used latest master libbpf .
Other wise it seems it fails for me (while with the master libbpf branch it compiles)
root@suricata:/opt# git clone --recurse-submodules https://github.com/Netronome/bpf-samples.git
Cloning into 'bpf-samples'...
remote: Enumerating objects: 181, done.
remote: Total 181 (delta 0), reused 0 (delta 0), pack-reused 181
Receiving objects: 100% (181/181), 472.88 KiB | 0 bytes/s, done.
Resolving deltas: 100% (74/74), done.
Submodule 'libbpf' (https://github.com/libbpf/libbpf.git) registered for path 'libbpf'
Cloning into '/opt/bpf-samples/libbpf'...
remote: Enumerating objects: 78, done.
remote: Counting objects: 100% (78/78), done.
remote: Compressing objects: 100% (42/42), done.
remote: Total 195 (delta 35), reused 63 (delta 32), pack-reused 117
Receiving objects: 100% (195/195), 228.27 KiB | 0 bytes/s, done.
Resolving deltas: 100% (78/78), done.
Submodule path 'libbpf': checked out '319ff2f0f6c6e823a705f21a6354af8d9cbadd14'
root@suricata:/opt# cd bpf-samples/programmable_rss/
root@suricata:/opt/bpf-samples/programmable_rss# make clean && make
cd ../libbpf/src/ && make clean;
make[1]: Entering directory '/opt/bpf-samples/libbpf/src'
../scripts/check-reallocarray.sh: 17: ../scripts/check-reallocarray.sh: Syntax error: Bad fd number
rm -f *.o *.a *.so
make[1]: Leaving directory '/opt/bpf-samples/libbpf/src'
rm -f rss
rm -f rss_kern.o
rm -f rss_user.o
rm -f *.ll
make[1]: Entering directory '/opt/bpf-samples/libbpf/src'
../scripts/check-reallocarray.sh: 17: ../scripts/check-reallocarray.sh: Syntax error: Bad fd number
cc -I. -I../include -I../include/uapi -g -O2 -Werror -Wall -c bpf.c -o bpf.o
cc -I. -I../include -I../include/uapi -g -O2 -Werror -Wall -c btf.c -o btf.o
cc -I. -I../include -I../include/uapi -g -O2 -Werror -Wall -c libbpf.c -o libbpf.o
libbpf.c: In function ‘bpf_object__add_program’:
libbpf.c:315:10: error: implicit declaration of function ‘reallocarray’ [-Werror=implicit-function-declaration]
progs = reallocarray(progs, nr_progs + 1, sizeof(progs[0]));
^~~~~~~~~~~~
libbpf.c:315:8: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
progs = reallocarray(progs, nr_progs + 1, sizeof(progs[0]));
^
libbpf.c: In function ‘bpf_object__elf_collect’:
libbpf.c:822:10: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
reloc = reallocarray(reloc, nr_reloc,
^
libbpf.c: In function ‘bpf_program__reloc_text’:
libbpf.c:1186:12: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
new_insn = reallocarray(prog->insns, new_cnt, sizeof(*insn));
^
cc1: all warnings being treated as errors
Makefile:57: recipe for target 'libbpf.o' failed
make[1]: *** [libbpf.o] Error 1
make[1]: Leaving directory '/opt/bpf-samples/libbpf/src'
make[1]: Entering directory '/opt/bpf-samples/libbpf/src'
../scripts/check-reallocarray.sh: 17: ../scripts/check-reallocarray.sh: Syntax error: Bad fd number
if [ ! -d 'root/usr/include/bpf' ]; then install -d -m 755 'root/usr/include/bpf'; fi; install bpf.h libbpf.h btf.h -m 644 'root/usr/include/bpf'
make[1]: Leaving directory '/opt/bpf-samples/libbpf/src'
cc -I../libbpf/src//root/usr/include/ -I../headers/ -L../libbpf/src/ -o rss rss_user.c -lbpf -lelf
/tmp/ccW4t9Fv.o: In function `main':
rss_user.c:(.text+0x6c2): undefined reference to `bpf_prog_load_xattr'
collect2: error: ld returned 1 exit status
Makefile:53: recipe for target 'rss' failed
make: *** [rss] Error 1
from bpf-samples.
some additional FYI
llc --version
LLVM (http://llvm.org/):
LLVM version 6.0.0
Optimized build.
Default target: x86_64-pc-linux-gnu
Host CPU: skylake-avx512
Registered Targets:
aarch64 - AArch64 (little endian)
aarch64_be - AArch64 (big endian)
amdgcn - AMD GCN GPUs
arm - ARM
arm64 - ARM64 (little endian)
armeb - ARM (big endian)
bpf - BPF (host endian)
bpfeb - BPF (big endian)
bpfel - BPF (little endian)
hexagon - Hexagon
lanai - Lanai
mips - Mips
mips64 - Mips64 [experimental]
mips64el - Mips64el [experimental]
mipsel - Mipsel
msp430 - MSP430 [experimental]
nvptx - NVIDIA PTX 32-bit
nvptx64 - NVIDIA PTX 64-bit
ppc32 - PowerPC 32
ppc64 - PowerPC 64
ppc64le - PowerPC 64 LE
r600 - AMD GPUs HD2XXX-HD6XXX
sparc - Sparc
sparcel - Sparc LE
sparcv9 - Sparc V9
systemz - SystemZ
thumb - Thumb
thumbeb - Thumb (big endian)
x86 - 32-bit X86: Pentium-Pro and above
x86-64 - 64-bit X86: EM64T and AMD64
xcore - XCore
from bpf-samples.
Ok, I missed the mention of the master branch in your original post, sorry.
Ouch, looks like something's wrong indeed. On a first glance it looks like the check-reallocarray.sh does not answer as expected but I don't remember how this is supposed to work, I'll try to investigate.
from bpf-samples.
Ok understood. Please let me know if i can provide something else as well.
Thank you for the help.
from bpf-samples.
So check-reallocarray.sh
seems broken in the version provided with git submodule
. It needs to be fixed as per this commit. As a result the Makefile believes it does not need to pass -DCOMPAT_NEED_REALLOCARRAY
when compiling the lib, and reallocarray()
is never defined.
Could you try the version from git submodule
(NOT master branch) of libbpf with the fix from that link?
I have not tried to compile with the master branch of libbpf yet, I'll keep you updated.
from bpf-samples.
Hmm it works for me with the master branch (kernel 4.20 too). I really don't understand this Operation not permitted
you get. My suggestion was not even correct, you don't even need to be root to have this probe work correctly.
Do you manage to load any other BPF program on your system?
from bpf-samples.
Suricata with xdp/ebpfilter enabled loads and runs. Not sure what could be the cause of this. I will try with a diff bpf program. What compile/build steps did you use- same as mine mentioned above ?
from bpf-samples.
Weird. Yep, I'm using the same commands:
$ git clone --recurse-submodules https://github.com/Netronome/bpf-samples.git
$ cd bpf-samples/libbpf
$ git checkout master
$ cd ../programmable_rss
$ make
# ./rss -i eth0 -j
from bpf-samples.
It runs now - it seems it was a library issue on my end.
Apologies for the noise!
from bpf-samples.
No worries, I'm glad you got it running!
from bpf-samples.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bpf-samples.