Created
May 5, 2017 10:41
-
-
Save yjuba/dc122177f63c07fee3ed1edb41748c03 to your computer and use it in GitHub Desktop.
XDP実行環境セットアップ用スクリプト、Ubuntu 16.04上でIntel e1000ドライバを使う前提
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
set -x | |
echo 'Acquire::ForceIPv4 "true";' | sudo tee /etc/apt/apt.conf.d/99force-ipv4 | |
sudo apt update | |
sudo apt -y upgrade | |
sudo apt -y dist-upgrade | |
# sudo apt install -y tmux | |
sudo apt install -y git build-essential kernel-package fakeroot libncurses5-dev libssl-dev ccache | |
WORK_DIR=$(mktemp -d work.XXXX) | |
cd ${WORK_DIR} | |
wget -4 https://git.kernel.org/pub/scm/linux/kernel/git/ast/bpf.git/snapshot/bpf-0afee87cfc800bf3317f4dc8847e6f36539b820c.tar.gz | |
tar xvzf bpf-0afee87cfc800bf3317f4dc8847e6f36539b820c.tar.gz > /dev/null | |
git clone --depth 1 https://git.launchpad.net/~ubuntu-kernel-test/ubuntu/+source/linux/+git/mainline-crack v4.11 | |
cd v4.11 | |
git checkout -b yjuba_work | |
## XDPサポートの入ったe1000に差し替え | |
cp ../bpf-0afee87cfc800bf3317f4dc8847e6f36539b820c/drivers/net/ethernet/intel/e1000/* ./drivers/net/ethernet/intel/e1000/ | |
cp /boot/config-$(uname -r) .config | |
yes '' | make oldconfig | |
## Option | |
# make menuconfig | |
scripts/config --disable DEBUG_INFO | |
make clean | |
## 必要に応じてオプションは変更 | |
make -j 48 bindeb-pkg LOCALVERSION=-yjuba | |
cd ../ | |
## XDPサポート付きのe1000を含むKernelのInstall | |
sudo dpkg -i *.deb | |
########################################################## | |
## ここ以降で、新しいKernelに変更するため、一度再起動が必要 ## | |
########################################################## | |
## BPF Compiler CollectionのInstall | |
## 参考: https://github.com/iovisor/bcc/blob/master/INSTALL.md#ubuntu-xenial---binary | |
echo 'deb [trusted=yes] https://repo.iovisor.org/apt/xenial xenial-nightly main' | sudo tee /etc/apt/sources.list.d/iovisor.list | |
sudo apt update | |
sudo apt install -y bcc-tools libbcc-examples python-pip | |
sudo pip install pyroute2 | |
## 実行後、ens3は一切のパケットをDropするため注意 | |
# sudo python /usr/share/bcc/examples/networking/xdp/xdp_drop_count.py ens3 | |
## Option | |
## XDPサポートを含むiproute2コマンド一式のInstall | |
## 参考: https://github.com/cilium/cilium | |
sudo apt install -y pkg-config libelf-dev bison flex | |
git clone --depth 1 -b v4.11.0 https://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git | |
cd iproute2/ | |
## 既存のipコマンドは/bin/以下 | |
## 新しいipコマンドは/sbin/以下に置かれる | |
make -j 48 | |
sudo make install | |
## yjuba@yjuba-xdp-work:~/git/iproute2$ sudo /sbin/ip link set dev ens3 xdp off | |
## yjuba@yjuba-xdp-work:~/git/iproute2$ sudo /bin/ip link set dev ens3 xdp off | |
## Error: either "dev" is duplicate, or "xdp" is a garbage. | |
cd ../ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment