ofproto: Match VLAN PCP and rewrite ToS bits (OpenFlow 0.9)
[sliver-openvswitch.git] / utilities / ovs-ofctl.8.in
1 .TH ovs\-ofctl 8 "June 2009" "Open vSwitch" "Open vSwitch Manual"
2 .ds PN ovs\-ofctl
3
4 .SH NAME
5 ovs\-ofctl \- administer OpenFlow switches
6
7 .SH SYNOPSIS
8 .B ovs\-ofctl
9 [\fIoptions\fR] \fIcommand \fR[\fIswitch\fR] [\fIargs\fR\&...]
10
11 .SH DESCRIPTION
12 The
13 .B ovs\-ofctl
14 program is a command line tool for monitoring and administering
15 OpenFlow switches.  It can also show the current state of an OpenFlow
16 switch, including features, configuration, and table entries.
17
18 .SS "OpenFlow Switch Management Commands"
19
20 These commands allow \fBovs\-ofctl\fR to monitor and administer an OpenFlow
21 switch.  It is able to show the current state of a switch, including
22 features, configuration, and table entries.
23
24 Most of these commands take an argument that specifies the method for
25 connecting to an OpenFlow switch.  The following connection methods
26 are supported:
27
28 .RS
29 .so lib/vconn-active.man
30 .
31 .IP "\fIfile\fR"
32 This is short for \fBunix:\fIfile\fR, as long as \fIfile\fR does not
33 contain a colon.
34 .
35 .IP \fIbridge\fR
36 This is short for \fBunix:@RUNDIR@/\fIbridge\fB.mgmt\fR, as long as
37 \fIbridge\fR does not contain a colon.
38 .
39 .IP [\fItype\fB@\fR]\fIdp\fR
40 Attempts to look up the bridge associated with \fIdp\fR and open as
41 above.  If \fItype\fR is given, it specifies the datapath provider of
42 \fIdp\fR, otherwise the default provider \fBsystem\fR is assumed.
43 .RE
44
45 .TP
46 \fBshow \fIswitch\fR
47 Prints to the console information on \fIswitch\fR, including
48 information on its flow tables and ports.
49
50 .TP
51 \fBstatus \fIswitch\fR [\fIkey\fR]
52 Prints to the console a series of key-value pairs that report the
53 status of \fIswitch\fR.  If \fIkey\fR is specified, only the key-value
54 pairs whose key names begin with \fIkey\fR are printed.  If \fIkey\fR is
55 omitted, all key-value pairs are printed.
56
57 .TP
58 \fBdump-tables \fIswitch\fR
59 Prints to the console statistics for each of the flow tables used by
60 \fIswitch\fR.
61
62 .TP
63 \fBdump-ports \fIswitch\fR
64 Prints to the console statistics for each of the network devices
65 associated with \fIswitch\fR.
66
67 .TP
68 \fBmod-port \fIswitch\fR \fInetdev\fR \fIaction\fR
69 Modify characteristics of an interface monitored by \fIswitch\fR.  
70 \fInetdev\fR can be referred to by its OpenFlow assigned port number or 
71 the device name, e.g. \fBeth0\fR.  The \fIaction\fR may be any one of the
72 following:
73
74 .RS
75 .IP \fBup\fR
76 Enables the interface.  This is equivalent to ``ifconfig up'' on a Unix
77 system.
78
79 .IP \fBdown\fR
80 Disables the interface.  This is equivalent to ``ifconfig down'' on a Unix
81 system.
82
83 .IP \fBflood\fR
84 When a \fIflood\fR action is specified, traffic will be sent out this
85 interface.  This is the default posture for monitored ports.
86
87 .IP \fBnoflood\fR
88 When a \fIflood\fR action is specified, traffic will not be sent out 
89 this interface.  This is primarily useful to prevent loops when a
90 spanning tree protocol is not in use.
91
92 .RE
93
94 .TP
95 \fBdump-flows \fIswitch \fR[\fIflows\fR]
96 Prints to the console all flow entries in \fIswitch\fR's
97 tables that match \fIflows\fR.  If \fIflows\fR is omitted, all flows
98 in the switch are retrieved.  See \fBFlow Syntax\fR, below, for the
99 syntax of \fIflows\fR.  The output format is described in 
100 \fBTable Entry Output\fR.
101
102 .TP
103 \fBdump-aggregate \fIswitch \fR[\fIflows\fR]
104 Prints to the console aggregate statistics for flows in 
105 \fIswitch\fR's tables that match \fIflows\fR.  If \fIflows\fR is omitted, 
106 the statistics are aggregated across all flows in the switch's flow
107 tables.  See \fBFlow Syntax\fR, below, for the syntax of \fIflows\fR.
108 The output format is descrbed in \fBTable Entry Output\fR.
109
110 .TP
111 \fBadd-flow \fIswitch flow\fR
112 Add the flow entry as described by \fIflow\fR to the \fIswitch\fR's 
113 tables.  The flow entry is in the format described in \fBFlow Syntax\fR, 
114 below.
115
116 .TP
117 \fBadd-flows \fIswitch file\fR
118 Add flow entries as described in \fIfile\fR to \fIswitch\fR's 
119 tables.  Each line in \fIfile\fR is a flow entry in the format
120 described in \fBFlow Syntax\fR, below.
121
122 .TP
123 \fBmod-flows \fIswitch flow\fR
124 Modify the actions in entries from the \fIswitch\fR's tables 
125 that match \fIflow\fR.  When invoked with the \fB--strict\fR option,
126 wildcards are not treated as active for matching purposes.  See 
127 \fBFlow Syntax\fR, below, for the syntax of \fIflows\fR.
128
129 .TP
130 \fBdel-flows \fIswitch \fR[\fIflow\fR]
131 Deletes entries from the \fIswitch\fR's tables that match
132 \fIflow\fR.  When invoked with the \fB--strict\fR option, wildcards are 
133 not treated as active for matching purposes.  If \fIflow\fR is 
134 omitted and the \fB--strict\fR option is not used, all flows in the 
135 switch's tables are removed.  See \fBFlow Syntax\fR, below, for the 
136 syntax of \fIflows\fR.
137
138 .TP
139 \fBmonitor \fIswitch\fR [\fImiss-len\fR [\fIsend-exp]]
140 Connects to \fIswitch\fR and prints to the console all OpenFlow
141 messages received.  Usually, \fIswitch\fR should specify a connection
142 named on \fBovs\-openflowd\fR(8)'s \fB-l\fR or \fB--listen\fR command line
143 option.
144
145 If \fImiss-len\fR is provided, \fBovs\-ofctl\fR sends an OpenFlow ``set
146 configuration'' message at connection setup time that requests
147 \fImiss-len\fR bytes of each packet that misses the flow table.  The
148 OpenFlow reference implementation does not send these messages to the
149 \fBovs\-ofctl monitor\fR client connection unless a nonzero value is
150 specified on this argument.
151
152 If \fIsend-exp\fR is specified as \fB1\fR, \fBovs\-ofctl\fR will also
153 request to be sent flow expiration messages.  If this argument is
154 omitted, or \fB0\fR is specified, then \fRovs\-ofctl\fR will not request
155 flow expirations.
156
157 This command may be useful for debugging switch or controller
158 implementations.
159
160 .SS "OpenFlow Switch and Controller Commands"
161
162 The following commands, like those in the previous section, may be
163 applied to OpenFlow switches, using any of the connection methods
164 described in that section.  Unlike those commands, these may also be
165 applied to OpenFlow controllers.
166
167 .TP
168 \fBprobe \fItarget\fR
169 Sends a single OpenFlow echo-request message to \fItarget\fR and waits
170 for the response.  With the \fB-t\fR or \fB--timeout\fR option, this
171 command can test whether an OpenFlow switch or controller is up and
172 running.
173
174 .TP
175 \fBping \fItarget \fR[\fIn\fR]
176 Sends a series of 10 echo request packets to \fItarget\fR and times
177 each reply.  The echo request packets consist of an OpenFlow header
178 plus \fIn\fR bytes (default: 64) of randomly generated payload.  This
179 measures the latency of individual requests.
180
181 .TP
182 \fBbenchmark \fItarget n count\fR
183 Sends \fIcount\fR echo request packets that each consist of an
184 OpenFlow header plus \fIn\fR bytes of payload and waits for each
185 response.  Reports the total time required.  This is a measure of the
186 maximum bandwidth to \fItarget\fR for round-trips of \fIn\fR-byte
187 messages.
188
189 .SS "Flow Syntax"
190
191 Some \fBovs\-ofctl\fR commands accept an argument that describes a flow or
192 flows.  Such flow descriptions comprise a series
193 \fIfield\fB=\fIvalue\fR assignments, separated by commas or white
194 space.  (Embedding spaces into a flow description normally requires
195 quoting to prevent the shell from breaking the description into
196 multiple arguments.)
197
198 The following field assignments describe how a flow matches a packet.
199 If any of these assignments is omitted from the flow syntax, the field
200 is treated as a wildcard; thus, if all of them are omitted, the
201 resulting flow matches all packets.  The string \fB*\fR or \fBANY\fR
202 may be specified to explicitly mark any of these fields as a wildcard.  
203 (\fB*\fR should be quoted to protect it from shell expansion.)
204
205 .IP \fBin_port=\fIport_no\fR
206 Matches physical port \fIport_no\fR.  Switch ports are numbered as
207 displayed by \fBovs\-ofctl show\fR.
208
209 .IP \fBdl_vlan=\fIvlan\fR
210 Matches IEEE 802.1q Virtual LAN tag \fIvlan\fR.  Specify \fB0xffff\fR
211 as \fIvlan\fR to match packets that are not tagged with a Virtual LAN;
212 otherwise, specify a number between 0 and 4095, inclusive, as the
213 12-bit VLAN ID to match.
214
215 .IP \fBdl_vlan_pcp=\fIpriority\fR
216 Matches IEEE 802.1q Priority Code Point (PCP) \fIpriority\fR, which is
217 specified as a value between 0 and 7, inclusive.  A higher value
218 indicates a higher frame priority level.
219
220 .IP \fBdl_src=\fImac\fR
221 Matches Ethernet source address \fImac\fR, which is specified as 6 pairs 
222 of hexadecimal digits delimited by colons (e.g. \fB00:0A:E4:25:6B:B0\fR).
223
224 .IP \fBdl_dst=\fImac\fR
225 Matches Ethernet destination address \fImac\fR.
226
227 .IP \fBdl_type=\fIethertype\fR
228 Matches Ethernet protocol type \fIethertype\fR, which is specified as an
229 integer between 0 and 65535, inclusive, either in decimal or as a 
230 hexadecimal number prefixed by \fB0x\fR (e.g. \fB0x0806\fR to match ARP 
231 packets).
232
233 .IP \fBnw_src=\fIip\fR[\fB/\fInetmask\fR]
234 Matches IPv4 source address \fIip\fR, which may be specified as an
235 IP address or host name (e.g. \fB192.168.1.1\fR or
236 \fBwww.example.com\fR).  The optional \fInetmask\fR allows restricting a
237 match to an IPv4 address prefix.  The netmask may be specified as a dotted 
238 quad (e.g. \fB192.168.1.0/255.255.255.0\fR) or as a CIDR block 
239 (e.g. \fB192.168.1.0/24\fR).
240
241 .IP \fBnw_dst=\fIip\fR[\fB/\fInetmask\fR]
242 Matches IPv4 destination address \fIip\fR.
243
244 .IP \fBnw_proto=\fIproto\fR
245 Matches IP protocol type \fIproto\fR, which is specified as a decimal 
246 number between 0 and 255, inclusive (e.g. 6 to match TCP packets).
247
248 .IP \fBtp_src=\fIport\fR
249 Matches UDP or TCP source port \fIport\fR, which is specified as a decimal 
250 number between 0 and 65535, inclusive (e.g. 80 to match packets originating 
251 from a HTTP server).
252
253 .IP \fBtp_dst=\fIport\fR
254 Matches UDP or TCP destination port \fIport\fR.
255
256 .IP \fBicmp_type=\fItype\fR
257 Matches ICMP message with \fItype\fR, which is specified as a decimal 
258 number between 0 and 255, inclusive.
259
260 .IP \fBicmp_code=\fIcode\fR
261 Matches ICMP messages with \fIcode\fR.
262
263 .PP
264 The following shorthand notations are also available:
265
266 .IP \fBip\fR
267 Same as \fBdl_type=0x0800\fR.
268
269 .IP \fBicmp\fR
270 Same as \fBdl_type=0x0800,nw_proto=1\fR.
271
272 .IP \fBtcp\fR
273 Same as \fBdl_type=0x0800,nw_proto=6\fR.
274
275 .IP \fBudp\fR
276 Same as \fBdl_type=0x0800,nw_proto=17\fR.
277
278 .IP \fBarp\fR
279 Same as \fBdl_type=0x0806\fR.
280
281 .PP
282 The \fBadd-flow\fR and \fBadd-flows\fR commands require an additional field:
283
284 .IP \fBactions=\fR[\fItarget\fR][\fB,\fItarget\fR...]\fR
285 Specifies a comma-separated list of actions to take on a packet when the 
286 flow entry matches.  If no \fItarget\fR is specified, then packets
287 matching the flow are dropped.  The \fItarget\fR may be a decimal port 
288 number designating the physical port on which to output the packet, or one 
289 of the following keywords:
290
291 .RS
292 .IP \fBoutput\fR:\fIport\fR
293 Outputs the packet on the port specified by \fIport\fR.
294
295 .IP \fBnormal\fR
296 Subjects the packet to the device's normal L2/L3 processing.  (This
297 action is not implemented by all OpenFlow switches.)
298
299 .IP \fBflood\fR
300 Outputs the packet on all switch physical ports other than the port on
301 which it was received and any ports on which flooding is disabled
302 (typically, these would be ports disabled by the IEEE 802.1D spanning
303 tree protocol).
304
305 .IP \fBall\fR
306 Outputs the packet on all switch physical ports other than the port on
307 which it was received.
308
309 .IP \fBcontroller\fR:\fImax_len\fR
310 Sends the packet to the OpenFlow controller as a ``packet in''
311 message.  If \fImax_len\fR is a number, then it specifies the maximum
312 number of bytes that should be sent.  If \fImax_len\fR is \fBALL\fR or
313 omitted, then the entire packet is sent.
314
315 .IP \fBlocal\fR
316 Outputs the packet on the ``local port,'' which corresponds to the
317 \fBof\fIn\fR network device (see \fBCONTACTING THE CONTROLLER\fR in
318 \fBovs\-openflowd\fR(8) for information on the \fBof\fIn\fR network device).
319
320 .IP \fBdrop\fR
321 Discards the packet, so no further processing or forwarding takes place.
322 If a drop action is used, no other actions may be specified.
323
324 .IP \fBmod_vlan_vid\fR:\fIvlan_vid\fR
325 Modifies the VLAN id on a packet.  The VLAN tag is added or modified 
326 as necessary to match the value specified.  If the VLAN tag is added,
327 a priority of zero is used (see the \fBmod_vlan_pcp\fR action to set
328 this).
329
330 .IP \fBmod_vlan_pcp\fR:\fIvlan_pcp\fR
331 Modifies the VLAN priority on a packet.  The VLAN tag is added or modified 
332 as necessary to match the value specified.  Valid values are between 0
333 (lowest) and 7 (highest).  If the VLAN tag is added, a vid of zero is used 
334 (see the \fBmod_vlan_vid\fR action to set this).
335
336 .IP \fBstrip_vlan\fR
337 Strips the VLAN tag from a packet if it is present.
338
339 .IP \fBmod_dl_src\fB:\fImac\fR
340 Sets the source Ethernet address to \fImac\fR.
341
342 .IP \fBmod_dl_dst\fB:\fImac\fR
343 Sets the destination Ethernet address to \fImac\fR.
344
345 .IP \fBmod_nw_src\fB:\fIip\fR
346 Sets the IPv4 source address to \fIip\fR.
347
348 .IP \fBmod_nw_dst\fB:\fIip\fR
349 Sets the IPv4 destination address to \fIip\fR.
350
351 .IP \fBmod_tp_src\fB:\fIport\fR
352 Sets the TCP or UDP source port to \fIport\fR.
353
354 .IP \fBmod_tp_dst\fB:\fIport\fR
355 Sets the TCP or UDP destination port to \fIport\fR.
356
357 .IP \fBmod_nw_tos\fB:\fItos\fR
358 Sets the IP ToS/DSCP field to \fItos\fR.  Valid values are between 0 and
359 255, inclusive.  Note that the two lower reserved bits are never
360 modified.
361
362 .RE
363
364 .IP
365 (The OpenFlow protocol supports other actions that \fBovs\-ofctl\fR does
366 not yet expose to the user.)
367
368 .PP
369 The \fBadd-flow\fR, \fBadd-flows\fR, and \fBdel-flows\fR commands
370 support an additional optional field:
371
372 .IP \fBpriority=\fIvalue\fR
373 The priority at which a wildcarded entry will match in comparison to
374 others.  \fIvalue\fR is a number between 0 and 65535, inclusive.  A higher 
375 \fIvalue\fR will match before a lower one.  An exact-match entry will always 
376 have priority over an entry containing wildcards, so it has an implicit 
377 priority value of 65535.  When adding a flow, if the field is not specified, 
378 the flow's priority will default to 32768.
379
380 .PP
381 The \fBadd-flow\fR and \fBadd-flows\fR commands support additional
382 optional fields:
383
384 .TP
385 \fBidle_timeout=\fIseconds\fR
386 Causes the flow to expire after the given number of seconds of
387 inactivity.  A value of 0 prevents a flow from expiring due to
388 inactivity.  The default is 60 seconds.
389
390 .IP \fBhard_timeout=\fIseconds\fR
391 Causes the flow to expire after the given number of seconds,
392 regardless of activity.  A value of 0 (the default) gives the flow no
393 hard expiration deadline.
394
395 .PP
396 The \fBdump-flows\fR, \fBdump-aggregate\fR, \fBdel-flow\fR 
397 and \fBdel-flows\fR commands support one additional optional field:
398
399 .TP
400 \fBout_port=\fIport\fR
401 If set, a matching flow must include an output action to \fIport\fR.
402
403 .PP
404 The \fBdump-flows\fR and \fBdump-aggregate\fR commands support an
405 additional optional field:
406
407 .IP \fBtable=\fInumber\fR
408 If specified, limits the flows about which statistics are gathered to
409 those in the table with the given \fInumber\fR.  Tables are numbered
410 as shown by the \fBdump-tables\fR command.
411
412 If this field is not specified, or if \fInumber\fR is given as
413 \fB255\fR, statistics are gathered about flows from all tables.
414
415 .SS "Table Entry Output"
416
417 The \fBdump-tables\fR and \fBdump-aggregate\fR commands print information 
418 about the entries in a datapath's tables.  Each line of output is a 
419 unique flow entry, which begins with some common information:
420
421 .IP \fBduration\fR
422 The number of seconds the entry has been in the table.
423
424 .IP \fBtable_id\fR
425 The table that contains the flow.  When a packet arrives, the switch 
426 begins searching for an entry at the lowest numbered table.  Tables are 
427 numbered as shown by the \fBdump-tables\fR command.
428
429 .IP \fBpriority\fR
430 The priority of the entry in relation to other entries within the same
431 table.  A higher value will match before a lower one.
432
433 .IP \fBn_packets\fR
434 The number of packets that have matched the entry.
435
436 .IP \fBn_bytes\fR
437 The total number of bytes from packets that have matched the entry.
438
439 .PP
440 The rest of the line consists of a description of the flow entry as 
441 described in \fBFlow Syntax\fR, above.
442
443
444 .SH OPTIONS
445 .TP
446 \fB--strict\fR
447 Uses strict matching when running flow modification commands.
448
449 .so lib/ssl.man
450 .so lib/vlog.man
451 .so lib/common.man
452
453 .SH EXAMPLES
454
455 The following examples assume that an OpenFlow switch on the local
456 host has been configured to listen for management connections on a
457 Unix domain socket named \fB@RUNDIR@/openflow.sock\fR, e.g. by
458 specifying \fB--listen=punix:@RUNDIR@/openflow.sock\fR on the
459 \fBovs\-openflowd\fR(8) command line.
460
461 .TP
462 \fBovs\-ofctl dump-tables unix:@RUNDIR@/openflow.sock\fR
463 Prints out the switch's table stats.  (This is more interesting after
464 some traffic has passed through.)
465
466 .TP
467 \fBovs\-ofctl dump-flows unix:@RUNDIR@/openflow.sock\fR
468 Prints the flow entries in the switch.
469
470 .SH "SEE ALSO"
471
472 .BR ovs\-appctl (8),
473 .BR ovs\-controller (8),
474 .BR ovs\-vswitchd (8)