Merge branch "partner", to simplify partner integration.
[sliver-openvswitch.git] / INSTALL
1        Installation Instructions for OpenFlow Reference Release
2
3 This document describes how to build, install, and execute the
4 reference implementation of OpenFlow.  Please send any comments to:
5
6                       <info@openflowswitch.org>
7
8 Build Methods
9 =============
10
11 There are two principal ways to build and install this distribution:
12
13         - Using "configure" and "make" in the ordinary way.  See
14           Building Conventionally below for detailed instructions.
15
16         - As a set of Debian packages.  Refer to Building Debian
17           Packages, below, for instructions.
18
19 Base Prerequisites
20 ------------------
21
22 Regardless of how it is built, OpenFlow has a common set of
23 prerequisites.  To compile the userspace programs in the OpenFlow
24 reference distribution, you will need the following software:
25
26     - A make program, e.g. GNU make
27       (http://www.gnu.org/software/make/).  BSD make should also work.
28
29     - The GNU C compiler (http://gcc.gnu.org/).  We generally test
30       with version 4.1 or 4.2.
31
32     - libssl, from OpenSSL (http://www.openssl.org/), is optional but
33       recommended.  libssl is required to establish confidentiality
34       and authenticity in the connections among OpenFlow switches and
35       controllers.  To enable, configure with --enable-ssl=yes
36
37 If you are working from a Git tree or snapshot (instead of from a
38 distribution tarball), or if you modify the OpenFlow build system, you
39 will also need the following software:
40
41     - Autoconf version 2.59 or later (http://www.gnu.org/software/autoconf).
42
43     - Automake version 1.10 or later (http://www.gnu.org/software/automake).  
44
45     - pkg-config (http://pkg-config.freedesktop.org/wiki/).  We test
46       with version 0.22.
47
48 Debian Prerequisites
49 --------------------
50
51 To build Debian packages from the OpenFlow distribution, you will need
52 to install a number of Debian packages in addition to the base
53 prerequisites listed above.  These additional prerequisites may be
54 found listed as "Build-Depends" in debian/control in the source tree.
55 To check that they are installed, first install the dpkg-dev package,
56 then run dpkg-checkbuilddeps from the top level of the OpenFlow source
57 tree.
58
59 To build Debian packages without being root, also install the
60 "fakeroot" package.
61
62 Kernel-Based Switch Prerequisites
63 ---------------------------------
64
65 The OpenFlow distribution also includes a Linux kernel module that can
66 be used to achieve higher switching performance.  To compile the
67 kernel module, you must install the following in addition to the
68 software listed in the "Base Prerequisites" section above:
69
70     - A supported Linux kernel version.  Please refer to README for a
71       list of supported versions.
72
73       The OpenFlow datapath requires bridging support (CONFIG_BRIDGE)
74       to be built as a kernel module.  (This is common in kernels
75       provided by Linux distributions.)  The bridge module must not be
76       loaded or in use.  If the bridge module is running (check with
77       "lsmod | grep bridge"), you must remove it ("rmmod bridge")
78       before starting the datapath.
79
80       In kernels prior to 2.6.9, VLAN support (CONFIG_VLAN_8021Q) must 
81       be compiled either directly or as a module.  Failure to do this
82       will cause an error on module insertion due to the 
83       "dev_change_flags" symbol being undefined.
84
85     - The correct version of GCC for the kernel that you are building
86       the module against:
87
88         * To build a kernel module for a Linux 2.6 kernel, you need
89           the same version of GCC that was used to build that kernel
90           (usually version 4.0 or later).
91
92         * To build a kernel module for a Linux 2.4 kernel, you need an
93           earlier version of GCC, typically GCC 2.95, 3.3, or 3.4.
94
95     - A kernel build directory corresponding to the Linux kernel image
96       the module is to run on.  Under Debian and Ubuntu, for example,
97       each linux-image package containing a kernel binary has a
98       corresponding linux-headers package with the required build
99       infrastructure.
100
101 Building Conventionally
102 =======================
103
104 This section explains how to build and install the OpenFlow
105 distribution in the ordinary way using "configure" and "make".
106
107 0. Check that you have installed all the prerequisites listed above in
108    the Base Prerequisites section.  If you want to compile the Linux
109    kernel module, also check that the prequisites listed under
110    Kernel-Based Switch Prequisites are installed.
111
112 1. In the top source directory, configure the package by running the
113    configure script.  You can usually invoke configure without any
114    arguments:
115
116       % ./configure
117
118    To use a specific C compiler for compiling OpenFlow user programs,
119    also specify it on the configure command line, like so:
120
121       % ./configure CC=gcc-4.2
122
123    To build the Linux kernel module, so that you can run the
124    kernel-based switch, add --with-l26 or --with-l24 option, or both,
125    to the configure script's command line.  Refer to Building the
126    Linux Kernel-Based Switch, below, for more information.
127
128    The configure script accepts a number of other options and honors
129    additional environment variables.  For a full list, invoke
130    configure with the --help option.
131
132 2. Run make in the top source directory: 
133
134       % make
135
136    The following binaries will be built:
137
138       - Switch executable: switch/switch.  This executable is built
139         only if the configure script detects a supported interface to
140         network devices.  Refer to README for a list of OSes whose
141         network device interfaces are supported.
142
143       - Secure channel executable: secchan/secchan.
144
145       - Controller executable: controller/controller.
146
147       - Datapath administration utility: utilities/dpctl.
148
149       - Runtime logging configuration utility: utilities/vlogconf.
150
151    If you passed --with-l26 to configure, "make" will also build the
152    following kernel modules:
153
154       - datapath/linux-2.6/openflow_mod.ko
155
156       - datapath/linux-2.6/hwtable_<table>_mod.ko for each <table>
157         specified on --enable-hw-tables (if any).
158
159    If you passed --with-l24 to configure, "make" will also build the
160    following kernel modules:
161
162       - datapath/linux-2.4/openflow_mod.o      
163
164       - datapath/linux-2.6/hwtable_<table>_mod.o for each <table>
165         specified on --enable-hw-tables (if any).
166
167 3. Run "make install" to install the executables and manpages into the
168    running system, by default under /usr/local.
169
170 4. If you built kernel modules, you may load them with "insmod", e.g.:
171
172       (Linux 2.6)
173       % insmod datapath/linux-2.6/openflow_mod.ko
174
175       (Linux 2.4)
176       % insmod datapath/linux-2.4/compat24_mod.o
177       % insmod datapath/linux-2.4/openflow_mod.o
178
179    After you load the openflow module, you may load one hardware switch
180    table module (if any were built) to enable support for that hardware
181    switching table.
182
183    The insmod program must be run as root.  You may need to specify a
184    full path to insmod, e.g. /sbin/insmod.  To verify that the modules
185    have been loaded, run "/sbin/lsmod" and check that openflow_mod is
186    listed.
187
188 4. Test the userspace programs, as described under Testing Userspace
189    Programs below.
190
191 5. If you built the kernel module, test the kernel-based switch, as
192    described under Testing the Kernel-Based Implementation below.
193
194 Building the Linux Kernel-Based Switch
195 --------------------------------------
196
197 To build the kernel module, follow the build process described above,
198 but pass the location of the kernel build directory as an additional
199 argument to the configure script, as described under step 1 in that
200 section.  Specify the location on --with-l26 for Linux 2.6, --with-l24
201 for Linux 2.4.  For example, to build for a running instance of Linux
202 2.6:
203
204       % ./configure --with-l26=/lib/modules/`uname -r`/build
205
206 To build for a running instance of Linux 2.4:
207
208       % ./configure --with-l24=/lib/modules/`uname -r`/build
209
210 If you wish to build OpenFlow for an architecture other than the
211 architecture used for compilation, you may specify the kernel
212 architecture string using the KARCH variable when invoking the
213 configure script. For example, to build OpenFlow for MIPS with Linux
214 2.4:
215
216       % ./configure --with-l24=/path/to/linux-2.4 KARCH=mips
217
218 If you have hardware that supports accelerated OpenFlow switching, and
219 you have obtained a hardware table module for your hardware and
220 extracted it into the OpenFlow reference distribution source tree,
221 then you may also enable building support for the hardware switching
222 table with --enable-hw-tables.  For example, if your hardware
223 switching table is in a directory named datapath/hwtable-foomatic, you
224 could compile support for it with the running Linux 2.6 kernel like
225 so:
226
227       % ./configure --with-l26=/lib/modules/`uname -r`/build \
228                     --enable-hw-tables=foomatic
229
230 For more information about hardware table modules, please read
231 README.hwtables at the root of the OpenFlow distribution tree.
232
233 Building Debian Packages
234 ========================
235
236 Follow these instructions to build Debian packages for OpenFlow.
237
238 0. Check that you have installed all the prerequisites listed above in
239    the Base Prerequisites and Debian Prerequisites sections above.
240
241 1. In the top source directory, run the following command, as root:
242
243       % dpkg-buildpackage
244
245    Alternatively, if you installed the "fakeroot" package, you may run
246    dpkg-buildpackage as an ordinary user with the following syntax:
247
248       % dpkg-buildpackage -rfakeroot
249
250    The following packages will be built in the directory above the
251    source tree:
252
253       - openflow-controller: The OpenFlow controller.  Depends on
254         openflow-pki (see below).
255
256       - openflow-switch: Install this package on a machine that acts
257         as an OpenFlow userspace or kernel switch.
258
259       - openflow-datapath-source: Source code for OpenFlow's Linux
260         kernel module.
261
262       - openflow-pki: Public-key infrastructure for OpenFlow.  Install
263         this package on a machine that acts as an OpenFlow PKI server
264         (see "Establishing a Public Key Infrastructure" below).
265
266       - openflow-common: Files and utilities required by more than one
267         of the above packages.
268
269 2. To set up an OpenFlow controller, install the openflow-controller
270    package and its dependencies.  You may configure it by editing
271    /etc/default/openflow-controller, e.g. to enable non-SSL
272    connections, which are disabled by default.  If you change the
273    default settings, you will need to restart the controller by
274    running:
275
276       % /etc/init.d/openflow-controller restart
277
278 3. To set up an OpenFlow switch, install the openflow-switch package
279    and its dependencies.  If it is to be a kernel-based switch, also
280    install openflow-datapath-source, then follow the instructions in
281    /usr/share/doc/openflow-datapath-source/README.Debian to build and
282    install the kernel module.
283
284    You may configure the switch one of the following ways:
285
286       - Completely by hand, as described under the Testing section
287         below.
288
289         For the userspace switch, this is the only supported form of
290         configuration.
291
292       - By editing /etc/default/openflow-switch.  You must at least
293         configure some network devices, by uncommenting NETDEVS and
294         adding the appropriate devices to the list, e.g. NETDEVS="eth0
295         eth1".
296
297         After you edit this file, you will need to start the switch by
298         running:
299
300            % /etc/init.d/openflow-switch restart
301
302         This form of configuration is not supported for the userspace
303         switch.
304
305       - By running the ofp-switch-setup program.  This interactive
306         program will walk you through all the steps of configuring an
307         OpenFlow switch, including configuration of SSL certificates.
308         Run it without arguments, as root:
309
310            % ofp-switch-setup
311
312         This form of configuration is not supported for the userspace
313         switch.
314
315 Testing
316 =======
317
318 Testing Userspace Programs
319 --------------------------
320
321 0. The commands below must run as root, so log in as root, or use a
322    program such as "su" to become root temporarily.
323
324 1. Start the OpenFlow controller running in the background, by running
325    the "controller" program with a command like the following:
326
327       # controller ptcp: &
328
329    This command causes the controller to bind to port 975 (the
330    default) awaiting connections from OpenFlow switches.  See
331    controller(8) for details.
332    
333 2. On the same machine, use the "switch" program to start an OpenFlow
334    switch, specifying network devices to use as switch ports on the -i
335    option as a comma-separated list, like so:
336
337       # switch tcp:127.0.0.1 -i eth1,eth2
338    
339    The network devices that you specify should not have configured IP
340    addresses.
341
342 3. The controller causes each switch that connects to it to act like a
343    learning Ethernet switch.  Thus, devices plugged into the specified
344    network ports should now be able to send packets to each other, as
345    if they were plugged into ports on a conventional Ethernet switch.
346
347 Troubleshooting: if the commands above do not work, try using the -v
348 or --verbose option on the controller or switch commands, which will
349 cause a large amount of debug output from each program.
350
351 Remote switches: These instructions assume that the controller and the
352 switch are running on the same machine.  This is an easy configuration
353 for testing, but a more conventional setup would run a controller on
354 one machine and one or more switches on different machines.  To do so,
355 simply specify the IP address of the controller as the first argument
356 to the switch program (in place of 127.0.0.1). (Note: The userspace
357 switch must be connected to the controller over a "control network"
358 that is physically separate from the one that the switch and
359 controller are controlling.  The kernel-based switch does not have
360 this limitation.)
361
362 Testing the Kernel-Based Implementation
363 ---------------------------------------
364
365 The OpenFlow kernel module must be loaded, as described in the
366 previous section, before it may be tested.
367
368 0. The commands below must run as root, so log in as root, or use a
369    program such as "su" to become root temporarily.
370
371 1. Create a datapath instance.  The command below creates a datapath with
372    ID 0 (see dpctl(8) for more detailed usage information).
373
374       # dpctl adddp 0
375    
376    In principle, openflow_mod supports multiple datapaths within the
377    same host, but this is rarely useful in practice.
378
379    If you built a support module for hardware accelerated OpenFlow
380    switching and you want to use it, you must load it before creating
381    the datapath with "dpctl adddp".
382
383 2. Use dpctl to attach the datapath to physical interfaces on the
384    machine.  Say, for example, you want to create a trivial 2-port
385    switch using interfaces eth1 and eth2, you would issue the following
386    commands:
387
388       # dpctl addif 0 eth1
389       # dpctl addif 0 eth2
390
391    You can verify that the interfaces were successfully added by asking
392    dpctl to print the current status of datapath 0:
393
394       # dpctl show 0
395
396 3. (Optional) You can manually add flows to the datapath to test using
397    dpctl add-flows and view them using dpctl dump-flows.  See dpctl(8)
398    for more details.
399
400 4. The simplest way to test the datapath is to run the provided sample
401    controller on the host machine to manage the datapath directly using
402    netlink:
403
404       # controller -v nl:0
405
406    Once the controller is running, the datapath should operate like a
407    learning Ethernet switch.  You may monitor the flows in the datapath
408    flow table using "dpctl dump-flows" command.
409
410 The preceding instructions assume that the controller and the switch
411 are running on the same machine.  This is an easy configuration for
412 testing, but a more conventional setup would run a controller on one
413 machine and one or more switches on different machines.  Use the
414 following instructions to set up remote switches:
415
416 1. Start the datapath and attach it to two or more physical ports as
417    described in the previous section.
418
419 2. Run the controller in passive TCP mode on the host which will act as
420    the controller. In the example below, the controller will bind to
421    port 975 (the default) awaiting connections from secure channels. 
422
423       # controller -v ptcp:
424
425    (See controller(8) for more details)
426    
427    Make sure the machine hosting the controller is reachable by the switch.  
428
429 3. Arrange so that the switch can reach the controller over the
430    network.  There are two ways to do this:
431
432       - Use a "control network" that is completely separate from the
433         "data network" to be controlled ("out-of-band control").  To
434         do so, configure a network device (one that has not been added
435         to the datapath with "dpctl addif") to access the control
436         network in the usual way.
437
438       - Use the same network for control and for data ("in-band
439         control").  For this purpose, each datapath nl:K has a
440         corresponding virtual network device named ofK.
441
442         When in-band control is used, the location of the controller
443         may be configured manually or discovered automatically:
444
445             * Manual configuration: Start by bringing up of0 before
446               you start the secure channel:
447
448                  # ifconfig of0 up
449
450               Before the secure channel starts up, the of0 device
451               cannot send or receive any packets, so the next step
452               depends on whether connectivity is required to configure
453               the device's IP address:
454
455                  . If the switch has a static IP address, you may
456                    configure its IP address now, e.g.:
457
458                       # ifconfig of0 192.168.1.1
459
460                  . If the switch does not have a static IP address,
461                    e.g. its IP address is obtained dynamically via
462                    DHCP, then proceed to step 4.  The DHCP client will
463                    not be able to contact the DHCP server until the
464                    secure channel has started up.
465
466             * Controller discovery: No special setup is required at
467               the switch, but you must specially configure a DHCP
468               server to give out the switch's IP address and to tell
469               it the location of the controller.  See secchan(8) for
470               details.
471
472 4. Run secchan on the datapath host to start the secure channel
473    connecting the datapath to a remote controller.  (See secchan(8)
474    for usage details).  The details depend on how you configured the
475    network in step 3:
476
477       - If you are using in-band control and controller discovery,
478         invoke secchan something like this:
479
480            # secchan -v nl:0
481
482         The secure channel should connect to the controller after it
483         obtains its own IP address and the controller's location via
484         DHCP.  This can take a few seconds.  Switch setup is now
485         complete.
486
487       - Otherwise, the secure channel should be configured to connect
488         to the controller's IP address on the port configured in step
489         2.  If the controller is running on host 192.168.1.2 port 975
490         (the default port) and the datapath ID is 0, the secchan
491         invocation would look like:
492
493            # secchan -v nl:0 tcp:192.168.1.2
494
495         If you are using out-of-band control, or if you are using
496         in-band control and the switch has a static IP address, the
497         secure channel should quickly connect to the controller.
498         Setup is now complete.  Otherwise, proceed to step 5.
499
500 5. If you are using the same network for control and data, and the
501    switch obtains its IP address dynamically, then you may now obtain
502    the switch's IP address, e.g. by invoking a DHCP client.  The
503    secure channel will only be able to connect to the controller after
504    an IP address has been obtained.
505
506 Configuration
507 =============
508
509 Secure operation over SSL
510 -------------------------
511
512 The instructions above set up OpenFlow for operation over a plaintext
513 TCP connection.  Production use of OpenFlow should use SSL[*] to
514 ensure confidentiality and authenticity of traffic among switches and
515 controllers.  The source must be configured with --enable-ssl=yes to
516 build with SSL support.
517
518 To use SSL with OpenFlow, you must set up a public-key infrastructure
519 (PKI) including a pair of certificate authorities (CAs), one for
520 controllers and one for switches.  If you have an established PKI,
521 OpenFlow can use it directly.  Otherwise, refer to "Establishing a
522 Public Key Infrastructure" below.
523
524 To configure the controller to listen for SSL connections on port 976
525 (the default), invoke it as follows:
526
527       # controller -v pssl: --private-key=PRIVKEY --certificate=CERT \
528             --ca-cert=CACERT
529
530 where PRIVKEY is a file containing the controller's private key, CERT
531 is a file containing the controller CA's certificate for the
532 controller's public key, and CACERT is a file containing the root
533 certificate for the switch CA.  If, for example, your PKI was created
534 with the instructions below, then the invocation would look like:
535
536       # controller -v pssl: --private-key=ctl-privkey.pem \
537             --certificate=ctl-cert.pem --ca-cert=pki/switchca/cacert.pem
538
539 To configure a switch to connect to a controller running on port 976
540 (the default) on host 192.168.1.2 over SSL, invoke it as follows:
541
542       # switch -v ssl:192.168.1.2 -i INTERFACES --private-key=PRIVKEY \
543             --certificate=CERT --ca-cert=CACERT
544
545 where INTERFACES is the command-separated list of network device
546 interfaces, PRIVKEY is a file containing the switch's private key,
547 CERT is a file containing the switch CA's certificate for the switch's
548 public key, and CACERT is a file containing the root certificate for
549 the controller CA.  If, for example, your PKI was created with the
550 instructions below, then the invocation would look like:
551
552       # secchan -v -i INTERFACES ssl:192.168.1.2 --private-key=sc-privkey.pem \
553             --certificate=sc-cert.pem --ca-cert=pki/controllerca/cacert.pem
554
555 [*] To be specific, OpenFlow uses TLS version 1.0 or later (TLSv1), as
556     specified by RFC 2246, which is very similar to SSL version 3.0.
557     TLSv1 was released in January 1999, so all current software and
558     hardware should implement it.
559
560 Establishing a Public Key Infrastructure
561 ----------------------------------------
562
563 If you do not have a PKI, the ofp-pki script included with OpenFlow
564 can help.  To create an initial PKI structure, invoke it as:
565       % ofp-pki init
566 which will create and populate a new PKI directory.  The default
567 location for the PKi directory depends on how the OpenFlow tree was
568 configured (to see the configured default, look for the --dir option
569 description in the output of "ofp-pki --help").
570
571 The pki directory contains two important subdirectories.  The
572 controllerca subdirectory contains controller certificate authority
573 related files, including the following:
574
575     - cacert.pem: Root certificate for the controller certificate
576       authority.  This file must be provided to the switch or secchan
577       program with the --ca-cert option to enable it to authenticate
578       valid controllers.
579
580     - private/cakey.pem: Private signing key for the controller
581       certificate authority.  This file must be kept secret.  There is
582       no need for switches or controllers to have a copy of it.
583
584 The switchca subdirectory contains switch certificate authority
585 related files, analogous to those in the controllerca subdirectory:
586
587     - cacert.pem: Root certificate for the switch certificate
588       authority.  This file must be provided to the controller program
589       with the --ca-cert option to enable it to authenticate valid
590       switches.
591
592     - private/cakey.pem: Private signing key for the switch
593       certificate authority.  This file must be kept secret.  There is
594       no need for switches or controllers to have a copy of it.
595
596 After you create the initial structure, you can create keys and
597 certificates for switches and controllers with ofp-pki.  To create a
598 controller private key and certificate in files named ctl-privkey.pem
599 and ctl-cert.pem, for example, you could run:
600       % ofp-pki req+sign ctl controller
601 ctl-privkey.pem and ctl-cert.pem would need to be copied to the
602 controller for its use at runtime (they could then be deleted from
603 their original locations).  The --private-key and --certificate
604 options of controller, respectively, would point to these files.
605
606 Analogously, to create a switch private key and certificate in files
607 named sc-privkey.pem and sc-cert.pem, for example, you could run: 
608       % ofp-pki req+sign sc switch
609 sc-privkey.pem and sc-cert.pem would need to be copied to the switch
610 for its use at runtime (they could then be deleted from their original
611 locations).  The --private-key and --certificate options,
612 respectively, of switch and secchan would point to these files.
613
614 Bug Reporting
615 -------------
616
617 Please report problems to: 
618 info@openflowswitch.org