In general, to use these features, a Linux kernel version 4.1 or newer is required. In addition, the following flags should be set:
CONFIG_BPF=y
CONFIG_BPF_SYSCALL=y
# [optional, for tc filters]
CONFIG_NET_CLS_BPF=m
# [optional, for tc actions]
CONFIG_NET_ACT_BPF=m
CONFIG_BPF_JIT=y
CONFIG_HAVE_BPF_JIT=y
# [optional, for kprobes]
CONFIG_BPF_EVENTS=y
Install a 4.3+ kernel from https://kernel.ubuntu.com/~kernel-ppa/mainline, for example:
VER=4.4.2-040402
PREFIX=https://kernel.ubuntu.com/~kernel-ppa/mainline/v4.3-wily/
REL=201602171633
wget ${PREFIX}/linux-headers-${VER}-generic_${VER}.${REL}_amd64.deb
wget ${PREFIX}/linux-headers-${VER}_${VER}.${REL}_all.deb
wget ${PREFIX}/linux-image-${VER}-generic_${VER}.${REL}_amd64.deb
sudo dpkg -i linux-*${VER}.${REL}*.deb
# reboot
Update PREFIX to the latest date, and you can browse the files in the PREFIX url to find the REL number.
Tagged and signed bcc binary packages are built for Ubuntu Trusty (14.04) and hosted at https://52.8.15.63/apt/.
To install:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D4284CDD
echo "deb https://52.8.15.63/apt trusty main" | sudo tee /etc/apt/sources.list.d/iovisor.list
sudo apt-get update
sudo apt-get install libbcc libbcc-examples python-bcc
Test it:
sudo python /usr/share/bcc/examples/hello_world.py
sudo python /usr/share/bcc/examples/task_switch.py
(Optional) Install pyroute2 for additional networking features
git clone https://github.com/svinota/pyroute2
cd pyroute2; sudo make install
sudo python /usr/share/bcc/examples/simple_tc.py
Install a 4.2+ kernel from https://alt.fedoraproject.org/pub/alt/rawhide-kernel-nodebug, for example:
sudo dnf config-manager --add-repo=https://alt.fedoraproject.org/pub/alt/rawhide-kernel-nodebug/fedora-rawhide-kernel-nodebug.repo
sudo dnf update
# reboot
Nightly bcc binary packages are built for Fedora 23 and 24, hosted at
https://52.8.15.63/yum/nightly/f{23,24}
.
To install (change 'f23' to 'f24' for rawhide):
echo -e '[iovisor]\nbaseurl=https://52.8.15.63/yum/nightly/f23/$basearch\nenabled=1\ngpgcheck=0' | sudo tee /etc/yum.repos.d/iovisor.repo
sudo dnf install bcc-tools
Upgrade the kernel to minimum 4.3.1-1 first; the CONFIG_BPF_SYSCALL=y
configuration was not added until this kernel release.
Install these packages using any AUR helper such as pacaur, yaourt, cower, etc.:
bcc bcc-tools python-bcc python2-bcc
All build and install dependencies are listed in the PKGBUILD and should install automatically.
To build the toolchain from source, one needs:
- LLVM 3.7 or newer, compiled with BPF support (default=on)
- Clang 3.7, built from the same tree as LLVM
- cmake, gcc (>=4.7), flex, bison
# Trusty and older
VER=trusty
echo "deb https://llvm.org/apt/$VER/ llvm-toolchain-$VER-3.7 main
deb-src https://llvm.org/apt/$VER/ llvm-toolchain-$VER-3.7 main" | \
sudo tee /etc/apt/sources.list.d/llvm.list
wget -O - https://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-get update
# All versions
sudo apt-get -y install bison build-essential cmake flex git libedit-dev \
libllvm3.7 llvm-3.7-dev libclang-3.7-dev python zlib1g-dev
git clone https://github.com/iovisor/bcc.git
mkdir bcc/build; cd bcc/build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr
make
sudo make install
sudo dnf install -y bison cmake ethtool flex git iperf libstdc++-static \
python-netaddr python-pip gcc gcc-c++ make zlib-devel
sudo dnf install -y \
https://pkgs.repoforge.org/netperf/netperf-2.6.0-1.el6.rf.x86_64.rpm
sudo pip install pyroute2
wget https://llvm.org/releases/3.7.0/clang+llvm-3.7.0-x86_64-fedora22.tar.xz
sudo tar xf clang+llvm-3.7.0-x86_64-fedora22.tar.xz -C /usr/local --strip 1
git clone https://github.com/iovisor/bcc.git
mkdir bcc/build; cd bcc/build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr
make
sudo make install
git clone https://llvm.org/git/llvm.git
cd llvm/tools; git clone https://llvm.org/git/clang.git
cd ..; mkdir -p build/install; cd build
cmake -G "Unix Makefiles" -DLLVM_TARGETS_TO_BUILD="BPF;X86" \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/install ..
make
make install
export PATH=$PWD/install/bin:$PATH