Installing Open vSwitch on Gentoo (Xen Hypervisor)


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


./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


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


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!


How to Install Open vSwitch on Linux, FreeBSD and NetBSD

Xen Networking – Xen (Setting up Open vSwitch networking)

QEMU with Open vSwitch network

1 Response to “Installing Open vSwitch on Gentoo (Xen Hypervisor)”

  1. Ronny

    The new Open vSwitch 2.0.0 ebuild is now available in portage. It does not install correctly if you just do an:

    emerge -avq openvswitch

    It ends up complaining about a missing kernel module that has long been removed and is no longer available:

    doins: brcompat.ko does not exist

    In order to get this version to compile using portage the ebuild must be edited:

    cd /usr/portage/net-misc/openvswitch
    vim openvswitch-2.0.0.ebuild

    Change the following line:

    MODULE_NAMES="brcompat(net:${S}/datapath/linux) openvswitch(net:${S}/datapath/linux)"

    to this:


    Then while still in that directory run the following command to commit the changes:

    ebuild openvswitch-2.0.0.ebuild digest

    Next we need to edit our kernel config, everything remains the same as posted above however openvswitch must be disabled in the kernel because the ebuild builds a new kernel module that it uses instead:

    Networking Support->Network Options->Openvswitch( )

    Once the change is made rebuild and install the modified kernel.

    Once that is complete run:

    emerge -avq openvswitch

    and it should compile and install correctly!

    To run it perform the following steps:

    First edit /etc/conf.d/ovsdb-server and make it look like this (note the addition of Open_vSwitch):

    # Socket for bringing the server up
    # Remote sockets are defined in the database by default
    # All certificates and keys are stored in the database (if any)
    # Alternative path for the database (default is /etc/openvswitch/conf.db)
    # DATABASE="/etc/openvswitch/conf.db"
    # Additional options
    # OPTIONS=""

    Then perform the intial configuration and start up the services:

    emerge --config =net-misc/openvswitch-2.0.0
    /etc/init.d/ovsdb-server start
    /etc/init.d/ovs-controller start
    /etc/init.d/ovs-vswitchd start
    rc-update add ovsdb-server default
    rc-update add ovs-controller default
    rc-update add ovs-vswitchd default

    Finally setup the first bridge interface:

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


    Gentoo Forum Post

    Gentoo Bugzilla Entry