eBPF Programming

eBPF lets you run sandboxed programs inside the Linux kernel without changing kernel source or loading kernel modules. It is the foundation for modern observability, networking, and security tooling used by Kubernetes, Cilium, Falco, and Datadog.

Overview

Overview

eBPF, originally Extended Berkeley Packet Filter, has grown from packet filtering into a general-purpose kernel execution environment. It lets you instrument and enforce policy inside the kernel without the risk or maintenance burden of a kernel module.

The 1990s Berkeley Packet Filter gave tcpdump a safe way to pick which packets to capture. The extended version added a 64-bit register file, arbitrary helper calls, persistent maps, and dozens of hook points across networking, tracing and security.

Every eBPF program travels the same path into the kernel. You write it in C, Clang compiles it to BPF bytecode plus BTF type information, and the bpf syscall hands it to the kernel. There the verifier checks that every path through the program is safe. A program that fails is rejected with a readable log. A program that passes is JIT-compiled to native code and attached to a hook in networking, tracing or security, where it shares maps with user space.

Key concepts

  • eBPF Verifier and Safety Model
  • CO-RE and BTF Portability
  • Program Types and Hook Points
  • Map Types
  • libbpf Skeleton API
  • bpftrace One-Liners and Scripts
  • XDP Return Codes and Packet Processing

Interview questions

  • What are the main constraints the eBPF verifier enforces, and how do you debug a verifier rejection?
  • How does CO-RE achieve kernel portability without recompiling on the target, and what are its limitations?
  • Write a libbpf kprobe program that counts how many times each process calls write(), with a user-space loader that prints the top counts every second.
  • What is the difference between XDP and TC hook points, and when would you choose one over the other?
  • Compare bpftrace with raw eBPF using libbpf. When is each the right tool, and what are the trade-offs?

Sign up free to read the full topic

More DevOps topics

Start free on Cariara · Coding problems · System design studio