Leanpub Header

Skip to main content

eBPF for Systems Engineers

From First Principles to Production Deployments

This book is 100% completeLast updated on 2026-08-02

Discover how eBPF is changing Linux systems engineering. Starting with the fundamentals, this book walks you through building, debugging and deploying real eBPF programs for observability, networking, security and performance. Learn practical techniques you can use with confidence in production across modern Linux environments.

Minimum price

$19.00

$29.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
APP
187
Pages
About

About

About the Book

This book teaches you everything you need to know about eBPF, from the foundational concepts to advanced production deployments. You will learn how to write, compile, load, debug, and operate eBPF programs that run safely in the Linux kernel to provide observability, networking, security, and performance capabilities without modifying kernel source code or loading traditional kernel modules. By the end of this book, you will be able to design and implement production-grade eBPF solutions using modern libbpf and CO-RE techniques that work across different kernel versions and environments.

Author

About the Author

Steve Publications

Steve is a technology professional with more than 20 years of experience in software development, server infrastructure, cybersecurity, vulnerability research and reverse engineering. Throughout his career, he has designed, secured, analyzed and tested complex software and infrastructure, with a particular focus on understanding how systems fail and how they can be made more secure.

Outside of work, Steve enjoys sharing knowledge with the technology community. He collaborates with researchers, industry experts and technology professionals to write practical books covering software development, cybersecurity, cloud computing, networking, DevOps, artificial intelligence and enterprise technologies. His books focus on practical learning through clear explanations, real-world examples and hands-on exercises. With more than two decades of industry experience, his goal is to help IT professionals, students and technology enthusiasts build useful skills and stay current in a rapidly changing industry.

We believe readers deserve to know how our books are created. Most of our authors are not native English speakers, so we use AI to help translate, proofread manuscripts, fix grammar, improve sentence structure and make technical explanations easier to read. AI is used as an editing tool only. It does not replace the research, technical knowledge or hands-on experience behind our books. Some of our authors also prefer to remain anonymous for privacy or professional reasons. In those cases, we publish their work under a different name. The author's name may be different, but the quality of the content and our review process remain the same.

Every book is written, reviewed and maintained by experienced technology professionals, with contributions from our private technical community of more than 420 engineers and researchers from Ukraine, Belarus and Russia. We spend far more time validating technical accuracy and keeping our content up to date than generating text. We are always interested in working with experienced professionals who have deep expertise in a particular technology or domain. If you would like to publish a book with us or help review an existing manuscript, we'd love to hear from you. Send us a message describing your area of expertise. We are especially interested in niche technologies, specialized skills and emerging topics that are underrepresented in existing technical literature.

If you look through the contents of our books, you'll see practical examples, detailed explanations and material that is regularly updated. Our goal is to publish books that professionals can actually rely on, not low-effort AI-generated content. If you ever feel that one of our books does not meet that standard, Leanpub offers a 60-day money-back guarantee. Feel free to request a refund if you are not satisfied with your purchase.

Contents

Table of Contents

From First Principles to Production Deployments

Introduction: The eBPF Revolution

  1. The Observability Problem in Modern Infrastructure
  2. Before eBPF: What We Used to Do
  3. What eBPF Gives You
  4. Who Should Read This Book
  5. How This Book Is Organized

Chapter 1: History and Evolution of BPF

  1. The Original Berkeley Packet Filter
  2. Linux Socket Filters: The First Step
  3. The Birth of cBPF and eBPF
  4. Alexei Starovoitov and the eBPF Project
  5. Major Milestones: From 3.18 to 6.x

Chapter 2: Linux Kernel Architecture for eBPF

  1. Kernel Space vs User Space: The Boundary
  2. System Calls and Context Switching
  3. Kernel Hooks and Tracing Infrastructure
  4. Memory Management Basics for eBPF
  5. The BPF Virtual Machine Architecture
  6. How Programs Attach to the Kernel

Chapter 3: The eBPF Execution Model

  1. The eBPF Instruction Set Architecture
  2. Registers and Calling Conventions
  3. The Fixed-Size Stack
  4. Control Flow: Loops and Conditionals
  5. Execution Contexts and Program Inputs
  6. Deterministic Termination Requirements

Chapter 4: Writing Your First eBPF Programs

  1. Setting Up the Development Environment
  2. The LLVM/Clang Compilation Pipeline
  3. A Hello World Tracepoint Program
  4. Building with libbpf Skeletons
  5. Running and Reading Output
  6. Understanding the Generated Code

