Installing Open vSwitch on Gentoo (Xen Hypervisor)

image_pdfimage_print

The Gentoo ebuild for Open vSwitch does not seem to work with the latest available kernel as of this writing (3.10.7-gentoo-r1). This post is documentation of the process that I performed in order to successfully install Open vSwitch on a Gentoo server running the Xen hypervisor. This guide assumes that you already have a Gentoo environment configured and running with the Xen hypervisor available in portage.

Note: See the update in the comment section below for how to install openvswitch-2.0.0 from portage!

First make sure the following kernel settings are enabled for full Open vSwitch compatibility:

Networking Support->Network Options->Openvswitch(M)
Networking Support->Network Options->802.1Q VLAN Support(*)
Networking Support->Network Options->GVRP (GARP VLAN Registration Protocol) support(*)
Networking Support->Network Options->QoS and/or fair queueing(*)
Networking Support->Network Options->QoS and/or fair queueing->SET ALL TO (M)
Networking Support->The IPv6 protocol <*>

After you rebuild the kernel and reboot the machine you can load the openvswitch module by typing:

modprobe openvswitch

Next add an entry for the openvswitch module to /etc/conf.d/modules so it loads on each reboot:

modules_3="openvswitch tun"

In order to successfully install Open vSwitch it must be downloaded and installed from source. The latest source code can be downloaded here.

In this guide the openvswitch-1.11.0.tar.gz file was downloaded and extracted to /usr/src/openvswitch. Perform the following commands to build and install Open vSwitch from the downloaded source code.

cd /usr/src/openvswitch
tar xaf openvswitch-1.11.0.tar.gz
cd openvswitch-1.11.0

cat README

./configure --prefix=/usr --localstatedir=/var
make -j2
make install

Open vSwitch should now have files installed in /usr and /var

The ovs-* commands should also now be available in your path

# ovs <TAB>
ovs-appctl               ovs-dpctl                ovs-pki                  ovs-vswitchd             ovsdb-tool               
ovs-benchmark            ovs-ofctl                ovs-vlan-bug-workaround  ovsdb-client             
ovs-controller           ovs-parse-leaks          ovs-vsctl                ovsdb-server             

Next it is necessary to create the openvswitch DB

ovsdb-tool create /usr/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema

Startup the Open vSwitch database server

ovsdb-server --remote=punix:/var/run/openvswitch/db.sock \
--remote=db:Open_vSwitch,Open_vSwitch,manager_options \
--private-key=db:Open_vSwitch,SSL,private_key \
--certificate=db:Open_vSwitch,SSL,certificate \
--bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert \
--pidfile --detach

Initialize the database

ovs-vsctl --no-wait init

Then start up openvswitch

ovs-vswitchd --pidfile --detach
2013-11-05T13:50:44Z|00001|reconnect|INFO|unix:/var/run/openvswitch/db.sock: connecting...
2013-11-05T13:50:44Z|00002|reconnect|INFO|unix:/var/run/openvswitch/db.sock: connected

In order to have Xen use Open vSwitch as its default virtual interface add the following entry to /etc/xen/xl.conf

vif.default.script="vif-openvswitch"

The physical Ethernet interface that will be used with Open vSwitch has to be set to null in /etc/conf.d/net

config_enp4s0="null"

Finally create the first Open vSwitch bridge called xenbr0

ovs-vsctl add-br xenbr0
ovs-vsctl add-port xenbr0 enp4s0
ovs-vsctl set bridge xenbr0 stp_enable=true

Note: See the update in the comment section below for how to install openvswitch-2.0.0 from portage!

References:

How to Install Open vSwitch on Linux, FreeBSD and NetBSD

Xen Networking – Xen (Setting up Open vSwitch networking)

QEMU with Open vSwitch network