Ben Hall
Ben Hall

Reputation: 2037

eBPF / XDP fails to compile on Ubuntu 16.04.6

After upgrading Ubuntu 16.04, it's no longer possible to compile eBPF. The bpf.h file is missing key structs and the uapi headers don't seem to be installed.

Sample code:

#include <linux/bpf.h>

int main()
{
    return XDP_DROP;
}

Compiled with clang -target bpf -O2 -c xdp.c -o xdp.o

This returns the error:

udp.c:13:12: error: use of undeclared identifier 'XDP_DROP'
    return XDP_DROP;
           ^
1 error generated.
$ cat /etc/*release*
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.6 LTS"
NAME="Ubuntu"
VERSION="16.04.6 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.6 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
$ uname -r
4.4.0-148-generic

No mention of XDP

$ grep -r XDP_DROP /usr/include
$ grep -r XDP_DROP /lib/modules/
$

What's the issue?

Upvotes: 0

Views: 751

Answers (1)

Qeole
Qeole

Reputation: 9174

Your kernel is 4.4.0-148, this is too old to have XDP support. XDP was introduced in Linux 4.8 (see this document).

Not sure what system you upgraded from. Try upgrading to Ubuntu 18.04 if you can? Or try installing a newer kernel (and relevant headers).

Upvotes: 3

Related Questions