Solved

Has anyone used BFD with an Ubuntu machine?


I'm in a situation where I need to run BGP between an Ubuntu machine and a Cumulus switch, and was wondering if anyone has gotten BFD to work between the two, or has any pointers for reducing convergence time on link failures.

4 replies

Userlevel 4
BFD is written into our PTM daemon (whose code is available here: https://github.com/CumulusNetworks/ptm ) but rather than use BFD here, linux offers another option: building a bond with one interface, then using the built-in arp-detection mechanism to arp for the IP on the far-side of link.

NOTE: This solution may not be scalable for largescale deployments as responding to ARP will tax your CPU.

ON THE HOST:
#Install ifenslave on the Ubuntu host
sudo apt-get install ifenslave

# Add the Bonding Driver
####The maximum number of arp_ip_targets that can be specified is 16--- separated by commas
####The arp_interval is specified in milliseconds
sudo modprobe -v bonding mode=1 arp_interval=50 arp_ip_target=192.168.1.2

# Add an address to the Bond (Optional)
sudo ip addr add 192.168.1.1/24 dev bond0

# Enslave Eth0 into the bond0 interface
sudo ifenslave bond0 eth0

#Try different modes of failure such as removing the IP from the far-side (to simulate a failure which does not cause the link to drop)
#Or try physically unplugging the link etc and watch the state of the bond interface as it reflects the changes
cat /proc/net/bonding/bond0

#When you're finished just remove the bonding driver and it should rip out the relevant config
sudo rmmod bonding

On the Cumulus Device:
# You can see the Arps flowing on swp1 with:
sudo tcpdump -i swp1
I've successfully installed Cumulus' latest version of Quagga (2.5.4) on Ubuntu 14.04 and have it working with BFD. Getting it up and running took a bit of compiling from source, modifying existing packages from Cumulus' repo and a little hacking. I've tried to be as detailed as possible.

There are three components required:
- Quagga
- ptmd for the BFD component
- lldpd as required by ptmd (version 0.7.11+)

Quagga
Create a deb package from the latest Quagga release in the Cumulus git repo (https://github.com/CumulusNetworks/quagga/archive/QuaggaCumulusLinux-2.5.4.tar.gz) with the below modifications made to source files.

The files from https://github.com/CumulusNetworks/quagga/archive/QuaggaCumulusLinux-2.5.4.tar.gz that were modified are as follows:

debian/control
-Depends: ${shlibs:Depends}, logrotate (>= 3.2-11), iproute, ${misc:Depends}, cl-utilities
+Depends: ${shlibs:Depends}, logrotate (>= 3.2-11), iproute, ${misc:Depends}
Explanation: Remove cl-utilities as a dependancy. This is not required for a the Ubuntu install, and while I tried getting it working on Ubuntu, it was more trouble than it was worth.

debian/quagga.install:
-debian/watchquagga.rc etc/cumulus/ssmonitor.d
Explanation: Removes the installation of debian/watchquagga.rc under etc/cumulus/ssmonitor.d from the build as this is specific to quagga running on cumulus kit.

debian/quagga-doc.docs
-doc/draft-zebra-00.txt
Explanation: Remove the non-existent file draft-zebra-00.txt from the deb build process.

Step by step process on a fresh install of Ubuntu 14.04.3:
- Install required compile dependancies
user@ubuntu:~$ sudo apt-get install devscripts debhelper libncurses5-dev libreadline-dev texlive-latex-base texlive-generic-recommended libpam0g-dev dh-autoreconf libcap-dev texinfo imagemagick ghostscript groff autotools-dev hardening-wrapper libpcre3-dev chrpath libsnmp-dev dpkg-dev libjson0 libjson0-dev
- Download the release from the Cumulus git repo
user@ubuntu:~$ wget https://github.com/CumulusNetworks/quagga/archive/QuaggaCumulusLinux-2.5.4.tar.gz
-Extract
user@ubuntu:~$ tar xf QuaggaCumulusLinux-2.5.4.tar.gz
user@ubuntu:~$ cd quagga-QuaggaCumulusLinux-2.5.4/
-Modify debian/quagga.install as per the above
user@ubuntu:~/quagga-QuaggaCumulusLinux-2.5.4$ sed -i '/debian\/watchquagga.rc   etc\/cumulus\/ssmonitor.d/d' debian/quagga.install
-Modify debian/quagga-doc.docs as per the above
user@ubuntu:~/quagga-QuaggaCumulusLinux-2.5.4$ sed -i '/doc\/draft-zebra-00.txt/d' debian/quagga-doc.docs
-Modify debian/control as per the above
user@ubuntu:~/quagga-QuaggaCumulusLinux-2.5.4$ sed -i 's|Depends: ${shlibs:Depends}, logrotate (>= 3.2-11), iproute, ${misc:Depends}, cl-utilities|Depends: ${shlibs:Depends}, logrotate (>= 3.2-11), iproute, ${misc:Depends}|' debian/control
-Compile and build the package
user@ubuntu:~/quagga-QuaggaCumulusLinux-2.5.4$ debuild -us -uc -b
-Once complete you should have three packages - quagga_0.99.23.1-1+cl2.5_amd64.deb quagga-dbg_0.99.23.1-1+cl2.5_amd64.deb and quagga-doc_0.99.23.1-1+cl2.5_all.deb
user@ubuntu:~/quagga-QuaggaCumulusLinux-2.5.4$ ll ../*.deb
-rw-r--r-- 1 user user 1254196 Oct 27 17:29 ../quagga_0.99.23.1-1+cl2.5_amd64.deb
-rw-r--r-- 1 user user 1935466 Oct 27 17:29 ../quagga-dbg_0.99.23.1-1+cl2.5_amd64.deb
-rw-r--r-- 1 user user 130844 Oct 27 17:29 ../quagga-doc_0.99.23.1-1+cl2.5_all.deb

ptmd
It was a little tricky getting ptmd installed, in particular creating a package. In the end I restored to a little hacking which involved downloading the latest ptmd package from the Cumulus repo, extracting the contents, modifying the below control files and then repackaging.

The files from http://repo.cumulusnetworks.com/pool/CumulusLinux-2.5/updates/ptmd_2.5-cl2.5+6_amd64.deb that were modified are as follows:

DEBIAN/control
-Depends: libcgraph5, lldpd, python
+Depends: libcgraph6, lldpd (>= 0.7.11), python
Explanation: Fix dependancies. Change libcgraph5 to libcgraph6 as libcgraph5 is not availble on 14.04 and has been replaced by libcgraph6. Updated lldpd to the minimum version required for ptmd to (0.7.11) - this will stop the latest version of lldpd available in the Ubuntu 14.04 repo being installed (0.7.7).

DEBIAN/postinst
+[ -f /usr/lib/libcgraph.so.5 ] || ln /usr/lib/libcgraph.so.6 /usr/lib/libcgraph.so.5
Explanation: This is the major hack. ptmd requires libcgraph5 (it tries to load /usr/lib/libcgraph.so.5 on startup) which has been replaced by libcgraph6 on Ubuntu 14.04. This edit creates a symlink when ptmd is installed, linking libcgraph.so.5 to libcgraph.so.6. ptmd will not start if libcgraph.so.5 does not exist.

DEBIAN/postrm
+[ -h /usr/lib/libcgraph.so.5 ] && unlink /usr/lib/libcgraph.so.5
Explanation: For tidiness. Removes the /usr/lib/libcgraph.so.5 symlink when ptmd is removed.

Step by step process on a fresh install of Ubuntu 14.04.3:
- Download the latest ptmd package from Cumulus' repo
user@ubuntu:~$ wget http://repo.cumulusnetworks.com/pool/CumulusLinux-2.5/updates/ptmd_2.5-cl2.5+6_amd64.deb
- Extract the contents of the package to a temp directory (ptmdeb/)
user@ubuntu:~$ dpkg-deb -x ptmd_2.5-cl2.5+6_amd64.deb ptmdeb/
- Extract the control contents of the package to the folder DEBIAN (case is important) in the temp directory (ptmdeb/)
user@ubuntu:~$ dpkg-deb --control ptmd_2.5-cl2.5+6_amd64.deb ptmdeb/DEBIAN
- Modify ptmdeb/DEBIAN/postinst as per the above
user@ubuntu:~$ sed -i '/exit 0/i[ -f /usr/lib/libcgraph.so.5 ] || ln /usr/lib/libcgraph.so.6 /usr/lib/libcgraph.so.5' ptmdeb/DEBIAN/postinst
- Modify ptmdeb/DEBIAN/postrm as per the above
user@ubuntu:~$ sed -i '$s|$|\n[ -h /usr/lib/libcgraph.so.5 ] \&\& unlink /usr/lib/libcgraph.so.5|'  ptmdeb/DEBIAN/postrm
- Modify ptmdeb/DEBIAN/control as per the above
user@ubuntu:~$ sed -i 's|Depends: libcgraph5, lldpd, python|Depends: libcgraph6, lldpd (>= 0.7.11), python|'  ptmdeb/DEBIAN/control
- Repackage
user@ubuntu:~$ dpkg -b ptmdeb ptmd_2.5-cl2.5+6_amd64.deb

lldpd
ptmd requires a lldpd version of at least 0.7.11 and the latest version available in the Ubuntu repo is 0.7.7. Compiling and building a package from source was quite easy.

Step by step process on a fresh install of Ubuntu 14.04.3:
- Install required compile dependancies
user@ubuntu:~$ sudo apt-get install devscripts debhelper  cdbs autotools-dev dh-autoreconf libsnmp-dev libxml2-dev libjansson-dev libevent-dev libreadline-dev libbsd-dev pkg-config
- Download the latest release
user@ubuntu:~$ wget https://github.com/vincentbernat/lldpd/archive/0.7.19.tar.gz
-Extract
user@ubuntu:~$ tar xf 0.7.19.tar.gz
-Download the specified release of libevent as per the lldpd repo, unzip and move to the source folder
user@ubuntu:~$ wget https://github.com/libevent/libevent/archive/c51b159cff9f5e86696f5b9a4c6f517276056258.zip
user@ubuntu:~$ unzip c51b159cff9f5e86696f5b9a4c6f517276056258.zip
user@ubuntu:~$ mv libevent-c51b159cff9f5e86696f5b9a4c6f517276056258/* lldpd-0.7.19/libevent/
-Compile and build the package
user@ubuntu:~$ cd lldpd-0.7.19/
user@ubuntu:~/lldpd-0.7.19$ debuild -us -uc -b
-Once complete you should have two packages - liblldpctl-dev_0.7.19-0_amd64.deb and lldpd_0.7.19-0_amd64.deb
user@ubuntu:~/lldpd-0.7.19$ ll ../*.deb
-rw-r--r-- 1 user user 51830 Oct 27 17:31 ../liblldpctl-dev_0.7.19-0_amd64.deb
-rw-r--r-- 1 user user 142950 Oct 27 17:31 ../lldpd_0.7.19-0_amd64.deb

After all packages have been created you should be able to install Quagga, ptmd and lldpd as follows:
-Install lldpd
user@ubuntu:~$ sudo lldpd_0.7.19-0_amd64.deb
-Install missing dependancies for lldpd
user@ubuntu:~$ apt-get -f install
-Install ptmd
user@ubuntu:~$ sudo dpkg -i ptmd_2.5-cl2.5+6_amd64.deb
-Install missing dependancies for ptmd
user@ubuntu:~$ apt-get -f install
-Install quagga
user@ubuntu:~$ dpkg -i quagga_0.99.23.1-1+cl2.5_amd64.deb
-Install missing dependancies for quagga
user@ubuntu:~$ apt-get -f install

BFD is configured in quagga as per http://docs.cumulusnetworks.com/display/DOCS/Bidirectional+Forwarding+Detection+-+BFD

A complete copy of the entire process on a fresh install of 14.04.3 can be found at https://paste.ee/p/pr8Ks. I'm also happy to make the packages available.

Good luck.
Tynan Young wrote:

I've successfully installed Cumulus' latest version of Quagga (2.5.4) on Ubuntu 14.04 and have it...

Just realised there needs to be a small adjustment to the above post in regards to ptmd as python-ipaddr is required to run ptmctl.

Changes as per the following:

DEBIAN/control
-Depends: libcgraph5, lldpd, python
+Depends: libcgraph6, lldpd (>= 0.7.11), python, python-ipaddr
Explanation: Fix dependancies. Change libcgraph5 to libcgraph6 as libcgraph5 is not availble on 14.04 and has been replaced by libcgraph6. Updated lldpd to the minimum version required for ptmd to (0.7.11) - this will stop the latest version of lldpd available in the Ubuntu 14.04 repo being installed (0.7.7). Require python-ipaddr as required to run ptmctl

- Modify ptmdeb/DEBIAN/control as per the above
user@ubuntu:~$ sed -i 's|Depends: libcgraph5, lldpd, python|Depends: libcgraph6, lldpd (>= 0.7.11), python, python-ipaddr|'  ptmdeb/DEBIAN/control
Wow, thank you for the detailed answer, awesome!

Reply