Skip to content

Latest commit

 

History

History
143 lines (102 loc) · 4.94 KB

setup_dependencies.org

File metadata and controls

143 lines (102 loc) · 4.94 KB

Setup dependencies

Before you can start completing the steps in this XDP-tutorial, go though this document and install the needed software packages.

Table of Contents

Based on libbpf

This XDP-tutorial leverages libbpf to ease development and loading of BPF-programs. The library libbpf is part of the kernel tree under tools/lib/bpf, but Facebook engineers maintain a stand-alone build on GitHub under https://github.com/libbpf/libbpf.

libbpf as git-submodule

This repository uses libbpf as a git-submodule. After cloning this repository you need to run the command:

git submodule update --init

If you want submodules to be part of the clone, you can use this command:

git clone --recurse-submodules https://github.com/xdp-project/xdp-tutorial

If you need to add this to your own project, you can use the command:

git submodule add https://github.com/libbpf/libbpf/ libbpf

Dependencies

The main dependencies are libbpf, llvm, clang and libelf. LLVM+clang compiles our restricted-C programs into BPF-byte-code, which is stored in an ELF object file (libelf), that is loaded by libbpf into the kernel via the bpf syscall. Some of the lessons also use the perf utility to track the kernel behaviour through tracepoints.

The Makefiles in this repo will try to detect if you are missing some dependencies, and give you some pointers.

Packages on Fedora

On a machine running the Fedora Linux distribution, install the packages:

$ sudo dnf install clang llvm
$ sudo dnf install elfutils-libelf-devel perf

Packages on Debian/Ubuntu

On Debian and Ubuntu installations, install the dependencies like this:

$ sudo apt install clang llvm libelf-dev

To install the ‘perf’ utility, run this on Debian:

$ sudo apt install linux-perf

or this on Ubuntu:

$ sudo apt install linux-tools-$(uname -r)

Kernel headers dependency

The Linux kernel provides a number of header files, which are usually installed in /usr/include/linux. The different Linux distributions usually provide a software package with these headers.

Some of the header files (we depend on) are located in the kernel tree under include/uapi/linux/ (e.g. include/uapi/linux/bpf.h), but you should not include those files as they go through a conversion process when exported/installed into distros’ /usr/include/linux directory. In the kernel git tree you can run the command: make headers_install which will create a lot of headers files in directory “usr/”.

For now, this tutorial depends on kernel headers package provided by your distro. We may choose to shadow some of these later.

Packages on Fedora

On a machine running the Fedora Linux distribution, install the package:

$ sudo dnf install kernel-headers

Packages on Debian/Ubuntu

On Debian and Ubuntu installations, install the headers like this

$ sudo apt install linux-headers-$(uname -r)

Recommended tools

The bpftool is the recommended tool for inspecting BPF programs running on your system. It also offers simple manipulation of eBPF programs and maps. The bpftool is part of the Linux kernel tree under tools/bpf/bpftool/, but some Linux distributions also ship the tool as a software package.

Packages on Fedora

On a machine running the Fedora Linux distribution, install package:

$ sudo dnf install bpftool

Packages on Debian/Ubuntu

Unfortunately, bpftool is not officially packaged for Debian/Ubuntu yet.

However, note that an unofficial .deb package is provided by Netronome on their support website. The binary is statically linked, and should work on any x86-64 Linux machine.