Chapter 5: The eBPF Verifier

  1. Why the Verifier Exists
  2. Safety Guarantees: Memory, Execution Time, Privileges
  3. How the Verifier Works: State Machine Analysis
  4. Common Verification Failures and Fixes
  5. Loop Unrolling and Complexity Limits
  6. Understanding Verifier Logs

Chapter 6: JIT Compilation

  1. Why JIT Compilation Matters
  2. The JIT Compilation Pipeline
  3. Architecture-Specific JITs (x86, ARM, RISC-V)
  4. JIT vs Interpreter Performance
  5. Enabling, Disabling, and Tuning JIT
  6. When Native Performance Is Critical

Chapter 7: eBPF Maps — Data Structures Between Kernel and User Space

  1. What Maps Are and Why They Matter
  2. Hash Maps: The Workhorse
  3. Array Maps and Perf Arrays
  4. Ring Buffers for High-Throughput Data
  5. LRU and Per-CPU Variants
  6. Map Performance and Capacity Planning

Chapter 8: Helper Functions — Talking to the Kernel

  1. The Helper Function Calling Convention
  2. Core Helpers: Time, Task, and Map Operations
  3. Networking Helpers for Packets and Sockets
  4. Tracing Helpers for kprobes and Tracepoints
  5. Security and Permission Helpers
  6. Choosing the Right Helper

Chapter 9: BTF and CO-RE — Kernel-Agnostic eBPF Programs

  1. The Kernel Version Compatibility Problem
  2. What BTF Is: Type Information in the Kernel
  3. How CO-RE Relocation Works
  4. Writing CO-RE-Compatible Programs
  5. libbpf’s Role in CO-RE
  6. Debugging CO-RE Relocations

Chapter 10: Tracing with kprobes, uprobes, and Tracepoints

  1. kprobes: Instrumenting Kernel Functions
  2. Finding Safe Probe Locations
  3. uprobes for User-Space Tracing
  4. Tracepoints: Stable Instrumentation Points
  5. Raw Tracepoints for Maximum Performance
  6. Choosing the Right Tracing Mechanism

Chapter 11: fentry, fexit, and Modern Function Tracing

  1. How fentry/fexit Differ from kprobes
  2. Performance Advantages of fentry/fexit
  3. Attaching to Kernel Functions Safely
  4. Return Value Tracing with fexit
  5. Limitations and Gotchas
  6. Migration Guide: From kprobes to fentry

Chapter 12: XDP — Extreme Packet Processing at Line Rate

  1. The Networking Performance Problem
  2. XDP Architecture and Execution Points
  3. Driver, Hardware, and Generic Modes
  4. Writing Your First XDP Program
  5. Packet Manipulation and Actions
  6. XDP in Production: Load Balancing and DDoS Protection

Chapter 13: Traffic Control, Socket Filters, and cgroups Programs

  1. Traffic Control (TC) Hooks
  2. Socket Filters for Application Traffic
  3. cgroup Attach Points: v1 vs v2
  4. Socket Operations Tracing
  5. Container-Aware Networking with cgroups
  6. Combining Multiple Network Hooks

Chapter 14: Security Monitoring with eBPF and LSM Hooks

  1. Why Traditional Security Tools Fall Short
  2. Syscall Monitoring and Auditing
  3. File System Access Tracking
  4. Process Lifecycle Monitoring
  5. LSM Hooks: Deep Kernel Security Integration
  6. Building a Security Monitoring Stack

Chapter 15: Observability, Profiling, and Performance Analysis

  1. The Three Pillars: Metrics, Traces, Logs
  2. Building Custom Observability Tools
  3. CPU Profiling with eBPF
  4. Latency Analysis and Histograms
  5. Integration with Prometheus and OpenTelemetry
  6. Production Monitoring Patterns

Chapter 16: Kubernetes and Container Visibility

  1. Containers as a Tracing Challenge
  2. Namespace-Aware eBPF Programs
  3. Pod and Container Identification
  4. Service Mesh Integration (Istio, Cilium)
  5. Runtime Security in Kubernetes
  6. Multi-Tenant Observability

Chapter 17: Production Operations — Deploying, Securing, and Maintaining eBPF

  1. Security Model and Privilege Management
  2. Deployment Strategies and Automation
  3. Debugging Production eBPF Programs
  4. Performance Tuning and Resource Limits
  5. Version Compatibility and Rollout Planning
  6. Monitoring Your eBPF Infrastructure

Conclusion: The Future of eBPF

  1. Where eBPF Has Been
  2. Emerging Capabilities and Active Development
  3. Beyond Linux: Cross-Platform Prospects
  4. Skills That Will Matter
  5. Final Thoughts on Systems Engineering with eBPF

References

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub