Skip to content

Instantly share code, notes, and snippets.

@aagontuk
Last active February 25, 2025 06:36
Show Gist options
  • Select an option

  • Save aagontuk/4dc12a6c891393043c36788335aacfe3 to your computer and use it in GitHub Desktop.

Select an option

Save aagontuk/4dc12a6c891393043c36788335aacfe3 to your computer and use it in GitHub Desktop.
Resources on eBPF

Resources

Projects

Kernel Source

Helper functions

Notes

  • ebpf programs can have 4096 instructions.
  • Load/store instruction can only access packet memory. epbf programs can access arbitrary kernel memory with bpf_prob_read(). But network context doesn't have this helper.
  • 512 bytes of stack. Load/Store can be used to access stack.

Compiling and debugging

Simple compilation:

$ clang -g -O2 -Wall -target bpf -c prog.c -o prog.o

See Assembly:

$ llvm-objdump -d prog.o

Assembly with embedded C source:

$ llvm-objdump -S prog.o

Running ebpf programs with libbpf

  • Install libbpf-dev and bpftool package (Ubuntu/Debian) or install them from source.
  • Adapt libbpf-bootstrap for your project.
  • For latest features compile and install latest kernel from net-next and latest clang.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment