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 5: ksyscall build issue

ayushman4 opened this issue · comments

The chapter says ctx is available but it doesn't seem to be able to reference it. Also, any parameters added to BPF_KSYSCALL seems to throw an error.

make
clang \
    -target bpf \
        -D __TARGET_ARCH_x86 \
    -Wall \
    -O2 -g -o hello-buffer-config.bpf.o -c hello-buffer-config.bpf.c
hello-buffer-config.bpf.c:27:31: error: expected identifier
int BPF_KPROBE_SYSCALL(hello, const char *pathname)
                              ^
hello-buffer-config.bpf.c:36:59: error: use of undeclared identifier 'pathname'
   bpf_probe_read_user_str(&data.path, sizeof(data.path), pathname);
                                                          ^
hello-buffer-config.bpf.c:45:26: error: use of undeclared identifier 'ctx'
   bpf_perf_event_output(ctx, &output, BPF_F_CURRENT_CPU, &data, sizeof(data));   
                         ^
3 errors generated.
make: *** [Makefile:15: hello-buffer-config.bpf.o] Error 1

Hello, I am facing the same issues. If you have solved this problem, could you tell me how to solve this, thx!

commented

Hello, I am facing the same issues. If you have solved this problem, could you tell me how to solve this, thx!

sudo apt install -t sid libbpf-dev was suggested in #12 (comment)