Skip to content

eBPF the Hard Way!

Welcome to eBPF the Hard Way - a comprehensive, hands-on guide to learning eBPF development from the ground up!

🎯 What You'll Build

This isn't just another tutorial. You'll build real, production-ready eBPF tools from scratch, understanding every line of code and concept along the way.

Learning by Building

We believe the best way to learn eBPF is by building actual tools. Each tutorial walks you through creating a complete monitoring tool, from the eBPF kernel program to the Go userspace application.

🧠 What is eBPF?

eBPF (extended Berkeley Packet Filter) is a revolutionary technology that allows you to run sandboxed programs in the Linux kernel without changing kernel source code or loading kernel modules.

Why eBPF Matters

  • πŸ” Observability: Monitor any aspect of your system in real-time
  • πŸ›‘οΈ Security: Implement custom security policies and detection
  • ⚑ Performance: Near-zero overhead monitoring and analysis
  • πŸ”§ Debugging: Create custom debugging tools for any application

πŸŽ“ What You'll Learn

By working through this guide, you'll master:

  • eBPF virtual machine and verifier
  • Program types and attachment points
  • Maps and data structures
  • Helper functions and kernel interaction
  • Writing eBPF programs in C
  • Building userspace applications in Go
  • Debugging eBPF programs
  • Performance optimization techniques
  • Cross-platform development
  • Production deployment strategies
  • CO-RE (Compile Once, Run Everywhere) development
  • Network packet processing with XDP/TC
  • Security monitoring with LSM hooks
  • Testing strategies and frameworks
  • Error handling and memory management
  • Process execution monitoring
  • File system activity tracking
  • Network connection analysis
  • Security event correlation
  • Performance profiling tools

πŸš€ Quick Start

Ready to dive in? Here's your learning path:

🌱 Beginners

  1. Set up your environment - Get everything installed
  2. Learn eBPF basics - Understand the core concepts
  3. Build your first tool - Create a complete eBPF application
  4. Explore basic tools - Learn from working examples

πŸš€ Advanced Users

  1. Master CO-RE development - Build portable eBPF programs
  2. Network programming - XDP and TC packet processing
  3. Security monitoring - LSM hooks and event correlation
  4. Testing strategies - Comprehensive testing frameworks

Estimated Time

  • Quick setup: 30 minutes
  • First tool: 2-3 hours
  • Basic proficiency: 1-2 weeks
  • Advanced topics: 2-4 weeks
  • Production mastery: 1-2 months (at your own pace)

πŸ› οΈ Tools You'll Build

Basic Tools

Tool Difficulty Category What It Does
execsnoop 🟒 Beginner Process Monitoring Monitor process executions in real-time
rmdetect 🟒 Beginner File System Monitor file deletions
opensnoop 🟑 Intermediate File System Monitor file opens

Advanced Tools

Tool Difficulty Category What It Does
tcpconnect 🟑 Intermediate Network Monitor TCP connections
biolatency πŸ”΄ Advanced Performance Measure block I/O latency
DDoS Protection πŸ”΄ Advanced Network Security XDP-based DDoS mitigation
Load Balancer πŸ”΄ Advanced Network Layer 4 load balancing with XDP
Security Monitor πŸ”΄ Advanced Security LSM-based security event detection

πŸ“‹ Prerequisites

System Requirements

  • Linux Kernel: 4.18+ (5.0+ recommended)
  • Architecture: x86_64 or arm64
  • Root Access: Required for loading eBPF programs
  • BTF Support: Check with ls /sys/kernel/btf/vmlinux

Development Knowledge

  • C Programming: Basic knowledge (we'll teach eBPF-specific parts)
  • Go Programming: Helpful but not required (examples are clear)
  • Linux Systems: Understanding of processes, files, networking

🌟 Why This Guide is Different

πŸ“š Comprehensive Yet Practical

  • Every concept is explained with working code
  • No "magic" - you'll understand every line
  • Progressive complexity from simple to advanced

🎯 Learning-Focused

  • Clear learning objectives for each section
  • Checkpoint exercises to test your understanding
  • Common pitfalls and how to avoid them

πŸ”§ Production-Ready

  • Real tools you can use in production
  • Best practices and performance considerations
  • Proper error handling and debugging techniques

🀝 Community-Driven

  • Open source and welcomes contributions
  • Active community support
  • Regular updates with new tools and concepts

πŸ—ΊοΈ Learning Path

graph TD
    A[Getting Started] --> B[eBPF Fundamentals]
    B --> C[Your First Tool]
    C --> D[Process Monitoring Tools]
    D --> E[File System Tools]
    E --> F[Network Tools]
    F --> G[Performance Tools]
    G --> H[Advanced Topics]

    style A fill:#e1f5fe
    style B fill:#f3e5f5
    style C fill:#e8f5e8
    style D fill:#fff3e0
    style E fill:#fce4ec
    style F fill:#e0f2f1
    style G fill:#fff8e1
    style H fill:#f1f8e9

πŸš€ Ready to Start?

Choose your path:

  • Complete Beginner


    Start with the fundamentals and build up your knowledge step by step.

    Begin Learning

  • Some Experience


    Jump straight to building your first tool if you know the basics.

    Build First Tool

  • Advanced Developer


    Explore advanced topics like CO-RE, XDP, LSM, and testing strategies.

    Advanced Topics

  • Production Ready


    Learn debugging, testing, and deployment strategies.

    Production Guide

πŸ“š Documentation Structure

πŸ“– Core Learning Path

πŸš€ Advanced Topics

πŸ“‹ Reference Materials

πŸ†˜ Need Help?

  • πŸ’¬ Discussions: Ask questions in GitHub Discussions
  • πŸ› Issues: Report bugs or request features
  • πŸ“– Docs: Check our comprehensive reference sections
  • 🀝 Contributing: Help improve this guide for others

Learning Philosophy

"The best way to learn eBPF is not by reading about it, but by building with it. This guide gives you the confidence to create, experiment, and innovate with eBPF."

Let's build something amazing together! πŸš€