Skip to content

gabhijit/xdp-tutorial-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

(Note: Not Ready Yet! Do not use!)

Overview

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.

Setting Up

Before starting the tutorial, one needs to install the development tools.

New to Rust?

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.

New to eBPF and XDP?

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.

Common Instructions

First let's get started by installing the required dependencies.

  1. 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
  1. Optional but recommended to install llvm-objdump. This tool is required for inspecting the generated object files for the BPF programs.
cargo install llvm

Starting the tutorial

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.

Installing cargo-xdp-tutorial

# 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

Running your first tutorial.

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

About

Code for xdp-project xdp-tutorial in Rust.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published