Working with Linux eBPF and XDP on ExoGENI

Overview

If you are interested in exploring the eBPF mechanism available in linux since late 3.x kernel series, there’s a Fedora 25 image with kernel 4.13.0 that include eBPF and XDP support that can be used in ExoGENI dataplane.

Name:Fedora 25 BPF XDP
URL: http://geni-images.renci.org/images/standard/fedora/fedora25-v1.0.3/fedora25-v1.0.3.xml
Hash: ed658235257296e230bbb640c0bbae2ec2b2602d

The image is automatically available in Flukes in the image list.

XDP is envisioned to eventually supplant the use of Intel’s DPDK, although at present isn’t as full features as DPDK.

A few definitions:

  • eBPF – extended Berkeley Packet Filters – an in-kernel virtual machine that allows attaching small BPF programs to various points in the running kernel: kprobes, uprobes and portions of the networking stack – TC classifiers, ingress and egress actions and XDP.
    • The kernel must be compiled with eBPF support
    • A separate option is the JIT compiler for eBPF included into the kernel which improves performance of BPF programs
    • BPF programs are typically written using a subset of C (less for loops, static variables and constants).
    • BPF programs are checked by eBPF verifier prior to insertion into the kernel to guarantee they terminate.
    • BPF is becoming a widely used tool for run-time unobtrusive profiling of various aspects of behavior of the system – tracing system calls, I/O behavior, network behavior.
  • XDP – a novel mechanism that allows attaching BPF programs to the receive path in the kernel before the networking stack gets hold of the frame from the driver. The program is presented with a single memory page containing the received frame (so there is no sk_buff with its scatter-gather semantics to deal with). Frames can be parsed by BPF programs and discarded, passed on to the stack or redirected back into the network driver. XDP has more limited compatibility compared to TC hooks due to the need for driver support. It, however has higher performance, due to simpler memory layout (sk_buffs have scatter-gather, while XDP uses a single memory page).
  • BCC (BPF Compiler Collection) – a collection of tools form Iovisor project that make it easy to write eBPF programs by combining Python and with BPF programs written in C.

There is a kernel compatibility matrix that shows which kernel versions have which BPF features available.

Using BPF on ExoGENI

Simply boot some number of instances with the Fedora 25 BPF XDP image to get access to full features of BPF as of kernel 4.13.0. The 8139 driver used in ExoGENI appears to support XDP, so it will be available on the management interface. Dataplane interfaces use the virtio-net driver, which, unfortunately, does not support XDP, however it is still possible to install eBPF programs on dataplane interfaces, however they have to be of type BPF_PROG_TYPE_SCHED_CLS or BPF_PROG_TYPE_SCHED_ACT and operate on sk_buffs, not pages, the way XDP programs do.

Read the references above and try the examples located under /usr/share/bcc/examples within the image to become more familiar with various capabilities.

Have something to add?

Loading Facebook Comments ...