Allow and use shorthands such as "ip" or "tcp" for specifying flows.
[openvswitch] / utilities / dpctl.8
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: 976) 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: 975) 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, modified, and monitored.  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 \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 \fInetdev\fR from the list of network devices datapath
84 \fIdp_idx\fR monitors.
85
86 .TP
87 \fBmonitor nl:\fIdp_idx\fR
88 Prints to the console all OpenFlow packets sent by datapath
89 \fIdp_idx\fR to its controller, where \fIdp_idx\fR is the ID of an
90 existing datapath.
91
92 .PP
93 The following commands can be apply to OpenFlow switches regardless of
94 the connection method.
95
96 .TP
97 \fBshow \fIswitch\fR
98 Prints to the console information on datapath \fIswitch\fR including
99 information on its flow tables and ports.
100
101 .TP
102 \fBdump-tables \fIswitch\fR
103 Prints to the console statistics for each of the flow tables used by
104 datapath \fIswitch\fR.
105
106 .TP
107 \fBdump-ports \fIswitch\fR
108 Prints to the console statistics for each of the network devices
109 associated with datapath \fIswitch\fR.
110
111 .TP
112 \fBdump-flows \fIswitch \fR[\fIflows\fR]
113 Prints to the console all flow entries in datapath \fIswitch\fR's
114 tables that match \fIflows\fR.  If \fIflows\fR is omitted, all flows
115 in the datapath are retrieved.  See \fBFLOW SYNTAX\fR, below, for the
116 syntax of \fIflows\fR.
117
118 .TP
119 \fBdump-aggregate \fIswitch \fR[\fIflows\fR]
120 Prints to the console aggregate statistics for flows in datapath
121 \fSWITCH\fR's tables that match \fIflows\fR.  If \fIflows\fR is omitted, 
122 the statistics are aggregated across all flows in the datapath's flow
123 tables.  See \fBFLOW SYNTAX\fR, below, for the syntax of \fIflows\fR.
124
125 .TP
126 \fBadd-flow \fIswitch flow\fR
127 Add the flow entry as described by \fIflow\fR to the datapath \fIswitch\fR's 
128 tables.  The flow entry is in the format described in \fBFLOW SYNTAX\fR, 
129 below.
130
131 .TP
132 \fBadd-flows \fIswitch file\fR
133 Add flow entries as described in \fIfile\fR to the datapath \fIswitch\fR's 
134 tables.  Each line in \fIfile\fR is a flow entry in the format
135 described in \fBFLOW SYNTAX\fR, below.
136
137 .TP
138 \fBdel-flows \fIswitch \fR[\fIflow\fR]
139 Deletes entries from the datapath \fIswitch\fR's tables that match
140 \fIflow\fR.  If \fIflow\fR is omitted, all flows in the datapath's
141 tables are removed.  See \fBFLOW SYNTAX\fR, below, for the syntax of
142 \fIflows\fR.
143
144 .PP
145 The following commands can be used regardless of the connection
146 method.  They apply to OpenFlow switches and controllers.
147
148 .TP
149 \fBprobe \fIvconn\fR
150 Connects to \fIvconn\fR and sends a single OpenFlow echo-request
151 packet and waits for the response.  With the \fB-t\fR or
152 \fB--timeout\fR option, this command can test whether an OpenFlow
153 switch or controller is up and running.
154
155 .TP
156 \fBping \fIvconn \fR[\fIn\fR]
157 Sends a series of 10 echo request packets to \fIvconn\fR and times
158 each reply.  The echo request packets consist of an OpenFlow header
159 plus \fIn\fR bytes (default: 64) of randomly generated payload.  This
160 measures the latency of individual requests.
161
162 .TP
163 \fBbenchmark \fIvconn n count\fR
164 Sends \fIcount\fR echo request packets that each consist of an
165 OpenFlow header plus \fIn\fR bytes of payload and waits for each
166 response.  Reports the total time required.  This is a measure of the
167 maximum bandwidth to \fIvconn\fR for round-trips of \fIn\fR-byte
168 messages.
169
170 .SH "FLOW SYNTAX"
171
172 Some \fBdpctl\fR commands accept an argument that describes a flow or
173 flows.  Such flow descriptions comprise a series
174 \fIfield\fB=\fIvalue\fR assignments, separated by commas or white
175 space.
176
177 The following field assignments describe how a flow matches a packet.
178 If any of these assignments is omitted from the flow syntax, the field
179 is treated as a wildcard; thus, if all of them are omitted, the
180 resulting flow matches all packets.  The string \fB*\fR or \fBANY\fR
181 may be specified a value to explicitly mark any of these fields as a
182 wildcard.
183
184 .IP \fBin_port=\fIport_no\fR
185 Matches physical port \fIport_no\fR.  Switch ports are numbered as
186 displayed by \fBdpctl show\fR.
187
188 .IP \fBdl_vlan=\fIvlan\fR
189 Matches IEEE 802.1q virtual LAN tag \fIvlan\fR.  Specify \fB0xffff\fR
190 as \fIvlan\fR to match packets that are not tagged with a virtual LAN;
191 otherwise, specify a number between 0 and 4095, inclusive, as the
192 12-bit VLAN ID to match.
193
194 .IP \fBdl_src=\fImac\fR
195 Matches Ethernet source address \fImac\fR, which should be specified
196 as 6 pairs of hexadecimal digits delimited by colons,
197 e.g. \fB00:0A:E4:25:6B:B0\fR.
198
199 .IP \fBdl_dst=\fImac\fR
200 Matches Ethernet destination address \fImac\fR.
201
202 .IP \fBdl_type=\fIethertype\fR
203 Matches Ethernet protocol type \fIethertype\fR, which should be
204 specified as a integer between 0 and 65535, inclusive, either in
205 decimal or as a hexadecimal number prefixed by \fB0x\fR,
206 e.g. \fB0x0806\fR to match ARP packets.
207
208 .IP \fBnw_src=\fIip\fR[\fB/\fInetmask\fR]
209 Matches IPv4 source address \fIip\fR, which should be specified as an
210 IP address or host name, e.g. \fB192.168.1.1\fR or
211 \fBwww.example.com\fR.  The optional \fInetmask\fR allows matching
212 only on an IPv4 address prefix.  It may be specified as a dotted quad
213 (e.g. \fB192.168.1.0/255.255.255.0\fR) or as a count of bits
214 (e.g. \fB192.168.1.0/24\fR).
215
216 .IP \fBnw_dst=\fIip\fR[\fB/\fInetmask\fR]
217 Matches IPv4 destination address \fIip\fR.
218
219 .IP \fBnw_proto=\fIproto\fR
220 Matches IP protocol type \fIproto\fR, which should be specified as a
221 decimal number between 0 and 255, inclusive, e.g. 6 to match TCP
222 packets.
223
224 .IP \fBtp_src=\fIport\fR
225 Matches UDP or TCP source port \fIport\fR, which should be specified
226 as a decimal number between 0 and 65535, inclusive, e.g. 80 to match
227 packets originating from a HTTP server.
228
229 .IP \fBtp_dst=\fIport\fR
230 Matches UDP or TCP destination port \fIport\fR.
231
232 .PP
233 The following shorthand notations are also available:
234
235 .IP \fBip\fR
236 Same as \fBdl_type=0x0800\fR.
237
238 .IP \fBicmp\fR
239 Same as \fBdl_type=0x0800,nw_proto=1\fR.
240
241 .IP \fBtcp\fR
242 Same as \fBdl_type=0x0800,nw_proto=6\fR.
243
244 .IP \fBudp\fR
245 Same as \fBdl_type=0x0800,nw_proto=17\fR.
246
247 .IP \fBarp\fR
248 Same as \fBdl_type=0x0806\fR.
249
250 .PP
251 The \fBadd-flow\fR and \fBadd-flows\fR commands require an additional field:
252
253 .IP \fIactions\fB=\fItarget\fR[\fB,\fItarget\fR...]\fR
254 Specifies a comma-separated list of actions to take on a packet when the 
255 flow entry matches.  The \fItarget\fR may be a decimal port number 
256 designating the physical port on which to output the packet, or one of 
257 the following keywords:
258
259 .RS
260 .IP \fBoutput\fR:\fIport\fR
261 Outputs the packet on the port specified by \fIport\fR.
262
263 .IP \fBnormal\fR
264 Subjects the packet to the device's normal L2/L3 processing.  (This
265 action is not implemented by all OpenFlow switches.)
266
267 .IP \fBflood\fR
268 Outputs the packet on all switch physical ports other than the port on
269 which it was received and any ports on which flooding is disabled
270 (typically, these would be ports disabled by the IEEE 802.1D spanning
271 tree protocol).
272
273 .IP \fBall\fR
274 Outputs the packet on all switch physical ports other than the port on
275 which it was received.
276
277 .IP \fBcontroller\fR:\fImax_len\fR
278 Sends the packet to the OpenFlow controller as a ``packet in''
279 message.  If \fImax_len\fR is a number, then it specifies the maximum
280 number of bytes that should be sent.  If \fImax_len\fR is \fBALL\fR or
281 omitted, then the entire packet is sent.
282
283 .IP \fBlocal\fR
284 Outputs the packet on the ``local port,'' which corresponds to the
285 \fBof\fIn\fR network device (see \fBCONTACTING THE CONTROLLER\fR in
286 \fBsecchan\fR(8) for information on the \fBof\fIn\fR network device).
287
288 .IP \fBmod_vlan\fR:\fIvlan_id\fR
289 Modifies the VLAN tag on a packet.  If \fIvlan_id\fR is a number, then 
290 the VLAN tag is added or modified as necessary to match the value 
291 specified.  If \fIvlan_id\fR is \fBSTRIP\fR, then the VLAN tag is 
292 stripped from the packet if one is present.  (This action is not 
293 implemented by all OpenFlow switches.)
294 .RE
295
296 .IP
297 (The OpenFlow protocol supports other actions that \fBdpctl\fR does
298 not yet expose to the user.)
299
300 .PP
301 The \fBadd-flow\fR, \fBadd-flows\fR, and \fBdel-flows\fR commands
302 support an additional optional field:
303
304 .IP \fBpriority=\fIvalue\fR
305 Sets the priority of the flow to be added or deleted to \fIvalue\fR,
306 which should be a number between 0 and 65535, inclusive.  If this
307 field is not specified, it defaults to 32768.
308
309 .PP
310 The \fBadd-flow\fR and \fBadd-flows\fR commands support additional
311 optional fields:
312
313 .TP
314 \fBidle_timeout=\fIseconds\fR
315 Causes the flow to expire after the given number of seconds of
316 inactivity.  A value of 0 prevents a flow from expiring due to
317 inactivity.  The default is 60 seconds.
318
319 .IP \fBhard_timeout=\fIseconds\fR
320 Causes the flow to expire after the given number of seconds,
321 regardless of activity.  A value of 0 (the default) gives the flow no
322 hard expiration deadline.
323
324 .PP
325 The \fBdump-flows\fR and \fBdump-aggregate\fR commands support an
326 additional optional field:
327
328 .IP \fBtable=\fInumber\fR
329 If specified, limits the flows about which statistics are gathered to
330 those in the table with the given \fInumber\fR.  Tables are numbered
331 as shown by the \fBdump-tables\fR command.
332
333 If this field is not specified, or if \fInumber\fR is given as
334 \fB255\fR, statistics are gathered about flows from all tables.
335
336 .SH OPTIONS
337 .TP
338 \fB-t\fR, \fB--timeout=\fIsecs\fR
339 Limits \fBdpctl\fR runtime to approximately \fIsecs\fR seconds.  If
340 the timeout expires, \fBdpctl\fR will exit with a \fBSIGALRM\fR
341 signal.
342
343 .TP
344 \fB-p\fR, \fB--private-key=\fIprivkey.pem\fR
345 Specifies a PEM file containing the private key used as the
346 identity for SSL connections to a switch.
347
348 .TP
349 \fB-c\fR, \fB--certificate=\fIcert.pem\fR
350 Specifies a PEM file containing a certificate, signed by the
351 controller's certificate authority (CA), that certifies the
352 private key to identify a trustworthy controller.
353
354 .TP
355 \fB-C\fR, \fB--ca-cert=\fIcacert.pem\fR
356 Specifies a PEM file containing the CA certificate used to verify that
357 a switch is trustworthy.
358
359 .TP
360 .BR \-h ", " \-\^\-help
361 Prints a brief help message to the console.
362
363 .TP
364 \fB-v\fImodule\fR[\fB:\fIfacility\fR[\fB:\fIlevel\fR]], \fB--verbose=\fImodule\fR[\fB:\fIfacility\fR[\fB:\fIlevel\fR]]
365 Sets the logging level for \fImodule\fR in \fIfacility\fR to
366 \fIlevel\fR.  The \fImodule\fR may be any valid module name (as
367 displayed by the \fB--list\fR action on \fBvlogconf\fR(8)), or the
368 special name \fBANY\fR to set the logging levels for all modules.  The
369 \fIfacility\fR may be \fBsyslog\fR or \fBconsole\fR to set the levels
370 for logging to the system log or to the console, respectively, or
371 \fBANY\fR to set the logging levels for both facilities.  If it is
372 omitted, \fIfacility\fR defaults to \fBANY\fR.  The \fIlevel\fR must
373 be one of \fBemer\fR, \fBerr\fR, \fBwarn\fR, or \fBdbg\fR, designating
374 the minimum severity of a message for it to be logged.  If it is
375 omitted, \fIlevel\fR defaults to \fBdbg\fR.
376
377 .TP
378 \fB-v\fR, \fB--verbose\fR
379 Sets the maximum logging verbosity level, equivalent to
380 \fB--verbose=ANY:ANY:dbg\fR.
381
382 .TP
383 .BR \-V ", " \-\^\-version
384 Prints version information to the console.
385
386 .SH EXAMPLES
387
388 A typical dpctl command sequence for controlling an OpenFlow kernel module:
389 .nf
390 .TP
391 Create datapath numbered 0:
392
393 .B % dpctl adddp nl:0
394
395 .TP
396 Add two network devices to the new datapath:
397
398 .B % dpctl addif nl:0 eth0
399 .B % dpctl addif nl:0 eth1
400
401 .TP
402 Monitor traffic received by the datapath (exit with control-C):
403
404 .B % dpctl monitor nl:0
405
406
407 .TP
408 View the datapath's table stats after some traffic has passed through:
409
410 .B % dpctl dump-tables nl:0
411
412 .TP
413 View the flow entries in the datapath:
414
415 .B % dpctl dump-flows nl:0 
416
417 .TP
418 Remove network devices from the datapath when finished:
419
420 .B % dpctl delif nl:0 eth0
421 .B % dpctl delif nl:0 eth1
422
423 .TP
424 Delete the datapath:
425
426 .B % dpctl deldp nl:0
427 .fi
428 .SH "SEE ALSO"
429
430 .BR secchan (8),
431 .BR switch (8),
432 .BR controller (8),
433 .BR vlogconf (8)