Use kernel build system for linux-2.4.
[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 userspace
128 switch must be connected to the controller over a "control network"
129 that is physically separate from the one that the switch and
130 controller are controlling.  The kernel-based switch does not have
131 this limitation.)
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 wish to build OpenFlow for an architecture other than the architecture
285 used for compilation, you may specify the kernel architecture string using the
286 KARCH variable when invoking the configure script. For example, to build
287 OpenFlow for MIPS with Linux 2.4:
288
289       % ./configure --with-l24=/path/to/linux-2.4 KARCH=mips
290
291 If you have hardware that supports accelerated OpenFlow switching, and
292 you have obtained a hardware table module for your hardware and
293 extracted it into the OpenFlow reference distribution source tree,
294 then you may also enable building support for the hardware switching
295 table with --enable-hw-tables.  For example, if your hardware
296 switching table is in a directory named datapath/hwtable-foomatic, you
297 could compile support for it with the running Linux 2.6 kernel like
298 so:
299
300       % ./configure --with-l26=/lib/modules/`uname -r`/build \
301                     --enable-hw-tables=foomatic
302
303 For more information about hardware table modules, please read
304 README.hwtables at the root of the OpenFlow distribution tree.
305
306 In addition to the binaries listed under step 2 in "Building Userspace
307 Programs" above, "make" will build the following kernel modules:
308
309       datapath/linux-2.6/openflow_mod.ko (if --with-l26 was specified)
310       datapath/linux-2.4/openflow_mod.o  (if --with-l24 was specified)
311
312 "make" will also build a kernel module for each hardware switch table
313 enabled with --enable-hw-tables.
314
315 Once you have built the kernel modules, activating them requires only
316 running "insmod", e.g.:
317
318       (Linux 2.6)
319       % insmod datapath/linux-2.6/openflow_mod.ko
320
321       (Linux 2.4)
322       % insmod datapath/linux-2.4/compat24_mod.o
323       % insmod datapath/linux-2.4/openflow_mod.o
324
325 After you load the openflow module, you may load one hardware switch
326 table module (if any were built) to enable support for that hardware
327 switching table.
328
329 The insmod program must be run as root.  You may need to specify a
330 full path to insmod, which is usually in the /sbin directory.  To
331 verify that the modules have been loaded, run "lsmod" (also in /sbin)
332 and check that openflow_mod appears in the result.
333
334 Testing the Kernel-Based Implementation
335 ---------------------------------------
336
337 The OpenFlow kernel module must be loaded, as described in the
338 previous section, before it may be tested.
339
340 0. The commands below must run as root, so log in as root, or use a
341    program such as "su" to become root temporarily.
342
343 1. Create a datapath instance.  The command below creates a datapath with
344    ID 0 (see dpctl(8) for more detailed usage information).
345
346       # dpctl adddp 0
347    
348    In principle, openflow_mod supports multiple datapaths within the
349    same host, but this is rarely useful in practice.
350
351    If you built a support module for hardware accelerated OpenFlow
352    switching and you want to use it, you must load it before creating
353    the datapath with "dpctl adddp".
354
355 2. Use dpctl to attach the datapath to physical interfaces on the
356    machine.  Say, for example, you want to create a trivial 2-port
357    switch using interfaces eth1 and eth2, you would issue the following
358    commands:
359
360       # dpctl addif 0 eth1
361       # dpctl addif 0 eth2
362
363    You can verify that the interfaces were successfully added by asking
364    dpctl to print the current status of datapath 0:
365
366       # dpctl show 0
367
368 3. (Optional) You can manually add flows to the datapath to test using
369    dpctl add-flows and view them using dpctl dump-flows.  See dpctl(8)
370    for more details.
371
372 4. The simplest way to test the datapath is to run the provided sample
373    controller on the host machine to manage the datapath directly using
374    netlink:
375
376       # controller -v nl:0
377
378    Once the controller is running, the datapath should operate like a
379    learning Ethernet switch.  You may monitor the flows in the datapath
380    flow table using "dpctl dump-flows" command.
381
382 The preceding instructions assume that the controller and the switch
383 are running on the same machine.  This is an easy configuration for
384 testing, but a more conventional setup would run a controller on one
385 machine and one or more switches on different machines.  Use the
386 following instructions to set up remote switches:
387
388 1. Start the datapath and attach it to two or more physical ports as
389    described in the previous section.
390
391 2. Run the controller in passive TCP mode on the host which will act as
392    the controller. In the example below, the controller will bind to
393    port 975 (the default) awaiting connections from secure channels. 
394
395       # controller -v ptcp:
396
397    (See controller(8) for more details)
398    
399    Make sure the machine hosting the controller is reachable by the switch.  
400
401 3. Arrange so that the switch can reach the controller over the
402    network.  There are two ways to do this:
403
404       - Use a "control network" that is completely separate from the
405         "data network" to be controlled.  To do so, configure a
406         network device (one that has not been added to the datapath
407         with "dpctl addif") to access the control network in the usual
408         way.
409
410       - Use the same network for control and for data.  For this
411         purpose, each datapath nl:K has a corresponding virtual
412         network device named ofK.  Start by bringing up of0 before you
413         start the secure channel:
414
415            # ifconfig of0 up
416
417         Before the secure channel starts up, the of0 device cannot
418         send or receive any packets, so the next step depends on
419         whether connectivity is required to configure the device's IP
420         address:
421
422            . If the switch has a static IP address, you may configure
423              its IP address now, e.g.:
424
425                 # ifconfig of0 192.168.1.1
426
427            . If the switch does not have a static IP address, e.g. its
428              IP address is obtained dynamically via DHCP, then proceed
429              to step 4.  The DHCP client will not be able to contact
430              the DHCP server until the secure channel has started up.
431
432 4. Run secchan on the datapath host to start the secure channel
433    connecting the datapath to a remote controller.  (See secchan(8)
434    for usage details).  The channel should be configured to connect to
435    the controller's IP address on the port configured in step 2.
436
437    If the controller is running on host 192.168.1.2 port 975 (the
438    default port) and the datapath ID is 0, the secchan invocation
439    would look like:
440
441       # secchan -v nl:0 tcp:192.168.1.2
442
443    If you are using separate control and data networks, or if the
444    networks are combined and the switch has a static IP address, the
445    secure channel should quickly connect to the controller.  Setup is
446    now complete.  Otherwise, proceed to step 5.
447
448 5. If you are using the same network for control and data, and the
449    switch obtains its IP address dynamically, then you may now obtain
450    the switch's IP address, e.g. by invoking a DHCP client.  The
451    secure channel will only be able to connect to the controller after
452    an IP address has been obtained.
453
454 Bug Reporting
455 -------------
456
457 Please report problems to: 
458 info@openflowswitch.org