Skip to content

How To: Install OVS (Kernel Module) from Source Code

Kentaro Ebisawa edited this page Mar 16, 2015 · 2 revisions

OpenVSwitch (OVS) を Source Code からインストールした際にハマったのでメモ。 ハマったポイントは make modules_install して modprobe しても既存の Kernel Module を掴んでしまい、コンパイルしたのを使ってくれなかったところ。 make modules_install する前に既存の openvswitch.ko を消しておく必要がありました。

Version: OVS2.3.0

Summary:

download source code

$ wget http://openvswitch.org/releases/openvswitch-2.3.0.tar.gz
$ tar xvf openvswitch-2.3.0.tar.gz

Install required packages mentioned in INSTALL

$ sudo apt-get install autoconf
$ sudo apt-get install libtool

cd ~/openvswitch-2.3.0/

$ ./boot.sh
$ ./configure --with-linux=/lib/modules/`uname -r`/build
$ make
$ sudo make install

Backup / Remove existing openvswitch.ko Kernel Module. /lib/modules//kernel/net/openvswitch/openvswitch.ko

$ sudo make modules_install
$ sudo modprobe openvswitch
$ lsmod | grep openvswitch

Why you need to remove existing Kernel Module before "make modules_install" ?

When you "make modules_install", message like "Can't read private key" will be shown. This is warning message that the Module is not signed. It would actually copied (installed) to /lib/modules/3.13.0-32-generic/extra/.

Now, when you run "modprobe openvswitch" :

  1. /lib/modules/3.13.0-32-generic/kernel/net/openvswitch/openvswitch.ko will be used if it exists.
  2. If not, extra/openvswitch.ko will be used.

Thus, you need to remove exsiting "kernel/net/openvswitch/openvswitch.ko" to load extra/openvswitch.ko which you compiled from source code.

Installation Log

1. Run boot.sh (autoreconf)
ebiken@ovs01:~/openvswitch-2.3.0$ pwd
/home/ebiken/openvswitch-2.3.0
ebiken@ovs01:~/openvswitch-2.3.0$ ./boot.sh
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, `build-aux'.
libtoolize: copying file `build-aux/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'.
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'

2. Configure package by running ./configure --with-linux=/lib/modules/`uname -r`/build
Default directory is /usr/local, while ubuntu general app is /usr.
Check INSTALL if you want to change it inline with ubuntu general App.
# Check for Ubuntu specific info : https://wiki.linaro.org/LNG/Engineering/OVSOnUbuntu

"--with-linux=/lib/modules/`uname -r`/build" is required to build Linux kernel module.

ebiken@ovs01:~/openvswitch-2.3.0$ ./configure --with-linux=/lib/modules/`uname -r`/build

# Note: if you want to use SSL to connect to controler, you need openssl available at this point.

3. Run GNU make in the build directory
ebiken@ovs01:~/openvswitch-2.3.0$ make

4. Run "make install" to install the executables and manpages into the
   running system, by default under /usr/local.

# This will also create an empty directory /usr/local/etc/openvswitch/
# Libraries have been installed in: /usr/local/lib

ebiken@ovs01:~/openvswitch-2.3.0$ sudo make install

5. If you built kernel modules, you may install and load them, e.g.:
# first, remove existing kernel module.
$ sudo cp /lib/modules/3.13.0-32-generic/kernel/net/openvswitch/openvswitch.ko <backup-folder>
$ sudo rm /lib/modules/3.13.0-32-generic/kernel/net/openvswitch/openvswitch.ko

ebiken@ovs01:~/openvswitch-2.3.0$ sudo make modules_install
ebiken@ovs01:~/openvswitch-2.3.0$ lsmod | grep bridge
ebiken@ovs01:~/openvswitch-2.3.0$ lsmod | grep openvswitch

6. Load Kernel Module
ebiken@ovs01:~/openvswitch-2.3.0$ sudo modprobe openvswitch
ebiken@ovs01:~/openvswitch-2.3.0$ lsmod | grep open
openvswitch            66901  0
gre                    13796  1 openvswitch
vxlan                  37619  1 openvswitch
libcrc32c              12644  1 openvswitch

ebiken@ovs01:~/openvswitch-2.3.0$ modinfo ./datapath/linux/openvswitch.ko
filename:       /home/ebiken/openvswitch-2.3.0/./datapath/linux/openvswitch.ko
version:        2.3.0
license:        GPL
description:    Open vSwitch switching datapath
srcversion:     EC4BFE790C33F314F3B4D09
depends:        libcrc32c,vxlan,gre
vermagic:       3.13.0-32-generic SMP mod_unload modversions

ebiken@ovs01:~/openvswitch-2.3.0$ modprobe -D openvswitch
insmod /lib/modules/3.13.0-32-generic/kernel/lib/libcrc32c.ko
insmod /lib/modules/3.13.0-32-generic/kernel/net/ipv4/ip_tunnel.ko
insmod /lib/modules/3.13.0-32-generic/kernel/drivers/net/vxlan.ko
insmod /lib/modules/3.13.0-32-generic/kernel/net/ipv4/gre.ko
insmod /lib/modules/3.13.0-32-generic/extra/openvswitch.ko
ebiken@ovs01:~/openvswitch-2.3.0$ modinfo /lib/modules/3.13.0-32-generic/extra/openvswitch.ko
filename:       /lib/modules/3.13.0-32-generic/extra/openvswitch.ko
version:        2.3.0
license:        GPL
description:    Open vSwitch switching datapath
srcversion:     EC4BFE790C33F314F3B4D09
depends:        libcrc32c,vxlan,gre
vermagic:       3.13.0-32-generic SMP mod_unload modversions


7. Initialize the configuration database using ovsdb-tool, e.g.:
## only if required: sudo mkdir -p /usr/local/etc/openvswitch
$ sudo ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema
ebiken@ovs01:~/openvswitch-2.3.0$ ls /usr/local/etc/openvswitch
conf.db