Comprehensive documentation for clj-ebpf, a pure Clojure library for eBPF programming.
Start with the main README in the project root for:
Learn how to extend clj-ebpf with new BPF helper functions as they're added to the Linux kernel.
Topics Covered:
Target Audience:
Prerequisites:
See the examples/ directory for runnable code:
Run examples:
# Custom helpers demo (no root required)
clj -M -m examples.custom-helpers
# System call tracing (requires root)
sudo clj -M -m examples.execve-tracer trace
clj-ebpf.core - Main public API
clj-ebpf.helpers - BPF helper function registry
clj-ebpf.dsl - BPF assembly DSL
clj-ebpf.maps - BPF map types and operations
clj-ebpf.programs - Program types and attachment
clj-ebpf.btf - BTF (BPF Type Format) support
clj-ebpf.relocate - CO-RE relocations
See tutorials/ for a comprehensive 25-chapter tutorial series:
Start with Tutorial Introduction.
clj-ebpf uses a layered architecture:
┌─────────────────────────────────────────┐
│ Core API (clj-ebpf.core) │
│ User-facing facade and conveniences │
└───────────────┬─────────────────────────┘
│
┌───────────────┴─────────────────────────┐
│ Domain Layer │
│ Maps | Programs | Events | DSL | BTF │
└───────────────┬─────────────────────────┘
│
┌───────────────┴─────────────────────────┐
│ Utils Layer (clj-ebpf.utils) │
│ Memory | Serialization | System Utils │
└───────────────┬─────────────────────────┘
│
┌───────────────┴─────────────────────────┐
│ Syscall Layer (clj-ebpf.syscall) │
│ Direct bpf() syscall via Panama │
└─────────────────────────────────────────┘
Design Principles:
git clone https://github.com/yourusername/clj-ebpf
cd clj-ebpf
clj -M:test # Run tests
# Unit tests (no root required)
clj -M:test
# Integration tests (requires root and BPF support)
sudo clj -M:test
# Specific test namespace
clj -M:test -n clj-ebpf.helpers-test
Contributions are welcome! Areas for contribution:
See the main README for contribution guidelines.
Permission Denied: Run with sudo or set capabilities
sudo setcap cap_bpf,cap_perfmon+ep $(which java)
BPF Filesystem Not Mounted:
sudo mount -t bpf bpf /sys/fs/bpf
Kernel Version Too Old: Upgrade to kernel 4.14+ (5.8+ recommended)
Program Load Failed: Check verifier log in exception data
Helper Not Available: Check kernel version compatibility
(require '[clj-ebpf.helpers :as helpers])
(helpers/helper-compatible? :my-helper :xdp "6.3")
Copyright © 2025
Distributed under the Eclipse Public License version 1.0.
Last updated: November 2024
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |