Update (9/Oct/2016): The NAT feature in Cake now supports older kernels.
Update (6/Oct/2016): NAT support has entered the main Cake repository. The feature currently only works on newer versions of the Linux kernel, so in my fork I’ve added an option to disable it, which is used below.
Update (5/Oct/2016): I’ve found another way to cross-compile for the MIPS architecture, and have updated the tutorial accordingly.
For a while I’ve been wanting to try out Cake on my ERL. It was pretty difficult to get it to work, but it was well worth it.
This tutorial is divided into two parts, one for compiling the sch_cake module and one for compiling iproute2.
- Debian Wheezy machine
- Cavium SDK (get it from cnusers (requires registration), or my mirror)
- ERL 1.9 firmware GPL archive
Download and extract the Cavium SDK (currently v3.1):
mkdir edgeos; cd edgeos
tar xzvf cnusers_sdk_3.1.0.tgz
Setup your environment to use the Octeon SDK
source ./env-setup OCTEON_CN50XX
Download and extract the UBNT GPL archive:
tar xjvf GPL.ER-e100.v184.108.40.20601118.tbz2
Extract the Cavium Executive headers:
tar xzvf source/cavm-executive_4899453-g82e0782.tgz
Create the correct folder structure and extract the kernel:
mkdir -p linux-src/linux-3.10
tar xzvf ../../source/kernel_4899453-gc1c94e2.tgz
Prepare and compile the kernel (replace -j2 with how many CPU cores you have in your system):
make ARCH=mips CROSS_COMPILE=mips64-octeon-linux-gnu- prepare
make ARCH=mips CROSS_COMPILE=mips64-octeon-linux-gnu- -j2
When the kernel is done compiling return to the edgeos folder and clone my sch_cake repository. It contains a fix to make sch_cake compile on this kernel.
git clone https://github.com/Lochnair/sch_cake.git
Compile the module:
make ARCH=mips CROSS_COMPILE=mips64-octeon-linux-gnu- KDIR=../linux-src/linux-3.10/kernel/
Upload the resulting sch_cake.ko file to your ERL and copy it to your /lib/modules/$(uname -r)/kernel/net/sched folder.
Lastly run modprobe to load our new module.
sudo depmod -a
sudo modprobe sch_cake
I’ve covered how to set up a build environment for MIPS cross-compiling in another post here. Follow that guide, then come back here.
When you’ve got a MIPS machine running Debian Wheezy up, install the needed packages to build iproute2.
apt-get install build-essential flex git bison iptables-dev
Clone my git repository containing the modified iproute2-4.4 source. This repository contains the UBNT iproute2 source modified with cake support from Dave Taht’s tc-adv repository.
git clone https://github.com/Lochnair/iproute2-4.4-cake-ubnt.git
Enter the iproute2 folder and run make.
When it’s done copy the resulting ip/ip and tc/tc files from the iproute2 folder and replace the ones on the ERL with your new ones.
Congratulations, you now have Cake support on your ERL!
Of course, this won’t work with the Vyatta configuration at the moment, so you’ll have to configure Cake manually using tc. There’s a good start configuration at the Cake wiki.