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