This project was built to learn and implement simple programs related to:
- Linux kernel eBPF
- Solana development with Anchor framework
- Run a Solana binary within
solana_rbpf
VM
Setup a development environment1
rustup install stable
rustup toolchain install nightly --component rust-src
cargo install bpf-linker
cargo install cargo-generate
# cargo generate https://github.com/aya-rs/aya-template
# cargo generate --name myapp -d program_type=xdp https://github.com/aya-rs/aya-template
cargo generate --name xdp-drop-limit -d program_type=xdp https://github.com/aya-rs/aya-template
cargo xtask build-ebpf
To verify the program:
# llvm-objdump -S target/bpfel-unknown-none/debug/myapp
llvm-objdump -S target/bpfel-unknown-none/debug/xdp-drop-limit
Build:
cargo build
Run:
# RUST_LOG=info cargo xtask run -- --iface [interface]
RUST_LOG=info cargo xtask run -- --iface wlp1s0
Check if eBPF program is running:
sudo bpftool prog list
Footnotes
-
https://aya-rs.dev/book/start/development "The Aya Book: Development Environment" ↩