AFXDP-rs

This module provides a Rust interface for AF_XDP built on libbpf-sys (https://github.com/alexforster/libbpf-sys).

Author: Dan Siemon dan@coverfire.com

docs.rs

AF_XDP:

The goals of this crate, in order, are:

  1. Correctness
  2. Performance
  3. Ease of use

Current Status

The API works for my current use cases but I expect it will change to achieve higher performance and better usability.

If you have knowledge of Rust FFI and general Rust unsafe things I would greatly appreciate some help auditing this crate as my experience in this area is limited.

Sample Programs

There are two sample programs in src/bin/:

l2fwd-1link: Receives frames on a single link/queue, swaps the MAC and writes back to the same link/queue. This is roughly like the kernel xdpsock_user.c sample program in l2fwd mode.

l2fwd-2link: Receives frames from two link/queue pairs (separate devices) and forwards the frames to the opposite link.

Performance

Test System:

Traffic Generator:

Scenario 1: l2fwd-2link on a single core running userspace and NAPI

Small amounts of packet loss starts at about 6.5M PPS unidirectional and 6.0M PPS bi-directionally (3M each direction).

Little effort has been put into optimizing this so I expect there are some easy performance wins.

AF_XDP Features

To Do