For SNAT, don't store the pre-fragment L2 header before actions are applied.
[sliver-openvswitch.git] / utilities / dpctl.8.in
1 .TH dpctl 8 "May 2008" "OpenFlow" "OpenFlow Manual"
2
3 .SH NAME
4 dpctl \- administer OpenFlow datapaths
5
6 .SH SYNOPSIS
7 .B dpctl
8 [\fIoptions\fR] \fIcommand \fR[\fIswitch\fR] [\fIargs\fR&...]
9
10 .SH DESCRIPTION
11 The
12 .B dpctl
13 program is a command line tool for monitoring and administering OpenFlow 
14 datapaths.  It is able to show the current state of a datapath,
15 including features, configuration, and tables entries.  When using the
16 OpenFlow kernel module,
17 .B dpctl
18 is used to add, delete, modify, and monitor datapaths.  
19
20 Most \fBdpctl\fR commands take an argument that specifies the
21 method for connecting to an OpenFlow switch.  The following connection
22 methods are supported:
23
24 .TP
25 \fBnl:\fIdp_idx\fR
26 The local Netlink datapath numbered \fIdp_idx\fR.  This form requires
27 that the local host has the OpenFlow kernel module for Linux loaded.
28
29 .TP
30 \fBssl:\fIhost\fR[\fB:\fIport\fR]
31 The specified SSL \fIport\fR (default: 6633) on the given remote
32 \fIhost\fR.  The \fB--private-key\fR, \fB--certificate\fR, and
33 \fB--ca-cert\fR options are mandatory when this form is used.
34
35 .TP
36 \fBtcp:\fIhost\fR[\fB:\fIport\fR]
37 The specified TCP \fIport\fR (default: 6633) on the given remote
38 \fIhost\fR.
39
40 .TP
41 \fBunix:\fIfile\fR
42 The Unix domain server socket named \fIfile\fR.
43
44 .SH COMMANDS
45
46 With the \fBdpctl\fR program, datapaths running in the kernel can be 
47 created, deleted, and modified.  A single machine may 
48 host up to 32 datapaths (numbered 0 to 31).  In most situations, 
49 a machine hosts only one datapath.
50
51 A newly created datapath is not associated with any of the
52 host's network devices thus does not process any incoming
53 traffic.  To intercept and process traffic on a given network device, the
54 network device must be explicitly added to a datapath through the
55 \fBaddif\fR command.
56
57 The following commands manage local datapaths.
58
59 .TP
60 \fBadddp nl:\fIdp_idx\fR
61 Creates datapath numbered \fIdp_idx\fR on the local host.  This will 
62 fail if \fIdp_idx\fR is not in the range 0 to 31, or if the datapath 
63 with that number already exists on the host.
64
65 .TP
66 \fBdeldp nl:\fIdp_idx\fR
67 Deletes datapath \fIdp_idx\fR on the local host.  \fIdp_idx\fR must be
68 an existing datapath.  All of a datapath's network devices must be
69 explicitly removed before the datapath can be deleted (see \fBdelif\fR
70 command).
71
72 .TP
73 \fBaddif nl:\fIdp_idx netdev\fR...
74 Adds each \fInetdev\fR to the list of network devices datapath
75 \fIdp_idx\fR monitors, where \fIdp_idx\fR is the ID of an existing
76 datapath, and \fInetdev\fR is the name of one of the host's
77 network devices, e.g. \fBeth0\fR.  Once a network device has been added
78 to a datapath, the datapath has complete ownership of the network device's
79 traffic and the network device appears silent to the rest of the system.
80
81 .TP
82 \fBdelif nl:\fIdp_idx netdev\fR...
83 Removes each \fInetdev\fR from the list of network devices datapath
84 \fIdp_idx\fR monitors.
85
86 .PP
87 The following commands can be apply to OpenFlow switches regardless of
88 the connection method.
89
90 .TP
91 \fBshow \fIswitch\fR
92 Prints to the console information on datapath \fIswitch\fR including
93 information on its flow tables and ports.
94
95 .TP
96 \fBstatus \fIswitch\fR [\fIkey\fR]
97 Prints to the console a series of key-value pairs that report the
98 status of \fIswitch\fR.  If \fIkey\fR is specified, only the key-value
99 pairs whose key names begin with \fIkey\fR are printed.  If \fIkey\fR is
100 omitted, all key-value pairs are printed.
101
102 (In the OpenFlow reference implementation, the \fBstatus\fR command is
103 implemented in \fBsecchan\fR(8), not in the kernel module, so the
104 \fBnl:\fIdp_idx\fR connection method should not be used with this
105 command.  Instead, specify \fB-l\fR or \fB--listen\fR on the
106 \fBsecchan\fR command line and tell \fBdpctl\fR to use the connection
107 method specified there.)
108
109 .TP
110 \fBdump-tables \fIswitch\fR
111 Prints to the console statistics for each of the flow tables used by
112 datapath \fIswitch\fR.
113
114 .TP
115 \fBdump-ports \fIswitch\fR
116 Prints to the console statistics for each of the network devices
117 associated with datapath \fIswitch\fR.
118
119 .TP
120 \fBmod-port \fIswitch\fR \fInetdev\fR \fIaction\fR
121 Modify characteristics of an interface monitored by \fIswitch\fR.  
122 \fInetdev\fR can be referred to by its OpenFlow assigned port number or 
123 the device name, e.g. \fBeth0\fR.  The \fIaction\fR may be any one of the
124 following:
125
126 .RS
127 .IP \fBup\fR
128 Enables the interface.  This is equivalent to ``ifconfig up'' on a Unix
129 system.
130
131 .IP \fBdown\fR
132 Disables the interface.  This is equivalent to ``ifconfig down'' on a Unix
133 system.
134
135 .IP \fBflood\fR
136 When a \fIflood\fR action is specified, traffic will be sent out this
137 interface.  This is the default posture for monitored ports.
138
139 .IP \fBnoflood\fR
140 When a \fIflood\fR action is specified, traffic will not be sent out 
141 this interface.  This is primarily useful to prevent loops when a
142 spanning tree protocol is not in use.
143
144 .RE
145
146 .TP
147 \fBdump-flows \fIswitch \fR[\fIflows\fR]
148 Prints to the console all flow entries in datapath \fIswitch\fR's
149 tables that match \fIflows\fR.  If \fIflows\fR is omitted, all flows
150 in the datapath are retrieved.  See \fBFLOW SYNTAX\fR, below, for the
151 syntax of \fIflows\fR.
152
153 .TP
154 \fBdump-aggregate \fIswitch \fR[\fIflows\fR]
155 Prints to the console aggregate statistics for flows in datapath
156 \fSWITCH\fR's tables that match \fIflows\fR.  If \fIflows\fR is omitted, 
157 the statistics are aggregated across all flows in the datapath's flow
158 tables.  See \fBFLOW SYNTAX\fR, below, for the syntax of \fIflows\fR.
159
160 .TP
161 \fBadd-flow \fIswitch flow\fR
162 Add the flow entry as described by \fIflow\fR to the datapath \fIswitch\fR's 
163 tables.  The flow entry is in the format described in \fBFLOW SYNTAX\fR, 
164 below.
165
166 .TP
167 \fBadd-flows \fIswitch file\fR
168 Add flow entries as described in \fIfile\fR to the datapath \fIswitch\fR's 
169 tables.  Each line in \fIfile\fR is a flow entry in the format
170 described in \fBFLOW SYNTAX\fR, below.
171
172 .TP
173 \fBmod-flows \fIswitch flow\fR
174 Modify the actions in entries from the datapath \fIswitch\fR's tables 
175 that match \fIflow\fR.  When invoked with the \fB--strict\fR option,
176 wildcards are not treated as active for matching purposes.  See 
177 \fBFLOW SYNTAX\fR, below, for the syntax of \fIflows\fR.
178
179 .TP
180 \fBdel-flows \fIswitch \fR[\fIflow\fR]
181 Deletes entries from the datapath \fIswitch\fR's tables that match
182 \fIflow\fR.  When invoked with the \fB--strict\fR option, wildcards are 
183 not treated as active for matching purposes.  If \fIflow\fR is 
184 omitted and the \fB--strict\fR option is not used, all flows in the 
185 datapath's tables are removed.  See \fBFLOW SYNTAX\fR, below, for the 
186 syntax of \fIflows\fR.
187
188 .TP
189 \fBmonitor \fIswitch\fR
190 Connects to \fIswitch\fR and prints to the console all OpenFlow
191 messages received.  Usually, \fIswitch\fR should specify a connection
192 named on \fBsecchan\fR(8)'s \fB-m\fR or \fB--monitor\fR command line
193 option, in which the messages printed will be all those sent or
194 received by \fBsecchan\fR to or from the kernel datapath module.  A
195 \fIswitch\fR of the form \fBnl:\fIdp_idx\fR will print all
196 asynchronously generated OpenFlow messages (such as packet-in
197 messages), but it will not print any messages sent to the kernel by
198 \fBsecchan\fR and other processes, nor will it print replies sent by
199 the kernel in response to those messages.
200
201 .TP
202 \fBexecute \fIswitch command \fR[\fIarg\fR...]
203
204 Sends a request to \fIswitch\fR to execute \fIcommand\fR along with
205 each \fIarg\fR, if any, then waits for the command to complete and
206 reports its completion status on \fBstderr\fR and its output, if any,
207 on \fBstdout\fR.  The set of available commands and their argument is
208 switch-dependent.  (This command uses a Nicira extension to OpenFlow
209 that may not be available on all switches.)
210
211 .PP
212 The following commands can be used regardless of the connection
213 method.  They apply to OpenFlow switches and controllers.
214
215 .TP
216 \fBprobe \fIvconn\fR
217 Connects to \fIvconn\fR and sends a single OpenFlow echo-request
218 packet and waits for the response.  With the \fB-t\fR or
219 \fB--timeout\fR option, this command can test whether an OpenFlow
220 switch or controller is up and running.
221
222 .TP
223 \fBping \fIvconn \fR[\fIn\fR]
224 Sends a series of 10 echo request packets to \fIvconn\fR and times
225 each reply.  The echo request packets consist of an OpenFlow header
226 plus \fIn\fR bytes (default: 64) of randomly generated payload.  This
227 measures the latency of individual requests.
228
229 .TP
230 \fBbenchmark \fIvconn n count\fR
231 Sends \fIcount\fR echo request packets that each consist of an
232 OpenFlow header plus \fIn\fR bytes of payload and waits for each
233 response.  Reports the total time required.  This is a measure of the
234 maximum bandwidth to \fIvconn\fR for round-trips of \fIn\fR-byte
235 messages.
236
237 .SH "FLOW SYNTAX"
238
239 Some \fBdpctl\fR commands accept an argument that describes a flow or
240 flows.  Such flow descriptions comprise a series
241 \fIfield\fB=\fIvalue\fR assignments, separated by commas or white
242 space.
243
244 The following field assignments describe how a flow matches a packet.
245 If any of these assignments is omitted from the flow syntax, the field
246 is treated as a wildcard; thus, if all of them are omitted, the
247 resulting flow matches all packets.  The string \fB*\fR or \fBANY\fR
248 may be specified a value to explicitly mark any of these fields as a
249 wildcard.
250
251 .IP \fBin_port=\fIport_no\fR
252 Matches physical port \fIport_no\fR.  Switch ports are numbered as
253 displayed by \fBdpctl show\fR.
254
255 .IP \fBdl_vlan=\fIvlan\fR
256 Matches IEEE 802.1q virtual LAN tag \fIvlan\fR.  Specify \fB0xffff\fR
257 as \fIvlan\fR to match packets that are not tagged with a virtual LAN;
258 otherwise, specify a number between 0 and 4095, inclusive, as the
259 12-bit VLAN ID to match.
260
261 .IP \fBdl_src=\fImac\fR
262 Matches Ethernet source address \fImac\fR, which should be specified
263 as 6 pairs of hexadecimal digits delimited by colons,
264 e.g. \fB00:0A:E4:25:6B:B0\fR.
265
266 .IP \fBdl_dst=\fImac\fR
267 Matches Ethernet destination address \fImac\fR.
268
269 .IP \fBdl_type=\fIethertype\fR
270 Matches Ethernet protocol type \fIethertype\fR, which should be
271 specified as a integer between 0 and 65535, inclusive, either in
272 decimal or as a hexadecimal number prefixed by \fB0x\fR,
273 e.g. \fB0x0806\fR to match ARP packets.
274
275 .IP \fBnw_src=\fIip\fR[\fB/\fInetmask\fR]
276 Matches IPv4 source address \fIip\fR, which should be specified as an
277 IP address or host name, e.g. \fB192.168.1.1\fR or
278 \fBwww.example.com\fR.  The optional \fInetmask\fR allows matching
279 only on an IPv4 address prefix.  It may be specified as a dotted quad
280 (e.g. \fB192.168.1.0/255.255.255.0\fR) or as a count of bits
281 (e.g. \fB192.168.1.0/24\fR).
282
283 .IP \fBnw_dst=\fIip\fR[\fB/\fInetmask\fR]
284 Matches IPv4 destination address \fIip\fR.
285
286 .IP \fBnw_proto=\fIproto\fR
287 Matches IP protocol type \fIproto\fR, which should be specified as a
288 decimal number between 0 and 255, inclusive, e.g. 6 to match TCP
289 packets.
290
291 .IP \fBtp_src=\fIport\fR
292 Matches UDP or TCP source port \fIport\fR, which should be specified
293 as a decimal number between 0 and 65535, inclusive, e.g. 80 to match
294 packets originating from a HTTP server.
295
296 .IP \fBtp_dst=\fIport\fR
297 Matches UDP or TCP destination port \fIport\fR.
298
299 .IP \fBicmp_type=\fItype\fR
300 Matches ICMP message with \fItype\fR, which should be specified as a decimal 
301 number between 0 and 255, inclusive.
302
303 .IP \fBicmp_code=\fIcode\fR
304 Matches ICMP messages with \fIcode\fR.
305
306 .PP
307 The following shorthand notations are also available:
308
309 .IP \fBip\fR
310 Same as \fBdl_type=0x0800\fR.
311
312 .IP \fBicmp\fR
313 Same as \fBdl_type=0x0800,nw_proto=1\fR.
314
315 .IP \fBtcp\fR
316 Same as \fBdl_type=0x0800,nw_proto=6\fR.
317
318 .IP \fBudp\fR
319 Same as \fBdl_type=0x0800,nw_proto=17\fR.
320
321 .IP \fBarp\fR
322 Same as \fBdl_type=0x0806\fR.
323
324 .PP
325 The \fBadd-flow\fR and \fBadd-flows\fR commands require an additional field:
326
327 .IP \fIactions\fB=\fItarget\fR[\fB,\fItarget\fR...]\fR
328 Specifies a comma-separated list of actions to take on a packet when the 
329 flow entry matches.  The \fItarget\fR may be a decimal port number 
330 designating the physical port on which to output the packet, or one of 
331 the following keywords:
332
333 .RS
334 .IP \fBoutput\fR:\fIport\fR
335 Outputs the packet on the port specified by \fIport\fR.
336
337 .IP \fBnormal\fR
338 Subjects the packet to the device's normal L2/L3 processing.  (This
339 action is not implemented by all OpenFlow switches.)
340
341 .IP \fBflood\fR
342 Outputs the packet on all switch physical ports other than the port on
343 which it was received and any ports on which flooding is disabled
344 (typically, these would be ports disabled by the IEEE 802.1D spanning
345 tree protocol).
346
347 .IP \fBall\fR
348 Outputs the packet on all switch physical ports other than the port on
349 which it was received.
350
351 .IP \fBcontroller\fR:\fImax_len\fR
352 Sends the packet to the OpenFlow controller as a ``packet in''
353 message.  If \fImax_len\fR is a number, then it specifies the maximum
354 number of bytes that should be sent.  If \fImax_len\fR is \fBALL\fR or
355 omitted, then the entire packet is sent.
356
357 .IP \fBlocal\fR
358 Outputs the packet on the ``local port,'' which corresponds to the
359 \fBof\fIn\fR network device (see \fBCONTACTING THE CONTROLLER\fR in
360 \fBsecchan\fR(8) for information on the \fBof\fIn\fR network device).
361
362 .IP \fBmod_vlan_vid\fR:\fIvlan_vid\fR
363 Modifies the VLAN id on a packet.  The VLAN tag is added or modified 
364 as necessary to match the value specified.  If the VLAN tag is added,
365 a priority of zero is used (see the \fBmod_vlan_pcp\fR action to set
366 this).
367
368 .IP \fBmod_vlan_pcp\fR:\fIvlan_pcp\fR
369 Modifies the VLAN priority on a packet.  The VLAN tag is added or modified 
370 as necessary to match the value specified.  Valid values are between 0
371 (lowest) and 7 (highest).  If the VLAN tag is added, a vid of zero is used 
372 (see the \fBmod_vlan_vid\fR action to set this).
373
374 .IP \fBstrip_vlan\fR
375 Strips the VLAN tag from a packet if it is present.
376 .RE
377
378 .IP
379 (The OpenFlow protocol supports other actions that \fBdpctl\fR does
380 not yet expose to the user.)
381
382 .PP
383 The \fBadd-flow\fR, \fBadd-flows\fR, and \fBdel-flows\fR commands
384 support an additional optional field:
385
386 .IP \fBpriority=\fIvalue\fR
387 Sets the priority of the flow to be added or deleted to \fIvalue\fR,
388 which should be a number between 0 and 65535, inclusive.  If this
389 field is not specified, it defaults to 32768.
390
391 .PP
392 The \fBadd-flow\fR and \fBadd-flows\fR commands support additional
393 optional fields:
394
395 .TP
396 \fBidle_timeout=\fIseconds\fR
397 Causes the flow to expire after the given number of seconds of
398 inactivity.  A value of 0 prevents a flow from expiring due to
399 inactivity.  The default is 60 seconds.
400
401 .IP \fBhard_timeout=\fIseconds\fR
402 Causes the flow to expire after the given number of seconds,
403 regardless of activity.  A value of 0 (the default) gives the flow no
404 hard expiration deadline.
405
406 .PP
407 The \fBdump-flows\fR, \fBdump-aggregate\fR, \fBdel-flow\fR 
408 and \fBdel-flows\fR commands support the additional optional field:
409
410 .TP
411 \fBout_port=\fIport\fR
412 If set, a matching flow must include an output action to \fIport\fR.
413
414 .PP
415 The \fBdump-flows\fR and \fBdump-aggregate\fR commands support an
416 additional optional field:
417
418 .IP \fBtable=\fInumber\fR
419 If specified, limits the flows about which statistics are gathered to
420 those in the table with the given \fInumber\fR.  Tables are numbered
421 as shown by the \fBdump-tables\fR command.
422
423 If this field is not specified, or if \fInumber\fR is given as
424 \fB255\fR, statistics are gathered about flows from all tables.
425
426 .SH OPTIONS
427 .TP
428 \fB--strict\fR
429 Uses strict matching when running flow modification commands.
430
431 .TP
432 \fB-t\fR, \fB--timeout=\fIsecs\fR
433 Limits \fBdpctl\fR runtime to approximately \fIsecs\fR seconds.  If
434 the timeout expires, \fBdpctl\fR will exit with a \fBSIGALRM\fR
435 signal.
436
437 .TP
438 \fB-p\fR, \fB--private-key=\fIprivkey.pem\fR
439 Specifies a PEM file containing the private key used as the
440 identity for SSL connections to a switch.
441
442 .TP
443 \fB-c\fR, \fB--certificate=\fIcert.pem\fR
444 Specifies a PEM file containing a certificate, signed by the
445 controller's certificate authority (CA), that certifies the
446 private key to identify a trustworthy controller.
447
448 .TP
449 \fB-C\fR, \fB--ca-cert=\fIcacert.pem\fR
450 Specifies a PEM file containing the CA certificate used to verify that
451 a switch is trustworthy.
452
453 .TP
454 .BR \-h ", " \-\^\-help
455 Prints a brief help message to the console.
456
457 @VLOG_OPTIONS@
458
459 .TP
460 .BR \-V ", " \-\^\-version
461 Prints version information to the console.
462
463 .SH EXAMPLES
464
465 A typical dpctl command sequence for controlling an OpenFlow kernel module:
466 .nf
467 .TP
468 Create datapath numbered 0:
469
470 .B % dpctl adddp nl:0
471
472 .TP
473 Add two network devices to the new datapath:
474
475 .B % dpctl addif nl:0 eth0
476 .B % dpctl addif nl:0 eth1
477
478 .TP
479 Monitor traffic received by the datapath (exit with control-C):
480
481 .B % dpctl monitor nl:0
482
483
484 .TP
485 View the datapath's table stats after some traffic has passed through:
486
487 .B % dpctl dump-tables nl:0
488
489 .TP
490 View the flow entries in the datapath:
491
492 .B % dpctl dump-flows nl:0 
493
494 .TP
495 Remove network devices from the datapath when finished:
496
497 .B % dpctl delif nl:0 eth0
498 .B % dpctl delif nl:0 eth1
499
500 .TP
501 Delete the datapath:
502
503 .B % dpctl deldp nl:0
504 .fi
505 .SH "SEE ALSO"
506
507 .BR secchan (8),
508 .BR controller (8),
509 .BR udatapath (8),
510 .BR vlogconf (8)