Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 56 additions & 51 deletions setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ We expect to use the wired Ethernet port for protocol experiments.
The `ifconfig` command will display lots of information about the available interfaces and their associated addresses.

```
$ ifconfig -a
ifconfig -a
```

### Choose a Hostname unique to your LAN (optional)

```
$ sudo vi /etc/hostname # replace "raspberrypi" with your chosen hostname
$ sudo vi /etc/hosts # replace "raspberrypi" with your chosen hostname
sudo vi /etc/hostname # replace "raspberrypi" with your chosen hostname
sudo vi /etc/hosts # replace "raspberrypi" with your chosen hostname
```

Reboot for hostname change to take effect.
```
$ sudo shutdown -r now
sudo shutdown -r now
```

### Assign a Static IP Address unique to your LAN (optional)
Expand All @@ -44,15 +44,20 @@ Instructions to set up

Check default Router (IP)
```
$ ip route
ip route
```
```
output:

default via 192.168.1.1 dev wlan0 proto dhcp src 192.168.1.116 metric 303
169.254.0.0/16 dev eth0 scope link src 169.254.59.93 metric 202
192.168.1.0/24 dev wlan0 proto dhcp scope link src 192.168.1.116 metric 303
```

Check Domain Name Server(s) (DNS)
```
$ cat /etc/resolv.conf
cat /etc/resolv.conf

# Generated by resolvconf
domain hsd1.co.comcast.net
nameserver 75.75.75.75
Expand All @@ -74,41 +79,41 @@ The `75.75.*` addresses are my local Comcast ISP.

Reboot to start using new configuration.
```
$ sudo reboot
sudo reboot
```

### Update to latest packages and OS

```
$ sudo apt update
$ sudo apt full-upgrade
$ sudo apt autoremove
sudo apt update
sudo apt full-upgrade
sudo apt autoremove
```

## Install Development Tools

Edit `/etc/apt/sources.list` and uncomment the `dev-src` line.

```
$ sudo apt install git make clang llvm
$ sudo apt install build-essential bc bison flex
$ sudo apt install libssl-dev libelf-dev libcap-dev libpcap-dev
sudo apt install git make clang llvm
sudo apt install build-essential bc bison flex
sudo apt install libssl-dev libelf-dev libcap-dev libpcap-dev
```

## Build Custom Kernel

We do our development under the `~/dev` directory.

```
$ cd ~
$ mkdir dev
$ cd dev
cd ~
mkdir dev
cd dev
```

Clone the kernel source repository.

```
$ git clone --depth=1 https://github.com/raspberrypi/linux
git clone --depth=1 https://github.com/raspberrypi/linux
```

We use `--depth=1` to prune the extensive history from the repository.
Expand All @@ -122,9 +127,9 @@ Configure which kernel image to build based on your target device.
#### For Raspberry Pi 3

```
$ cd ~/dev/linux
$ KERNEL=kernel7
$ make bcm2709_defconfig
cd ~/dev/linux
KERNEL=kernel7
make bcm2709_defconfig
```

Edit `.config` to label your custom kernel and enable XDP features.
Expand All @@ -138,9 +143,9 @@ CONFIG_XDP_SOCKETS_DIAG=y
#### For Raspberry Pi 4

```
$ cd ~/dev/linux
$ KERNEL=kernel7l
$ make bcm2711_defconfig
cd ~/dev/linux
KERNEL=kernel7l
make bcm2711_defconfig
```

Edit `.config` to label your custom kernel and enable XDP features.
Expand All @@ -156,20 +161,20 @@ CONFIG_XDP_SOCKETS_DIAG=y
Launch kernel compile using all 4 cores (prepare to wait a while...)

```
$ make -j4 zImage modules dtbs
$ sudo make headers_install INSTALL_HDR_PATH=/usr
$ sudo make modules_install
$ sudo cp arch/arm/boot/dts/*.dtb /boot/
$ sudo cp arch/arm/boot/dts/overlays/*.dtb* /boot/overlays/
$ sudo cp arch/arm/boot/dts/overlays/README /boot/overlays/
make -j4 zImage modules dtbs
sudo make headers_install INSTALL_HDR_PATH=/usr
sudo make modules_install
sudo cp arch/arm/boot/dts/*.dtb /boot/
sudo cp arch/arm/boot/dts/overlays/*.dtb* /boot/overlays/
sudo cp arch/arm/boot/dts/overlays/README /boot/overlays/
```

We install the kernel image with a custom name, so it won't be overwritten but the package manager.

#### Install RPi3 kernel image

```
$ sudo cp arch/arm/boot/zImage /boot/kernel7-xdp.img
sudo cp arch/arm/boot/zImage /boot/kernel7-xdp.img
```

Edit `/boot/config.txt` to specify boot kernel `kernel7-xdp.img`
Expand All @@ -183,7 +188,7 @@ kernel=kernel7-xdp.img
#### Install RPi4 kernel image

```
$ sudo cp arch/arm/boot/zImage /boot/kernel7l-xdp.img
sudo cp arch/arm/boot/zImage /boot/kernel7l-xdp.img
```

Edit `/boot/config.txt` to specify boot kernel `kernel7l-xdp.img`
Expand All @@ -197,67 +202,67 @@ kernel=kernel7l-xdp.img
### Reboot to run newly-build kernel

```
$ sudo shutdown -r now
sudo shutdown -r now
```

Verify that you're running the new custom kernel

```
$ uname -a
uname -a
Linux raspberrypi 5.4.65-v7l-xdp+ #1 SMP Wed Sep 23 13:24:39 MDT 2020 armv7l GNU/Linux
```

## Build eBPF support tools

```
$ cd ~/dev/linux/tools/lib/bpf
$ make
$ sudo make install
$ sudo make install_headers
cd ~/dev/linux/tools/lib/bpf
make
sudo make install
sudo make install_headers
```

Confirm that `libbpf` is available as a shared library.
```
$ ldconfig -p | grep bpf
ldconfig -p | grep bpf
```
If nothing is shown,
add `/usr/local/lib` to the paths searched for shared libraries.
```
$ sudo ldconfig /usr/local/lib
sudo ldconfig /usr/local/lib
```

### Build `bpftool` program.
```
$ cd ~/dev/linux/tools/bpf/bpftool
$ make
$ sudo make install
cd ~/dev/linux/tools/bpf/bpftool
make
sudo make install
```

### Build BPF samples in the kernel source tree.
```
$ cd ~/dev/linux/samples/bpf
$ make
cd ~/dev/linux/samples/bpf
make
```

## Build eBPF experiments

```
$ cd ~/dev
$ git clone https://github.com/dalnefre/eBPF.git
$ cd eBPF
cd ~/dev
git clone https://github.com/dalnefre/eBPF.git
cd eBPF
```

### Build [protocol lab](proto/README.md)

```
$ cd ~/dev/eBPF/proto
$ make clean all test
cd ~/dev/eBPF/proto
make clean all test
```


### Build [XDP experiments](XDP/README.md)

```
$ cd ~/dev/eBPF/XDP
$ make clean all test
cd ~/dev/eBPF/XDP
make clean all test
```