1 How to Install Open vSwitch on Linux, FreeBSD and NetBSD
2 ========================================================
4 This document describes how to build and install Open vSwitch on a
5 generic Linux, FreeBSD, or NetBSD host. For specifics around installation
6 on a specific platform, please see one of these files:
17 To compile the userspace programs in the Open vSwitch distribution,
18 you will need the following software:
22 - A C compiler, such as:
26 * Clang. Clang 3.4 and later provide useful static semantic
27 analysis and thread-safety checks. For Ubuntu, there are
28 nightly built packages available on clang's website.
30 - libssl, from OpenSSL, is optional but recommended if you plan to
31 connect the Open vSwitch to an OpenFlow controller. libssl is
32 required to establish confidentiality and authenticity in the
33 connections from an Open vSwitch to an OpenFlow controller. If
34 libssl is installed, then Open vSwitch will automatically build
37 - Python 2.x, for x >= 4.
39 To compile the kernel module on Linux, you must also install the
40 following. If you cannot build or install the kernel module, you may
41 use the userspace-only implementation, at a cost in performance. The
42 userspace implementation may also lack some features. Refer to
43 INSTALL.userspace for more information.
45 - A supported Linux kernel version. Please refer to README for a
46 list of supported versions.
48 The Open vSwitch datapath requires bridging support
49 (CONFIG_BRIDGE) to be built as a kernel module. (This is common
50 in kernels provided by Linux distributions.) The bridge module
51 must not be loaded or in use. If the bridge module is running
52 (check with "lsmod | grep bridge"), you must remove it ("rmmod
53 bridge") before starting the datapath.
55 For optional support of ingress policing, you must enable kernel
56 configuration options NET_CLS_BASIC, NET_SCH_INGRESS, and
57 NET_ACT_POLICE, either built-in or as modules. (NET_CLS_POLICE is
58 obsolete and not needed.)
60 To use GRE tunneling on Linux 2.6.37 or newer, kernel support
61 for GRE must be compiled in or available as a module
62 (CONFIG_NET_IPGRE_DEMUX).
64 To configure HTB or HFSC quality of service with Open vSwitch,
65 you must enable the respective configuration options.
67 To use Open vSwitch support for TAP devices, you must enable
70 - To build a kernel module, you need the same version of GCC that
71 was used to build that kernel.
73 - A kernel build directory corresponding to the Linux kernel image
74 the module is to run on. Under Debian and Ubuntu, for example,
75 each linux-image package containing a kernel binary has a
76 corresponding linux-headers package with the required build
79 If you are working from a Git tree or snapshot (instead of from a
80 distribution tarball), or if you modify the Open vSwitch build system
81 or the database schema, you will also need the following software:
83 - Autoconf version 2.64 or later.
85 - Automake version 1.10 or later.
87 - libtool version 2.4 or later. (Older versions might work too.)
89 To run the unit tests, you also need:
91 - Perl. Version 5.10.1 is known to work. Earlier versions should
94 The ovs-vswitchd.conf.db(5) manpage will include an E-R diagram, in
95 formats other than plain text, only if you have the following:
97 - "dot" from graphviz (http://www.graphviz.org/).
99 - Perl. Version 5.10.1 is known to work. Earlier versions should
102 - Python 2.x, for x >= 4.
104 If you are going to extensively modify Open vSwitch, please consider
105 installing the following to obtain better warnings:
107 - "sparse" version 0.4.4 or later
108 (http://www.kernel.org/pub/software/devel/sparse/dist/).
112 - clang, version 3.4 or later
114 Also, you may find the ovs-dev script found in utilities/ovs-dev.py useful.
116 Installation Requirements
117 -------------------------
119 The machine on which Open vSwitch is to be installed must have the
122 - libc compatible with the libc used for build.
124 - libssl compatible with the libssl used for build, if OpenSSL was
127 - On Linux, the same kernel version configured as part of the build.
129 - For optional support of ingress policing on Linux, the "tc" program
130 from iproute2 (part of all major distributions and available at
131 http://www.linux-foundation.org/en/Net:Iproute2).
133 On Linux you should ensure that /dev/urandom exists. To support TAP
134 devices, you must also ensure that /dev/net/tun exists.
136 Building and Installing Open vSwitch for Linux, FreeBSD or NetBSD
137 =================================================================
139 Once you have installed all the prerequisites listed above in the Base
140 Prerequisites section, follow the procedure below to build.
142 1. If you pulled the sources directly from an Open vSwitch Git tree,
143 run boot.sh in the top source directory:
147 2. In the top source directory, configure the package by running the
148 configure script. You can usually invoke configure without any
153 By default all files are installed under /usr/local. If you want
154 to install into, e.g., /usr and /var instead of /usr/local and
155 /usr/local/var, add options as shown here:
157 % ./configure --prefix=/usr --localstatedir=/var
159 To use a specific C compiler for compiling Open vSwitch user
160 programs, also specify it on the configure command line, like so:
162 % ./configure CC=gcc-4.2
164 To use 'clang' compiler:
166 % ./configure CC=clang
168 To build the Linux kernel module, so that you can run the
169 kernel-based switch, pass the location of the kernel build
170 directory on --with-linux. For example, to build for a running
173 % ./configure --with-linux=/lib/modules/`uname -r`/build
175 If you wish to build the kernel module for an architecture other
176 than the architecture of the machine used for the build, you may
177 specify the kernel architecture string using the KARCH variable
178 when invoking the configure script. For example, to build for MIPS
181 % ./configure --with-linux=/path/to/linux KARCH=mips
183 If you plan to do much Open vSwitch development, you might want to
184 add --enable-Werror, which adds the -Werror option to the compiler
185 command line, turning warnings into errors. That makes it
186 impossible to miss warnings generated by the build.
188 The configure script accepts a number of other options and honors
189 additional environment variables. For a full list, invoke
190 configure with the --help option.
192 3. Run GNU make in the top source directory, e.g.:
196 or if GNU make is installed as "gmake":
200 For improved warnings if you installed "sparse" (see
201 "Prerequisites"), add C=1 to the command line.
203 4. Consider running the testsuite. Refer to "Running the Testsuite"
204 below, for instructions.
206 5. Become root by running "su" or another program.
208 6. Run "make install" to install the executables and manpages into the
209 running system, by default under /usr/local.
211 7. If you built kernel modules, you may install and load them, e.g.:
213 % make modules_install
214 % /sbin/modprobe openvswitch
216 To verify that the modules have been loaded, run "/sbin/lsmod" and
217 check that openvswitch is listed.
219 If the "modprobe" operation fails, look at the last few kernel log
220 messages (e.g. with "dmesg | tail"):
222 - The message "openvswitch: exports duplicate symbol
223 br_should_route_hook (owned by bridge)" means that the bridge
224 module is loaded. Run "/sbin/rmmod bridge" to remove it.
226 If "/sbin/rmmod bridge" fails with "ERROR: Module bridge does
227 not exist in /proc/modules", then the bridge is compiled into
228 the kernel, rather than as a module. Open vSwitch does not
229 support this configuration (see "Build Requirements", above).
231 - The message "openvswitch: exports duplicate symbol
232 dp_ioctl_hook (owned by ofdatapath)" means that the ofdatapath
233 module from the OpenFlow reference implementation is loaded.
234 Run "/sbin/rmmod ofdatapath" to remove it. (You might have to
235 delete any existing datapaths beforehand, using the "dpctl"
236 program included with the OpenFlow reference implementation.
237 "ovs-dpctl" will not work.)
239 - Otherwise, the most likely problem is that Open vSwitch was
240 built for a kernel different from the one into which you are
241 trying to load it. Run "modinfo" on openvswitch.ko and on
242 a module built for the running kernel, e.g.:
244 % /sbin/modinfo openvswitch.ko
245 % /sbin/modinfo /lib/modules/`uname -r`/kernel/net/bridge/bridge.ko
247 Compare the "vermagic" lines output by the two commands. If
248 they differ, then Open vSwitch was built for the wrong kernel.
250 - If you decide to report a bug or ask a question related to
251 module loading, please include the output from the "dmesg" and
252 "modinfo" commands mentioned above.
254 There is an optional module parameter to openvswitch.ko called
255 vlan_tso that enables TCP segmentation offload over VLANs on NICs
256 that support it. Many drivers do not expose support for TSO on VLANs
257 in a way that Open vSwitch can use but there is no way to detect
258 whether this is the case. If you know that your particular driver can
259 handle it (for example by testing sending large TCP packets over VLANs)
260 then passing in a value of 1 may improve performance. Modules built for
261 Linux kernels 2.6.37 and later, as well as specially patched versions
262 of earlier kernels, do not need this and do not have this parameter. If
263 you do not understand what this means or do not know if your driver
264 will work, do not set this.
266 8. Initialize the configuration database using ovsdb-tool, e.g.:
268 % mkdir -p /usr/local/etc/openvswitch
269 % ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema
274 Before starting ovs-vswitchd itself, you need to start its
275 configuration database, ovsdb-server. Each machine on which Open
276 vSwitch is installed should run its own copy of ovsdb-server.
277 Configure it to use the database you created during step 7 of
278 installation, above, to listen on a Unix domain socket, to connect to
279 any managers specified in the database itself, and to use the SSL
280 configuration in the database:
282 % ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock \
283 --remote=db:Open_vSwitch,Open_vSwitch,manager_options \
284 --private-key=db:Open_vSwitch,SSL,private_key \
285 --certificate=db:Open_vSwitch,SSL,certificate \
286 --bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert \
289 (If you built Open vSwitch without SSL support, then omit
290 --private-key, --certificate, and --bootstrap-ca-cert.)
292 Then initialize the database using ovs-vsctl. This is only
293 necessary the first time after you create the database with
294 ovsdb-tool (but running it at any time is harmless):
296 % ovs-vsctl --no-wait init
298 Then start the main Open vSwitch daemon, telling it to connect to the
299 same Unix domain socket:
301 % ovs-vswitchd --pidfile --detach
303 Now you may use ovs-vsctl to set up bridges and other Open vSwitch
304 features. For example, to create a bridge named br0 and add ports
305 eth0 and vif1.0 to it:
307 % ovs-vsctl add-br br0
308 % ovs-vsctl add-port br0 eth0
309 % ovs-vsctl add-port br0 vif1.0
311 Please refer to ovs-vsctl(8) for more details.
316 When you upgrade Open vSwitch from one version to another, you should
317 also upgrade the database schema:
319 1. Stop the Open vSwitch daemons, e.g.:
321 % kill `cd /usr/local/var/run/openvswitch && cat ovsdb-server.pid ovs-vswitchd.pid`
323 2. Install the new Open vSwitch release.
325 3. Upgrade the database, in one of the following two ways:
327 - If there is no important data in your database, then you may
328 delete the database file and recreate it with ovsdb-tool,
329 following the instructions under "Building and Installing Open
330 vSwitch for Linux, FreeBSD or NetBSD".
332 - If you want to preserve the contents of your database, back it
333 up first, then use "ovsdb-tool convert" to upgrade it, e.g.:
335 % ovsdb-tool convert /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema
337 4. Start the Open vSwitch daemons as described under "Building and
338 Installing Open vSwitch for Linux, FreeBSD or NetBSD" above.
342 Upgrading Open vSwitch from one version to the next version with minimum
343 disruption of traffic going through the system that is using that Open vSwitch
344 needs some considerations:
346 1. If the upgrade only involves upgrading the userspace utilities and daemons
347 of Open vSwitch, make sure that the new userspace version is compatible with
348 the previously loaded kernel module.
350 2. An upgrade of userspace daemons means that they have to be restarted.
351 Restarting the daemons means that the Openflow flows in the ovs-vswitchd daemon
352 will be lost. One way to restore the flows is to let the controller
353 re-populate it. Another way is to save the previous flows using a utility
354 like ovs-ofctl and then re-add them after the restart. Restoring the old flows
355 is accurate only if the new Open vSwitch interfaces retain the old 'ofport'
358 3. When the new userspace daemons get restarted, they automatically flush
359 the old flows setup in the kernel. This can be expensive if there are hundreds
360 of new flows that are entering the kernel but userspace daemons are busy
361 setting up new userspace flows from either the controller or an utility like
362 ovs-ofctl. Open vSwitch database provides an option to solve this problem
363 through the other_config:flow-restore-wait column of the Open_vSwitch table.
364 Refer to the ovs-vswitchd.conf.db(5) manpage for details.
366 4. If the upgrade also involves upgrading the kernel module, the old kernel
367 module needs to be unloaded and the new kernel module should be loaded. This
368 means that the kernel network devices belonging to Open vSwitch is recreated
369 and the kernel flows are lost. The downtime of the traffic can be reduced
370 if the userspace daemons are restarted immediately and the userspace flows
371 are restored as soon as possible.
373 The ovs-ctl utility's "restart" function only restarts the userspace daemons,
374 makes sure that the 'ofport' values remain consistent across restarts, restores
375 userspace flows using the ovs-ofctl utility and also uses the
376 other_config:flow-restore-wait column to keep the traffic downtime to the
377 minimum. The ovs-ctl utility's "force-reload-kmod" function does all of the
378 above, but also replaces the old kernel module with the new one. Open vSwitch
379 startup scripts for Debian, XenServer and RHEL use ovs-ctl's functions and it
380 is recommended that these functions be used for other software platforms too.
382 Running the Testsuite
383 =====================
385 Open vSwitch includes a testsuite. Before you submit patches
386 upstream, we advise that you run the tests and ensure that they pass.
387 If you add new features to Open vSwitch, then adding tests for those
388 features will ensure your features don't break as developers modify
389 other areas of Open vSwitch.
391 You must configure and build Open vSwitch (steps 1 through 3 in
392 "Building and Installing Open vSwitch for Linux, FreeBSD or NetBSD" above)
393 before you run the testsuite. You do not need to install Open vSwitch
394 or to build or load the kernel module to run the testsuite. You do
395 not need supervisor privilege to run the testsuite.
397 To run all the unit tests in Open vSwitch, one at a time:
399 This takes under 5 minutes on a modern desktop system.
401 To run all the unit tests in Open vSwitch, up to 8 in parallel:
402 make check TESTSUITEFLAGS=-j8
403 This takes under a minute on a modern 4-core desktop system.
405 To see a list of all the available tests, run:
406 make check TESTSUITEFLAGS=--list
408 To run only a subset of tests, e.g. test 123 and tests 477 through 484:
409 make check TESTSUITEFLAGS='123 477-484'
410 (Tests do not have inter-dependencies, so you may run any subset.)
412 To run tests matching a keyword, e.g. "ovsdb":
413 make check TESTSUITEFLAGS='-k ovsdb'
415 To see a complete list of test options:
416 make check TESTSUITEFLAGS=--help
418 The results of a testing run are reported in tests/testsuite.log.
419 Please report test failures as bugs and include the testsuite.log in
422 If you have "valgrind" installed, then you can also run the testsuite
423 under valgrind by using "make check-valgrind" in place of "make
424 check". All the same options are available via TESTSUITEFLAGS. When
425 you do this, the "valgrind" results for test <N> are reported in files
426 named tests/testsuite.dir/<N>/valgrind.*. You may find that the
427 valgrind results are easier to interpret if you put "-q" in
428 ~/.valgrindrc, since that reduces the amount of output.
430 Sometimes a few tests may fail on some runs but not others. This is
431 usually a bug in the testsuite, not a bug in Open vSwitch itself. If
432 you find that a test fails intermittently, please report it, since the
433 developers may not have noticed.
438 Please report problems to bugs@openvswitch.org.