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