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.
Compile the sch_cake module for the ERL
Prerequisites
- Debian Wheezy machine
- Git
- 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):
1 | mkdir edgeos; cd edgeos |
Setup your environment to use the Octeon SDK
1 | cd OCTEON-SDK |
Download and extract the UBNT GPL archive:
1 | wget "http://dl.ubnt.com/firmwares/edgemax/v1.9.0/GPL.ER-e100.v1.9.0.4901118.tbz2" |
Extract the Cavium Executive headers:
1 | tar xzvf source/cavm-executive_4899453-g82e0782.tgz |
Create the correct folder structure and extract the kernel:
1 | mkdir -p linux-src/linux-3.10 |
Prepare and compile the kernel (replace -j2 with how many CPU cores you have in your system):
1 | make ARCH=mips CROSS_COMPILE=mips64-octeon-linux-gnu- prepare |
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.
1 | git clone https://github.com/Lochnair/sch_cake.git |
Compile the module:
1 | 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.
1 | sudo depmod -a |
Compile iproute2 with cake support
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.
1 | 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.
1 | git clone https://github.com/Lochnair/iproute2-4.4-cake-ubnt.git |
Enter the iproute2 folder and run make.
1 | cd iproute2-4.4-cake-ubnt |
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.