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 7 Make error

Faru0 opened this issue · comments

commented

root@xxx:/tmp/learning-ebpf/chapter7# ls -larth
total 2.9M
-rw-r--r-- 1 root root 312 Jul 14 08:56 README.md
-rw-r--r-- 1 root root 736 Jul 14 08:56 Makefile
-rw-r--r-- 1 root root 143 Jul 14 08:56 hello.h
-rw-r--r-- 1 root root 2.1K Jul 14 08:56 hello.c
-rw-r--r-- 1 root root 5.4K Jul 14 08:56 hello.bpf.c
drwxr-xr-x 12 root root 4.0K Jul 14 08:56 ..
-rw-r--r-- 1 root root 2.8M Jul 14 12:54 vmlinux.h
drwxr-xr-x 2 root root 4.0K Jul 14 12:57 .
root@xxx:/tmp/learning-ebpf/chapter7# make
clang
-target bpf
-D BPF_TRACING
-D __TARGET_ARCH_x86
-Wall
-O2 -g -o hello.bpf.o -c hello.bpf.c
hello.bpf.c:27:43: error: expected identifier
int BPF_KPROBE_SYSCALL(kprobe_sys_execve, const char *pathname)
^
hello.bpf.c:32:51: error: use of undeclared identifier 'pathname'; did you mean 'Opt_name'?
bpf_printk("%s: pathname: %s", kprobe_sys_msg, pathname);
^~~~~~~~
Opt_name
/usr/include/bpf/bpf_helpers.h:22:7: note: expanded from macro 'bpf_printk'
##VA_ARGS);
^
./vmlinux.h:40369:2: note: 'Opt_name' declared here
Opt_name = 3,
^
hello.bpf.c:37:55: error: use of undeclared identifier 'pathname'
bpf_probe_read_user(&data.path, sizeof(data.path), pathname);
^
hello.bpf.c:39:26: error: use of undeclared identifier 'ctx'
bpf_perf_event_output(ctx, &output, BPF_F_CURRENT_CPU, &data, sizeof(data));
^
4 errors generated.
make: *** [Makefile:18: hello.bpf.o] Error 1
root@xxx:/tmp/learning-ebpf/chapter7#

commented

fixed with bpftool/src/ -> make install