Wasm-bpf is a WebAssembly eBPF library, toolchain and runtime powered by CO-RE(Compile Once – Run Everywhere) libbpf. It can help you build almost every eBPF programs or usecases to
Wasm with nearly zero modification, and run them cross platforms with Wasm sandbox.
WebAssembly (Wasm) is a portable binary format for executable code. The code is executed at a nearly-native speed in a memory-safe (for host) sandbox, with clearly defined resource constraints, and APIs for communicating with the embedding host environment (eg. proxy).The
wasm-bpf project combines Wasm and eBPF technologies to enhance the performance and programmability of eBPF applications.
wasm-bpf, users can dynamically load and securely execute user-defined or community-contributed Wasm-eBPF codes as
plug-ins in their software products, such as observability platforms or service proxy. This enables efficient and scalable data collection, while also allowing for advanced processing and analysis of that data.
It also enables developers to write eBPF programs in familiar languages like
Go, and more than 30 other programming languages, and deploy them easily across different Linux distributions. Additionally, cloud providers can leverage wasm-bpf to offer a
high-performance environment for their customers to develop and deploy eBPF applications in their cloud environments.
General purpose: provide most abilities from eBPF to Wasm,
pollingfrom the ring buffer or perf buffer, bidirectional communications between
detaching, etc. Supports a large number of eBPF program types and map types.
High performance: No
serializationoverhead for complex data types, using
shared memoryto avoid copy overhead between host and Wasm.
Easy to use: provide a similar developing experience as the libbpf-bootstrap,
auto generatethe Wasm-eBPF skeleton headers and type definitions for bindings. Write your eBPF programs in
Goand compile to Wasm.
Ultralightweight: the miminal runtime has only
1.5 MBin binary size. Compiled Wasm module would be only
~90K. With the same toolchain, you can easily build your own Wasm-eBPF runtime in any languages and platforms!
See the examples directory for examples of eBPF programs written in C, Rust, Go and compiled to Wasm, covering the use cases from