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