In this project, I will rewrite O'Reily's "Learning eBPF" code examples into Go, complete with exercises where applicable. Each example is set up as its own package. Run TODO
to compile everything; to compile an individual example, run TODO
while inside that folder. Userspace examples are rewritten based on my own expertise and thanks to ebpf-go documentation; eBPF code is rewritten for libbpf based on the book's explanations, considerations from here and a bit of information from here.
Chapter 3 contains only eBPF C and thus omitted Chapter 10 contains no code and thus omitted
Here's a short recap of how to build eBPF programs with Go. This is not an in-depth guide!
- Set up your module and don't forget to manually add
bpf2go
by runninggo get github.com/cilium/ebpf/cmd/bpf2go
in the root of your module; - Write your eBPF C code;
- Run
go generate
to havebpf2go
build the helpers for your Go code; - Write your Go code and run
go build
.
Head over here for detailed instructions
Liz Rice
ebpf-go
myself
idk what else
- Makefile
- go run -exec sudo [./kprobe, ./uretprobe, ./ringbuffer, ...]