ebpf-lab.sh (1793B)
1 #!/usr/bin/env bash 2 3 set -o errexit 4 set -o nounset 5 #set -o xtrace 6 7 dnf config-manager --set-enabled crb 8 dnf install -y epel-release epel-next-release 9 10 # Install BCC prerequisites 11 # https://github.com/iovisor/bcc/blob/master/INSTALL.md 12 dnf install -y bison cmake ethtool flex git iperf3 libstdc++-devel python3-netaddr \ 13 python3-pyroute2 python3-pip python3-docutils gcc gcc-c++ make \ 14 zlib-devel elfutils-libelf-devel clang-15.0.7 clang-devel-15.0.7 \ 15 llvm-15.0.7 llvm-devel-15.0.7 llvm-static-15.0.7 ncurses-devel zip unzip netperf 16 17 # Lock Clang and LLVM versions 18 dnf install -y python3-dnf-plugin-versionlock 19 yum versionlock llvm* 20 yum versionlock clang* 21 22 # LLVM required because of issue: 23 # https://github.com/llvm/llvm-project/issues/61436 24 25 # Install BCC from source 26 git clone https://github.com/iovisor/bcc.git 27 mkdir bcc/build; cd bcc/build 28 29 # LLVM should always link shared library 30 cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DENABLE_LLVM_SHARED=1 31 make -j10 32 make install 33 34 # Install bpftool 35 # https://github.com/libbpf/bpftool 36 cd $HOME 37 git clone --recurse-submodules https://github.com/libbpf/bpftool.git 38 cd bpftool/src; make install 39 cd ../docs; make install 40 41 # Install bpftrace 42 # https://github.com/iovisor/bpftrace/blob/master/INSTALL.md 43 cd $HOME 44 dnf install -y bcc-devel systemtap-sdt-devel binutils-devel libbpf-devel vim-common \ 45 libpcap-devel gtest-devel gmock-devel cereal-devel asciidoctor dwarves \ 46 elfutils-devel 47 git clone https://github.com/iovisor/bpftrace --recurse-submodules 48 cd bpftrace 49 mkdir build; cd build 50 ../build-libs.sh 51 cmake -DCMAKE_BUILD_TYPE=Release .. 52 make -j8 53 make install 54 55 # Prepare eBPF lab with samples 56 hostnamectl hostname ebpf-lab 57 cd $HOME 58 git clone https://github.com/in0rdr/ebpf-lab.git