others-How to solve Unable to locate package bpfcc-tools problem?

How to solve Unable to locate package bpfcc-tools when installing bpf dependencies in ubuntu ?

Problem

When you want to install bpf dependencies in ubuntu, you run this command:

apt install build-essential git make libelf-dev clang strace tar bpfcc-tools linux-headers-$(uname -r) gcc-multilib

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package bpfcc-tools

Environment

You check your os version by this command:

cat /etc/os-release

NAME="Ubuntu"
VERSION="16.04.6 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.6 LTS"

Solution: Upgrade your system version

Upgrade your ubuntu system version to 18+:

cat /etc/os-release

NAME="Ubuntu"
VERSION="18.04.4 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.4 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

Test Again

Then you can test your vim again:

apt install build-essential git make libelf-dev clang strace tar bpfcc-tools linux-headers-$(uname -r) gcc-multilib

Setting up libx32asan4 (7.5.0-3ubuntu1~18.04) ...
Setting up libx32cilkrts5 (7.5.0-3ubuntu1~18.04) ...
Setting up lib32gomp1 (8.4.0-1ubuntu1~18.04) ...
Setting up libx32ubsan0 (7.5.0-3ubuntu1~18.04) ...
Setting up lib32asan4 (7.5.0-3ubuntu1~18.04) ...
Setting up lib32mpx2 (8.4.0-1ubuntu1~18.04) ...
Setting up libelf-dev:amd64 (0.170-0.4ubuntu0.1) ...
Setting up python-bpfcc (0.5.0-5ubuntu1) ...
Setting up bpfcc-tools (0.5.0-5ubuntu1) ...
Setting up llvm-6.0 (1:6.0-1ubuntu2) ...
Setting up lib32stdc++6 (8.4.0-1ubuntu1~18.04) ...
Setting up lib32ubsan0 (7.5.0-3ubuntu1~18.04) ...
Setting up lib32cilkrts5 (7.5.0-3ubuntu1~18.04) ...
Setting up libclang-common-6.0-dev (1:6.0-1ubuntu2) ...
Setting up libx32gcc-7-dev (7.5.0-3ubuntu1~18.04) ...
Setting up llvm-6.0-dev (1:6.0-1ubuntu2) ...
Setting up clang-6.0 (1:6.0-1ubuntu2) ...
Setting up lib32gcc-7-dev (7.5.0-3ubuntu1~18.04) ...
Setting up clang (1:6.0-41~exp5~ubuntu1) ...
Setting up gcc-7-multilib (7.5.0-3ubuntu1~18.04) ...
Setting up gcc-multilib (4:7.4.0-1ubuntu2.3) ...
Processing triggers for systemd (237-3ubuntu10.41) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for ureadahead (0.100.0-21) ...
Processing triggers for install-info (6.5.0.dfsg.1-2) ...
Processing triggers for libc-bin (2.27-3ubuntu1.2) ...

Reason

Note on Kernel version: make sure to have a recent kernel to run the ebpf examples, a kernel version >=5.0.0 will do the job. Most Ubuntu 18.04 providers are shipping with the kernel 4.15 that doesn’t work for most of the examples. Upgrading options are left to the reader, we’ve been successful on aws by installing the linux-image-5.0.0-1019-aws package.

According to wikipedia of ebpf:

Since version 3.18, the Linux kernel includes an extended BPF virtual machine with ten 64-bit registers, termed extended BPF (eBPF). It can be used for non-networking purposes, such as for attaching eBPF programs to various tracepoints.[4][5][6] Since kernel version 3.19, eBPF filters can be attached to sockets,[7][8] and, since kernel version 4.1, to traffic control classifiers for the ingress and egress networking data path.[9][10] The original and obsolete version has been retroactively renamed to classic BPF (cBPF). Nowadays, the Linux kernel runs eBPF only and loaded cBPF bytecode is transparently translated into an eBPF representation in the kernel before program execution.[11] All bytecode is verified before running to prevent denial-of-service attacks. Until Linux 5.3, the verifier prohibited the use of loops.

Here is the mapping of ubuntu version and its corresponding linux kernel version:

20.04   Focal Fossa       5.4
19.10   Eoan Ermine       5.3
19.04   Disco Dingo       5.0
18.10   Cosmic Cuttlefish 4.18
18.04   Bionic Beaver     4.15
17.10   Artful Aardvark   4.13
17.04   Zesty Zapus       4.10
16.10   Yakkety Yak       4.8
16.04   Xenial Xerus      4.4
15.10   Wily Werewolf     4.2
15.04   Vivid Vervet      3.19
14.10   Utopic Unicorn    3.16
14.04   Trusty Tahr       3.13
13.10   Saucy Salamander  3.11
13.04   Raring Ringtail   3.8
12.10   Quantal Quetzal   3.5
12.04   Precise Pangolin  3.2+
11.10   Oneiric Ocelot    3.0
11.04   Natty Narwhal     2.6.38
10.10   Maverick Meerkat  2.6.35
10.04   Lucid Lynx        2.6.32
09.10   Karmic Koala      2.6.31
09.04   Jaunty Jackalope  2.6.28
08.10   Intrepid Ibex     2.6.27
08.04   Hardy Heron       2.6.24
07.10   Gutsy Gibbon      2.6.22
07.04   Feisty Fawn       2.6.20
06.10   Edgy Eft          2.6.17
06.06   Dapper Drake      2.6.15
05.10   Breezy Badger     2.6.12
05.04   Hoary Hedgehog    2.6.10
04.10   Warty Warthog     2.6.8