Development Environment
Prerequisites
Before getting started you will need the Rust stable and nightly toolchains
installed on your system. This is easily achieved with
rustup
:
Once you have the Rust toolchains installed, you must also install bpf-linker
.
The linker depends on LLVM, and it can be built against the version shipped with
the rust toolchain if you are running on a linux x86_64 system with:
If you are running macos, or linux on any other architecture, you need to
install the newest stable version of LLVM first (for example, with
brew install llvm
), then install the linker with:
To generate the scaffolding for your project, you're going to need
cargo-generate
, which you can install with:
And finally to generate bindings for kernel data structures, you must install
bpftool
, either from your distribution or building it from
source.
Running on Ubuntu 20.04 LTS (Focal)?
If you're running on Ubuntu 20.04, there is a bug with bpftool and the default kernel installed by the distribution. To avoid running into it, you can install a newer bpftool version that does not include the bug with:
Starting A New Project
To start a new project, you can use cargo-generate
:
This will prompt you for a project name - we'll be using myapp
in this
example. It will also prompt you for a program type and possibly other options
depending on the chosen type (for example, the attach direction for network
classifiers).
If you prefer, you can set template options directly from the command line, eg:
See the cargo-generate.toml file (in the aya-template repository) for the full list of available options.