]> git.proxmox.com Git - ovs.git/blame - lib/ovs-actions.xml
ovs-actions: Fix sentence.
[ovs.git] / lib / ovs-actions.xml
CommitLineData
be51cd41
BP
1<?xml version="1.0" encoding="utf-8"?>
2<actions>
3 <h1>Introduction</h1>
4
5 <p>
6 This document aims to comprehensively document all of the OpenFlow actions
7 and instructions, both standard and non-standard, supported by Open
8 vSwitch, regardless of origin. The document includes information of
9 interest to Open vSwitch users, such as the semantics of each supported
10 action and the syntax used by Open vSwitch tools, and to developers seeking
11 to build controllers and switches compatible with Open vSwitch, such as the
12 wire format for each supported message.
13 </p>
14
15 <h2>Actions</h2>
16
17 <p>
18 In this document, we define an <dfn>action</dfn> as an OpenFlow action,
19 which is a kind of command that specifies what to do with a packet.
20 Actions are used in OpenFlow flows to describe what to do when the flow
21 matches a packet, and in a few other places in OpenFlow. Each version of
22 the OpenFlow specification defines standard actions, and beyond that many
23 OpenFlow switches, including Open vSwitch, implement extensions to the
24 standard.
25 </p>
26
27 <p>
28 OpenFlow groups actions in two ways: as an <dfn>action list</dfn> or an
29 <dfn>action set</dfn>, described below.
30 </p>
31
32 <h3>Action Lists</h3>
33
34 <p>
35 An <dfn>action list</dfn>, a concept present in every version of OpenFlow,
36 is simply an ordered sequence of actions. The OpenFlow specifications
37 require a switch to execute actions within an action list in the order
38 specified, and to refuse to execute an action list entirely if it cannot
39 implement the actions in that order [OpenFlow 1.0, section 3.3], with one
40 exception: when an action list outputs multiple packets, the switch may
41 output the packets in an order different from that specified. Usually,
42 this exception is not important, especially in the common case when the
43 packets are output to different ports.
44 </p>
45
46 <h3>Action Sets</h3>
47
48 <p>
49 OpenFlow 1.1 introduced the concept of an <dfn>action set</dfn>. An action
50 set is also a sequence of actions, but the switch reorders the actions and
51 drops duplicates according to rules specified in the OpenFlow
52 specifications. Because of these semantics, some standard OpenFlow actions
53 cannot usefully be included in an action set. For some, but not all, Open
54 vSwitch extension actions, Open vSwitch defines its own action set
55 semantics and ordering.
56 </p>
57
58 <p>
59 The OpenFlow pipeline has an action set associated with it as a packet is
60 processed. After pipeline processing is otherwise complete, the switch
61 executes the actions in the action set.
62 </p>
63
64 <p>
65 Open vSwitch applies actions in an action set in the following order:
66 Except as noted otherwise below, the action set only executes at most a
67 single action of each type, and when more than one action of a given type
68 is present, the one added to the set later replaces the earlier action:
69 </p>
70
71 <ol>
72 <li><code>strip_vlan</code></li>
73 <li><code>pop_mpls</code></li>
74 <li><code>decap</code></li>
75 <li><code>encap</code></li>
76 <li><code>push_mpls</code></li>
77 <li><code>push_vlan</code></li>
78 <li><code>dec_ttl</code></li>
79 <li><code>dec_mpls_ttl</code></li>
80 <li><code>dec_nsh_ttl</code></li>
81 <li>
82 <p>
83 All of the following actions are executed in the order added to the
84 action set, with cumulative effect. That is, when multiple actions
85 modify the same part of a field, the later modification takes effect,
86 and when they modify different parts of a field (or different fields),
87 then both modifications are applied:
88 </p>
89
90 <ul>
91 <li><code>load</code></li>
92 <li><code>move</code></li>
93 <li><code>mod_dl_dst</code></li>
94 <li><code>mod_dl_src</code></li>
95 <li><code>mod_nw_dst</code></li>
96 <li><code>mod_nw_src</code></li>
97 <li><code>mod_nw_tos</code></li>
98 <li><code>mod_nw_ecn</code></li>
99 <li><code>mod_nw_ttl</code></li>
100 <li><code>mod_tp_dst</code></li>
101 <li><code>mod_tp_src</code></li>
102 <li><code>mod_vlan_pcp</code></li>
103 <li><code>mod_vlan_vid</code></li>
104 <li><code>set_field</code></li>
105 <li><code>set_tunnel</code></li>
106 <li><code>set_tunnel64</code></li>
107 </ul>
108 </li>
109 <li><code>set_queue</code></li>
110 <li>
111 <code>group</code>, <code>output</code>, <code>resubmit</code>,
112 <code>ct_clear</code>, or <code>ct</code>. If more than one of these
113 actions is present, then the one listed earliest above is executed and
114 the others are ignored, regardless of the order in which they were added
115 to the action set. (If none of these actions is present, the action set
116 has no real effect, because the modified packet is not sent anywhere and
117 thus the modifications are not visible.)
118 </li>
119 </ol>
120
121 <p>
122 An action set may only contain the actions listed above.
123 </p>
124
125 <h2>Error Handling</h2>
126
127 <p>
128 Packet processing can encounter a variety of errors:
129 </p>
130
131 <dl>
132 <dt>Bridge not found</dt>
133 <dd>
134 <p>
135 Open vSwitch supports an extension to the standard OpenFlow
136 <code>controller</code> action called a ``continuation,'' which allows
137 the controller to interrupt and later resume the processing of a packet
138 through the switch pipeline. This error occurs when such a packet's
139 processing cannot be resumed, e.g. because the bridge processing it has
140 been destroyed. Open vSwitch reports this error to the controller as
141 Open vSwitch extension error <code>NXR_STALE</code>.
142 </p>
143
144 <p>
145 This error prevents packet processing entirely.
146 </p>
147 </dd>
148
149 <dt>Recursion too deep</dt>
150 <dd>
151 <p>
152 While processing a given packet, Open vSwitch limits the flow table
153 recursion depth to 64, to ensure that packet processing uses a finite
154 amount of time and space. Actions that count against the recursion
155 limit include <code>resubmit</code> from a given OpenFlow table to the
156 same or an earlier table, <code>group</code>, and <code>output</code>
157 to patch ports.
158 </p>
159
160 <p>
161 A <code>resubmit</code> from one table to a later one (or,
162 equivalently. a <code>goto_table</code> instruction) does not count
163 against the depth limit because resubmits to strictly monotonically
164 increasing tables will eventually terminate. OpenFlow tables are most
165 commonly traversed in numerically increasing order, so this limit has
166 little effect on conventionally designed OpenFlow pipelines.
167 </p>
168
169 <p>
170 This error terminates packet processing. Any previous side effects
171 (e.g. output actions) are retained.
172 </p>
173
174 <p>
175 Usually this error indicates a loop or other bug in the OpenFlow flow
176 tables. To assist debugging, when this error occurs, Open vSwitch 2.10
177 and later logs a trace of the packet execution, as if by
178 <code>ovs-appctl ofproto/trace</code>, rate-limited to one per minute
179 to reduce the log volume.
180 </p>
181 </dd>
182
183 <dt>Too many resubmits</dt>
184 <dd>
185 <p>
186 Open vSwitch limits the total number of <code>resubmit</code> actions
187 that a given packet can execute to 4,096. For this purpose,
188 <code>goto_table</code> instructions and output to the
189 <code>table</code> port are treated like <code>resubmit</code>. This
190 limits the amount of time to process a single packet.
191 </p>
192
193 <p>
194 Unlike the limit on recursion depth, the limit on resubmits counts all
195 resubmits, regardless of direction.
196 </p>
197
198 <p>
199 This error has the same effect, including logging, as exceeding the
200 recursion depth limit.
201 </p>
202 </dd>
203
204 <dt>Stack too deep</dt>
205 <dd>
206 <p>
207 Open vSwitch limits the amount of data that the <code>push</code>
208 action can put onto the stack at one time to 64 kB of data.
209 </p>
210
211 <p>
212 This error terminates packet processing. Any previous side effects
213 (e.g. output actions) are retained.
214 </p>
215 </dd>
216
217 <dt>No recirculation context</dt>
218 <dt>Recirculation conflict</dt>
219 <dd>
220 These errors indicate internal errors inside Open vSwitch and should
221 generally not occur. If you notice recurring log messages about these
222 errors, please report a bug.
223 </dd>
224
225 <dt>Too many MPLS labels</dt>
226 <dd>
227 <p>
228 Open vSwitch can process packets with any number of MPLS labels, but
229 its ability to push and pop MPLS labels is limited, currently to 3
230 labels. Attempting to push more than the supported number of labels
231 onto a packet, or to pop any number of labels from a packet with more
232 than the supported number, raises this error.
233 </p>
234
235 <p>
236 This error terminates packet processing, retaining any previous side
237 effects (e.g. output actions). When this error arises within the
238 execution of a group bucket, it only terminates that bucket's
239 execution, not packet processing overall.
240 </p>
241 </dd>
242
243 <dt>Invalid tunnel metadata</dt>
244 <dd>
245 <p>
246 Open vSwitch raises this error when it processes a Geneve packet that
247 has TLV options with an invalid form, e.g. where the length in a TLV
248 would extend past the end of the options.
249 </p>
250
251 <p>
252 This error prevents packet processing entirely.
253 </p>
254 </dd>
255
256 <dt>Unsupported packet type</dt>
257 <dd>
258 <p>
259 When a <code>encap</code> action encapsulates a packet, Open vSwitch
260 raises this error if it does not support the combination of the new
261 encapsulation with the current packet. <code>encap(ethernet)</code>
262 raises this error if the current packet is not an L3 packet, and
263 <code>encap(nsh)</code> raises this error if the current packet is not
264 Ethernet, IPv4, IPv6, or NSH.
265 </p>
266
267 <p>
268 When a <code>decap</code> action decapsulates a packet, Open vSwitch
269 raises this error if it does not support the type of inner packet.
270 <code>decap</code> of an Ethernet header raises this error if a VLAN
271 header is present, <code>decap</code> of a NSH packet raises this error
272 if the NSH inner packet is not Ethernet, IPv4, IPv6, or NSH, and
273 <code>decap</code> of other types of packets is unsupported and also
274 raises this error.
275 </p>
276
277 <p>
278 This error terminates packet processing, retaining any previous side
279 effects (e.g. output actions). When this error arises within the
280 execution of a group bucket, it only terminates that bucket's
281 execution, not packet processing overall.
282 </p>
283 </dd>
284 </dl>
285
286 <h2>Inconsistencies</h2>
287
288 <p>
289 OpenFlow 1.0 allows any action to be part of any flow, regardless of the
290 flow's match. Some combinations do not make sense, e.g. an
291 <code>set_nw_tos</code> action in a flow that matches only ARP packets or
292 <code>strip_vlan</code> in a flow that matches packets without VLAN tags.
293 Other combinations have varying results depending on the kind of packet
294 that the flow processes, e.g. a <code>set_nw_src</code> action in a flow
295 that does not match on Ethertype will be treated as a no-op when it
296 processes a non-IPv4 packet. Nevertheless OVS allows all of the above in
297 conformance with OpenFlow 1.0, that is, the following will succeed:
298 </p>
299
300 <pre>
301$ ovs-ofctl -O OpenFlow10 add-flow br0 arp,actions=mod_nw_tos:12
302$ ovs-ofctl -O OpenFlow10 add-flow br0 dl_vlan=0xffff,actions=strip_vlan
303$ ovs-ofctl -O OpenFlow10 add-flow br0 actions=mod_nw_src:1.2.3.4
304 </pre>
305
306 <p>
307 Open vSwitch calls these kinds of combinations <dfn>inconsistencies</dfn>
308 between match and actions. OpenFlow 1.1 and later forbid inconsistencies,
309 and disallow the examples described above by preventing such flows from
310 being added. All of the above, for example, will fail with an error
311 message if one replaces <code>OpenFlow10</code> by <code>OpenFlow11</code>.
312 </p>
313
314 <p>
315 OpenFlow 1.1 and later cannot detect and disallow all inconsistencies. For
316 example, the <code>write_actions</code> instruction arbitrarily delays
317 execution of the actions inside it, which can even be canceled with
318 <code>clear_actions</code>, so that there is no way to ensure that its
319 actions are consistent with the packet at the time they execute. Thus,
320 actions with <code>write_actions</code> and some other contexts are exempt
321 from consistency requirements.
322 </p>
323
324 <p>
325 When OVS executes an action inconsistent with the packet, it treats it as a
326 no-op.
327 </p>
328
329 <h2>Inter-Version Compatibility</h2>
330
331 <p>
332 Open vSwitch supports multiple OpenFlow versions simultaneously on a single
333 switch. When actions are added with one OpenFlow version and then
334 retrieved with another, Open vSwitch does its best to translate between
335 them.
336 </p>
337
338 <p>
339 Inter-version compatibility issues can still arise when different
340 connections use different OpenFlow versions. Backward compatibility is the
341 most obvious case. Suppose, for example, that an OpenFlow 1.1 session adds
342 a flow with a <code>push_vlan</code> action, for which there is no
343 equivalent in OpenFlow 1.0. If an OpenFlow 1.0 session retrieves this
344 flow, Open vSwitch must somehow represent the action.
345 </p>
346
347 <p>
348 Forward compatibility can also be an issue, because later OpenFlow versions
349 sometimes remove functionality. The best example is the
350 <code>enqueue</code> action from OpenFlow 1.0, which OpenFlow 1.1 removed.
351 </p>
352
353 <p>
354 In practice, Open vSwitch uses a variety of strategies for inter-version
355 compatibility:
356 </p>
357
358 <ul>
359 <li>
360 Most standard OpenFlow actions, such as <code>output</code> actions,
361 translate without compatibility issues.
362 </li>
363
364 <li>
365 Open vSwitch supports its extension actions in every OpenFlow version, so
366 they do not pose inter-version compatibility problems.
367 </li>
368
369 <li>
370 Open vSwitch sometimes adds extension actions to ensure backward or
371 forward compatibility. For example, for backward compatibility with the
372 <code>group</code> action added in OpenFlow 1.1, Open vSwitch includes
373 an OpenFlow 1.0 extension <code>group</code> action.
374 </li>
375 </ul>
376
377 <p>
378 Perfect inter-version compatibility is not possible, so best results
379 require OpenFlow connections to use a consistent version. One may enforce
380 use of a particular version by setting the <code>protocols</code> column
381 for a bridge, e.g. to force <code>br0</code> to use only OpenFlow 1.3:
382 </p>
383
384 <pre>
385 ovs-vsctl set bridge br0 protocols=OpenFlow13
386 </pre>
387
388 <h2>Field Specifications</h2>
389
390 <p>
391 Many Open vSwitch actions refer to fields. In such cases, fields may
392 usually be referred to by their common names, such as <code>eth_dst</code>
393 for the Ethernet destination field, or by their full OXM or NXM names, such
394 as <code>NXM_OF_ETH_DST</code> or <code>OXM_OF_ETH_DST</code>. Before Open
395 vSwitch 2.7, only OXM or NXM field names were accepted.
396 </p>
397
398 <p>
399 Many actions that act on fields can also act on <dfn>subfields</dfn>, that
400 is, parts of fields, written as
401 <code><var>field</var>[<var>start</var>..<var>end</var>]</code>, where
402 <var>start</var> is the first bit and <var>end</var> is the last bit to use
403 in <var>field</var>, e.g. <code>vlan_tci[13..15]</code> for the VLAN PCP.
404 A single-bit subfield may also be written as
405 <code><var>field</var>[<var>offset</var>]</code>,
406 e.g. <code>vlan_tci[13]</code> for the least-significant bit of the VLAN
407 PCP. Empty brackets may be used to explicitly designate an entire field,
408 e.g. <code>vlan_tci[]</code> for the entire 16-bit VLAN TCI header. Before
409 Open vSwitch 2.7, brackets were required in field specifications.
410 </p>
411
412 <p>
413 See <code>ovs-fields</code>(7) for a list of fields and their names.
414 </p>
415
416 <h2>Port Specifications</h2>
417
418 <p>
419 Many Open vSwitch actions refer to OpenFlow ports. In such cases, the port
420 may be specified as a numeric port number in the range 0 to 65,535,
421 although Open vSwitch only assigns port numbers in the range 1 through
422 62,279 to ports. OpenFlow 1.1 and later use 32-bit port numbers, but Open
423 vSwitch never assigns a port number that requires more than 16 bits.
424 </p>
425
426 <p>
427 In most contexts, the name of a port may also be used. (The most obvious
428 context where a port name may not be used is in an <code>ovs-ofctl</code>
429 command along with the <code>--no-names</code> option.) When a port's name
430 contains punctuation or could be ambiguous with other actions, the name may
431 be enclosed in double quotes, with JSON-like string escapes supported (see
432 [RFC 8259]).
433 </p>
434
435 <p>
436 Open vSwitch also supports the following standard OpenFlow port names (even
437 in contexts where port names are not otherwise supported). The
438 corresponding OpenFlow 1.0 and 1.1+ port numbers are listed alongside them
439 but should not be used in flow syntax:
440 </p>
441
442 <ul>
443 <li><code>in_port</code> (65528 or 0xfff8; 0xfffffff8)</li>
444 <li><code>table</code> (65529 or 0xfff9; 0xfffffff9)</li>
445 <li><code>normal</code> (65530 or 0xfffa; 0xfffffffa)</li>
446 <li><code>flood</code> (65531 or 0xfffb; 0xfffffffb)</li>
447 <li><code>all</code> (65532 or 0xfffc; 0xfffffffc)</li>
448 <li><code>controller</code> (65533 or 0xfffd; 0xfffffffd)</li>
449 <li><code>local</code> (65534 or 0xfffe; 0xfffffffe)</li>
450 <li><code>any</code> or <code>none</code> (65535 or 0xffff; 0xffffffff)</li>
451 <li><code>unset</code> (not in OpenFlow 1.0; 0xfffffff7)</li>
452 </ul>
453
454 <!-- What about OVS version compatibility as opposed to OF version -->
455
456 <group title="Output Actions">
457 <p>
458 These actions send a packet to a physical port or a controller. A packet
459 that never encounters an output action on its trip through the Open
460 vSwitch pipeline is effectively dropped. Because actions are executed in
461 order, a packet modification action that is not eventually followed by an
462 output action will not have an externally visible effect.
463 </p>
464
465 <action name="OUTPUT, OUTPUT_REG, OUTPUT_TRUNC">
466 <h2>The <code>output</code> action</h2>
467 <syntax><var>port</var></syntax>
468 <syntax><code>output:</code><var>port</var></syntax>
469 <syntax><code>output:<var>field</var></code></syntax>
470 <syntax><code>output(port=<var>port</var>, max_len=<var>nbytes</var>)</code></syntax>
471
472 <p>
473 Outputs the packet to an OpenFlow port most commonly specified as
474 <var>port</var>. Alternatively, the output port may be read from
475 <var>field</var>, a field or subfield in the syntax described under
476 ``Field Specifications'' above. Either way, if the port is the
477 packet's input port, the packet is not output.
478 </p>
479
480 <p>
481 The port may be one of the following standard OpenFlow ports:
482 </p>
483
484 <dl>
485 <dt><code>local</code></dt>
486 <dd>
487 Outputs the packet on the ``local port'' that corresponds to the
488 network device that has the same name as the bridge, unless the
489 packet was received on the local port. OpenFlow switch
490 implementations are not required to have a local port, but Open
491 vSwitch bridges always do.
492 </dd>
493
494 <dt><code>in_port</code></dt>
495 <dd>
496 Outputs the packet on the port on which it was received. This is the
497 only standard way to output the packet to the input port (but see
498 ``Output to the Input port'', below).
499 </dd>
500 </dl>
501
502 <p>
503 The port may also be one of the following additional OpenFlow ports,
504 unless <code>max_len</code> is specified:
505 </p>
506
507 <dl>
508 <dt><code>normal</code></dt>
509 <dd>
510 Subjects the packet to the device's normal L2/L3 processing. This
511 action is not implemented by all OpenFlow switches, and each switch
512 implements it differently.
513 </dd>
514
515 <dt><code>flood</code></dt>
516 <dd>
517 Outputs the packet on all switch physical ports, except the port on
518 which it was received and any ports on which flooding is disabled.
519 Flooding can be disabled automatically on a port by Open vSwitch when
520 IEEE 802.1D spanning tree (STP) or rapid spanning tree (RSTP) is
521 enabled, or by a controller using an OpenFlow
522 <code>OFPT_MOD_PORT</code> request to set the port's
523 <code>OFPPC_NO_FLOOD</code> flag (<code>ovs-ofctl mod-port</code>
524 provides a command-line interface to set this flag).
525 </dd>
526
527 <dt><code>all</code></dt>
528 <dd>
529 Outputs the packet on all switch physical ports except the port on
530 which it was received.
531 </dd>
532
533 <dt><code>controller</code></dt>
534 <dd>
4272c604 535 Sends the packet and its metadata to an OpenFlow controller or
be51cd41
BP
536 controllers encapsulated in an OpenFlow ``packet-in'' message. The
537 separate <code>controller</code> action, described below, provides
538 more options for output to a controller.
539 </dd>
540 </dl>
541
542 <p>
543 Open vSwitch rejects output to other standard OpenFlow ports, including
544 <code>none</code>, <code>unset</code>, and port numbers reserved for
545 future use as standard ports, with the error
546 <code>OFPBAC_BAD_OUT_PORT</code>.
547 </p>
548
549 <p>
550 With <var>max_len</var>, the packet is truncated to at most
551 <var>nbytes</var> bytes before being output. In this case, the output
552 port may not be a patch port. Truncation is just for the single output
553 action, so that later actions in the OpenFlow pipeline work with the
554 complete packet. The truncation feature is meant for use in monitoring
555 applications, e.g. for mirroring packets to a collector.
556 </p>
557
558 <p>
559 When an <code>output</code> action specifies the number of a port that
560 does not currently exist (and is not in the range for standard ports),
561 the OpenFlow specification allows but does not require OVS to reject
562 the action. All versions of Open vSwitch treat such an action as a
563 no-op. If a port with the number is created later, then the action
564 will be honored at that point. (OpenFlow requires OVS to reject output
565 to a port number that will never be valid, with
566 <code>OFPBAC_BAD_OUT_PORT</code>, but this situation does not arise
567 when OVS is a software switch, since the user can add or renumber ports
568 at any time.)
569 </p>
570
571 <p>
572 A controller can suppress output to a port by setting its
573 <code>OFPPC_NO_FORWARD</code> flag using an OpenFlow
574 <code>OFPT_MOD_PORT</code> request (<code>ovs-ofctl mod-port</code>
575 provides a command-line interface to set this flag). When output is
576 disabled, <code>output</code> actions (and other actions that output to
577 the port) are allowed but have no effect.
578 </p>
579
580 <p>
581 Open vSwitch allows output to a port that does not exist, although
582 OpenFlow allows switches to reject such actions.
583 </p>
584
585 <!-- XXX output to normal details -->
586 <!-- XXX output to patch ports details -->
587
588 <h3>Output to the Input Port</h3>
589
590 <p>
591 OpenFlow requires a switch to ignore attempts to send a packet out its
592 ingress port in the most straightforward way. For example,
593 <code>output:234</code> has no effect if the packet has ingress port
594 234. The rationale is that dropping these packets makes it harder to
595 loop the network. Sometimes this behavior can even be convenient,
596 e.g. it is often the desired behavior in a flow that forwards a packet
597 to several ports (``floods'' the packet).
598 </p>
599
600 <p>
601 Sometimes one really needs to send a packet out its ingress port
602 (``hairpin''). In this case, use <code>in_port</code> to explicitly
603 output the packet to its input port, e.g.:
604 </p>
605
606 <pre>
607 $ ovs-ofctl add-flow br0 in_port=2,actions=in_port
608 </pre>
609
610 <p>
611 This also works in some circumstances where the flow doesn't match on
612 the input port. For example, if you know that your switch has five
613 ports numbered 2 through 6, then the following will send every received
614 packet out every port, even its ingress port:
615 </p>
616
617 <pre>
618 $ ovs-ofctl add-flow br0 actions=2,3,4,5,6,in_port
619 </pre>
620
621 <p>
622 or, equivalently:
623 </p>
624
625 <pre>
626 $ ovs-ofctl add-flow br0 actions=all,in_port
627 </pre>
628
629 <p>
630 Sometimes, in complicated flow tables with multiple levels of
631 <code>resubmit</code> actions, a flow needs to output to a particular
632 port that may or may not be the ingress port. It's difficult to take
633 advantage of output to <code>in_port</code> in this situation. To
634 help, Open vSwitch provides, as an OpenFlow extension, the ability to
635 modify the <code>in_port</code> field. Whatever value is currently in
636 the <code>in_port</code> field is both the port to which output will be
637 dropped and the destination for <code>in_port</code>. This means that
638 the following adds flows that reliably output to port 2 or to ports 2
639 through 6, respectively:
640 </p>
641
642 <pre>
643 $ ovs-ofctl add-flow br0 "in_port=2,actions=load:0-&gt;in_port,2"
644 $ ovs-ofctl add-flow br0 "actions=load:0-&gt;in_port,2,3,4,5,6"
645 </pre>
646
647 <p>
648 If <code>in_port</code> is important for matching or other reasons, one
649 may save and restore it on the stack:
650 </p>
651
652 <pre>
653 $ ovs-ofctl add-flow br0 actions="push:in_port,\
654 load:0-&gt;in_port,\
655 2,3,4,5,6,\
656 pop:in_port"
657 </pre>
658
659 <conformance>
660 All versions of OpenFlow and Open vSwitch support <code>output</code>
661 to a literal <var>port</var>. Output to a register is an OpenFlow
662 extension introduced in Open vSwitch 1.3. Output with truncation is an
663 OpenFlow extension introduced in Open vSwitch 2.6.
664 </conformance>
665 </action>
666
667 <action name="CONTROLLER">
668 <h2>The <code>controller</code> action</h2>
669 <syntax><code>controller</code></syntax>
670 <syntax><code>controller:</code><var>max_len</var></syntax>
671 <syntax><code>controller(</code><var>key</var>[<code>=</code><var>value</var>]<code>,</code> ...<code>)</code></syntax>
672
673 <p>
674 Sends the packet and its metadata to an OpenFlow controller or
675 controllers encapsulated in an OpenFlow ``packet-in'' message. The
676 supported options are:
677 </p>
678
679 <dl>
680 <dt><code>max_len=</code><var>max_len</var></dt>
681 <dd>
682 <p>
683 Limit to <var>max_len</var> the number of bytes of the packet to
684 send in the ``packet-in.'' A <var>max_len</var> of 0 prevents any
685 of the packet from being sent (thus, only metadata is included).
686 By default, the entire packet is sent, equivalent to a
687 <var>max_len</var> of 65535.
688 </p>
689 </dd>
690
691 <dt><code>reason=</code><var>reason</var></dt>
692 <dd>
693 Specify <var>reason</var> as the reason for sending the message in
694 the ``packet-in.'' The supported reasons are <code>no_match</code>,
695 <code>action</code>, <code>invalid_ttl</code>,
696 <code>action_set</code>, <code>group</code>, and
697 <code>packet_out</code>. The default reason is <code>action</code>.
698 </dd>
699
700 <dt><code>id=</code><var>controller_id</var></dt>
701 <dd>
1705b8b3 702 Specify <var>controller_id</var>, a 16-bit integer, as the connection
be51cd41
BP
703 ID of the OpenFlow controller or controllers to which the
704 ``packet-in'' message should be sent. The default is zero. Zero is
705 also the default connection ID for each controller connection, and a
706 given controller connection will only have a nonzero connection ID if
707 its controller uses the <code>NXT_SET_CONTROLLER_ID</code> Open
708 vSwitch extension to OpenFlow.
709 </dd>
710
711 <dt><code>userdata=</code><var>hh</var>...</dt>
712 <dd>
713 Supplies the bytes represented as hex digits <var>hh</var> as
714 additional data to the controller in the ``packet-in'' message.
715 Pairs of hex digits may be separated by periods for readability.
716 </dd>
717
718 <dt><code>pause</code></dt>
719 <dd>
720 Causes the switch to freeze the packet's trip through Open vSwitch
721 flow tables and serializes that state into the packet-in message as a
722 ``continuation,'' an additional property in the
723 <code>NXT_PACKET_IN2</code> message. The controller can later send
724 the continuation back to the switch in an <code>NXT_RESUME</code>
725 message, which will restart the packet's traversal from the point
726 where it was interrupted. This permits an OpenFlow controller to
727 interpose on a packet midway through processing in Open vSwitch.
728 </dd>
729 </dl>
730
731 <conformance>
732 All versions of OpenFlow and Open vSwitch support
733 <code>controller</code> action and its <code>max_len</code> option.
734 The <code>userdata</code> and <code>pause</code> options require the
735 Open vSwitch <code>NXAST_CONTROLLER2</code> extension action added in
736 Open vSwitch 2.6. In the absence of these options, the
737 <var>reason</var> (other than <code>reason=action</code>) and
738 <var>controller_id</var> (option than <code>controller_id=0</code>)
739 options require the Open vSwitch <code>NXAST_CONTROLLER</code>
740 extension action added in Open vSwitch 1.6.
741 </conformance>
742 </action>
743
744 <action name="ENQUEUE">
745 <h2>The <code>enqueue</code> action</h2>
746 <syntax><code>enqueue(</code><var>port</var><code>,</code><var>queue</var><code>)</code></syntax>
747 <syntax><code>enqueue:</code><var>port</var><code>:</code><var>queue</var></syntax>
748
749 <p>
750 Enqueues the packet on the specified <var>queue</var> within port
751 <var>port</var>.
752 </p>
753
754 <p>
755 <var>port</var> must be an OpenFlow port number or name as described
756 under ``Port Specifications'' above. <var>port</var> may be
757 <code>in_port</code> or <code>local</code> but the other standard
758 OpenFlow ports are not allowed.
759 </p>
760
761 <p>
762 <var>queue</var> must be a a number between 0 and 4294967294
763 (0xfffffffe), inclusive. The number of actually supported queues
764 depends on the switch. Some OpenFlow implementations do not support
765 queuing at all. In Open vSwitch, the supported queues vary depending
766 on the operating system, datapath, and hardware in use. Use the
767 <code>QoS</code> and <code>Queue</code> tables in the Open vSwitch
768 database to configure queuing on individual OpenFlow ports (see
769 <code>ovs-vswitchd.conf.db</code>(5) for more information).
770 </p>
771
772 <conformance>
773 <p>
774 Only OpenFlow 1.0 supports <code>enqueue</code>. OpenFlow 1.1 added
775 the <code>set_queue</code> action to use in its place along with
776 <code>output</code>.
777 </p>
778
779 <p>
780 Open vSwitch translates <code>enqueue</code> to a sequence of three
781 actions in OpenFlow 1.1 or later: <code>set_queue:<var>queue</var>,
782 output:<var>port</var>, pop_queue</code>. This is equivalent in
783 behavior as long as the flow table does not otherwise use
784 <code>set_queue</code>, but it relies on the <code>pop_queue</code>
785 Open vSwitch extension action.
786 </p>
787 </conformance>
788 </action>
789
790 <action name="BUNDLE,BUNDLE_LOAD">
791 <h2>The <code>bundle</code> and <code>bundle_load</code> actions</h2>
5a7f15ab
BP
792 <syntax><code>bundle(</code><var>fields</var><code>, </code><var>basis</var><code>, </code><var>algorithm</var><code>, ofport, slaves:</code><var>port</var>...<code>)</code></syntax>
793 <syntax><code>bundle_load(</code><var>fields</var><code>, </code><var>basis</var><code>, </code><var>algorithm</var><code>, ofport, </code><var>dst</var><code>, slaves:</code><var>port</var>...<code>)</code></syntax>
be51cd41
BP
794
795 <p>
796 These actions choose a port (``slave'') from a comma-separated OpenFlow
797 <var>port</var> list. After selecting the port, <code>bundle</code>
798 outputs to it, whereas <code>bundle_load</code> writes its port number
5a7f15ab
BP
799 to <var>dst</var>, which must be a 16-bit or wider field or subfield in
800 the syntax described under ``Field Specifications'' above.
be51cd41
BP
801 </p>
802
803 <p>
804 These actions hash a set of <var>fields</var> using <var>basis</var> as
805 a universal hash parameter, then apply the bundle link selection
806 <var>algorithm</var> to choose a <var>port</var>.
807 </p>
808
809 <p>
810 <var>fields</var> must be one of the following. For the options with
811 ``symmetric'' in the name, reversing source and destination addresses
812 yields the same hash:
813 </p>
814
815 <dl>
816 <dt><code>eth_src</code></dt>
817 <dd>
818 Ethernet source address.
819 </dd>
820
821 <dt><code>nw_src</code></dt>
822 <dd>
823 IPv4 or IPv6 source address.
824 </dd>
825
826 <dt><code>nw_dst</code></dt>
827 <dd>
828 IPv4 or IPv6 destination address.
829 </dd>
830
831 <dt><code>symmetric_l4</code></dt>
832 <dd>
833 Ethernet source and destination, Ethernet type, VLAN ID or IDs (if
834 any), IPv4 or IPv6 source and destination, IP protocol, TCP or SCTP
835 (but not UDP) source and destination.
836 </dd>
837
838 <dt><code>symmetric_l3l4</code></dt>
839 <dd>
840 IPv4 or IPv6 source and destination, IP protocol, TCP or SCTP (but
841 not UDP) source and destination.
842 </dd>
843
844 <dt><code>symmetric_l3l4+udp</code></dt>
845 <dd>
846 Like <code>symmetric_l3l4</code> but include UDP ports.
847 </dd>
848 </dl>
849
5a7f15ab
BP
850 <p>
851 <var>algorithm</var> must be one of the following:
852 </p>
853
854 <dl>
855 <dt><code>active_backup</code></dt>
856 <dd>
857 Chooses the first live port listed in <var>slaves</var>.
858 </dd>
859
860 <dt><code>hrw</code> (Highest Random Weight)</dt>
861 <dd>
862 <p>
863 Computes the following, considering only the live ports in
864 <var>slaves</var>:
865 </p>
866
867 <pre>
868for <var>i</var> in [1,<var>n_slaves</var>]:
869 <var>weights</var>[<var>i</var>] = hash(<var>flow</var>, <var>i</var>)
870<var>slave</var> = { <var>i</var> such that <var>weights</var>[<var>i</var>] &gt;= <var>weights</var>[<var>j</var>] for all <var>j</var> != <var>i</var> }
871 </pre>
872
873 <p>
874 This algorithm is specified by RFC 2992.
875 </p>
876 </dd>
877 </dl>
878
879 <p>
880 The algorithms take port liveness into account when selecting slaves.
881 The definition of whether a port is live is subject to change. It
882 currently takes into account carrier status and link monitoring
883 protocols such as BFD and CFM. If none of the slaves is live,
884 <code>bundle</code> does not output the packet and
885 <code>bundle_load</code> stores <code>OFPP_NONE</code> (65535) in the
886 output field.
887 </p>
888
889 <p>
890 Example: <code>bundle(eth_src,0,hrw,ofport,slaves:4,8)</code> uses an
891 Ethernet source hash with basis 0, to select between OpenFlow ports 4
892 and 8 using the Highest Random Weight algorithm.
893 </p>
894
be51cd41
BP
895 <conformance>
896 Open vSwitch 1.2 introduced the <code>bundle</code> and
897 <code>bundle_load</code> OpenFlow extension actions.
898 </conformance>
899 </action>
900
901 <action name="GROUP">
902 <h2>The <code>group</code> action</h2>
903 <syntax><code>group:</code><var>group</var></syntax>
904 <p>
905 Outputs the packet to the OpenFlow group <var>group</var>, which must
906 be a number in the range 0 to 4294967040 (0xffffff00). The group must
907 exist or Open vSwitch will refuse to add the flow. When a group is
908 deleted, Open vSwitch also deletes all of the flows that output to it.
909 </p>
910
911 <p>
912 Groups contain action sets, whose semantics are described above in the
913 section ``Action Sets''. The semantics of action sets can be
914 surprising to users who expect action list semantics, since action sets
915 reorder and sometimes ignore actions.
916 </p>
917
918 <p>
919 A <code>group</code> action usually executes the action set or sets in
920 one or more group buckets. Open vSwitch saves the packet and metadata
921 before it executes each bucket, and then restores it afterward. Thus,
922 when a group executes more than one bucket, this means that each bucket
923 executes on the same packet and metadata. Moreover, regardless of the
924 number of buckets executed, the packet and metadata are the same before
925 and after executing the group.
926 </p>
927
928 <p>
929 Sometimes saving and restoring the packet and metadata can be
930 undesirable. In these situations, workarounds are possible. For
931 example, consider a pipeline design in which a <code>select</code>
932 group bucket is to communicate to a later stage of processing a value
933 based on which bucket was selected. An obvious design would be for the
934 bucket to communicate the value via <code>set_field</code> on a
935 register. This does not work because registers are part of the
936 metadata that <code>group</code> saves and restores. A design that
937 would work would be for the bucket to recursively invoke the rest of
938 the pipeline with <code>resubmit</code> rather than to attempt to
939 return it. Another possibility is for the bucket to use
940 <code>push</code> to put the value on the stack for the caller to
941 <code>pop</code> off, since <code>group</code> preserves only packet
942 data and metadata, not the stack.
943 </p>
944
945 <p>
946 An <code>exit</code> action within a group bucket terminates only
947 execution of that bucket, not other buckets or the overall pipeline.
948 </p>
949
950 <conformance>
951 OpenFlow 1.1 introduced <code>group</code>. Open vSwitch 2.6 and later
952 also supports <code>group</code> as an extension to OpenFlow 1.0.
953 </conformance>
954 </action>
955
956 </group>
957
958 <group title="Encapsulation and Decapsulation Actions">
959 <action name="STRIP_VLAN">
960 <h2>The <code>strip_vlan</code> and <code>pop</code> actions</h2>
961 <syntax><code>strip_vlan</code></syntax>
962 <syntax><code>pop_vlan</code></syntax>
963
964 <p>
965 Removes the outermost VLAN tag, if any, from the packet.
966 </p>
967
968 <p>
969 The two names for this action are synonyms with no semantic difference.
970 The OpenFlow 1.0 specification uses the name <code>strip_vlan</code>
971 and later versions use <code>pop_vlan</code>, but OVS accepts either
972 name regardless of version.
973 </p>
974
975 <p>
976 In OpenFlow 1.1 and later, consistency rules allow
977 <code>strip_vlan</code> only in a flow that matches only packets with a
978 VLAN tag (or following an action that pushes a VLAN tag, such as
979 <code>push_vlan</code>). See ``Inconsistencies'', above, for more
980 information.
981 </p>
982
983 <conformance>
984 All versions of OpenFlow and Open vSwitch support this action.
985 </conformance>
986 </action>
987
988 <action name="PUSH_VLAN">
989 <h2>The <code>push_vlan</code> action</h2>
990 <syntax><code>push_vlan:</code><var>ethertype</var></syntax>
991
992 <p>
993 Pushes a new outermost VLAN onto the packet. Uses TPID
994 <var>ethertype</var>, which must be <code>0x8100</code> for an 802.1Q
995 C-tag or <code>0x88a8</code> for a 802.1ad S-tag.
996 </p>
997
998 <conformance>
999 OpenFlow 1.1 and later supports this action. Open vSwitch 2.8 added
1000 support for multiple VLAN tags (with a limit of 2) and 802.1ad S-tags.
1001 </conformance>
1002 </action>
1003
1004 <action name="PUSH_MPLS">
1005 <h2>The <code>push_mpls</code> action</h2>
1006 <syntax><code>push_mpls:<var>ethertype</var></code></syntax>
1007
1008 <p>
1009 Pushes a new outermost MPLS label stack entry (LSE) onto the packet and
1010 changes the packet's Ethertype to <var>ethertype</var>, which must be
1011 either <code>B0x8847</code> or <code>0x8848</code>.
1012 </p>
1013
1014 <p>
1015 If the packet did not already contain any MPLS labels, initializes the
1016 new LSE as:
1017 </p>
1018
1019 <dl>
1020 <dt>Label</dt>
1021 <dd>
1022 2, if the packet contains IPv6, 0 otherwise.
1023 </dd>
1024 <dt>TC</dt>
1025 <dd>
1026 The low 3 bits of the packet's DSCP value, or 0 if the packet is not
1027 IP.
1028 </dd>
1029 <dt>TTL</dt>
1030 <dd>
1031 Copied from the IP TTL, or 64 if the packet is not IP.
1032 </dd>
1033 </dl>
1034
1035 <p>
1036 If the packet did already contain an MPLS label, initializes the new
1037 outermost label as a copy of the existing outermost label.
1038 </p>
1039
1040 <p>
1041 OVS currently supports at most 3 MPLS labels.
1042 </p>
1043
1044 <p>
1045 This action applies only to Ethernet packets.
1046 </p>
1047
1048 <conformance>
1049 Open vSwitch 1.11 introduced support for MPLS. OpenFlow 1.1 and later
1050 support <code>push_mpls</code>. Open vSwitch implements
1051 <code>push_mpls</code> as an extension to OpenFlow 1.0.
1052 </conformance>
1053 </action>
1054
1055 <action name="POP_MPLS">
1056 <h2>The <code>pop_mpls</code> action</h2>
1057 <syntax><code>pop_mpls:<var>ethertype</var></code></syntax>
1058
1059 <p>
1060 Strips the outermost MPLS label stack entry and changes the packet's
1061 Ethertype to <var>ethertype</var>.
1062 </p>
1063
1064 <p>
1065 This action applies only to Ethernet packets with at least one MPLS
1066 label. If there is more than one MPLS label, then <var>ethertype</var>
1067 should be an MPLS Ethertype (<code>B0x8847</code> or
1068 <code>0x8848</code>).
1069 </p>
1070
1071 <conformance>
1072 Open vSwitch 1.11 introduced support for MPLS. OpenFlow 1.1 and later
1073 support <code>pop_mpls</code>. Open vSwitch implements
1074 <code>pop_mpls</code> as an extension to OpenFlow 1.0.
1075 </conformance>
1076 </action>
1077
1078 <action name="ENCAP">
1079 <h2>The <code>encap</code> action</h2>
1080 <syntax><code>encap(nsh(</code>[<code>md_type=<var>md_type</var></code>]<code>, </code>[<code>tlv(<var>class</var>,<var>type</var>,<var>value</var>)</code>]...<code>))</code></syntax>
1081 <syntax><code>encap(ethernet)</code></syntax>
1082
1083 <p>
1084 The <code>encap</code> action encapsulates a packet with a specified
1085 header. It has variants for different kinds of encapsulation.
1086 </p>
1087
1088 <p>
1089 The <code>encap(nsh(</code>...<code>))</code> variant encapsulates an
1090 Ethernet frame with NSH. The <var>md_type</var> may be <code>1</code>
1091 or <code>2</code> for metadata type 1 or 2, defaulting to 1. For
1092 metadata type 2, TLVs may be specified with <var>class</var> as a
1093 16-bit hexadecimal integer beginning with <code>0x</code>,
1094 <var>type</var> as an 8-bit decimal integer, and <var>value</var> a
1095 sequence of pairs of hex digits beginning with <code>0x</code>. For
1096 example:
1097 </p>
1098
1099 <dl>
1100 <dt><code>encap(nsh(md_type=1))</code></dt>
1101 <dd>
1102 Encapsulates the packet with an NSH header with metadata type 1.
1103 </dd>
1104
1105 <dt><code>encap(nsh(md_type=2,tlv(0x1000,10,0x12345678)))</code></dt>
1106 <dd>
1107 Encapsulates the packet with an NSH header, NSH metadata type 2, and
1108 an NSH TLV with class 0x1000, type 10, and the 4-byte value
1109 0x12345678.
1110 </dd>
1111 </dl>
1112
1113 <p>
1114 The <code>encap(ethernet)</code> variant encapsulate a bare L3 packet
1115 in an Ethernet frame. The Ethernet type is initialized to the L3
1116 packet's type, e.g. 0x0800 if the L3 packet is IPv4. The Ethernet
1117 source and destination are initially zeroed.
1118 </p>
1119
1120 <conformance>
1121 This action is an Open vSwitch extension to OpenFlow 1.3 and later,
1122 introduced in Open vSwitch 2.8.
1123 </conformance>
1124 </action>
1125
1126 <action name="DECAP">
1127 <h2>The <code>decap</code> action</h2>
1128 <syntax><code>decap</code></syntax>
1129
1130 <p>
1131 Removes an outermost encapsulation from the packet:
1132 </p>
1133
1134 <ul>
1135 <li>
1136 If the packet is an Ethernet packet, removes the Ethernet header,
1137 which changes the packet into a bare L3 packet. If the packet has
1138 VLAN tags, raises an unsupported packet type error (see ``Error
1139 Handling'', above).
1140 </li>
1141
1142 <li>
1143 Otherwise, if the packet is an NSH packet, removes the NSH header,
1144 revealing the inner packet. Open vSwitch supports Ethernet, IPv4,
1145 IPv6, and NSH inner packet types. Other types raise unsupported
1146 packet type errors.
1147 </li>
1148
1149 <li>
1150 Otherwise, raises an unsupported packet type error.
1151 </li>
1152 </ul>
1153
1154 <conformance>
1155 This action is an Open vSwitch extension to OpenFlow 1.3 and later,
1156 introduced in Open vSwitch 2.8.
1157 </conformance>
1158 </action>
1159 </group>
1160
1161 <group title="Field Modification Actions">
1162 <p>
1163 These actions modify packet data and metadata fields.
1164 </p>
1165
1166 <action name="SET_FIELD">
1167 <h2>The <code>set_field</code> and <code>load</code> actions</h2>
1168 <syntax><code>set_field:</code><var>value</var>[<code>/</code><var>mask</var>]<code>-&gt;</code><var>dst</var></syntax>
1169 <syntax><code>load:</code><var>value</var><code>-&gt;</code><var>dst</var><code></code></syntax>
1170
1171 <p>
1172 These actions loads a literal value into a field or part of a field.
1173 The <code>set_field</code> action takes <var>value</var> in the
1174 customary syntax for field <var>dst</var>,
1175 e.g. <code>00:11:22:33:44:55</code> for an Ethernet address, and
1176 <var>dst</var> as the field's name. The optional <var>mask</var>
1177 allows part of a field to be set.
1178 </p>
1179
1180 <p>
1181 The <code>load</code> action takes <var>value</var> as an integer value
1182 (in decimal or prefixed by <code>0x</code> for hexadecimal) and
1183 <var>dst</var> as a field or subfield in the syntax described under
1184 ``Field Specifications'' above.
1185 </p>
1186
1187 <p>
1188 The following all set the Ethernet source address to 00:11:22:33:44:55:
1189 </p>
1190
1191 <ul>
1192 <li><code>set_field:00:11:22:33:44:55-&gt;eth_src</code></li>
1193 <li><code>load:0x001122334455-&gt;eth_src</code></li>
1194 <li><code>load:0x001122334455-&gt;OXM_OF_ETH_SRC[]</code></li>
1195 </ul>
1196
1197 <p>
1198 The following all set the multicast bit in the Ethernet destination
1199 address:
1200 </p>
1201
1202 <ul>
1203 <li><code>set_field:01:00:00:00:00:00/01:00:00:00:00:00-&gt;eth_dst</code></li>
1204 <li><code>load:1-&gt;eth_dst[40]</code></li>
1205 </ul>
1206
1207 <p>
1208 Open vSwitch prohibits a <code>set_field</code> or <code>load</code>
1209 action whose <var>dst</var> is not guaranteed to be part of the packet;
1210 for example, <code>set_field</code> of <code>nw_dst</code> is only
1211 allowed in a flow that matches on Ethernet type 0x800. In some cases,
1212 such as in an action set, Open vSwitch can't statically check that
1213 <var>dst</var> is part of the packet, and in that case if it is not
1214 then Open vSwitch treats the action as a no-op.
1215 </p>
1216
1217 <conformance>
1218 Open vSwitch 1.1 introduced <code>NXAST_REG_LOAD</code> as a extension
1219 to OpenFlow 1.0 and used <code>load</code> to express it. Later,
1220 OpenFlow 1.2 introduced a standard <code>OFPAT_SET_FIELD</code> action
1221 that was restricted to loading entire fields, so Open vSwitch added the
1222 form <code>set_field</code> with this restriction. OpenFlow 1.5
1223 extended <code>OFPAT_SET_FIELD</code> to the point that it became a
1224 superset of <code>NXAST_REG_LOAD</code>. Open vSwitch translates
1225 either syntax as necessary for the OpenFlow version in use: in OpenFlow
1226 1.0 and 1.1, <code>NXAST_REG_LOAD</code>; in OpenFlow 1.2, 1.3, and
1227 1.4, <code>NXAST_REG_LOAD</code> for <code>load</code> or for loading a
1228 subfield, <code>OFPAT_SET_FIELD</code> otherwise; and OpenFlow 1.5 and
1229 later, <code>OFPAT_SET_FIELD</code>.
1230 </conformance>
1231 </action>
1232
1233 <action name="REG_MOVE">
1234 <h2>The <code>move</code> action</h2>
1235 <syntax><code>move:<var>src</var>-&gt;<var>dst</var></code></syntax>
1236
1237 <p>
1238 Copies the named bits from field or subfield <var>src</var> to field or
1239 subfield <var>dst</var>. <var>src</var> and <var>dst</var> should
1240 fields or subfields in the syntax described under ``Field
1241 Specifications'' above. The two fields or subfields must have the same
1242 width.
1243 </p>
1244
1245 <p>
1246 Examples:
1247 </p>
1248
1249 <ul>
1250 <li>
1251 <code>move:reg0[0..5]-&gt;reg1[26..31]</code> copies the six bits
1252 numbered 0 through 5 in register 0 into bits 26 through 31 of
1253 register 1.
1254 </li>
1255 <li>
1256 <code>move:reg0[0..15]-&gt;vlan_tci</code> copies the least
1257 significant 16 bits of register 0 into the VLAN TCI field.
1258 </li>
1259 </ul>
1260
1261 <conformance>
1262 In OpenFlow 1.0 through 1.4, <code>move</code> ordinarily uses an Open
1263 vSwitch extension to OpenFlow. In OpenFlow 1.5, <code>move</code> uses
1264 the OpenFlow 1.5 standard <code>OFPAT_COPY_FIELD</code> action. The
1265 ONF has also made <code>OFPAT_COPY_FIELD</code> available as an
1266 extension to OpenFlow 1.3. Open vSwitch 2.4 and later understands this
1267 extension and uses it if a controller uses it, but for backward
1268 compatibility with older versions of Open vSwitch,
1269 <code>ovs-ofctl</code> does not use it.
1270 </conformance>
1271 </action>
1272
1273 <action name="SET_ETH_SRC, SET_ETH_DST">
1274 <h2>The <code>mod_dl_src</code> and <code>mod_dl_dst</code> actions</h2>
1275 <syntax><code>mod_dl_src:</code><var>mac</var></syntax>
1276 <syntax><code>mod_dl_dst:</code><var>mac</var></syntax>
1277
1278 <p>
1279 Sets the Ethernet source or destination address, respectively, to
1280 <var>mac</var>, which should be expressed in the form
1281 <code><var>xx</var>:<var>xx</var>:<var>xx</var>:<var>xx</var>:<var>xx</var>:<var>xx</var></code>.
1282 </p>
1283
1284 <p>
1285 For L3-only packets, that is, those that lack an Ethernet header, this
1286 action has no effect.
1287 </p>
1288
1289 <conformance>
1290 OpenFlow 1.0 and 1.1 have specialized actions for these purposes.
1291 OpenFlow 1.2 and later do not, so Open vSwitch translates them to
1292 appropriate <code>OFPAT_SET_FIELD</code> actions for those versions,
1293 </conformance>
1294 </action>
1295
1296 <action name="SET_IP_SRC, SET_IP_DST">
1297 <h2>The <code>mod_nw_src</code> and <code>mod_nw_dst</code> actions</h2>
1298 <syntax><code>mod_nw_src:</code><var>ip</var></syntax>
1299 <syntax><code>mod_nw_dst:</code><var>ip</var></syntax>
1300
1301 <p>
1302 Sets the IPv4 source or destination address, respectively, to
1303 <var>ip</var>, which should be expressed in the form
1304 <code><var>w</var>.<var>x</var>.<var>y</var>.<var>z</var></code>.
1305 </p>
1306
1307 <p>
1308 In OpenFlow 1.1 and later, consistency rules allow these actions only
1309 in a flow that matches only packets that contain an IPv4 header (or
1310 following an action that adds an IPv4 header,
1311 e.g. <code>pop_mpls:0x0800</code>). See ``Inconsistencies'', above,
1312 for more information.
1313 </p>
1314
1315 <conformance>
1316 OpenFlow 1.0 and 1.1 have specialized actions for these purposes.
1317 OpenFlow 1.2 and later do not, so Open vSwitch translates them to
1318 appropriate <code>OFPAT_SET_FIELD</code> actions for those versions,
1319 </conformance>
1320 </action>
1321
1322 <action name="SET_IP_DSCP, SET_IP_ECN">
1323 <h2>The <code>mod_nw_tos</code> and <code>mod_nw_ecn</code> actions</h2>
1324 <syntax><code>mod_nw_tos:</code><var>tos</var></syntax>
1325 <syntax><code>mod_nw_ecn:</code><var>ecn</var></syntax>
1326
1327 <p>
1328 The <code>mod_nw_tos</code> action sets the DSCP bits in the IPv4
1329 ToS/DSCP or IPv6 traffic class field to <var>tos</var>, which must be a
1330 multiple of 4 between 0 and 255. This action does not modify the two
1331 least significant bits of the ToS field (the ECN bits).
1332 </p>
1333
1334 <p>
1335 The <code>mod_nw_ecn</code> action sets the ECN bits in the IPv4 ToS or
1336 IPv6 traffic class field to <code>ecn</code>, which must be a value
1337 between 0 and 3, inclusive. This action does not modify the six most
1338 significant bits of the field (the DSCP bits).
1339 </p>
1340
1341 <p>
1342 In OpenFlow 1.1 and later, consistency rules allow these actions only
1343 in a flow that matches only packets that contain an IPv4 or IPv6 header
1344 (or following an action that adds such a header). See
1345 ``Inconsistencies'', above, for more information.
1346 </p>
1347
1348 <conformance>
1349 OpenFlow 1.0 has a <code>mod_nw_tos</code> action but not
1350 <code>mod_nw_ecn</code>. Open vSwitch implements the latter in
1351 OpenFlow 1.0 as an extension using <code>NXAST_REG_LOAD</code>.
1352 OpenFlow 1.1 has specialized actions for these purposes. OpenFlow 1.2
1353 and later do not, so Open vSwitch translates them to appropriate
1354 <code>OFPAT_SET_FIELD</code> actions for those versions,
1355 </conformance>
1356 </action>
1357
1358 <action name="SET_L4_SRC_PORT, SET_L4_DST_PORT">
1359 <h2>The <code>mod_tp_src</code> and <code>mod_tp_dst</code> actions</h2>
1360 <syntax><code>mod_tp_src:</code><var>port</var></syntax>
1361 <syntax><code>mod_tp_dst:</code><var>port</var></syntax>
1362
1363 <p>
1364 Sets the TCP or UDP or SCTP source or destination port, respectively,
1365 to <var>port</var>. Both IPv4 and IPv6 are supported.
1366 </p>
1367
1368 <p>
1369 In OpenFlow 1.1 and later, consistency rules allow these actions only
1370 in a flow that matches only packets that contain a TCP or UDP or SCTP
1371 header. See ``Inconsistencies'', above, for more information.
1372 </p>
1373
1374 <conformance>
1375 OpenFlow 1.0 and 1.1 have specialized actions for these purposes.
1376 OpenFlow 1.2 and later do not, so Open vSwitch translates them to
1377 appropriate <code>OFPAT_SET_FIELD</code> actions for those versions,
1378 </conformance>
1379 </action>
1380
1381 <action name="DEC_TTL">
1382 <h2>The <code>dec_ttl</code> action</h2>
1383 <syntax><code>dec_ttl</code></syntax>
1384 <syntax><code>dec_ttl(<var>id1</var>, </code>[<code><var>id2</var></code>]...<code>)</code></syntax>
1385
1386 <p>
1387 Decrement TTL of IPv4 packet or hop limit of IPv6 packet. If the TTL
1388 or hop limit is initially 0 or 1, no decrement occurs, as packets
1389 reaching TTL zero must be rejected. Instead, Open vSwitch sends a
1390 ``packet-in'' message with reason code <code>OFPR_INVALID_TTL</code> to
1391 each connected controller that has enabled receiving such messages, and
1392 stops processing the current set of actions. (However, if the current
1393 set of actions was reached through <code>resubmit</code>, the remaining
1394 actions in outer levels resume processing.)
1395 </p>
1396
1397 <p>
1398 As an Open vSwitch extension to OpenFlow, this action supports the
1399 ability to specify a list of controller IDs. Open vSwitch will only
1400 send the message to controllers with the given ID or IDs. Specifying
1401 no list is equivalent to specifying a single controller ID of zero.
1402 </p>
1403
1404 <p>
1405 Sets the TCP or UDP or SCTP source or destination port, respectively,
1406 to <var>port</var>. Both IPv4 and IPv6 are supported.
1407 </p>
1408
1409 <p>
1410 In OpenFlow 1.1 and later, consistency rules allow these actions only
1411 in a flow that matches only packets that contain an IPv4 or IPv6
1412 header. See ``Inconsistencies'', above, for more information.
1413 </p>
1414
1415 <conformance>
1416 All versions of OpenFlow and Open vSwitch support this action.
1417 </conformance>
1418 </action>
1419
1420 <action name="SET_MPLS_LABEL, SET_MPLS_TC, SET_MPLS_TTL">
1421 <h2>The <code>set_mpls_label</code>, <code>set_mpls_tc</code>, and <code>set_mpls_ttl</code> actions</h2>
1422 <syntax><code>set_mpls_label:</code><var>label</var></syntax>
1423 <syntax><code>set_mpls_tc:</code><var>tc</var></syntax>
1424 <syntax><code>set_mpls_ttl:</code><var>ttl</var></syntax>
1425
1426 <p>
1427 The <code>set_mpls_label</code> action sets the label of the packet's
1428 outer MPLS label stack entry. <var>label</var> should be a 20-bit
1429 value that is decimal by default; use a <code>0x</code> prefix to
1430 specify the value in hexadecimal.
1431 </p>
1432
1433 <p>
1434 The <code>set_mpls_tc</code> action sets the traffic class of the
1435 packet's outer MPLS label stack entry. <var>tc</var> should be in the
1436 range 0 to 7, inclusive.
1437 </p>
1438
1439 <p>
1440 The <code>set_mpls_ttl</code> action sets the TTL of the packet's outer
1441 MPLS label stack entry. <var>ttl</var> should be in the range 0 to 255
1442 inclusive.
1443 </p>
1444
1445 <p>
1446 In OpenFlow 1.1 and later, consistency rules allow these actions only
1447 in a flow that matches only packets that contain an MPLS label (or
1448 following an action that adds an MPLS label,
1449 e.g. <code>push_mpls:0x8847</code>). See ``Inconsistencies'', above,
1450 for more information.
1451 </p>
1452
1453 <conformance>
1454 OpenFlow 1.0 does not support MPLS, but Open vSwitch implements these
1455 actions as extensions. OpenFlow 1.1 has specialized actions for these
1456 purposes. OpenFlow 1.2 and later do not, so Open vSwitch translates
1457 them to appropriate <code>OFPAT_SET_FIELD</code> actions for those
1458 versions,
1459 </conformance>
1460 </action>
1461
1462 <action name="DEC_MPLS_TTL, DEC_NSH_TTL">
1463 <h2>The <code>dec_mpls_ttl</code> and <code>dec_nsh_ttl</code> actions</h2>
1464 <syntax><code>dec_mpls_ttl</code></syntax>
1465 <syntax><code>dec_nsh_ttl</code></syntax>
1466
1467 <p>
1468 These actions decrement the TTL of the packet's outer MPLS label stack
1469 entry or its NSH header, respectively. If the TTL is initially 0 or 1,
1470 no decrement occurs. Instead, Open vSwitch sends a ``packet-in''
1471 message with reason code <code>BOFPR_INVALID_TTL</code> to OpenFlow
1472 controllers with ID 0, if it has enabled receiving them. Processing
1473 the current set of actions then stops. (However, if the current set of
1474 actions was reached through <code>resubmit</code>, remaining actions in
1475 outer levels resume processing.)
1476 </p>
1477
1478 <p>
1479 In OpenFlow 1.1 and later, consistency rules allow this actions only in
1480 a flow that matches only packets that contain an MPLS label or an NSH
1481 header, respectively. See ``Inconsistencies'', above, for more
1482 information.
1483 </p>
1484
1485 <conformance>
1486 <p>
1487 Open vSwitch 1.11 introduced support for MPLS. OpenFlow 1.1 and
1488 later support <code>dec_mpls_ttl</code>. Open vSwitch implements
1489 <code>dec_mpls_ttl</code> as an extension to OpenFlow 1.0.
1490 </p>
1491
1492 <p>
1493 Open vSwitch 2.8 introduced support for NSH, although the NSH draft
1494 changed after release so that only Open vSwitch 2.9 and later conform
1495 to the final protocol specification. The <code>dec_nsh_ttl</code>
1496 action and NSH support in general is an Open vSwitch extension not
1497 supported by any version of OpenFlow.
1498 </p>
1499 </conformance>
1500 </action>
5b34f8fc
NS
1501
1502 <action name="CHECK_PKT_LARGER">
1503 <h2>The <code>check_pkt_larger</code> action</h2>
1504 <syntax>
1505 <code>check_pkt_larger(<var>pkt_len</var>)-&gt;<var>dst</var></code>
1506 </syntax>
1507
1508 <p>
1509 Checks if the packet is larger than the specified length in
1510 <var>pkt_len</var>. If so, stores 1 in <var>dst</var>, which should be
1511 a 1-bit field; if not, stores 0.
1512 </p>
1513
1514 <p>
1515 The packet length to check againt the argument <var>pkt_len</var>
1516 includes the L2 header and L2 payload of the packet, but not the VLAN
1517 tag (if present).
1518 </p>
1519
1520 <p>
1521 Examples:
1522 </p>
1523
1524 <ul>
1525 <li>
1526 <code>check_pkt_larger(1500)-&gt;reg0[0]</code>
1527 </li>
1528
1529 <li>
1530 <code>check_pkt_larger(8000)-&gt;reg9[10]</code>
1531 </li>
1532 </ul>
1533
1534 <p>
1535 This action was added in Open vSwitch 2.11.90.
1536 </p>
1537 </action>
be51cd41
BP
1538 </group>
1539
1540 <group title="Metadata Actions">
1541 <action name="SET_TUNNEL">
1542 <h2>The <code>set_tunnel</code> action</h2>
1543 <syntax><code>set_tunnel:</code><var>id</var></syntax>
1544 <syntax><code>set_tunnel64:</code><var>id</var></syntax>
1545
1546 <p>
1547 Many kinds of tunnels support a tunnel ID, e.g. VXLAN and Geneve have a
1548 24-bit VNI, and GRE has an optional 32-bit key. This action sets the
1549 value used for tunnel ID in such tunneled packets, although whether it
1550 is used for a particular tunnel depends on the tunnel's configuration.
1551 See the tunnel ID documentation in <code>ovs-fields</code>(7) for more
1552 information.
1553 </p>
1554
1555 <conformance>
1556 <p>
1557 These actions are OpenFlow extensions. <code>set_tunnel</code> was
1558 introduced in Open vSwitch 1.0. <code>set_tunnel64</code>, which is
1559 needed if <var>id</var> is wider than 32 bits, was added in Open
1560 vSwitch 1.1. Both actions always set the entire tunnel ID field.
1561 </p>
1562
1563 <p>
1564 Open vSwitch supports these actions in all versions of OpenFlow, but
1565 in OpenFlow 1.2 and later it translates them to an appropriate
1566 standardized <code>OFPAT_SET_FIELD</code> action.
1567 </p>
1568 </conformance>
1569 </action>
1570
1571 <action name="SET_QUEUE, POP_QUEUE">
1572 <h2>The <code>set_queue</code> and <code>pop_queue</code> actions</h2>
1573 <syntax><code>set_queue:</code><var>queue</var></syntax>
1574 <syntax><code>pop_queue</code></syntax>
1575
1576 <p>
1577 The <code>set_queue</code> action sets the queue ID to be used for
1578 subsequent output actions to <var>queue</var>, which must be a 32-bit
1579 integer. The range of meaningful values of <var>queue</var>, and their
1580 meanings, varies greatly from one OpenFlow implementation to another.
1581 Even within a single implementation, there is no guarantee that all
1582 OpenFlow ports have the same queues configured or that all OpenFlow
1583 ports in an implementation can be configured the same way queue-wise.
1584 For more information, see the documentation for the output queue field
1585 in <code>ovs-fields</code>(7).
1586 </p>
1587
1588 <p>
1589 The <code>pop_queue</code> restores the output queue to the default
1590 that was set when the packet entered the switch (generally 0).
1591 </p>
1592
1593 <p>
1594 Four billion queues ought to be enough for anyone: <url
1595 href="https://mailman.stanford.edu/pipermail/openflow-spec/2009-August/000394.html"/>
1596 </p>
1597
1598 <conformance>
1599 <p>
1600 OpenFlow 1.1 introduced the <code>set_queue</code> action. Open
1601 vSwitch also supports it as an extension in OpenFlow 1.0.
1602 </p>
1603
1604 <p>
1605 The <code>pop_queue</code> action is an Open vSwitch extension.
1606 </p>
1607 </conformance>
1608 </action>
1609 </group>
1610
1611 <group title="Firewalling Actions">
1612 <p>
1613 Open vSwitch is often used to implement a firewall. The preferred way to
1614 implement a firewall is ``connection tracking,'' that is, to keep track
1615 of the connection state of individual TCP sessions. The <code>ct</code>
1616 action described in this section, added in Open vSwitch 2.5, implements
1617 connection tracking. For new deployments, it is the recommended way to
1618 implement firewalling with Open vSwitch.
1619 </p>
1620
1621 <p>
1622 Before <code>ct</code> was added, Open vSwitch did not have built-in
1623 support for connection tracking. Instead, Open vSwitch supported the
1624 <code>learn</code> action, which allows a received packet to add a flow
1625 to an OpenFlow flow table. This could be used to implement a primitive
1626 form of connection tracking: packets passing through the firewall in one
1627 direction could create flows that allowed response packets back through
1628 the firewall in the other direction. The additional
1629 <code>fin_timeout</code> action allowed the learned flows to expire
1630 quickly after TCP session termination.
1631 </p>
1632
1633 <action name="CT">
1634 <h2>The <code>ct</code> action</h2>
1635 <syntax><code>ct(<var>argument</var></code>]...<code>)</code></syntax>
1636 <syntax><code>ct(commit</code>[<code>, <var>argument</var></code>]...<code>)</code></syntax>
1637
1638 <p>
1639 The action has two modes of operation, distinguished by whether
1640 <code>commit</code> is present. The following arguments may be present
1641 in either mode:
1642 </p>
1643
1644 <dl>
1645 <dt><code>zone=<var>value</var></code></dt>
1646 <dd>
1647 A zone is a 16-bit id that isolates connections into separate
1648 domains, allowing overlapping network addresses in different zones.
1649 If a zone is not provided, then the default is 0. The
1650 <var>value</var> may be specified either as a 16-bit integer literal
1651 or a field or subfield in the syntax described under ``Field
1652 Specifications'' above.
1653 </dd>
1654 </dl>
1655
1656 <p>
1657 Without <code>commit</code>, this action sends the packet through the
1658 connection tracker. The connection tracker keeps track of the state of
1659 TCP connections for packets passed through it. For each packet through
1660 a connection, it checks that it satisfies TCP invariants and signals
1661 the connection state to later actions using the <code>ct_state</code>
1662 metadata field, which is documented in <code>ovs-fields</code>(7).
1663 </p>
1664
1665 <p>
1666 In this form, <code>ct</code> forks the OpenFlow pipeline:
1667 </p>
1668
1669 <ul>
1670 <li>
1671 In one fork, <code>ct</code> passes the packet to the connection
1672 tracker. Afterward, it reinjects the packet into the OpenFlow
1673 pipeline with the connection tracking fields initialized. The
1674 <code>ct_state</code> field is initialized with connection state and
1675 <code>ct_zone</code> to the connection tracking zone specified on the
1676 <code>zone</code> argument. If the connection is one that is already
1677 tracked, <code>ct_mark</code> and <code>ct_label</code> to its
1678 existing mark and label, respectively; otherwise they are zeroed. In
1679 addition, <code>ct_nw_proto</code>, <code>ct_nw_src</code>,
1680 <code>ct_nw_dst</code>, <code>ct_ipv6_src</code>,
1681 <code>ct_ipv6_dst</code>, <code>ct_tp_src</code>, and
1682 <code>ct_tp_dst</code> are initialized appropriately for the original
1683 direction connection. See the <code>resubmit</code> action for a way
1684 to search the flow table with the connection tracking original
1685 direction fields swapped with the packet 5-tuple fields. See
1686 <code>ovs-fields</code>(7) for details on the connection tracking
1687 fields.
1688 </li>
1689
1690 <li>
1691 In the other fork, the original instance of the packet continues
1692 independent processing following the <code>ct</code> action. The
1693 <code>ct_state</code> field and other connection tracking metadata
1694 are cleared.
1695 </li>
1696 </ul>
1697
1698 <p>
1699 Without <code>commit</code>, the <code>ct</code> action accepts the
1700 following arguments:
1701 </p>
1702
1703 <dl>
1704 <dt><code>table=<var>table</var></code></dt>
1705 <dd>
1706 Sets the OpenFlow table where the packet is reinjected. The
1707 <var>table</var> must be a number between 0 and 254 inclusive, or a
1708 table's name. If <var>table</var> is not specified, then the packet
1709 is not reinjected.
1710 </dd>
1711
1712 <dt><code>nat</code></dt>
1713 <dt><code>nat(<var>type</var>=<var>addrs</var></code>[<code>:<var>ports</var></code>][<code>,<var>flag</var></code>]...<code>)</code></dt>
1714 <dd>
1715 <p>
1716 Specify address and port translation for the connection being
1717 tracked. The <var>type</var> must be <code>src</code>, for source
1718 address/port translation (SNAT), or <code>dst</code>, for destination
1719 address/port translation (DNAT). Setting up address translation for
1720 a new connection takes effect only if the connection is later
1721 committed with <code>ct(commit</code>...<code>)</code>.
1722 </p>
1723
1724 <p>
1725 The <code>src</code> and <code>dst</code> options take the following
1726 arguments:
1727 </p>
1728
1729 <dl>
1730 <dt><var>addrs</var></dt>
1731 <dd>
1732 The IP address <var>addr</var> or range
1733 <code><var>addr1</var>-<var>addr2</var></code> from which the
1734 translated address should be selected. If only one address is
1735 given, then that address will always be selected, otherwise the
1736 address selection can be informed by the optional persistent flag
1737 as described below. Either IPv4 or IPv6 addresses can be provided,
1738 but both addresses must be of the same type, and the datapath
1739 behavior is undefined in case of providing IPv4 address range for
1740 an IPv6 packet, or IPv6 address range for an IPv4 packet. IPv6
1741 addresses must be bracketed with <code>[</code> and <code>]</code>
1742 if a port range is also given.
1743 </dd>
1744
1745 <dt><var>ports</var></dt>
1746 <dd>
1747 The L4 <var>port</var> or range
1748 <code><var>port1</var>-<var>port2</var></code> from which the
32b2c81f
DB
1749 translated port should be selected. When a port range is
1750 specified, fallback to ephemeral ports does not happen, else,
1751 it will. The port number selection can be informed by the
1752 optional <code>random</code> and <code>hash</code> flags
1753 described below. The userspace datapath only supports the
1754 <code>hash</code> behavior.
be51cd41
BP
1755 </dd>
1756 </dl>
1757
1758 <p>
1759 The optional flags are:
1760 </p>
1761
1762 <dl>
1763 <dt><code>random</code></dt>
1764 <dd>
1765 The selection of the port from the given range should be done using
1766 a fresh random number. This flag is mutually exclusive with
1767 <code>hash</code>.
1768 </dd>
1769
1770 <dt><code>hash</code></dt>
1771 <dd>
1772 The selection of the port from the given range should be done using
1773 a datapath specific hash of the packet's IP addresses and the
1774 other, non-mapped port number. This flag is mutually exclusive
1775 with <code>random</code>.
1776 </dd>
1777
1778 <dt><code>persistent</code></dt>
1779 <dd>
1780 The selection of the IP address from the given range should be done
1781 so that the same mapping can be provided after the system restarts.
1782 </dd>
1783 </dl>
1784
1785 <p>
1786 If <code>alg</code> is specified for the committing <code>ct</code>
1787 action that also includes <code>nat</code> with a <code>src</code> or
1788 <code>dst</code> attribute, then the datapath tries to set up the
1789 helper to be NAT-aware. This functionality is datapath specific and
1790 may not be supported by all datapaths.
1791 </p>
1792
1793 <p>
1794 A ``bare'' <code>nat</code> argument with no options will only
1795 translate the packet being processed in the way the connection has been
1796 set up with an earlier, committed <code>ct</code> action. A
1797 <code>nat</code> action with <code>src</code> or <code>dst</code>, when
1798 applied to a packet belonging to an established (rather than new)
1799 connection, will behave the same as a bare <code>nat</code>.
1800 </p>
1801
1802 <p>
1803 Open vSwitch 2.6 introduced <code>nat</code>. Linux 4.6 was the
1804 earliest upstream kernel that implemented <code>ct</code> support for
1805 <code>nat</code>.
1806 </p>
1807 </dd>
1808 </dl>
1809
1810 <p>
1811 With <code>commit</code>, the connection tracker commits the connection
1812 to the connection tracking module. The <code>commit</code> flag should
1813 only be used from the pipeline within the first fork of <code>ct</code>
1814 without <code>commit</code>. Information about the connection is
1815 stored beyond the lifetime of the packet in the pipeline. Some
1816 <code>ct_state</code> flags are only available for committed
1817 connections.
1818 </p>
1819
1820 <p>
1821 The following options are available only with <code>commit</code>:
1822 </p>
1823
1824 <dl>
1825 <dt><code>force</code></dt>
1826 <dd>
1827 A committed connection always has the directionality of the packet
1828 that caused the connection to be committed in the first place. This
1829 is the ``original direction'' of the connection, and the opposite
1830 direction is the ``reply direction''. If a connection is already
1831 committed, but it is in the wrong direction, <code>force</code>
1832 effectively terminates the existing connection and starts a new one
1833 in the current direction. This flag has no effect if the original
1834 direction of the connection is already the same as that of the
1835 current packet.
1836 </dd>
1837
1838 <dt><code>exec(<var>action</var></code>...<code>)</code></dt>
1839 <dd>
1840 <p>
1841 Perform each <var>action</var> within the context of connection
1842 tracking. Only actions which modify the <code>ct_mark</code> or
1843 <code>ct_label</code> fields are accepted within <code>exec</code>
1844 action, and these fields may only be modified with this option. For
1845 example:
1846 </p>
1847
1848 <dl>
1849 <dt><code>set_field:<var>value</var>[/<var>mask</var>]->ct_mark</code></dt>
1850 <dd>
1851 Store a 32-bit metadata value with the connection. Subsequent
1852 lookups for packets in this connection will populate
1853 <code>ct_mark</code> when the packet is sent to the connection
1854 tracker with the table specified.
1855 </dd>
1856
1857 <dt><code>set_field:<var>value</var>[/<var>mask</var>]->ct_label</code></dt>
1858 <dd>
1859 Store a 128-bit metadata value with the connection. Subsequent
1860 lookups for packets in this connection will populate
1861 <code>ct_label</code> when the packet is sent to the connection
1862 tracker with the table specified.
1863 </dd>
1864 </dl>
1865 </dd>
1866
1867 <dt><code>alg=<var>alg</var></code></dt>
1868 <dd>
1869 <p>
1870 Specify application layer gateway <var>alg</var> to track specific
1871 connection types. If subsequent related connections are sent
1872 through the <code>ct</code> action, then the <code>rel</code> flag
1873 in the <code>ct_state</code> field will be set. Supported types
1874 include:
1875 </p>
1876
1877 <dl>
1878 <dt><code>ftp</code></dt>
1879 <dd>
1880 Look for negotiation of FTP data connections. Specify this
1881 option for FTP control connections to detect related data
1882 connections and populate the <code>rel</code> flag for the data
1883 connections.
1884 </dd>
1885
1886 <dt><code>tftp</code></dt>
1887 <dd>
1888 <p>
1889 Look for negotiation of TFTP data connections. Specify this
1890 option for TFTP control connections to detect related data
1891 connections and populate the <code>rel</code> flag for the data
1892 connections.
1893 </p>
1894 </dd>
1895 </dl>
1896
1897 <p>
1898 Related connections inherit <code>ct_mark</code> from that stored
1899 with the original connection (i.e. the connection created by
1900 <code>ct(alg=</code>...<code>)</code>).
1901 </p>
1902 </dd>
1903 </dl>
1904
1905 <p>
1906 With the Linux datapath, global sysctl options affect <code>ct</code>
1907 behavior. In particular, if
1908 <code>net.netfilter.nf_conntrack_helper</code> is enabled, which it is
1909 by default until Linux 4.7, then application layer gateway helpers may
1910 be executed even if <code>alg</code> is not specified. For security
1911 reasons, the netfilter team recommends users disable this option. For
1912 further details, please see <url
1913 href="http://www.netfilter.org/news.html#2012-04-03"/>.
1914 </p>
1915
1916 <p>
1917 The <code>ct</code> action may be used as a primitive to construct
1918 stateful firewalls by selectively committing some traffic, then
1919 matching <code>ct_state</code> to allow established connections while
1920 denying new connections. The following flows provide an example of how
1921 to implement a simple firewall that allows new connections from port 1
1922 to port 2, and only allows established connections to send traffic from
1923 port 2 to port 1:
1924 </p>
1925
1926 <pre>
1927table=0,priority=1,action=drop
1928table=0,priority=10,arp,action=normal
1929table=0,priority=100,ip,ct_state=-trk,action=ct(table=1)
1930table=1,in_port=1,ip,ct_state=+trk+new,action=ct(commit),2
1931table=1,in_port=1,ip,ct_state=+trk+est,action=2
1932table=1,in_port=2,ip,ct_state=+trk+new,action=drop
1933table=1,in_port=2,ip,ct_state=+trk+est,action=1
1934 </pre>
1935
1936 <p>
1937 If <code>ct</code> is executed on IPv4 (or IPv6) fragments, then the
1938 message is implicitly reassembled before sending to the connection
1939 tracker and refragmented upon output, to the original maximum received
1940 fragment size. Reassembly occurs within the context of the zone,
1941 meaning that IP fragments in different zones are not assembled
1942 together. Pipeline processing for the initial fragments is halted.
1943 When the final fragment is received, the message is assembled and
1944 pipeline processing continues for that flow. Packet ordering is not
1945 guaranteed by IP protocols, so it is not possible to determine which IP
1946 fragment will cause message reassembly (and therefore continue pipeline
1947 processing). As such, it is strongly recommended that multiple flows
1948 should not execute <code>ct</code> to reassemble fragments from the
1949 same IP message.
1950 </p>
1951
1952 <conformance>
1953 The <code>ct</code> action was introduced in Open vSwitch 2.5. Some of
1954 its features were introduced later, noted individually above.
1955 </conformance>
1956 </action>
1957
1958 <action name="CT_CLEAR">
1959 <h2>The <code>ct_clear</code> action</h2>
1960 <syntax><code>ct_clear</code></syntax>
1961
1962 <p>
1963 Clears connection tracking state from the flow, zeroing
1964 <code>ct_state</code>, <code>ct_zone</code>, <code>ct_mark</code>, and
1965 <code>ct_label</code>.
1966 </p>
1967
1968 <p>
1969 This action was introduced in Open vSwitch 2.6.90.
1970 </p>
1971 </action>
1972
1973 <action name="LEARN">
1974 <h2>The <code>learn</code> action</h2>
1975 <syntax><code>learn(<var>argument</var></code>...<code>)</code></syntax>
1976
1977 <p>
1978 The <code>learn</code> action adds or modifies a flow in an OpenFlow
1979 table, similar to <code>ovs-ofctl --strict mod-flows</code>. The
1980 arguments specify the match fields, actions, and other properties of
1981 the flow to be added or modified.
1982 </p>
1983
1984 <p>
1985 Match fields for the new flow are specified as follows. At least one
1986 match field should ordinarily be specified:
1987 </p>
1988
1989 <dl>
1990 <dt><code><var>field</var>=<var>value</var></code></dt>
1991 <dd>
1992 <p>
1993 Specifies that <var>field</var>, in the new flow, must match the
1994 literal <var>value</var>, e.g. <code>dl_type=0x800</code>.
1995 Shorthand match syntax, such as <code>ip</code> in place of
1996 <code>dl_type=0x800</code>, is not supported.
1997 </p>
1998 </dd>
1999
2000 <dt><code><var>field</var>=<var>src</var></code></dt>
2001 <dd>
2002 <p>
2003 Specifies that <var>field</var> in the new flow must match
2004 <var>src</var> taken from the packet currently being processed.
2005 For example, <code>udp_dst=udp_src</code>, applied to a UDP packet
2006 with source port 53, creates a flow which matches
2007 <code>udp_dst=53</code>. <var>field</var> and <var>src</var> must
2008 have the same width.
2009 </p>
2010 </dd>
2011
2012 <dt><code><var>field</var></code></dt>
2013 <dd>
2014 Shorthand for the previous form when <var>field</var> and
2015 <var>src</var> are the same. For example, <code>udp_dst</code>,
2016 applied to a UDP packet with destination port 53, creates a flow
2017 which matches <code>udp_dst=53</code>.
2018 </dd>
2019 </dl>
2020
2021 <p>
2022 The <var>field</var> and <var>src</var> arguments above should be
2023 fields or subfields in the syntax described under ``Field
2024 Specifications'' above.
2025 </p>
2026
2027 <p>
2028 Match field specifications must honor prerequisites for both the flow
2029 with the <code>learn</code> and the new flow that it creates. Consider
2030 the following complete flow, in the syntax accepted by
2031 <code>ovs-ofctl</code>. If the flow's match on <code>udp</code> were
2032 omitted, then the flow would not satisfy the prerequisites for the
2033 <code>learn</code> action's use of <code>udp_src</code>. If
2034 <code>dl_type=0x800</code> or <code>nw_proto</code> were omitted from
2035 <code>learn</code>, then the new flow would not satisfy the
2036 prerequisite for its match on <code>udp_dst</code>. For more
2037 information on prerequisites, please refer to
2038 <code>ovs-fields</code>(7):
2039 </p>
2040
2041 <pre>
2042 udp, actions=learn(dl_type=0x800, nw_proto=17, udp_dst=udp_src)
2043 </pre>
2044
2045 <p>
2046 Actions for the new flow are specified as follows. At least one action
2047 should ordinarily be specified:
2048 </p>
2049
2050 <dl>
2051 <dt><code>load:<var>value</var>-&gt;<var>dst</var></code></dt>
2052 <dd>
2053 Adds a <code>load</code> action to the new flow that loads the
2054 literal <var>value</var> into <var>dst</var>. The syntax is the same
2055 as the <code>load</code> action explained in the ``Header
2056 Modification'' section.
2057 </dd>
2058
2059 <dt><code>load:<var>src</var>-&gt;<var>dst</var></code></dt>
2060 <dd>
2061 Adds a <code>load</code> action to the new flow that loads
2062 <var>src</var>, a field or subfield from the packet being processed,
2063 into <var>dst</var>.
2064 </dd>
2065
2066 <dt><code>output:<var>field</var></code></dt>
2067 <dd>
2068 Adds an <code>output</code> action to the new flow's actions that
2069 outputs to the OpenFlow port taken from <var>field</var>, which must
2070 be a field as described above.
2071 </dd>
2072
2073 <dt><code>fin_idle_timeout=<var>seconds</var></code></dt>
2074 <dt><code>fin_hard_timeout=<var>seconds</var></code></dt>
2075 <dd>
2076 Adds a <code>fin_timeout</code> action with the specified arguments
2077 to the new flow. This feature was added in Open vSwitch 1.5.90.
2078 </dd>
2079 </dl>
2080
2081 The following additional arguments are optional:
2082
2083 <dl>
2084 <dt><code>idle_timeout=<var>seconds</var></code></dt>
2085 <dt><code>hard_timeout=<var>seconds</var></code></dt>
2086 <dt><code>priority=<var>value</var></code></dt>
2087 <dt><code>cookie=<var>value</var></code></dt>
2088 <dt><code>send_flow_rem</code></dt>
2089 <dd>
2090 These arguments have the same meaning as in the usual flow syntax
2091 documented in <code>ovs-ofctl</code>(8).
2092 </dd>
2093
2094 <dt><code>table=<var>table</var></code></dt>
2095 <dd>
2096 The table in which the new flow should be inserted. Specify a
2097 decimal number between 0 and 254 inclusive or the name of a table.
2098 The default, if table is unspecified, is table 1 (not 0).
2099 </dd>
2100
2101 <dt><code>delete_learned</code></dt>
2102 <dd>
2103 <p>
2104 When this flag is specified, deleting the flow that contains the
2105 <code>learn</code> action will also delete the flows created by
2106 <code>learn</code>. Specifically, when the last <code>learn</code>
2107 action with this flag and particular <code>table</code> and
2108 <code>cookie</code> values is removed, the switch deletes all of
2109 the flows in the specified table with the specified cookie.
2110 </p>
2111
2112 <p>
2113 This flag was added in Open vSwitch 2.4.
2114 </p>
2115 </dd>
2116
2117 <dt><code>limit=<var>number</var></code></dt>
2118 <dd>
2119 <p>
2120 If the number of flows in the new flow's table with the same cookie
2121 exceeds <code>number</code>, the action will not add a new flow.
2122 By default, or with <code>limit=0</code>, there is no limit.
2123 </p>
2124
2125 <p>
2126 This flag was added in Open vSwitch 2.8.
2127 </p>
2128 </dd>
2129
2130 <dt><code>result_dst=<var>field</var>[<var>bit</var>]</code></dt>
2131 <dd>
2132 <p>
2133 If learn fails (because the number of flows exceeds
2134 <code>limit</code>), the action sets
2135 <code><var>field</var>[<var>bit</var>]</code> to 0, otherwise it
2136 will be set to 1. <code>field[bit]</code> must be a single bit.
2137 </p>
2138
2139 <p>
2140 This flag was added in Open vSwitch 2.8.
2141 </p>
2142 </dd>
2143 </dl>
2144
2145 <p>
2146 By itself, the <code>learn</code> action can only put two kinds of
2147 actions into the flows that it creates: <code>load</code> and
2148 <code>output</code> actions. If <code>learn</code> is used in
2149 isolation, these are severe limits.
2150 </p>
2151
2152 <p>
2153 However, <code>learn</code> is not meant to be used in isolation. It
2154 is a primitive meant to be used together with other Open vSwitch
2155 features to accomplish a task. Its existing features are enough to
2156 accomplish most tasks.
2157 </p>
2158
2159 <p>
2160 Here is an outline of a typical pipeline structure that allows for
2161 versatile behavior using <code>learn</code>:
2162 </p>
2163
2164 <ul>
2165 <li>
2166 Flows in table <var>A</var> contain a <code>learn</code> action, that
2167 populates flows in table <var>L</var>, that use a <code>load</code>
2168 action to populate register <var>R</var> with information about what
2169 was learned.
2170 </li>
2171
2172 <li>
2173 Flows in table <var>B</var> contain two sequential resubmit actions:
2174 one to table <var>L</var> and another one to table <var>B</var>+1.
2175 </li>
2176
2177 <li>
2178 Flows in table <var>B</var>+1 match on register <var>R</var> and act
2179 differently depending on what the flows in table <var>L</var> loaded
2180 into it.
2181 </li>
2182 </ul>
2183
2184 <p>
2185 This approach can be used to implement many <code>learn</code>-based
2186 features. For example:
2187 </p>
2188
2189 <ul>
2190 <li>
2191 Resubmit to a table selected based on learned information, e.g. see
2192 <url href="https://mail.openvswitch.org/pipermail/ovs-discuss/2016-June/021694.html"/>.
2193 </li>
2194
2195 <li>
2196 MAC learning in the middle of a pipeline, as described in the ``Open
2197 vSwitch Advanced Features Tutorial'' in the OVS documentation.
2198 </li>
2199
2200 <li>
2201 TCP state based firewalling, by learning outgoing connections based
2202 on SYN packets and matching them up with incoming packets. (This is
2203 usually better implemented using the <code>ct</code> action.)
2204 </li>
2205
2206 <li>
2207 At least some of the features described in T. A. Hoff, ``Extending
2208 Open vSwitch to Facilitate Creation of Stateful SDN Applications''.
2209 </li>
2210 </ul>
2211
2212 <conformance>
2213 The <code>learn</code> action is an Open vSwitch extension to OpenFlow
2214 added in Open vSwitch 1.3. Some features of <code>learn</code> were
2215 added in later versions, as noted individually above.
2216 </conformance>
2217 </action>
2218
2219 <action name="FIN_TIMEOUT">
2220 <h2>The <code>fin_timeout</code> action</h2>
2221 <syntax><code>fin_timeout(<var>key</var>=<var>value</var></code>...<code>)</code></syntax>
2222
2223 <p>
2224 This action changes the idle timeout or hard timeout, or both, of the
2225 OpenFlow flow that contains it, when the flow matches a TCP packet with
2226 the FIN or RST flag. When such a packet is observed, the action
2227 reduces the rule's timeouts to those specified on the action. If the
2228 rule's existing timeout is already shorter than the one that the action
2229 specifies, then that timeout is unaffected.
2230 </p>
2231
2232 <p>
2233 The timeouts are specified as key-value pairs:
2234 </p>
2235
2236 <dl>
2237 <dt><code>idle_timeout=</code><var>seconds</var></dt>
2238 <dd>
2239 Causes the flow to expire after the given number of seconds of
2240 inactivity.
2241 </dd>
2242
2243 <dt><code>hard_timeout=</code><var>seconds</var></dt>
2244 <dd>
2245 Causes the flow to expire after the given number of
2246 <var>seconds</var>, regardless of activity. (<var>seconds</var>
2247 specifies time since the flow's creation, not since the receipt of
2248 the FIN or RST.)
2249 </dd>
2250 </dl>
2251
2252 <p>
2253 This action is normally added to a learned flow by the
2254 <code>learn</code> action. It is unlikely to be useful otherwise.
2255 </p>
2256
2257 <conformance>
2258 This Open vSwitch extension action was added in Open vSwitch 1.5.90.
2259 </conformance>
2260 </action>
2261 </group>
2262
2263 <group title="Programming and Control Flow Actions">
2264 <action name="RESUBMIT">
2265 <h2>The <code>resubmit</code> action</h2>
2266 <syntax><code>resubmit:<var>port</var></code></syntax>
2267 <syntax><code>resubmit(</code>[<code><var>port</var></code>]<code>,</code>[<code><var>table</var></code>][<code>,ct</code>]<code>)</code></syntax>
2268
2269 <p>
2270 Searches an OpenFlow flow table for a matching flow and executes the
2271 actions found, if any, before continuing to the following action in the
2272 current flow entry. Arguments can customize the search:
2273 </p>
2274
2275 <ul>
2276 <li>
2277 If <var>port</var> is given as an OpenFlow port number or name, then
2278 it specifies a value to use for the input port metadata field as part
2279 of the search, in place of the input port currently in the flow.
2280 Specifying <code>in_port</code> as <var>port</var> is equivalent to
2281 omitting it.
2282 </li>
2283
2284 <li>
2285 If <var>table</var> is given as an integer between 0 and 254 or a
2286 table name, it specifies the OpenFlow table to search. If it is not
2287 specified, the table from the current flow is used.
2288 </li>
2289
2290 <li>
2291 <p>
2292 If <code>ct</code> is specified, then the search is done with
2293 packet 5-tuple fields swapped with the corresponding conntrack
2294 original direction tuple fields. See the documentation for
2295 <code>ct</code> above, for more information about connection
2296 tracking, or <code>ovs-fields</code>(7) for details about the
2297 connection tracking fields.
2298 </p>
2299
2300 <p>
2301 This flag requires a valid connection tracking state as a match
2302 prerequisite in the flow where this action is placed. Examples of
2303 valid connection tracking state matches include
2304 <code>ct_state=+new</code>, <code>ct_state=+est</code>,
2305 <code>ct_state=+rel</code>, and <code>ct_state=+trk-inv</code>.
2306 </p>
2307 </li>
2308 </ul>
2309
2310 <p>
2311 The changes, if any, to the input port and connection tracking fields
2312 are just for searching the flow table. The changes are not visible to
2313 actions or to later flow table lookups.
2314 </p>
2315
2316 <p>
2317 The most common use of <code>resubmit</code> is to visit another flow
2318 table without <var>port</var> or <code>ct</code>, like this:
2319 <code>resubmit(,<var>table</var>)</code>.
2320 </p>
2321
2322 <p>
2323 Recursive <code>resubmit</code> actions are permitted.
2324 </p>
2325
2326 <conformance>
2327 <p>
2328 The <code>resubmit</code> action is an Open vSwitch extension.
2329 However, the <code>goto_table</code> instruction in OpenFlow 1.1 and
2330 later can be viewed as a kind of restricted <code>resubmit</code>.
2331 </p>
2332
2333 <p>
2334 Open vSwitch 1.2.90 added <var>table</var>. Open vSwitch 2.7 added
2335 <code>ct</code>.
2336 </p>
2337
2338 <p>
2339 Open vSwitch imposes a limit on <code>resubmit</code> recursion that
2340 varies among version:
2341 </p>
2342
2343 <ul>
2344 <li>
2345 Open vSwitch 1.0.1 and earlier did not support recursion.
2346 </li>
2347
2348 <li>
2349 Open vSwitch 1.0.2 and 1.0.3 limited recursion to 8 levels.
2350 </li>
2351
2352 <li>
2353 Open vSwitch 1.1 and 1.2 limited recursion to 16 levels.
2354 </li>
2355
2356 <li>
2357 Open vSwitch 1.2 through 1.8 limited recursion to 32 levels.
2358 </li>
2359
2360 <li>
2361 Open vSwitch 1.9 through 2.0 limited recursion to 64 levels.
2362 </li>
2363
2364 <li>
2365 Open vSwitch 2.1 through 2.5 limited recursion to 64 levels and
2366 impose a total limit of 4,096 resubmits per flow translation
2367 (earlier versions did not impose any total limit).
2368 </li>
2369
2370 <li>
2371 Open vSwitch 2.6 and later imposes the same limits as 2.5, with one
2372 exception: resubmit from table <var>x</var> to any table
2373 <var>y</var> &gt; <var>x</var> does not count against the recursion
2374 depth limit.
2375 </li>
2376 </ul>
2377 </conformance>
2378 </action>
2379
2380 <action name="CLONE">
2381 <h2>The <code>clone</code> action</h2>
2382 <syntax><code>clone(<var>action</var>...)</code></syntax>
2383
2384 <p>
2385 Executes each nested <var>action</var>, saving much of the packet and
2386 pipeline state beforehand and then restoring it afterward. The state
2387 that is saved and restored includes all flow data and metadata
2388 (including, for example, <code>in_port</code> and
2389 <code>ct_state</code>), the stack accessed by <code>push</code> and
2390 <code>pop</code> actions, and the OpenFlow action set.
2391 </p>
2392
2393 <p>
2394 This action was added in Open vSwitch 2.6.90.
2395 </p>
2396 </action>
2397
2398 <action name="STACK_PUSH, STACK_POP">
2399 <h2>The <code>push</code> and <code>pop</code> actions</h2>
2400 <syntax><code>push:<var>src</var></code></syntax>
2401 <syntax><code>pop:<var>dst</var></code></syntax>
2402 <p>
2403 The <code>push</code> action pushes <var>src</var> on a general-purpose
2404 stack. The <code>pop</code> action pops an entry off the stack into
2405 <var>dst</var>. <var>src</var> and <var>dst</var> should be fields or
2406 subfields in the syntax described under ``Field Specifications'' above.
2407 </p>
2408
2409 <p>
2410 Controllers can use the stack for saving and restoring data or metadata
2411 around <code>resubmit</code> actions, for swapping or rearranging data
2412 and metadata, or for other purposes. Any data or metadata field, or
2413 part of one, may be pushed, and any modifiable field or subfield may be
2414 popped.
2415 </p>
2416
2417 <p>
2418 The number of bits pushed in a stack entry do not have to match the
2419 number of bits later popped from that entry. If more bits are popped
2420 from an entry than were pushed, then the entry is conceptually
2421 left-padded with 0-bits as needed. If fewer bits are popped than
2422 pushed, then bits are conceptually trimmed from the left side of the
2423 entry.
2424 </p>
2425
2426 <p>
2427 The stack's size is limited. The limit is intended to be high enough
2428 that ``normal'' use will not pose problems. Stack overflow or
2429 underflow is an error that stops action execution (see ``Stack too
2430 deep'' under ``Error Handling'', above).
2431 </p>
2432
2433 <p>
2434 Examples:
2435 </p>
2436
2437 <ul>
2438 <li>
2439 <code>push:reg2[0..5]</code> or <code>push:NXM_NX_REG2[0..5]</code>
2440 pushes on the stack the 6 bits in register 2 bits 0 through 5.
2441 </li>
2442
2443 <li>
2444 <code>pop:reg2[0..5]</code> or <code>pop:NXM_NX_REG2[0..5]</code>
2445 pops the value from top of the stack and copy bits 0 through 5 of
2446 that value into bits 0 through 5 of register 2.
2447 </li>
2448 </ul>
2449
2450 <conformance>
2451 Open vSwitch 1.2 introduced <code>push</code> and <code>pop</code> as
2452 OpenFlow extension actions.
2453 </conformance>
2454 </action>
2455
2456 <action name="EXIT">
2457 <h2>The <code>exit</code> action</h2>
2458 <syntax><code>exit</code></syntax>
2459
2460 <p>
2461 This action causes Open vSwitch to immediately halt execution of
2462 further actions. Actions which have already been executed are
2463 unaffected. Any further actions, including those which may be in other
2464 tables, or different levels of the <code>resubmit</code> call stack,
2465 are ignored. However, an <code>exit</code> action within a group
2466 bucket terminates only execution of that bucket, not other buckets or
2467 the overall pipeline. Actions in the action set are still executed
2468 (specify <code>clear_actions</code> before <code>exit</code> to discard
2469 them).
2470 </p>
2471 </action>
2472
2473 <action name="MULTIPATH">
2474 <h2>The <code>multipath</code> action</h2>
2475 <syntax><code>multipath(<var>fields</var>, <var>basis</var>, <var>algorithm</var>, <var>n_links</var>, <var>arg</var>, <var>dst</var>)</code></syntax>
2476
2477 <p>
2478 Hashes <var>fields</var> using <var>basis</var> as a universal hash
2479 parameter, then the applies multipath link selection
2480 <var>algorithm</var> (with parameter <var>arg</var>) to choose one of
2481 <var>n_links</var> output links numbered 0 through <var>n_links</var>
2482 minus 1, and stores the link into <var>dst</var>, which must be a field
2483 or subfield in the syntax described under ``Field Specifications''
2484 above.
2485 </p>
2486
2487 <p>
2488 The <code>bundle</code> or <code>bundle_load</code> actions are usually
2489 easier to use than <code>multipath</code>.
2490 </p>
2491
2492 <p>
2493 <var>fields</var> must be one of the following:
2494 </p>
2495
2496 <dl>
2497 <dt><code>eth_src</code></dt>
2498 <dd>
2499 Hashes Ethernet source address only.
2500 </dd>
2501
2502 <dt><code>symmetric_l4</code></dt>
2503 <dd>
2504 Hashes Ethernet source, destination, and type, VLAN ID, IPv4/IPv6
70506167 2505 source, destination, and protocol, and TCP or SCTP (but not UDP)
be51cd41
BP
2506 ports. The hash is computed so that pairs of corresponding flows in
2507 each direction hash to the same value, in environments where L2 paths
2508 are the same in each direction. UDP ports are not included in the
70506167 2509 hash to support protocols such as VXLAN that use asymmetric ports
be51cd41
BP
2510 in each direction.
2511 </dd>
2512
2513 <dt><code>symmetric_l3l4</code></dt>
2514 <dd>
2515 Hashes IPv4/IPv6 source, destination, and protocol, and TCP or SCTP
2516 (but not UDP) ports. Like <code>symmetric_l4</code>, this is a
2517 symmetric hash, but by excluding L2 headers it is more effective in
2518 environments with asymmetric L2 paths (e.g. paths involving VRRP IP
2519 addresses on a router). Not an effective hash function for protocols
2520 other than IPv4 and IPv6, which hash to a constant zero.
2521 </dd>
2522
2523 <dt><code>symmetric_l3l4+udp</code></dt>
2524 <dd>
2525 Like <code>symmetric_l3l4+udp</code>, but UDP ports are included in
2526 the hash. This is a more effective hash when asymmetric UDP
2527 protocols such as VXLAN are not a consideration.
2528 </dd>
2529
2530 <dt><code>symmetric_l3</code></dt>
2531 <dd>
2532 Hashes network source address and network destination address.
2533 </dd>
2534
2535 <dt><code>nw_src</code></dt>
2536 <dd>
2537 Hashes network source address only.
2538 </dd>
2539
2540 <dt><code>nw_dst</code></dt>
2541 <dd>
2542 Hashes network destination address only.
2543 </dd>
2544 </dl>
2545
2546 <p>
2547 The <var>algorithm</var> used to compute the final result
2548 <var>link</var> must be one of the following:
2549 </p>
2550
2551 <dl>
2552 <dt><code>modulo_n</code></dt>
2553 <dd>
2554 <p>
2555 Computes <var>link</var> = hash(<var>flow</var>) % <var>n_links</var>.
2556 </p>
2557
2558 <p>
2559 This algorithm redistributes all traffic when <var>n_links</var>
2560 changes. It has <i>O(1)</i> performance.
2561 </p>
2562
2563 <p>
2564 Use 65535 for <var>max_link</var> to get a raw hash value.
2565 </p>
2566
2567 <p>
2568 This algorithm is specified by RFC 2992.
2569 </p>
2570 </dd>
2571
2572 <dt><code>hash_threshold</code></dt>
2573 <dd>
2574 <p>
2575 Computes <var>link</var> = hash(<var>flow</var>) / (<code>MAX_HASH</code> / <var>n_links</var>).
2576 </p>
2577
2578 <p>
2579 Redistributes between one-quarter and one-half of traffic when
2580 n_links changes. It has <i>O(1)</i> performance.
2581 </p>
2582
2583 <p>
2584 This algorithm is specified by RFC 2992.
2585 </p>
2586 </dd>
2587
2588 <dt><code>hrw</code> (Highest Random Weight)</dt>
2589 <dd>
2590 <p>
2591 Computes the following:
2592 </p>
2593
2594 <pre>
2595for <var>i</var> in [0,<var>n_links</var>]:
2596 <var>weights</var>[<var>i</var>] = hash(<var>flow</var>, <var>i</var>)
2597<var>link</var> = { <var>i</var> such that <var>weights</var>[<var>i</var>] &gt;= <var>weights</var>[<var>j</var>] for all <var>j</var> != <var>i</var> }
2598 </pre>
2599
2600 <p>
2601 Redistributes 1/<var>n_links</var> of traffic when
2602 <var>n_links</var> changes. It has <i>O(<var>n_links</var>)</i>
2603 performance. If <var>n_links</var> is greater than a threshold
2604 (currently 64, but subject to change), Open vSwitch will substitute
2605 another algorithm automatically.
2606 </p>
2607
2608 <p>
2609 This algorithm is specified by RFC 2992.
2610 </p>
2611 </dd>
2612
2613 <dt><code>iter_hash</code> (Iterative Hash)</dt>
2614 <dd>
2615 <p>
2616 Computes the following:
2617 </p>
2618
2619 <pre>
2620<var>i</var> = 0
2621repeat:
2622 <var>i</var> = <var>i</var> + 1
2623 <var>link</var> = hash(<var>flow</var>, <var>i</var>) % <var>arg</var>
2624while <var>link</var> &gt; <var>max_link</var>
2625 </pre>
2626
2627 <p>
2628 Redistributes 1/<var>n_links</var> of traffic when
2629 <var>n_links</var> changes. O(1) performance when
2630 <var>arg</var>/<var>max_link</var> is bounded by a constant.
2631 </p>
2632
2633 <p>
2634 Redistributes all traffic when <var>arg</var> changes.
2635 </p>
2636
2637 <p>
2638 <var>arg</var> must be greater than <var>max_link</var> and for
2639 best performance should be no more than approximately
2640 <var>max_link</var> * 2. If <var>arg</var> is outside the
2641 acceptable range, Open vSwitch will automatically substitute the
2642 least power of 2 greater than <var>max_link</var>.
2643 </p>
2644
2645 <p>
2646 This algorithm is specific to Open vSwitch.
2647 </p>
2648 </dd>
2649 </dl>
2650
2651 <p>
2652 Only the <code>iter_hash</code> algorithm uses <var>arg</var>.
2653 </p>
2654
2655 <p>
2656 It is an error if <var>max_link</var> is greater than or equal to
2657 2**<var>n_bits</var>.
2658 </p>
2659
2660 <conformance>
2661 This is an OpenFlow extension added in Open vSwitch 1.1.
2662 </conformance>
2663 </action>
2664 </group>
2665
2666 <group title="Other Actions">
2667 <action name="CONJUNCTION">
2668 <h2>The <code>conjunction</code> action</h2>
2669 <syntax><code>conjunction(<var>id</var>, <var>k</var>/<var>n</var>)</code></syntax>
2670
2671 <p>
2672 This action allows for sophisticated ``conjunctive match'' flows.
2673 Refer to ``Conjunctive Match Fields'' in <code>ovs-fields</code>(7) for
2674 details.
2675 </p>
2676
2677 <p>
2678 A flow that has one or more <code>conjunction</code> actions may not
2679 have any other actions except for <code>note</code> actions.
2680 </p>
2681
2682 <conformance>
2683 Open vSwitch 2.4 introduced the <code>conjunction</code> action and
2684 <code>conj_id</code> field. They are Open vSwitch extensions to
2685 OpenFlow.
2686 </conformance>
2687 </action>
2688
2689 <action name="NOTE">
2690 <h2>The <code>note</code> action</h2>
2691 <syntax><code>note:</code>[<var>hh</var>]...</syntax>
2692
2693 <p>
2694 This action does nothing at all. OpenFlow controllers may use it to
2695 annotate flows with more data than can fit in a flow cookie.
2696 </p>
2697
2698 <p>
2699 The action may include any number of bytes represented as hex digits
2700 <var>hh</var>. Periods may separate pairs of hex digits, for
2701 readability. The <code>note</code> action's format doesn't include an
2702 exact length for its payload, so the provided bytes will be padded on
2703 the right by enough bytes with value 0 to make the total number 6 more
2704 than a multiple of 8.
2705 </p>
2706
2707 <p>
2708
2709 </p>
2710
2711 <conformance>
2712 This action is an extension to OpenFlow introduced in Open vSwitch 1.1.
2713 </conformance>
2714 </action>
2715
2716 <action name="SAMPLE">
2717 <h2>The <code>sample</code> action</h2>
2718 <syntax><code>sample(<var>argument</var>...)</code></syntax>
2719
2720 <p>
2721 Samples packets and sends one sample for every sampled packet.
2722 </p>
2723
2724 <p>
2725 The following <var>argument</var> forms are accepted:
2726 </p>
2727
2728 <dl>
2729 <dt><code>probability=<var>packets</var></code></dt>
2730 <dd>
2731 The number of sampled packets out of 65535. Must be greater or equal
2732 to 1.
2733 </dd>
2734
2735 <dt><code>collector_set_id=<var>id</var></code></dt>
2736 <dd>
2737 The unsigned 32-bit integer identifier of the set of sample
2738 collectors to send sampled packets to. Defaults to 0.
2739 </dd>
2740
2741 <dt><code>obs_domain_id=<var>id</var></code></dt>
2742 <dd>
2743 When sending samples to IPFIX collectors, the unsigned 32-bit integer
2744 Observation Domain ID sent in every IPFIX flow record. Defaults to
2745 0.
2746 </dd>
2747
2748 <dt><code>obs_point_id=<var>id</var></code></dt>
2749 <dd>
2750 When sending samples to IPFIX collectors, the unsigned 32-bit integer
2751 Observation Point ID sent in every IPFIX flow record. Defaults to 0.
2752 </dd>
2753
2754 <dt><code>sampling_port=<var>port</var></code></dt>
2755 <dd>
2756 Sample packets on <var>port</var>, which should be the ingress or
2757 egress port. This option, which was added in Open vSwitch 2.5.90,
2758 allows the IPFIX implementation to export egress tunnel information.
2759 </dd>
2760
2761 <dt><code>ingress</code></dt>
2762 <dt><code>egress</code></dt>
2763 <dd>
2764 Specifies explicitly that the packet is being sampled on ingress to
2765 or egress from the switch. IPFIX reports sent by Open vSwitch before
2766 version 2.5.90 did not include a direction. From 2.5.90 until
2767 2.6.90, IPFIX reports inferred a direction from
2768 <var>sampling_port</var>: if it was the packet's output port, then
2769 the direction was reported as egress, otherwise as ingress. Open
2770 vSwitch 2.6.90 introduced these options, which allow the inferred
2771 direction to be overridden. This is particularly useful when the
2772 ingress (or egress) port is not a tunnel.
2773 </dd>
2774 </dl>
2775
2776 <p>
2777 Refer to <code>ovs-vswitchd.conf.db</code>(5) for more details on
2778 configuring sample collector sets.
2779 </p>
2780
2781 <conformance>
2782 This action is an OpenFlow extension added in Open vSwitch 2.4.
2783 </conformance>
2784 </action>
2785 </group>
2786
2787 <group title="Instructions">
2788 <p>
2789 Every version of OpenFlow includes actions. OpenFlow 1.1 introduced the
2790 higher-level, related concept of <dfn>instructions</dfn>. In OpenFlow
2791 1.1 and later, actions within a flow are always encapsulated within an
2792 instruction. Each flow has at most one instruction of each kind, which
2793 are executed in the following fixed order defined in the OpenFlow
2794 specification:
2795 </p>
2796
2797 <ol>
2798 <li><code>Meter</code></li>
2799 <li><code>Apply-Actions</code></li>
2800 <li><code>Clear-Actions</code></li>
2801 <li><code>Write-Actions</code></li>
2802 <li><code>Write-Metadata</code></li>
2803 <li><code>Stat-Trigger</code> (not supported by Open vSwitch)</li>
2804 <li><code>Goto-Table</code></li>
2805 </ol>
2806
2807 <p>
2808 The most important instruction is <code>Apply-Actions</code>. This
2809 instruction encapsulates any number of actions, which the instruction
2810 executes. Open vSwitch does not explicitly represent
2811 <code>Apply-Actions</code>. Instead, any action by itself is implicitly
2812 part of an <code>Apply-Actions</code> instructions.
2813 </p>
2814
2815 <p>
2816 Open vSwitch syntax requires other instructions, if present, to be in the
2817 order listed above. Otherwise it will flag an error.
2818 </p>
2819
2820 <action name="METER">
2821 <h2>The <code>meter</code> action and instruction</h2>
2822 <syntax><code>meter:<var>meter_id</var></code></syntax>
2823
2824 <p>
2825 Apply meter <var>meter_id</var>. If a meter band rate is exceeded, the
2826 packet may be dropped, or modified, depending on the meter band type.
2827 </p>
2828
2829 <conformance>
2830 <p>
2831 OpenFlow 1.3 introduced the <code>meter</code> instruction. OpenFlow
2832 1.5 changes <code>meter</code> from an instruction to an action.
2833 </p>
2834
2835 <p>
2836 Open vSwitch 2.0 introduced OpenFlow protocol support for meters, but
2837 it did not include a datapath implementation. Open vSwitch 2.7 added
2838 meter support to the userspace datapath. Open vSwitch 2.10 added
2839 meter support to the kernel datapath.
2840 </p>
2841 </conformance>
2842 </action>
2843
2844 <action name="CLEAR_ACTIONS">
2845 <h2>The <code>clear_actions</code> instruction</h2>
2846 <syntax><code>clear_actions</code></syntax>
2847
2848 <p>
2849 Clears the action set. See ``Action Sets'', above, for more
2850 information.
2851 </p>
2852
2853 <conformance>
2854 OpenFlow 1.1 introduced <code>clear_actions</code>. Open vSwitch 2.1
2855 added support for <code>clear_actions</code>.
2856 </conformance>
2857 </action>
2858
2859 <action name="WRITE_ACTIONS">
2860 <h2>The <code>write_actions</code> instruction</h2>
2861 <syntax><code>write_actions(<var>action</var></code>...<code>)</code></syntax>
2862
2863 <p>
2864 Adds each <var>action</var> to the action set. The action set is
2865 carried between flow tables and then executed at the end of the
2866 pipeline. Only certain actions may be written to the action set. See
2867 ``Action Sets'', above, for more information.
2868 </p>
2869
2870 <conformance>
2871 OpenFlow 1.1 introduced <code>write_actions</code>. Open vSwitch 2.1
2872 added support for <code>write_actions</code>.
2873 </conformance>
2874 </action>
2875
2876 <action name="WRITE_METADATA">
2877 <h2>The <code>write_metadata</code> instruction</h2>
2878 <syntax><code>write_metadata:<var>value</var></code>[<code>/<var>mask</var></code>]</syntax>
2879
2880 <p>
2881 Updates the flow's <code>metadata</code> field. If <var>mask</var> is
2882 omitted, <code>metadata</code> is set exactly to <var>value</var>; if
2883 <var>mask</var> is specified, then a 1-bit in <var>mask</var> indicates
2884 that the corresponding bit in <code>metadata</code> will be replaced
2885 with the corresponding bit from <var>value</var>. Both
2886 <var>value</var> and <var>mask</var> are 64-bit values that are decimal
2887 by default; use a <code>0x</code> prefix to specify them in
2888 hexadecimal.
2889 </p>
2890
2891 <p>
2892 The <code>metadata</code> field can also be matched in the flow table
2893 and updated with actions such as <code>set_field</code> and
2894 <code>move</code>.
2895 </p>
2896
2897 <conformance>
2898 OpenFlow 1.1 introduced <code>write_metadata</code>. Open vSwitch 2.1
2899 added support for <code>write_metadata</code>.
2900 </conformance>
2901 </action>
2902
2903 <action name="GOTO_TABLE">
2904 <h2>The <code>goto_table</code> instruction</h2>
2905 <syntax><code>goto_table:<var>table</var></code></syntax>
2906
2907 <p>
2908 Jumps to <var>table</var> as the next table in the process pipeline.
2909 The table may be a number between 0 and 254 or a table name.
2910 </p>
2911
2912 <p>
2913 It is an error if <var>table</var> is less than or equal to the table
2914 of the flow that contains it; that is, <code>goto_table</code> must
2915 move forward in the OpenFlow pipeline. Since <code>goto_table</code>
2916 must be the last instruction in a flow, it never leads to recursion.
2917 The <code>resubmit</code> extension action is more flexible.
2918 </p>
2919
2920 <conformance>
2921 OpenFlow 1.1 introduced <code>goto_table</code>. Open vSwitch 2.1
2922 added support for <code>goto_table</code>.
2923 </conformance>
2924 </action>
2925 </group>
2926</actions>