mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2026-02-07 21:50:55 +00:00
Add comprehensive Sphinx documentation structure and content
Co-authored-by: r41k0u <76248539+r41k0u@users.noreply.github.com>
This commit is contained in:
96
docs/index.md
Normal file
96
docs/index.md
Normal file
@ -0,0 +1,96 @@
|
||||
# PythonBPF Documentation
|
||||
|
||||
Welcome to **PythonBPF** - a Python frontend for writing eBPF programs without embedding C code. PythonBPF uses [llvmlite](https://github.com/numba/llvmlite) to generate LLVM IR and compiles directly to eBPF object files that can be loaded into the Linux kernel.
|
||||
|
||||
```{note}
|
||||
This project is under active development and not ready for production use.
|
||||
```
|
||||
|
||||
## What is PythonBPF?
|
||||
|
||||
PythonBPF is an LLVM IR generator for eBPF programs written in Python. It provides:
|
||||
|
||||
* **Pure Python syntax** - Write eBPF programs in Python using familiar decorators and type annotations
|
||||
* **Direct compilation** - Compile to LLVM object files without relying on BCC
|
||||
* **Full eBPF features** - Support for maps, helpers, global definitions, and more
|
||||
* **Integration with libbpf** - Works with [pylibbpf](https://github.com/pythonbpf/pylibbpf) for object loading and execution
|
||||
|
||||
## Quick Example
|
||||
|
||||
Here's a simple "Hello World" BPF program that traces process creation:
|
||||
|
||||
```python
|
||||
from pythonbpf import bpf, section, bpfglobal, BPF, trace_pipe
|
||||
from ctypes import c_void_p, c_int64
|
||||
|
||||
@bpf
|
||||
@section("tracepoint/syscalls/sys_enter_execve")
|
||||
def hello_world(ctx: c_void_p) -> c_int64:
|
||||
print("Hello, World!")
|
||||
return c_int64(0)
|
||||
|
||||
@bpf
|
||||
@bpfglobal
|
||||
def LICENSE() -> str:
|
||||
return "GPL"
|
||||
|
||||
b = BPF()
|
||||
b.load()
|
||||
b.attach_all()
|
||||
trace_pipe()
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
* Generate eBPF programs directly from Python
|
||||
* Compile to LLVM object files for kernel execution
|
||||
* Built with `llvmlite` for IR generation
|
||||
* Supports maps, helpers, and global definitions for BPF
|
||||
* Companion project: [pylibbpf](https://github.com/pythonbpf/pylibbpf), which provides bindings for object loading
|
||||
|
||||
## Table of Contents
|
||||
|
||||
```{toctree}
|
||||
:maxdepth: 2
|
||||
:caption: Getting Started
|
||||
|
||||
getting-started/index
|
||||
getting-started/installation
|
||||
getting-started/quickstart
|
||||
```
|
||||
|
||||
```{toctree}
|
||||
:maxdepth: 2
|
||||
:caption: User Guide
|
||||
|
||||
user-guide/index
|
||||
user-guide/decorators
|
||||
user-guide/maps
|
||||
user-guide/structs
|
||||
user-guide/compilation
|
||||
user-guide/helpers
|
||||
```
|
||||
|
||||
```{toctree}
|
||||
:maxdepth: 2
|
||||
:caption: API Reference
|
||||
|
||||
api/index
|
||||
```
|
||||
|
||||
## Links
|
||||
|
||||
* **GitHub Repository**: [pythonbpf/Python-BPF](https://github.com/pythonbpf/Python-BPF)
|
||||
* **PyPI Package**: [pythonbpf](https://pypi.org/project/pythonbpf/)
|
||||
* **Video Demo**: [YouTube](https://youtu.be/eMyLW8iWbks)
|
||||
* **Slide Deck**: [Google Slides](https://docs.google.com/presentation/d/1DsWDIVrpJhM4RgOETO9VWqUtEHo3-c7XIWmNpi6sTSo/edit?usp=sharing)
|
||||
|
||||
## License
|
||||
|
||||
PythonBPF is licensed under the Apache License 2.0.
|
||||
|
||||
## Indices and tables
|
||||
|
||||
* {ref}`genindex`
|
||||
* {ref}`modindex`
|
||||
* {ref}`search`
|
||||
Reference in New Issue
Block a user