Add-on hardware tables initial implementation.
[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 Prerequisites
9 -------------
10
11 To compile the userspace programs in the OpenFlow reference
12 distribution, you will need the following software:
13
14     - A make program, e.g. GNU make
15       (http://www.gnu.org/software/make/).  BSD make should also work.
16
17     - The GNU C compiler (http://gcc.gnu.org/).  We generally test
18       with version 4.1 or 4.2.
19
20     - libssl, from OpenSSL (http://www.openssl.org/), is optional but
21       recommended.  libssl is required to establish confidentiality
22       and authenticity in the connections among OpenFlow switches and
23       controllers.  To enable, compile with --enable-ssl=yes
24
25 If you are working from a Git tree or snapshot (instead of from a
26 distribution tarball), or if you modify the OpenFlow build system, you
27 will also need the following software:
28
29     - Autoconf version 2.59 or later (http://www.gnu.org/software/autoconf).
30
31     - Automake version 1.10 or later (http://www.gnu.org/software/automake).  
32
33     - pkg-config (http://pkg-config.freedesktop.org/wiki/).  We test
34       with version 0.22.
35
36 The optional Linux module has additional prerequisites, described
37 later in the section "Building and Testing the Linux Kernel-Based
38 Switch".
39
40 Building Userspace Programs
41 ---------------------------
42
43 The OpenFlow distribution includes two implementations of the switch:
44 one entirely in userspace, for portability and ease of installation,
45 and another with a Linux kernel module component that is more
46 difficult to install but should also yield better performance.  These
47 instructions describe how to build the userspace components of the
48 OpenFlow distribution.  Refer to "Building and Testing the Linux
49 Kernel-Based Switch", below, for additional instructions on how to
50 build the optional Linux kernel module.
51
52 1. In the top source directory, configure the package by running the
53    configure script.  You can usually invoke configure without any
54    arguments:
55
56       % ./configure
57
58    To use a specific C compiler for compiling OpenFlow user programs,
59    also specify it on the configure command line, like so:
60
61       % ./configure CC=gcc-4.2
62
63    The configure script accepts a number of other options and honors
64    additional environment variables.  For a full list, invoke
65    configure with the --help option.
66
67 2. Run make in the top source directory: 
68
69       % make
70
71    The following binaries will be built:
72
73       - Switch executable: switch/switch.  This executable is built
74         only if the configure script detects a supported interface to
75         network devices.  Refer to README for a list of OSes whose
76         network device interfaces are supported.
77
78       - Secure channel executable: secchan/secchan.
79
80       - Controller executable: controller/controller.
81
82       - Datapath administration utility: utilities/dpctl.
83
84       - Runtime logging configuration utility: utilities/vlogconf.
85
86 3. (Optional) Run "make install" to install the executables and
87    manpages into the running system, by default under /usr/local.
88
89 Testing Userspace Programs
90 --------------------------
91
92 0. The commands below must run as root, so log in as root, or use a
93    program such as "su" to become root temporarily.
94
95 1. Start the OpenFlow controller running in the background, by running
96    the "controller" program with a command like the following:
97
98       # controller ptcp: &
99
100    This command causes the controller to bind to port 975 (the
101    default) awaiting connections from OpenFlow switches.  See
102    controller(8) for details.
103    
104 2. On the same machine, use the "switch" program to start an OpenFlow
105    switch, specifying network devices to use as switch ports on the -i
106    option as a comma-separated list, like so:
107
108       # switch tcp:127.0.0.1 -i eth1,eth2
109    
110    The network devices that you specify should not have configured IP
111    addresses.
112
113 3. The controller causes each switch that connects to it to act like a
114    learning Ethernet switch.  Thus, devices plugged into the specified
115    network ports should now be able to send packets to each other, as
116    if they were plugged into ports on a conventional Ethernet switch.
117
118 Troubleshooting: if the commands above do not work, try using the -v
119 or --verbose option on the controller or switch commands, which will
120 cause a large amount of debug output from each program.
121
122 Remote switches: These instructions assume that the controller and the
123 switch are running on the same machine.  This is an easy configuration
124 for testing, but a more conventional setup would run a controller on
125 one machine and one or more switches on different machines.  To do so,
126 simply specify the IP address of the controller as the first argument
127 to the switch program (in place of 127.0.0.1).  (Note: The current
128 version of the switch and controller requires that they be connected
129 through a "control network" that is physically separate from the one
130 that they are controlling.  Future releases will support in-band
131 control communication.)
132
133 Secure operation over SSL
134 -------------------------
135
136 The instructions above set up OpenFlow for operation over a plaintext
137 TCP connection.  Production use of OpenFlow should use SSL[*] to
138 ensure confidentiality and authenticity of traffic among switches and
139 controllers.  The source must be configured with --enable-ssl=yes to
140 build with ssl support.
141
142 To use SSL with OpenFlow, you must set up a public-key infrastructure
143 (PKI) including a pair of certificate authorities (CAs), one for
144 controllers and one for switches.  If you have an established PKI,
145 OpenFlow can use it directly.  Otherwise, refer to "Establishing a
146 Public Key Infrastructure" below.
147
148 To configure the controller to listen for SSL connections on port 976
149 (the default), invoke it as follows:
150
151       # controller -v pssl: --private-key=PRIVKEY --certificate=CERT \
152             --ca-cert=CACERT
153
154 where PRIVKEY is a file containing the controller's private key, CERT
155 is a file containing the controller CA's certificate for the
156 controller's public key, and CACERT is a file containing the root
157 certificate for the switch CA.  If, for example, your PKI was created
158 with the instructions below, then the invocation would look like:
159
160       # controller -v pssl: --private-key=ctl-privkey.pem \
161             --certificate=ctl-cert.pem --ca-cert=pki/switchca/cacert.pem
162
163 To configure a switch to connect to a controller running on port 976
164 (the default) on host 192.168.1.2 over SSL, invoke it as follows:
165
166       # switch -v ssl:192.168.1.2 -i INTERFACES --private-key=PRIVKEY \
167             --certificate=CERT --ca-cert=CACERT
168
169 where INTERFACES is the command-separated list of network device
170 interfaces, PRIVKEY is a file containing the switch's private key,
171 CERT is a file containing the switch CA's certificate for the switch's
172 public key, and CACERT is a file containing the root certificate for
173 the controller CA.  If, for example, your PKI was created with the
174 instructions below, then the invocation would look like:
175
176       # secchan -v -i INTERFACES ssl:192.168.1.2 --private-key=sc-privkey.pem \
177             --certificate=sc-cert.pem --ca-cert=pki/controllerca/cacert.pem
178
179 [*] To be specific, OpenFlow uses TLS version 1.0 or later (TLSv1), as
180     specified by RFC 2246, which is very similar to SSL version 3.0.
181     TLSv1 was released in January 1999, so all current software and
182     hardware should implement it.
183
184 Establishing a Public Key Infrastructure
185 ----------------------------------------
186
187 If you do not have a PKI, the ofp-pki script included with OpenFlow
188 can help.  To create an initial PKI structure, invoke it as:
189       % ofp-pki new-pki
190 which will create and populate a new directory named "pki" under the
191 current directory.
192
193 The pki directory contains two important subdirectories.  The
194 controllerca subdirectory contains controller certificate authority
195 related files, including the following:
196
197     - cacert.pem: Root certificate for the controller certificate
198       authority.  This file must be provided to the switch or secchan
199       program with the --ca-cert option to enable it to authenticate
200       valid controllers.
201
202     - private/cakey.pem: Private signing key for the controller
203       certificate authority.  This file must be kept secret.  There is
204       no need for switches or controllers to have a copy of it.
205
206 The switchca subdirectory contains switch certificate authority
207 related files, analogous to those in the controllerca subdirectory:
208
209     - cacert.pem: Root certificate for the switch certificate
210       authority.  This file must be provided to the controller program
211       with the --ca-cert option to enable it to authenticate valid
212       switches.
213
214     - private/cakey.pem: Private signing key for the switch
215       certificate authority.  This file must be kept secret.  There is
216       no need for switches or controllers to have a copy of it.
217
218 After you create the initial structure, you can create keys and
219 certificates for switches and controllers with ofp-pki.  To create a
220 controller private key and certificate in files named ctl-privkey.pem
221 and ctl-cert.pem, for example, you could run:
222       % ofp-pki req+sign ctl controller
223 ctl-privkey.pem and ctl-cert.pem would need to be copied to the
224 controller for its use at runtime (they could then be deleted from
225 their original locations).  The --private-key and --certificate
226 options of controller, respectively, would point to these files.
227
228 Analogously, to create a switch private key and certificate in files
229 named sc-privkey.pem and sc-cert.pem, for example, you could run: 
230       % ofp-pki req+sign sc switch
231 sc-privkey.pem and sc-cert.pem would need to be copied to the switch
232 for its use at runtime (they could then be deleted from their original
233 locations).  The --private-key and --certificate options,
234 respectively, of switch and secchan would point to these files.
235
236 Building and Testing the Linux Kernel-Based Switch
237 --------------------------------------------------
238
239 The OpenFlow distribution also includes a Linux kernel module that can
240 be used to achieve higher switching performance at a cost in
241 portability and ease of installation.  Compiling the kernel module has
242 the following prerequisites in addition to those listed in the
243 "Prerequisites" section above:
244
245     - A supported Linux kernel version.  Please refer to README for a
246       list of supported versions.
247
248       The OpenFlow datapath requires bridging support (CONFIG_BRIDGE)
249       to be built as a kernel module.  (This is common in kernels
250       provided by Linux distributions.)  The bridge module must not be
251       loaded or in use.  If the bridge module is running (check with
252       "lsmod | grep bridge"), you must remove it ("rmmod bridge")
253       before starting the datapath.
254
255     - The correct version of GCC for the kernel that you are building
256       the module against:
257
258         * To build a kernel module for a Linux 2.6 kernel, you need
259           the same version of GCC that was used to build that kernel
260           (usually version 4.0 or later).
261
262         * To build a kernel module for a Linux 2.4 kernel, you need an
263           earlier version of GCC, typically GCC 2.95, 3.3, or 3.4.
264
265     - A kernel build directory corresponding to the Linux kernel image
266       the module is to run on.  Under Debian and Ubuntu, for example,
267       each linux-image package containing a kernel binary has a
268       corresponding linux-headers package with the required build
269       infrastructure.
270
271 To build the kernel module, follow the build process described under
272 "Building Userspace Programs" above, but pass the location of the
273 kernel build directory as an additional argument to the configure
274 script, as described under step 1 in that section.  Specify the
275 location on --with-l26 for Linux 2.6, --with-l24 for Linux 2.4.  For
276 example, to build for a running instance of Linux 2.6:
277
278       % ./configure --with-l26=/lib/modules/`uname -r`/build
279
280 To build for a running instance of Linux 2.4:
281
282       % ./configure --with-l24=/lib/modules/`uname -r`/build
283
284 If you have hardware that supports accelerated OpenFlow switching, and
285 you have obtained a hardware table module for your hardware and
286 extracted it into the OpenFlow reference distribution source tree,
287 then you may also enable building support for the hardware switching
288 table with --enable-hw-tables.  For example, if your hardware
289 switching table is in a directory named datapath/hwtable-foomatic, you
290 could compile support for it with the running Linux 2.6 kernel like
291 so:
292
293       % ./configure --with-l26=/lib/modules/`uname -r`/build \
294                     --enable-hw-tables=foomatic
295
296 For more information about hardware table modules, please read
297 README.hwtables at the root of the OpenFlow distribution tree.
298
299 In addition to the binaries listed under step 2 in "Building Userspace
300 Programs" above, "make" will build the following kernel modules:
301
302       datapath/linux-2.6/openflow_mod.ko (if --with-l26 was specified)
303       datapath/linux-2.4/openflow_mod.o  (if --with-l24 was specified)
304
305 "make" will also build a kernel module for each hardware switch table
306 enabled with --enable-hw-tables.
307
308 Once you have built the kernel modules, activating them requires only
309 running "insmod", e.g.:
310
311       (Linux 2.6)
312       % insmod datapath/linux-2.6/openflow_mod.ko
313
314       (Linux 2.4)
315       % insmod datapath/linux-2.4/compat24_mod.o
316       % insmod datapath/linux-2.4/openflow_mod.o
317
318 After you load the openflow module, you may load one hardware switch
319 table module (if any were built) to enable support for that hardware
320 switching table.
321
322 The insmod program must be run as root.  You may need to specify a
323 full path to insmod, which is usually in the /sbin directory.  To
324 verify that the modules have been loaded, run "lsmod" (also in /sbin)
325 and check that openflow_mod appears in the result.
326
327 Testing the Kernel-Based Implementation
328 ---------------------------------------
329
330 The OpenFlow kernel module must be loaded, as described in the
331 previous section, before it may be tested.
332
333 0. The commands below must run as root, so log in as root, or use a
334    program such as "su" to become root temporarily.
335
336 1. Create a datapath instance.  The command below creates a datapath with
337    ID 0 (see dpctl(8) for more detailed usage information).
338
339       # dpctl adddp 0
340    
341    In principle, openflow_mod supports multiple datapaths within the
342    same host, but this is rarely useful in practice.
343
344    If you built a support module for hardware accelerated OpenFlow
345    switching and you want to use it, you must load it before creating
346    the datapath with "dpctl adddp".
347
348 2. Use dpctl to attach the datapath to physical interfaces on the
349    machine.  Say, for example, you want to create a trivial 2-port
350    switch using interfaces eth1 and eth2, you would issue the following
351    commands:
352
353       # dpctl addif 0 eth1
354       # dpctl addif 0 eth2
355
356    You can verify that the interfaces were successfully added by asking
357    dpctl to print the current status of datapath 0:
358
359       # dpctl show 0
360
361 3. (Optional) You can manually add flows to the datapath to test using
362    dpctl add-flows and view them using dpctl dump-flows.  See dpctl(8)
363    for more details.
364
365 4. The simplest way to test the datapath is to run the provided sample
366    controller on the host machine to manage the datapath directly using
367    netlink:
368
369       # controller -v nl:0
370
371    Once the controller is running, the datapath should operate like a
372    learning Ethernet switch.  You may monitor the flows in the datapath
373    flow table using "dpctl dump-flows" command.
374
375 The preceding instructions assume that the controller and the switch
376 are running on the same machine.  This is an easy configuration for
377 testing, but a more conventional setup would run a controller on one
378 machine and one or more switches on different machines.  Use the
379 following instructions to set up remote switches:
380
381 1. Start the datapath and attach it to two or more physical ports as
382    described in the previous section.
383
384    Note: The current version of the switch and controller requires
385    that they be connected through a "control network" that is
386    physically separate from the one that they are controlling.  Future
387    releases will support in-band control communication.
388
389 2. Run the controller in passive tcp mode on the host which will act as
390    the controller. In the example below, the controller will bind to
391    port 975 (the default) awaiting connections from secure channels. 
392
393       # controller -v ptcp:
394
395    (See controller(8) for more details)
396    
397    Make sure the machine hosting the controller is reachable by the switch.  
398
399 3. Run secchan on the datapath host to start the secure channel
400    connecting the datapath to a remote controller.  (See secchan(8)
401    for usage details).  The channel should be configured to connect to
402    the controller's IP address on the port configured in step 2.
403
404    If the controller is running on host 192.168.1.2 port 975 (the
405    default port) and the datapath ID is 0, the secchan invocation
406    would look like:
407
408       # secchan -v nl:0 tcp:192.168.1.2
409
410 Bug Reporting
411 -------------
412
413 Please report problems to: 
414 info@openflowswitch.org