(Note: Not Ready Yet! Do not use!)
Code for xdp-project's xdp-tutorial in Rust.
This project implements all the examples and assignments of the XDP Tutorial in Rust. The intended audience for this tutorial is - developers looking to get started with Rust and XDP. This tutorial also uses parts from the aya-rs book, but for the sake of completion, will describe those parts here fully.
Before starting the tutorial, one needs to install the development tools.
If you are new to rust, it's better to get started with installing Rust following the instructions from the official website. This should install rustup
a tool for managing the Rust toolchains.
If you are totally new to eBPF
you might want to go quickly through getting started guide on the eBPF website.
Quickly going through the XDP academic paper might also be a good idea for most of the users, unless you are an XDP developer already.
You might want to quickly go through the introduction from the original tutorial's website.
First let's get started by installing the required dependencies.
- Install the BPF Linker. This is required for generating the binaries for the eBPF programs. This will work with LLVM provided by
rustc
.
cargo install ebpf-linker
- Optional but recommended to install
llvm-objdump
. This tool is required for inspecting the generated object files for the BPF programs.
cargo install llvm
Once the required dependencies are setup properly, we can start running the tutorial. This is done in two parts. First part would install cargo-xdp-tutorial
command from the repository of the root and then in the second part, we will use the command cargo-xdp-tutorial
to actually get started with the tutorial. This is described below.
# This will install the latest `cargo-xdp-tutorial` binary from the current directory (crate).
$ cargo install --path . --force
# Verify that `xdp-tutorial` sub command is installed.
$ cargo xdp-tutorial help
We create a very simple tutorial that prints a simple log statement when a packet is received on an interface.
# Following command will copy 'templates' from the templates/initial directory and creating a basic
# scaffolding to which individual tutorials can be added subsequently.
$ cargo xdp-tutorial init templates/initial tutorial
# Add the 'basic-01' to the tutorial created above.
# Follow the instructions when prompted.
$ cargo xdp-tutorial add templates/basic/basic-01 tutorial