lizrice / learning-ebpf

Learning eBPF, published by O'Reilly - out now! Here's where you'll find a VM config for the examples, and more

Home Page:https://www.amazon.com/Learning-eBPF-Programming-Observability-Networking/dp/1098135121

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Chapter 2 - hello-buffer.py - Failed to load BPF program b'hello': Invalid argument

TuuuanZi opened this issue · comments

Hello
I run the code from the ch2, but something went wrong.
Here is the ERROR generated by python:

bpf: Failed to load program: Invalid argument
last insn is not an exit or jmp
processed 0 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0

Traceback (most recent call last):
File "/home/zrj/learning-eBPF/hello_buffer.py", line 32, in
b.attach_kprobe(event=syscall, fn_name="hello")
File "/usr/lib/python3.6/site-packages/bcc/init.py", line 646, in attach_kprobe
fn = self.load_func(fn_name, BPF.KPROBE)
File "/usr/lib/python3.6/site-packages/bcc/init.py", line 384, in load_func
(func_name, errstr))
Exception: Failed to load BPF program b'hello': Invalid argument

but it works when I delete bpf_probe_read_kernel(&data.message, sizeof(data.message), message);
I'm new in eBPF, and I want to figure out what's wrong with this line
thanks a lot!

Here is my kernel version

Linux 6.6.1-1.el7.elrepo.x86_64

Did you download the code or typed it out (maybe you made a typo?)?

I didn't have any problems running it on 6.6.1 (openSUSE Tumbleweed), so maybe a distro specific bug?

I would recommend using the provided VM configuration to get started. I have not tested this code on a 6.6 kernel