ovsdb: optimize match_any_clause() condition evaluation
[cascardo/ovs.git] / utilities / ovs-ctl.8
1 .\" -*- nroff -*-
2 .de IQ
3 .  br
4 .  ns
5 .  IP "\\$1"
6 ..
7 .de ST
8 .  PP
9 .  RS -0.15in
10 .  I "\\$1"
11 .  RE
12 ..
13 .TH ovs\-ctl 8 "June 2011" "Open vSwitch" "Open vSwitch Manual"
14 .ds PN ovs\-ctl
15 .
16 .SH NAME
17 ovs\-ctl \- OVS startup helper script
18 .
19 .SH SYNOPSIS
20 \fBovs\-ctl\fR \fB\-\-system\-id=random\fR|\fIuuid\fR
21 [\fIoptions\fR] \fBstart
22 .br
23 \fBovs\-ctl stop
24 .br
25 \fBovs\-ctl\fR \fB\-\-system\-id=random\fR|\fIuuid\fR
26 [\fIoptions\fR] \fBrestart
27 .br
28 \fBovs\-ctl status
29 .br
30 \fBovs\-ctl version
31 .br
32 \fBovs\-ctl
33 [\fIoptions\fR]
34 \fBload\-kmod\fR
35 .br
36 \fBovs\-ctl
37 \fB\-\-system\-id=random\fR|\fIuuid\fR
38 [\fIoptions\fR]
39 \fBforce\-reload\-kmod\fR
40 .br
41 \fBovs\-ctl
42 \fR[\fB\-\-protocol=\fIprotocol\fR]
43 [\fB\-\-sport=\fIsport\fR]
44 [\fB\-\-dport=\fIdport\fR]
45 \fBenable\-protocol\fR
46 .br
47 \fBovs\-ctl help \fR| \fB\-h \fR| \fB\-\-help
48 .br
49 \fBovs\-ctl \-\-version
50 .
51 .SH DESCRIPTION
52 .
53 .PP
54 The \fBovs\-ctl\fR program starts, stops, and checks the status of
55 Open vSwitch daemons.  It is not meant to be invoked directly by
56 system administrators but to be called internally by system startup
57 scripts.
58 .
59 .PP
60 Each of \fBovs\-ctl\fR's commands is described separately below.
61 .
62 .SH "The ``start'' command"
63 .
64 .PP
65 The \fBstart\fR command starts Open vSwitch.  It performs the
66 following tasks:
67 .
68 .IP 1.
69 Loads the Open vSwitch kernel module.  If this fails, and the Linux
70 bridge module is loaded but no bridges exist, it tries to unload the
71 bridge module and tries loading the Open vSwitch kernel module again.
72 (This is because the Open vSwitch kernel module cannot coexist with
73 the Linux bridge module before 2.6.37.)
74 .
75 .PP
76 The \fBstart\fR command skips the following steps if
77 \fBovsdb\-server\fR is already running:
78 .IP 2.
79 If the Open vSwitch database file does not exist, it creates it.
80 If the database does exist, but it has an obsolete version, it
81 upgrades it to the latest schema.
82 .
83 .IP 3.
84 Starts \fBovsdb-server\fR, unless the \fB\-\-no\-ovsdb\-server\fR command
85 option is given.
86 .
87 .IP 4.
88 Initializes a few values inside the database.
89 .
90 .IP 5.
91 If the \fB\-\-delete\-bridges\fR option was used, deletes all of the
92 bridges from the database.
93 .
94 .IP 6.
95 If the \fB\-\-delete\-transient\-ports\fR option was used, deletes all ports
96 that have \fBother_config:transient\fR set to true.
97 .
98 .PP
99 The \fBstart\fR command skips the following step if
100 \fBovs\-vswitchd\fR is already running, or if the \fB\-\-no\-ovs\-vswitchd\fR
101 command option is given:
102 .IP 7.
103 Starts \fBovs\-vswitchd\fR.
104 .
105 .SS "Options"
106 .PP
107 Several command-line options influence the \fBstart\fR command's
108 behavior.  Some form of the following option should ordinarily be
109 specified:
110 .
111 .IP "\fB\-\-system\-id=\fIuuid\fR"
112 .IQ "\fB\-\-system\-id=random\fR"
113 This specifies a unique system identifier to store into
114 \fBexternal-ids:system-id\fR in the database's \fBOpen_vSwitch\fR
115 table.  Remote managers that talk to the Open vSwitch database server
116 over network protocols use this value to identify and distinguish Open
117 vSwitch instances, so it should be unique (at least) within OVS
118 instances that will connect to a single controller.
119 .IP
120 When \fBrandom\fR is specified, \fBovs\-ctl\fR will generate a random
121 ID that persists from one run to another (stored in a file).  When
122 another string is specified \fBovs\-ctl\fR uses it literally.
123 .
124 .PP
125 The following options should be specified if the defaults are not
126 suitable:
127 .
128 .IP "\fB\-\-system\-type=\fItype\fR"
129 .IQ "\fB\-\-system\-version=\fIversion\fR"
130 Sets the value to store in the \fBsystem-type\fR and
131 \fBsystem-version\fR columns, respectively, in the database's
132 \fBOpen_vSwitch\fR table.  Remote managers may use these values to
133 determine the kind of system to which they are connected (primarily
134 for display to human administrators).
135 .IP
136 When not specified, \fBovs\-ctl\fR uses values from the optional
137 \fBsystem\-type.conf\fR and \fBsystem\-version.conf\fR files(see section
138 \fBFILES\fR) or it uses the \fBlsb_release\fR program, if present, to
139 provide reasonable defaults.
140 .
141 .PP
142 The following options are also likely to be useful:
143 .
144 .IP "\fB\-\-external\-id=\(dq\fIname\fB=\fIvalue\fB\(dq"
145 Sets \fBexternal-ids:\fIname\fR to \fIvalue\fR in the database's
146 \fBOpen_vSwitch\fR table.  Specifying this option multiple times adds
147 multiple key-value pairs.
148 .
149 .IP "\fB\-\-delete\-bridges\fR"
150 Ordinarily Open vSwitch bridges persist from one system boot to the
151 next, as long as the database is preserved.  Some environments instead
152 expect to re-create all of the bridges and other configuration state
153 on every boot.  This option supports that, by deleting all Open
154 vSwitch bridges after starting \fBovsdb\-server\fR but before starting
155 \fBovs\-vswitchd\fR.
156 .
157 .IP "\fB\-\-delete\-transient\-ports\fR"
158 Deletes all ports that have the other_config:transient value set to true. This
159 is important on certain environments where some ports are going to be recreated
160 after reboot, but other ports need to be persisted in the database.
161 .
162 .PP
163 The following options are less important:
164 .
165 .IP "\fB\-\-daemon-cwd=\fIdirectory\fR"
166 Specifies the current working directory that the OVS daemons should
167 run from.  The default is \fB/\fR (the root directory) if this option
168 is not specified.  (This option is useful because most systems create
169 core files in a process's current working directory and because a file
170 system that is in use as a process's current working directory cannot
171 be unmounted.)
172 .
173 .IP "\fB\-\-no\-force\-corefiles\fR"
174 By default, \fBovs\-ctl\fR enables core dumps for the OVS daemons.
175 This option disables that behavior.
176 .
177 .IP "\fB\-\-no\-mlockall\fR"
178 By default \fBovs\-ctl\fR passes \fB\-\-mlockall\fR to
179 \fBovs\-vswitchd\fR, requesting that it lock all of its virtual
180 memory, preventing it from being paged to disk.  This option
181 suppresses that behavior.
182 .
183 .IP "\fB\-\-no\-self\-confinement\fR"
184 Disable self-confinement for \fBovs-vswitchd\fR and \fBovsdb\-server\fR
185 daemons.  This flag may be used when, for example, OpenFlow controller
186 creates its Unix Domain Socket outside OVS run directory and OVS needs
187 to connect to it.  It is better to stick with the default behavior and
188 not to use this flag, unless:
189 .
190 .RS
191 .IP \(bu
192 You have Open vSwitch running under SELinux or AppArmor Mandatory
193 Access Control that would prevent OVS from messing with sockets
194 outside ordinary OVS directories.
195 .
196 .IP \(bu
197 You believe that relying on protocol handshakes (e.g. OpenFlow)
198 is enough to prevent OVS to adversely interact with other daemons
199 running on your system.
200 .
201 .IP \(bu
202 You don't have much worries of remote OVSDB exploits in the first
203 place, because, perhaps, OVSDB manager is running on the same host
204 as OVS and share similar attack vectors.
205 .RE
206 .
207 .IP "\fB\-\-ovsdb\-server\-priority=\fIniceness\fR"
208 .IQ "\fB\-\-ovs\-vswitchd\-priority=\fIniceness\fR"
209 Sets the \fBnice\fR(1) level used for each daemon.  All of them
210 default to \fB\-10\fR.
211 .
212 .IP "\fB\-\-ovsdb\-server\-wrapper=\fIwrapper\fR"
213 .IQ "\fB\-\-ovs\-vswitchd\-wrapper=\fIwrapper\fR"
214 .
215 Configures the specified daemon to run under \fIwrapper\fR, which is
216 one of the following:
217 .
218 .RS
219 .IP "\fBvalgrind\fR"
220 Run the daemon under \fBvalgrind\fR(1), if it is installed, logging to
221 \fIdaemon\fB.valgrind.log.\fIpid\fR in the log directory.
222 .
223 .IP "\fBstrace\fR"
224 Run the daemon under \fBstrace\fR(1), if it is installed, logging to
225 \fIdaemon\fB.strace.log.\fIpid\fR in the log directory.
226 .
227 .IP "\fBglibc\fR"
228 Enable GNU C library features designed to find memory errors.
229 .RE
230 .
231 .IP
232 By default, no wrapper is used.
233 .
234 .IP
235 Each of the wrappers can expose bugs in Open vSwitch that lead to
236 incorrect operation, including crashes.  The \fBvalgrind\fR and
237 \fBstrace\fR wrappers greatly slow daemon operations so they should
238 not be used in production.  They also produce voluminous logs that can
239 quickly fill small disk partitions.  The \fBglibc\fR wrapper is less
240 resource-intensive but still somewhat slows the daemons.
241 .
242 .PP
243 The following options control file locations.  They should only be
244 used if the default locations cannot be used.  See \fBFILES\fR, below,
245 for more information.
246 .
247 .IP "\fB\-\-db\-file=\fIfile\fR"
248 Overrides the file name for the OVS database.
249 .
250 .IP "\fB\-\-db\-sock=\fIsocket\fR"
251 Overrides the file name for the Unix domain socket used to connect to
252 \fBovsdb\-server\fR.
253 .
254 .IP "\fB\-\-db\-schema=\fIschema\fR"
255 Overrides the file name for the OVS database schema.
256 .
257 .IP "\fB\-\-extra-dbs=\fIfile\fR"
258 Adds \fIfile\fR as an extra database for \fBovsdb\-server\fR to serve
259 out.  Multiple space-separated file names may also be specified.
260 \fIfile\fR should begin with \fB/\fR; if it does not, then it will be
261 taken as relative to \fIdbdir\fR.
262 .
263 .SH "The ``stop'' command"
264 .
265 .PP
266 The \fBstop\fR command does not unload the Open vSwitch kernel
267 modules. It can take the same \fB\-\-no\-ovsdb\-server\fR and
268 \fB\-\-no\-ovs\-vswitchd\fR options as that of the \fBstart\fR
269 command. 
270 .
271 .PP
272 This command does nothing and finishes successfully if the OVS daemons
273 aren't running.
274 .
275 .SH "The ``restart'' command"
276 .
277 .PP
278 The \fBrestart\fR command performs a \fBstop\fR followed by a \fBstart\fR
279 command.  The command can take the same options as that of the \fBstart\fR
280 command. In addition, it saves and restores OpenFlow flows for each
281 individual bridge.
282 .
283 .SH "The ``status'' command"
284 .
285 .PP
286 The \fBstatus\fR command checks whether the OVS daemons
287 \fBovs-vswitchd\fR and \fBovsdb\-server\fR are running and prints
288 messages with that information.  It exits with status 0 if
289 the daemons are running, 1 otherwise.
290 .
291 .SH "The ``version'' command"
292 .
293 .PP
294 The \fBversion\fR command runs \fBovsdb\-server \-\-version\fR and
295 \fBovs\-vswitchd \-\-version\fR.
296 .
297 .SH "The ``force\-reload\-kmod'' command"
298 .
299 .PP
300 The \fBforce\-reload\-kmod\fR command allows upgrading the Open
301 vSwitch kernel module without rebooting.  It performs the following
302 tasks:
303 .
304 .IP 1.
305 Gets a list of OVS ``internal'' interfaces, that is, network devices
306 implemented by Open vSwitch.  The most common examples of these are
307 bridge ``local ports''.
308 .
309 .IP 2.
310 Saves the OpenFlow flows of each bridge.
311 .
312 .IP 3.
313 Stops the Open vSwitch daemons, as if by a call to \fBovs\-ctl
314 stop\fR.
315 .
316 .IP 4.
317 Saves the kernel configuration state of the OVS internal interfaces
318 listed in step 1, including IP and IPv6 addresses and routing table
319 entries.
320 .
321 .IP 5.
322 Unloads the Open vSwitch kernel module (including the bridge
323 compatibility module if it is loaded).
324 .
325 .IP 6.
326 Starts OVS back up, as if by a call to \fBovs\-ctl start\fR.  This
327 reloads the kernel module, restarts the OVS daemons and finally
328 restores the saved OpenFlow flows.
329 .
330 .IP 7.
331 Restores the kernel configuration state that was saved in step 4.
332 .
333 .IP 8.
334 Checks for daemons that may need to be restarted because they have
335 packet sockets that are listening on old instances of Open vSwitch
336 kernel interfaces and, if it finds any, prints a warning on stdout.
337 DHCP is a common example: if the ISC DHCP client is running on an OVS
338 internal interface, then it will have to be restarted after completing
339 the above procedure.  (It would be nice if \fBovs\-ctl\fR could restart
340 daemons automatically, but the details are far too specific to a
341 particular distribution and installation.)
342 .
343 .PP
344 \fBforce\-kmod\-reload\fR internally stops and starts OVS, so it
345 accepts all of the options accepted by the \fBstart\fR command except
346 for the \fB\-\-no\-ovs\-vswitchd\fR option.
347 .
348 .SH "The ``load\-kmod'' command"
349 .
350 .PP
351 The \fBload\-kmod\fR command loads the openvswitch kernel modules if
352 they are not already loaded. This operation also occurs as part of
353 the \fBstart\fR command. The motivation for providing the \fBload\-kmod\fR
354 command is to allow errors when loading modules to be handled separatetly
355 from other errors that may occur when running the \fBstart\fR command.
356 .
357 .PP
358 By default the \fBload\-kmod\fR command attempts to load the
359 openvswitch kernel module.
360 .
361 .SH "The ``enable\-protocol'' command"
362 .
363 .PP
364 The \fBenable\-protocol\fR command checks for rules related to a
365 specified protocol in the system's \fBiptables\fR(8) configuration.  If there
366 are no rules specifically related to that protocol, then it inserts a
367 rule to accept the specified protocol.
368 .
369 .PP
370 More specifically:
371 .
372 .IP \(bu
373 If \fBiptables\fR is not installed or not enabled, this command does
374 nothing, assuming that lack of filtering means that the protocol is
375 enabled.
376 .
377 .IP \(bu
378 If the \fBINPUT\fR chain has a rule that matches the specified
379 protocol, then this command does nothing, assuming that whatever rule
380 is installed reflects the system administrator's decisions.
381 .
382 .IP \(bu
383 Otherwise, this command installs a rule that accepts traffic of the
384 specified protocol.
385 .
386 .PP
387 This command normally completes successfully, even if it does
388 nothing.  Only the failure of an attempt to insert a rule normally
389 causes it to return an exit code other than 0.
390 .
391 The following options control the protocol to be enabled:
392 .
393 .IP "\fB\-\-protocol=\fIprotocol\fR"
394 The name of the IP protocol to be enabled, such as \fBgre\fR or
395 \fBtcp\fR.  The default is \fBgre\fR.
396 .
397 .IP "\fB\-\-sport=\fIsport\fR"
398 .IQ "\fB\-\-dport=\fIdport\fR"
399 TCP or UDP source or destination port to match.  These are optional
400 and allowed only with \fB\-\-protocol=tcp\fR or
401 \fB\-\-protocol=udp\fR.
402 .
403 .SH "The ``help'' command"
404 .
405 Prints a usage message and exits successfully.
406 .
407 .SH "OPTIONS"
408 .PP
409 In addition to the options listed for each command above, these options
410 control the behavior of several of \fBovs\-ctl\fR's commands.
411 .
412 .PP
413 By default, \fBovs\-ctl\fR will control the \fBovsdb\-server\fR, and
414 the \fBovs\-vswitchd\fR daemons. The following options restrict that control
415 to exclude one or the other:
416 .
417 .IP "\fB\-\-no\-ovsdb-server\fR"
418 Specifies that the \fBovs\-ctl\fR commands \fBstart\fR, \fBstop\fR, and
419 \fBrestart\fR should not modify the running status of \fBovsdb\-server\fR.
420 .
421 .IP "\fB\-\-no\-ovs\-vswitchd\fR"
422 Specifies that the \fBovs\-ctl\fR commands \fBstart\fR, \fBstop\fR, and
423 \fBrestart\fR should not modify the running status of \fBovs\-vswitchd\fR.
424 It is an error to include this option with the \fBforce\-reload\-kmod\fR
425 command.
426 .
427 .SH "EXIT STATUS"
428 .
429 \fBovs\-ctl\fR exits with status 0 on success and nonzero on failure.
430 The \fBstart\fR command is considered to succeed if OVS is already
431 started; the \fBstop\fR command is considered to succeed if OVS is
432 already stopped.
433 .
434 .SH "ENVIRONMENT"
435 .
436 The following environment variables affect \fBovs\-ctl\fR:
437 .
438 .IP "\fBPATH\fR"
439 \fBovs\-ctl\fR does not hardcode the location of any of the programs
440 that it runs.  \fBovs\-ctl\fR will add the \fIsbindir\fR and
441 \fIbindir\fR that were specified at \fBconfigure\fR time to
442 \fBPATH\fR, if they are not already present.
443 .
444 .IP "\fBOVS_LOGDIR\fR"
445 .IQ "\fBOVS_RUNDIR\fR"
446 .IQ "\fBOVS_DBDIR\fR"
447 .IQ "\fBOVS_SYSCONFDIR\fR"
448 .IQ "\fBOVS_PKGDATADIR\fR"
449 .IQ "\fBOVS_BINDIR\fR"
450 .IQ "\fBOVS_SBINDIR\fR"
451 Setting one of these variables in the environment overrides the
452 respective \fBconfigure\fR option, both for \fBovs\-ctl\fR itself and
453 for the other Open vSwitch programs that it runs.
454 .
455 .SH "FILES"
456 .
457 \fBovs\-ctl\fR uses the following files:
458 .
459 .IP "\fBovs\-lib"
460 Shell function library used internally by \fBovs\-ctl\fR.  It must be
461 installed in the same directory as \fBovs\-ctl\fR.
462 .
463 .IP "\fIlogdir\fB/\fIdaemon\fB.log\fR"
464 Per-daemon logfiles.
465 .
466 .IP "\fIrundir\fB/\fIdaemon\fB.pid\fR"
467 Per-daemon pidfiles to track whether a daemon is running and with what
468 process ID.
469 .
470 .IP "\fIpkgdatadir\fB/vswitch.ovsschema\fR"
471 The OVS database schema used to initialize the database (use
472 \fB\-\-db\-schema to override this location).
473 .
474 .IP "\fIdbdir\fB/conf.db\fR"
475 The OVS database (use \fB\-\-db\-file\fR to override this location).
476 .
477 .IP "\fIrundir\fB/openvswitch/db.sock\fR"
478 The Unix domain socket used for local communication with
479 \fBovsdb\-server\fR (use \fB\-\-db\-sock\fR to override this
480 location).
481 .
482 .IP "\fIsysconfdir\fB/openvswitch/system-id.conf\fR"
483 The persistent system UUID created and read by
484 \fB\-\-system\-id=random\fR.
485 .
486 .IP "\fIsysconfdir\fB/openvswitch/system\-type.conf\fR"
487 .IQ "\fIsysconfdir\fB/openvswitch/system\-version.conf\fR"
488 The \fBsystem\-type\fR  and \fBsystem\-version\fR values stored in the database's
489 \fBOpen_vSwitch\fR table when not specified as a command-line option.
490 .
491 .SH "EXAMPLE"
492 .
493 .PP
494 The files \fBdebian/openvswitch\-switch.init\fR and
495 \fBxenserver/etc_init.d_openvswitch\fR in the Open vSwitch source
496 distribution are good examples of how to use \fBovs\-ctl\fR.
497 .
498 .SH "SEE ALSO"
499 .
500 \fBREADME.md\fR, \fBINSTALL.Linux.md\fR, \fBovsdb\-server\fR(8),
501 \fBovs\-vswitchd\fR(8).