]> git.proxmox.com Git - mirror_ovs.git/blob - INSTALL.rst
2b7f9b174a3e5c546d55c953025954b0106dc879
[mirror_ovs.git] / INSTALL.rst
1 ..
2 Licensed under the Apache License, Version 2.0 (the "License"); you may
3 not use this file except in compliance with the License. You may obtain
4 a copy of the License at
5
6 http://www.apache.org/licenses/LICENSE-2.0
7
8 Unless required by applicable law or agreed to in writing, software
9 distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10 WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11 License for the specific language governing permissions and limitations
12 under the License.
13
14 Convention for heading levels in Open vSwitch documentation:
15
16 ======= Heading 0 (reserved for the title in a document)
17 ------- Heading 1
18 ~~~~~~~ Heading 2
19 +++++++ Heading 3
20 ''''''' Heading 4
21
22 Avoid deeper levels because they do not render well.
23
24 =========================================
25 Open vSwitch on Linux, FreeBSD and NetBSD
26 =========================================
27
28 This document describes how to build and install Open vSwitch on a generic
29 Linux, FreeBSD, or NetBSD host. For specifics around installation on a specific
30 platform, refer to one of these installation guides:
31
32 - `Debian <INSTALL.Debian.md>`__
33 - `Fedora <INSTALL.Fedora.md>`__
34 - `RHEL <INSTALL.RHEL.md>`__
35 - `XenServer <INSTALL.XenServer.md>`__
36 - `NetBSD <INSTALL.NetBSD.md>`__
37 - `Windows <INSTALL.Windows.md>`__
38 - `DPDK <INSTALL.DPDK.md>`__
39
40 .. _general-build-reqs:
41
42 Build Requirements
43 ------------------
44
45 To compile the userspace programs in the Open vSwitch distribution, you will
46 need the following software:
47
48 - GNU make
49
50 - A C compiler, such as:
51
52 - GCC 4.x.
53
54 - Clang. Clang 3.4 and later provide useful static semantic analysis and
55 thread-safety checks. For Ubuntu, there are nightly built packages
56 available on clang's website.
57
58 - MSVC 2013. See the `Windows installation guide <INSTALL.Windows>`__
59 for additional Windows build instructions.
60
61 While OVS may be compatible with other compilers, optimal support for atomic
62 operations may be missing, making OVS very slow (see ``lib/ovs-atomic.h``).
63
64 - libssl, from OpenSSL, is optional but recommended if you plan to connect the
65 Open vSwitch to an OpenFlow controller. libssl is required to establish
66 confidentiality and authenticity in the connections from an Open vSwitch to
67 an OpenFlow controller. If libssl is installed, then Open vSwitch will
68 automatically build with support for it.
69
70 - libcap-ng, written by Steve Grubb, is optional but recommended. It is
71 required to run OVS daemons as a non-root user with dropped root privileges.
72 If libcap-ng is installed, then Open vSwitch will automatically build with
73 support for it.
74
75 - Python 2.7. You must also have the Python ``six`` library.
76
77 On Linux, you may choose to compile the kernel module that comes with the Open
78 vSwitch distribution or to use the kernel module built into the Linux kernel
79 (version 3.3 or later). See the `FAQ <FAQ.md>`__ question "What features
80 are not available in the Open vSwitch kernel datapath that ships as part of the
81 upstream Linux kernel?" for more information on this trade-off. You may also
82 use the userspace-only implementation, at some cost in features and performance
83 (see the `userspace installation guide <INSTALL.userspace.md>`__ for
84 details).
85
86 To compile the kernel module on Linux, you must also install the
87 following:
88
89 - A supported Linux kernel version. Refer to the `README <README.md>`__
90 for a list of supported versions.
91
92 For optional support of ingress policing, you must enable kernel
93 configuration options ``NET_CLS_BASIC``, ``NET_SCH_INGRESS``, and
94 ``NET_ACT_POLICE``, either built-in or as modules. ``NET_CLS_POLICE`` is
95 obsolete and not needed.)
96
97 On kernels before 3.11, the ``ip_gre`` module, for GRE tunnels over IP
98 (``NET_IPGRE``), must not be loaded or compiled in.
99
100 To configure HTB or HFSC quality of service with Open vSwitch, you must
101 enable the respective configuration options.
102
103 To use Open vSwitch support for TAP devices, you must enable ``CONFIG_TUN``.
104
105 - To build a kernel module, you need the same version of GCC that was used to
106 build that kernel.
107
108 - A kernel build directory corresponding to the Linux kernel image the module
109 is to run on. Under Debian and Ubuntu, for example, each linux-image package
110 containing a kernel binary has a corresponding linux-headers package with
111 the required build infrastructure.
112
113 If you are working from a Git tree or snapshot (instead of from a distribution
114 tarball), or if you modify the Open vSwitch build system or the database
115 schema, you will also need the following software:
116
117 - Autoconf version 2.63 or later.
118
119 - Automake version 1.10 or later.
120
121 - libtool version 2.4 or later. (Older versions might work too.)
122
123 To run the unit tests, you also need:
124
125 - Perl. Version 5.10.1 is known to work. Earlier versions should also
126 work.
127
128 The datapath tests for userspace and Linux datapaths also rely upon:
129
130 - pyftpdlib. Version 1.2.0 is known to work. Earlier versions should
131 also work.
132
133 - GNU wget. Version 1.16 is known to work. Earlier versions should also
134 work.
135
136 The ovs-vswitchd.conf.db(5) manpage will include an E-R diagram, in formats
137 other than plain text, only if you have the following:
138
139 - dot from graphviz (http://www.graphviz.org/).
140
141 - Perl. Version 5.10.1 is known to work. Earlier versions should also
142 work.
143
144 If you are going to extensively modify Open vSwitch, consider installing the
145 following to obtain better warnings:
146
147 - "sparse" version 0.4.4 or later
148 (http://www.kernel.org/pub/software/devel/sparse/dist/).
149
150 - GNU make.
151
152 - clang, version 3.4 or later
153
154 - flake8, version 2.X, along with the hacking flake8 plugin (for Python code).
155 The automatic flake8 check that runs against Python code has some warnings
156 enabled that come from the "hacking" flake8 plugin. If it's not installed,
157 the warnings just won't occur until it's run on a system with "hacking"
158 installed. Note that there are problems with flake8 3.0 and the "hacking"
159 plugin. To ensure you get flake8 2.X, you can use::
160
161 $ pip install 'flake8<3.0'
162
163 You may find the ovs-dev script found in ``utilities/ovs-dev.py`` useful.
164
165 .. _general-install-reqs:
166
167 Installation Requirements
168 -------------------------
169
170 The machine you build Open vSwitch on may not be the one you run it on. To
171 simply install and run Open vSwitch you require the following software:
172
173 - libc compatible with the libc used for build.
174
175 - libssl compatible with the libssl used for build, if OpenSSL was used
176 for the build.
177
178 - On Linux, the same kernel version configured as part of the build.
179
180 - For optional support of ingress policing on Linux, the "tc" program
181 from iproute2 (part of all major distributions and available at
182 http://www.linux-foundation.org/en/Net:Iproute2).
183
184 - Python 2.7. You must also have the Python six library.
185
186 On Linux you should ensure that ``/dev/urandom`` exists. To support TAP
187 devices, you must also ensure that ``/dev/net/tun`` exists.
188
189 .. _general-bootstrapping:
190
191 Bootstrapping
192 -------------
193
194 This step is not needed if you have downloaded a released tarball. If
195 you pulled the sources directly from an Open vSwitch Git tree or got a
196 Git tree snapshot, then run boot.sh in the top source directory to build
197 the "configure" script::
198
199 $ ./boot.sh
200
201 .. _general-configuring:
202
203 Configuring
204 -----------
205
206 Configure the package by running the configure script. You can usually
207 invoke configure without any arguments. For example::
208
209 $ ./configure
210
211 By default all files are installed under ``/usr/local``. Open vSwitch also
212 expects to find its database in ``/usr/local/etc/openvswitch`` by default. If
213 you want to install all files into, e.g., ``/usr`` and ``/var`` instead of
214 ``/usr/local`` and ``/usr/local/var`` and expect to use ``/etc/openvswitch`` as
215 the default database directory, add options as shown here::
216
217 $ ./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc
218
219 .. note::
220
221 Open vSwitch installed with packages like .rpm (e.g. via ``yum install`` or
222 ``rpm -ivh``) and .deb (e.g. via ``apt-get install`` or ``dpkg -i``) use the
223 above configure options.
224
225 By default, static libraries are built and linked against. If you want to use
226 shared libraries instead::
227
228 $ ./configure --enable-shared
229
230 To use a specific C compiler for compiling Open vSwitch user programs, also
231 specify it on the configure command line, like so::
232
233 $ ./configure CC=gcc-4.2
234
235 To use 'clang' compiler::
236
237 $ ./configure CC=clang
238
239 To supply special flags to the C compiler, specify them as ``CFLAGS`` on the
240 configure command line. If you want the default CFLAGS, which include ``-g`` to
241 build debug symbols and ``-O2`` to enable optimizations, you must include them
242 yourself. For example, to build with the default CFLAGS plus ``-mssse3``, you
243 might run configure as follows::
244
245 $ ./configure CFLAGS="-g -O2 -mssse3"
246
247 For efficient hash computation special flags can be passed to leverage built-in
248 intrinsics. For example on X86_64 with SSE4.2 instruction set support, CRC32
249 intrinsics can be used by passing ``-msse4.2``::
250
251 $ ./configure CFLAGS="-g -O2 -msse4.2"`
252
253 If you are on a different processor and don't know what flags to choose, it is
254 recommended to use ``-march=native`` settings::
255
256 $ ./configure CFLAGS="-g -O2 -march=native"
257
258 With this, GCC will detect the processor and automatically set appropriate
259 flags for it. This should not be used if you are compiling OVS outside the
260 target machine.
261
262 .. note::
263 CFLAGS are not applied when building the Linux kernel module. Custom CFLAGS
264 for the kernel module are supplied using the ``EXTRA_CFLAGS`` variable when
265 running make. For example::
266
267 $ make EXTRA_CFLAGS="-Wno-error=date-time"
268
269 To build the Linux kernel module, so that you can run the kernel-based switch,
270 pass the location of the kernel build directory on ``--with-linux``. For
271 example, to build for a running instance of Linux::
272
273 $ ./configure --with-linux=/lib/modules/$(uname -r)/build
274
275 .. note::
276 If ``--with-linux`` requests building for an unsupported version of Linux,
277 then ``configure`` will fail with an error message. Refer to the `FAQ
278 <FAQ.md>`__ for advice in that case.
279
280 If you wish to build the kernel module for an architecture other than the
281 architecture of the machine used for the build, you may specify the kernel
282 architecture string using the KARCH variable when invoking the configure
283 script. For example, to build for MIPS with Linux::
284
285 $ ./configure --with-linux=/path/to/linux KARCH=mips
286
287 If you plan to do much Open vSwitch development, you might want to add
288 ``--enable-Werror``, which adds the ``-Werror`` option to the compiler command
289 line, turning warnings into errors. That makes it impossible to miss warnings
290 generated by the build. For example::
291
292 $ ./configure --enable-Werror
293
294 To build with gcov code coverage support, add ``--enable-coverage``::
295
296 $ ./configure --enable-coverage
297
298 The configure script accepts a number of other options and honors additional
299 environment variables. For a full list, invoke configure with the ``--help``
300 option::
301
302 $ ./configure --help
303
304 You can also run configure from a separate build directory. This is helpful if
305 you want to build Open vSwitch in more than one way from a single source
306 directory, e.g. to try out both GCC and Clang builds, or to build kernel
307 modules for more than one Linux version. For example::
308
309 $ mkdir _gcc && (cd _gcc && ./configure CC=gcc)
310 $ mkdir _clang && (cd _clang && ./configure CC=clang)
311
312 Under certains loads the ovsdb-server and other components perform better when
313 using the jemalloc memory allocator, instead of the glibc memory allocator. If
314 you wish to link with jemalloc add it to LIBS::
315
316 $ ./configure LIBS=-ljemalloc
317
318 .. _general-building:
319
320 Building
321 --------
322
323 1. Run GNU make in the build directory, e.g.::
324
325 $ make
326
327 or if GNU make is installed as "gmake"::
328
329 $ gmake
330
331 If you used a separate build directory, run make or gmake from that
332 directory, e.g.::
333
334 $ make -C _gcc
335 $ make -C _clang
336
337 For improved warnings if you installed ``sparse`` (see "Prerequisites"), add
338 ``C=1`` to the command line.
339
340 .. note::
341 Some versions of Clang and ccache are not completely compatible. If you
342 see unusual warnings when you use both together, consider disabling
343 ccache.
344
345 2. Consider running the testsuite. Refer to **Testing** for instructions.
346
347 3. Run ``make install`` to install the executables and manpages into the
348 running system, by default under ``/usr/local``::
349
350 $ make install
351
352 5. If you built kernel modules, you may install them, e.g.::
353
354 $ make modules_install
355
356 It is possible that you already had a Open vSwitch kernel module installed
357 on your machine that came from upstream Linux (in a different directory). To
358 make sure that you load the Open vSwitch kernel module you built from this
359 repository, you should create a ``depmod.d`` file that prefers your newly
360 installed kernel modules over the kernel modules from upstream Linux. The
361 following snippet of code achieves the same::
362
363 $ config_file="/etc/depmod.d/openvswitch.conf"
364 $ for module in datapath/linux/*.ko; do
365 modname="$(basename ${module})"
366 echo "override ${modname%.ko} * extra" >> "$config_file"
367 echo "override ${modname%.ko} * weak-updates" >> "$config_file"
368 done
369 $ depmod -a
370
371 Finally, load the kernel modules that you need. e.g.::
372
373 $ /sbin/modprobe openvswitch
374
375 To verify that the modules have been loaded, run ``/sbin/lsmod`` and check
376 that openvswitch is listed::
377
378 $ /sbin/lsmod | grep openvswitch
379
380 .. note::
381 If the ``modprobe`` operation fails, look at the last few kernel log
382 messages (e.g. with ``dmesg | tail``). Generally, issues like this occur
383 when Open vSwitch is built for a kernel different from the one into which
384 you are trying to load it. Run ``modinfo`` on ``openvswitch.ko`` and on a
385 module built for the running kernel, e.g.::
386
387 $ /sbin/modinfo openvswitch.ko
388 $ /sbin/modinfo /lib/modules/$(uname -r)/kernel/net/bridge/bridge.ko
389
390 Compare the "vermagic" lines output by the two commands. If they differ,
391 then Open vSwitch was built for the wrong kernel.
392
393 If you decide to report a bug or ask a question related to module loading,
394 include the output from the ``dmesg`` and ``modinfo`` commands mentioned
395 above.
396
397 .. _general-starting:
398
399 Starting
400 --------
401
402 Before starting ovs-vswitchd itself, you need to start its configuration
403 database, ovsdb-server. Each machine on which Open vSwitch is installed should
404 run its own copy of ovsdb-server. Before ovsdb-server itself can be started,
405 configure a database that it can use::
406
407 $ mkdir -p /usr/local/etc/openvswitch
408 $ ovsdb-tool create /usr/local/etc/openvswitch/conf.db \
409 vswitchd/vswitch.ovsschema
410
411 Configure ovsdb-server to use database created above, to listen on a Unix
412 domain socket, to connect to any managers specified in the database itself, and
413 to use the SSL configuration in the database::
414
415 $ mkdir -p /usr/local/var/run/openvswitch
416 $ ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock \
417 --remote=db:Open_vSwitch,Open_vSwitch,manager_options \
418 --private-key=db:Open_vSwitch,SSL,private_key \
419 --certificate=db:Open_vSwitch,SSL,certificate \
420 --bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert \
421 --pidfile --detach
422
423 .. note::
424 If you built Open vSwitch without SSL support, then omit ``--private-key``,
425 ``--certificate``, and ``--bootstrap-ca-cert``.)
426
427 Initialize the database using ovs-vsctl. This is only necessary the first time
428 after you create the database with ovsdb-tool, though running it at any time is
429 harmless::
430
431 $ ovs-vsctl --no-wait init
432
433 Start the main Open vSwitch daemon, telling it to connect to the same Unix
434 domain socket::
435
436 $ ovs-vswitchd --pidfile --detach
437
438 Validating
439 ----------
440
441 At this point you can use ovs-vsctl to set up bridges and other Open vSwitch
442 features. For example, to create a bridge named ``br0`` and add ports ``eth0``
443 and ``vif1.0`` to it::
444
445 $ ovs-vsctl add-br br0
446 $ ovs-vsctl add-port br0 eth0
447 $ ovs-vsctl add-port br0 vif1.0
448
449 Refer to ovs-vsctl(8) for more details.
450
451 Upgrading
452 ---------
453
454 When you upgrade Open vSwitch from one version to another you should also
455 upgrade the database schema:
456
457 1. Stop the Open vSwitch daemons, e.g.::
458
459 $ kill `cd /usr/local/var/run/openvswitch && cat ovsdb-server.pid ovs-vswitchd.pid`
460
461 2. Install the new Open vSwitch release by using the same configure options as
462 was used for installing the previous version. If you do not use the same
463 configure options, you can end up with two different versions of Open
464 vSwitch executables installed in different locations.
465
466 3. Upgrade the database, in one of the following two ways:
467
468 - If there is no important data in your database, then you may delete the
469 database file and recreate it with ovsdb-tool, following the instructions
470 under "Building and Installing Open vSwitch for Linux, FreeBSD or NetBSD".
471
472 - If you want to preserve the contents of your database, back it up first,
473 then use ``ovsdb-tool convert`` to upgrade it, e.g.::
474
475 $ ovsdb-tool convert /usr/local/etc/openvswitch/conf.db \
476 vswitchd/vswitch.ovsschema
477
478 4. Start the Open vSwitch daemons as described under **Starting** above.
479
480 Hot Upgrading
481 -------------
482
483 Upgrading Open vSwitch from one version to the next version with minimum
484 disruption of traffic going through the system that is using that Open vSwitch
485 needs some considerations:
486
487 1. If the upgrade only involves upgrading the userspace utilities and daemons
488 of Open vSwitch, make sure that the new userspace version is compatible with
489 the previously loaded kernel module.
490
491 2. An upgrade of userspace daemons means that they have to be restarted.
492 Restarting the daemons means that the OpenFlow flows in the ovs-vswitchd
493 daemon will be lost. One way to restore the flows is to let the controller
494 re-populate it. Another way is to save the previous flows using a utility
495 like ovs-ofctl and then re-add them after the restart. Restoring the old
496 flows is accurate only if the new Open vSwitch interfaces retain the old
497 'ofport' values.
498
499 3. When the new userspace daemons get restarted, they automatically flush the
500 old flows setup in the kernel. This can be expensive if there are hundreds
501 of new flows that are entering the kernel but userspace daemons are busy
502 setting up new userspace flows from either the controller or an utility like
503 ovs-ofctl. Open vSwitch database provides an option to solve this problem
504 through the ``other_config:flow-restore-wait`` column of the
505 ``Open_vSwitch`` table. Refer to the ovs-vswitchd.conf.db(5) manpage for
506 details.
507
508 4. If the upgrade also involves upgrading the kernel module, the old kernel
509 module needs to be unloaded and the new kernel module should be loaded. This
510 means that the kernel network devices belonging to Open vSwitch is recreated
511 and the kernel flows are lost. The downtime of the traffic can be reduced if
512 the userspace daemons are restarted immediately and the userspace flows are
513 restored as soon as possible.
514
515 The ovs-ctl utility's ``restart`` function only restarts the userspace daemons,
516 makes sure that the 'ofport' values remain consistent across restarts, restores
517 userspace flows using the ovs-ofctl utility and also uses the
518 ``other_config:flow-restore-wait`` column to keep the traffic downtime to the
519 minimum. The ovs-ctl utility's ``force-reload-kmod`` function does all of the
520 above, but also replaces the old kernel module with the new one. Open vSwitch
521 startup scripts for Debian, XenServer and RHEL use ovs-ctl's functions and it
522 is recommended that these functions be used for other software platforms too.
523
524 .. _general-testing:
525
526 Testing
527 -------
528
529 This section describe Open vSwitch's built-in support for various test
530 suites. You must bootstrap, configure and build Open vSwitch (steps are
531 in "Building and Installing Open vSwitch for Linux, FreeBSD or NetBSD"
532 above) before you run the tests described here. You do not need to
533 install Open vSwitch or to build or load the kernel module to run these
534 test suites. You do not need supervisor privilege to run these test
535 suites.
536
537 Unit Tests
538 ~~~~~~~~~~
539
540 Open vSwitch includes a suite of self-tests. Before you submit patches
541 upstream, we advise that you run the tests and ensure that they pass. If you
542 add new features to Open vSwitch, then adding tests for those features will
543 ensure your features don't break as developers modify other areas of Open
544 vSwitch.
545
546 To run all the unit tests in Open vSwitch, one at a time, run::
547
548 $ make check
549
550 This takes under 5 minutes on a modern desktop system.
551
552 To run all the unit tests in Open vSwitch in parallel, run::
553
554 $ make check TESTSUITEFLAGS=-j8
555
556 You can run up to eight threads. This takes under a minute on a modern 4-core
557 desktop system.
558
559 To see a list of all the available tests, run:
560
561 $ make check TESTSUITEFLAGS=--list
562
563 To run only a subset of tests, e.g. test 123 and tests 477 through 484, run::
564
565 $ make check TESTSUITEFLAGS='123 477-484'
566
567 Tests do not have inter-dependencies, so you may run any subset.
568
569 To run tests matching a keyword, e.g. ``ovsdb``, run::
570
571 $ make check TESTSUITEFLAGS='-k ovsdb'
572
573 To see a complete list of test options, run::
574
575 $ make check TESTSUITEFLAGS=--help
576
577 The results of a testing run are reported in ``tests/testsuite.log``. Report
578 report test failures as bugs and include the ``testsuite.log`` in your report.
579
580 .. note::
581 Sometimes a few tests may fail on some runs but not others. This is usually a
582 bug in the testsuite, not a bug in Open vSwitch itself. If you find that a
583 test fails intermittently, please report it, since the developers may not
584 have noticed. You can make the testsuite automatically rerun tests that fail,
585 by adding ``RECHECK=yes`` to the ``make`` command line, e.g.::
586
587 $ make check TESTSUITEFLAGS=-j8 RECHECK=yes
588
589 Coverage
590 ++++++++
591
592 If the build was configured with ``--enable-coverage`` and the ``lcov`` utility
593 is installed, you can run the testsuite and generate a code coverage report by
594 using the ``check-lcoc`` target::
595
596 $ make check-lcov
597
598 All the same options are avaiable via TESTSUITEFLAGS. For example::
599
600 $ make check-lcov TESTSUITEFLAGS=-j8 -k ovn
601
602 Valgrind
603 ++++++++
604
605 If you have ``valgrind`` installed, you can run the testsuite under
606 valgrind by using the ``check-valgrind`` target::
607
608 $ make check-valgrind
609
610 When you do this, the "valgrind" results for test ``<N>`` are reported in files
611 named ``tests/testsuite.dir/<N>/valgrind.*``.
612
613 All the same options are available via TESTSUITEFLAGS.
614
615 .. hint::
616 You may find that the valgrind results are easier to interpret if you put
617 ``-q`` in ``~/.valgrindrc``, since that reduces the amount of output.
618
619 .. _general-oftest:
620
621 OFTest
622 ~~~~~~
623
624 OFTest is an OpenFlow protocol testing suite. Open vSwitch includes a Makefile
625 target to run OFTest with Open vSwitch in "dummy mode". In this mode of
626 testing, no packets travel across physical or virtual networks. Instead, Unix
627 domain sockets stand in as simulated networks. This simulation is imperfect,
628 but it is much easier to set up, does not require extra physical or virtual
629 hardware, and does not require supervisor privileges.
630
631 To run OFTest with Open vSwitch, first read and follow the instructions under
632 **Testing** above. Second, obtain a copy of OFTest and install its
633 prerequisites. You need a copy of OFTest that includes commit 406614846c5 (make
634 ovs-dummy platform work again). This commit was merged into the OFTest
635 repository on Feb 1, 2013, so any copy of OFTest more recent than that should
636 work. Testing OVS in dummy mode does not require root privilege, so you may
637 ignore that requirement.
638
639 Optionally, add the top-level OFTest directory (containing the ``oft`` program)
640 to your ``$PATH``. This slightly simplifies running OFTest later.
641
642 To run OFTest in dummy mode, run the following command from your Open vSwitch
643 build directory::
644
645 $ make check-oftest OFT=<oft-binary>
646
647 where ``<oft-binary>`` is the absolute path to the ``oft`` program in OFTest.
648 If you added "oft" to your $PATH, you may omit the OFT variable
649 assignment
650
651 By default, ``check-oftest`` passes ``oft`` just enough options to enable dummy
652 mode. You can use ``OFTFLAGS`` to pass additional options. For example, to run
653 just the ``basic.Echo`` test instead of all tests (the default) and enable
654 verbose logging, run::
655
656 $ make check-oftest OFT=<oft-binary> OFTFLAGS='--verbose -T basic.Echo'
657
658 If you use OFTest that does not include commit 4d1f3eb2c792 (oft: change
659 default port to 6653), merged into the OFTest repository in October 2013, then
660 you need to add an option to use the IETF-assigned controller port::
661
662 $ make check-oftest OFT=<oft-binary> OFTFLAGS='--port=6653'
663
664 Interpret OFTest results cautiously. Open vSwitch can fail a given test in
665 OFTest for many reasons, including bugs in Open vSwitch, bugs in OFTest, bugs
666 in the "dummy mode" integration, and differing interpretations of the OpenFlow
667 standard and other standards.
668
669 .. note::
670 Open vSwitch has not been validated against OFTest. Report test failures that
671 you believe to represent bugs in Open vSwitch. Include the precise versions
672 of Open vSwitch and OFTest in your bug report, plus any other information
673 needed to reproduce the problem.
674
675 Ryu
676 ~~~
677
678 Ryu is an OpenFlow controller written in Python that includes an extensive
679 OpenFlow testsuite. Open vSwitch includes a Makefile target to run Ryu in
680 "dummy mode". See **OFTest** above for an explanation of dummy mode.
681
682 To run Ryu tests with Open vSwitch, first read and follow the instructions
683 under **Testing** above. Second, obtain a copy of Ryu, install its
684 prerequisites, and build it. You do not need to install Ryu (some of the tests
685 do not get installed, so it does not help).
686
687 To run Ryu tests, run the following command from your Open vSwitch build
688 directory::
689
690 $ make check-ryu RYUDIR=<ryu-source-dir>``
691
692 where ``<ryu-source-dir>`` is the absolute path to the root of the Ryu source
693 distribution. The default ``<ryu-source-dir>`` is ``$srcdir/../ryu``
694 where ``$srcdir`` is your Open vSwitch source directory. If this is correct,
695 omit ``RYUDIR``
696
697 .. note::
698 Open vSwitch has not been validated against Ryu. Report test failures that
699 you believe to represent bugs in Open vSwitch. Include the precise versions
700 of Open vSwitch and Ryu in your bug report, plus any other information
701 needed to reproduce the problem.
702
703 Datapath testing
704 ~~~~~~~~~~~~~~~~
705
706 Open vSwitch includes a suite of tests specifically for datapath functionality,
707 which can be run against the userspace or kernel datapaths. If you are
708 developing datapath features, it is recommended that you use these tests and
709 build upon them to verify your implementation.
710
711 The datapath tests make some assumptions about the environment. They must be
712 run under root privileges on a Linux system with support for network
713 namespaces. For ease of use, the OVS source tree includes a vagrant box to
714 invoke these tests. Running the tests inside Vagrant provides kernel isolation,
715 protecting your development host from kernel panics or configuration conflicts
716 in the testsuite. If you wish to run the tests without using the vagrant box,
717 there are further instructions below.
718
719 Vagrant
720 +++++++
721
722 .. important::
723
724 Requires Vagrant (version 1.7.0 or later) and a compatible hypervisor
725
726 .. note::
727 You must **Bootstrap** and **Configure** the sources before you run the steps
728 described here.
729
730 A Vagrantfile is provided allowing to compile and provision the source tree as
731 found locally in a virtual machine using the following command::
732
733 $ vagrant up
734
735 This will bring up a Fedora 23 VM by default. If you wish to use a different
736 box or a vagrant backend not supported by the default box, the ``Vagrantfile``
737 can be modified to use a different box as base.
738
739 The VM can be reprovisioned at any time::
740
741 $ vagrant provision
742
743 OVS out-of-tree compilation environment can be set up with::
744
745 $ ./boot.sh
746 $ vagrant provision --provision-with configure_ovs,build_ovs
747
748 This will set up an out-of-tree build environment inside the VM in
749 ``/root/build``. The source code can be found in ``/vagrant``.
750
751 To recompile and reinstall OVS in the VM using RPM::
752
753 $ ./boot.sh
754 $ vagrant provision --provision-with configure_ovs,install_rpm
755
756 Two provisioners are included to run system tests with the OVS kernel module or
757 with a userspace datapath. This tests are different from the self-tests
758 mentioned above. To run them::
759
760 $ ./boot.sh
761 $ vagrant provision --provision-with \
762 configure_ovs,test_ovs_kmod,test_ovs_system_userspace
763
764 The results of the testsuite reside in the VM root user's home directory::
765
766 $ vagrant ssh
767 $ sudo -s
768 $ cd /root/build
769 $ ls tests/system*
770
771 Native
772 ++++++
773
774 The datapath testsuite as invoked by Vagrant above may also be run manually on
775 a Linux system with root privileges. These tests may take several minutes to
776 complete, and cannot be run in parallel.
777
778 Userspace datapath
779 '''''''''''''''''''
780
781 To invoke the datapath testsuite with the userspace datapath, run::
782
783 $ make check-system-userspace
784
785 The results of the testsuite are in ``tests/system-userspace-traffic.dir``.
786
787 Kernel datapath
788 '''''''''''''''
789
790 Make targets are also provided for testing the Linux kernel module. Note that
791 these tests operate by inserting modules into the running Linux kernel, so if
792 the tests are able to trigger a bug in the OVS kernel module or in the upstream
793 kernel then the kernel may panic.
794
795 To run the testsuite against the kernel module which is currently installed on
796 your system, run::
797
798 $ make check-kernel
799
800 To install the kernel module from the current build directory and run the
801 testsuite against that kernel module::
802
803 $ make check-kmod
804
805 The results of the testsuite are in ``tests/system-kmod-traffic.dir``.
806
807 Continuous Integration with Travis-CI
808 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
809
810 A .travis.yml file is provided to automatically build Open vSwitch with various
811 build configurations and run the testsuite using travis-ci. Builds will be
812 performed with gcc, sparse and clang with the -Werror compiler flag included,
813 therefore the build will fail if a new warning has been introduced.
814
815 The CI build is triggered via git push (regardless of the specific branch) or
816 pull request against any Open vSwitch GitHub repository that is linked to
817 travis-ci.
818
819 Instructions to setup travis-ci for your GitHub repository:
820
821 1. Go to http://travis-ci.org/ and sign in using your GitHub ID.
822 2. Go to the "Repositories" tab and enable the ovs repository. You may disable
823 builds for pushes or pull requests.
824 3. In order to avoid forks sending build failures to the upstream mailing list,
825 the notification email recipient is encrypted. If you want to receive email
826 notification for build failures, replace the the encrypted string:
827
828 1. Install the travis-ci CLI (Requires ruby >=2.0): gem install travis
829 2. In your Open vSwitch repository: travis encrypt mylist@mydomain.org
830 3. Add/replace the notifications section in .travis.yml and fill in the
831 secure string as returned by travis encrypt::
832
833 notifications:
834 email:
835 recipients:
836 - secure: "....."
837
838 .. note::
839 You may remove/omit the notifications section to fall back to default
840 notification behaviour which is to send an email directly to the author and
841 committer of the failing commit. Note that the email is only sent if the
842 author/committer have commit rights for the particular GitHub repository.
843
844 4. Pushing a commit to the repository which breaks the build or the
845 testsuite will now trigger a email sent to mylist@mydomain.org
846
847 Static Code Analysis
848 ~~~~~~~~~~~~~~~~~~~~
849
850 Static Analysis is a method of debugging Software by examining code rather than
851 actually executing it. This can be done through 'scan-build' commandline
852 utility which internally uses clang (or) gcc to compile the code and also
853 invokes a static analyzer to do the code analysis. At the end of the build, the
854 reports are aggregated in to a common folder and can later be analyzed using
855 'scan-view'.
856
857 Open vSwitch includes a Makefile target to trigger static code analysis::
858
859 $ ./boot.sh
860 $ ./configure CC=clang # clang
861 # or
862 $ ./configure CC=gcc CFLAGS="-std=gnu99" # gcc
863 $ make clang-analyze
864
865 You should invoke scan-view to view analysis results. The last line of output
866 from ``clang-analyze`` will list the command (containing results directory)
867 that you should invoke to view the results on a browser.
868
869 Bug Reporting
870 -------------
871
872 Please report problems to bugs@openvswitch.org.