Open vSwitch
2.11.1
openvswitch
Production Quality, Multilayer Open Virtual Switch
NAME
ovs-actions - OpenFlow actions and instructions with Open vSwitch extensions
INTRODUCTION
This document aims to comprehensively document all of the OpenFlow actions and instructions, both standard and non-standard, supported by Open vSwitch, regardless of origin[char46] The document includes information of interest to Open vSwitch users, such as the semantics of each supported action and the syntax used by Open vSwitch tools, and to developers seeking to build controllers and switches compatible with Open vSwitch, such as the wire format for each supported message[char46]
Actions
In this document, we define an action as an OpenFlow action, which is a kind of command that specifies what to do with a packet[char46] Actions are used in OpenFlow flows to describe what to do when the flow matches a packet, and in a few other places in OpenFlow[char46] Each version of the OpenFlow specification defines standard actions, and beyond that many OpenFlow switches, including Open vSwitch, implement extensions to the standard[char46]
OpenFlow groups actions in two ways: as an action list or an action set, described below[char46]
Action Lists
An action list, a concept present in every version of OpenFlow, is simply an ordered sequence of actions[char46] The OpenFlow specifications require a switch to execute actions within an action list in the order specified, and to refuse to execute an action list entirely if it cannot implement the actions in that order [OpenFlow 1[char46]0, section 3[char46]3], with one exception: when an action list outputs multiple packets, the switch may output the packets in an order different from that specified[char46] Usually, this exception is not important, especially in the common case when the packets are output to different ports[char46]
Action Sets
OpenFlow 1[char46]1 introduced the concept of an action set[char46] An action set is also a sequence of actions, but the switch reorders the actions and drops duplicates according to rules specified in the OpenFlow specifications[char46] Because of these semantics, some standard OpenFlow actions cannot usefully be included in an action set[char46] For some, but not all, Open vSwitch extension actions, Open vSwitch defines its own action set semantics and ordering[char46]
The OpenFlow pipeline has an action set associated with it as a packet is processed[char46] After pipeline processing is otherwise complete, the switch executes the actions in the action set[char46]
Open vSwitch applies actions in an action set in the following order: Except as noted otherwise below, the action set only executes at most a single action of each type, and when more than one action of a given type is present, the one added to the set later replaces the earlier action:
1. | strip_vlan | ||||||||||||||||||||||||||||||||
2. | pop_mpls | ||||||||||||||||||||||||||||||||
3. | decap | ||||||||||||||||||||||||||||||||
4. | encap | ||||||||||||||||||||||||||||||||
5. | push_mpls | ||||||||||||||||||||||||||||||||
6. | push_vlan | ||||||||||||||||||||||||||||||||
7. | dec_ttl | ||||||||||||||||||||||||||||||||
8. | dec_mpls_ttl | ||||||||||||||||||||||||||||||||
9. | dec_nsh_ttl | ||||||||||||||||||||||||||||||||
10. | All of the following actions are executed in the order added to the action set, with cumulative effect[char46] That is, when multiple actions modify the same part of a field, the later modification takes effect, and when they modify different parts of a field (or different fields), then both modifications are applied:
|
||||||||||||||||||||||||||||||||
11. | set_queue | ||||||||||||||||||||||||||||||||
12. | group, output, resubmit, ct_clear, or ct[char46] If more than one of these actions is present, then the one listed earliest above is executed and the others are ignored, regardless of the order in which they were added to the action set[char46] (If none of these actions is present, the action set has no real effect, because the modified packet is not sent anywhere and thus the modifications are not visible[char46]) |
An action set may only contain the actions listed above[char46]
Error Handling
Packet processing can encounter a variety of errors:
Bridge not found | |
Open vSwitch supports an extension to the standard OpenFlow controller action called a ‘‘continuation,\(cq\(cq which allows the controller to interrupt and later resume the processing of a packet through the switch pipeline[char46] This error occurs when such a packet\(cqs processing cannot be resumed, e[char46]g[char46] because the bridge processing it has been destroyed[char46] Open vSwitch reports this error to the controller as Open vSwitch extension error NXR_STALE[char46] | |
This error prevents packet processing entirely[char46] | |
Recursion too deep | |
While processing a given packet, Open vSwitch limits the flow table recursion depth to 64, to ensure that packet processing uses a finite amount of time and space[char46] Actions that count against the recursion limit include resubmit from a given OpenFlow table to the same or an earlier table, group, and output to patch ports[char46] | |
A resubmit from one table to a later one (or, equivalently[char46] a goto_table instruction) does not count against the depth limit because resubmits to strictly monotonically increasing tables will eventually terminate[char46] OpenFlow tables are most commonly traversed in numerically increasing order, so this limit has little effect on conventionally designed OpenFlow pipelines[char46] | |
This error terminates packet processing[char46] Any previous side effects (e[char46]g[char46] output actions) are retained[char46] | |
Usually this error indicates a loop or other bug in the OpenFlow flow tables[char46] To assist debugging, when this error occurs, Open vSwitch 2[char46]10 and later logs a trace of the packet execution, as if by ovs-appctl ofproto/trace, rate-limited to one per minute to reduce the log volume[char46] | |
Too many resubmits | |
Open vSwitch limits the total number of resubmit actions that a given packet can execute to 4,096[char46] For this purpose, goto_table instructions and output to the table port are treated like resubmit[char46] This limits the amount of time to process a single packet[char46] | |
Unlike the limit on recursion depth, the limit on resubmits counts all resubmits, regardless of direction[char46] | |
This error has the same effect, including logging, as exceeding the recursion depth limit[char46] | |
Stack too deep | |
Open vSwitch limits the amount of data that the push action can put onto the stack at one time to 64 kB of data[char46] | |
This error terminates packet processing[char46] Any previous side effects (e[char46]g[char46] output actions) are retained[char46] | |
No recirculation context | |
Recirculation conflict | |
These errors indicate internal errors inside Open vSwitch and should generally not occur[char46] If you notice recurring log messages about these errors, please report a bug[char46] | |
Too many MPLS labels | |
Open vSwitch can process packets with any number of MPLS labels, but its ability to push and pop MPLS labels is limited, currently to 3 labels[char46] Attempting to push more than the supported number of labels onto a packet, or to pop any number of labels from a packet with more than the supported number, raises this error[char46] | |
This error terminates packet processing, retaining any previous side effects (e[char46]g[char46] output actions)[char46] When this error arises within the execution of a group bucket, it only terminates that bucket\(cqs execution, not packet processing overall[char46] | |
Invalid tunnel metadata | |
Open vSwitch raises this error when it processes a Geneve packet that has TLV options with an invalid form, e[char46]g[char46] where the length in a TLV would extend past the end of the options[char46] | |
This error prevents packet processing entirely[char46] | |
Unsupported packet type | |
When a encap action encapsulates a packet, Open vSwitch raises this error if it does not support the combination of the new encapsulation with the current packet[char46] encap(ethernet) raises this error if the current packet is not an L3 packet, and encap(nsh) raises this error if the current packet is not Ethernet, IPv4, IPv6, or NSH[char46] | |
When a decap action decapsulates a packet, Open vSwitch raises this error if it does not support the type of inner packet[char46] decap of an Ethernet header raises this error if a VLAN header is present, decap of a NSH packet raises this error if the NSH inner packet is not Ethernet, IPv4, IPv6, or NSH, and decap of other types of packets is unsupported and also raises this error[char46] | |
This error terminates packet processing, retaining any previous side effects (e[char46]g[char46] output actions)[char46] When this error arises within the execution of a group bucket, it only terminates that bucket\(cqs execution, not packet processing overall[char46] |
Inconsistencies
OpenFlow 1[char46]0 allows any action to be part of any flow, regardless of the flow\(cqs match[char46] Some combinations do not make sense, e[char46]g[char46] an set_nw_tos action in a flow that matches only ARP packets or strip_vlan in a flow that matches packets without VLAN tags[char46] Other combinations have varying results depending on the kind of packet that the flow processes, e[char46]g[char46] a set_nw_src action in a flow that does not match on Ethertype will be treated as a no-op when it processes a non-IPv4 packet[char46] Nevertheless OVS allows all of the above in conformance with OpenFlow 1[char46]0, that is, the following will succeed:
$ ovs-ofctl -O OpenFlow10 add-flow br0 arp,actions=mod_nw_tos:12
$ ovs-ofctl -O OpenFlow10 add-flow br0 dl_vlan=0xffff,actions=strip_vlan
$ ovs-ofctl -O OpenFlow10 add-flow br0 actions=mod_nw_src:1[char46]2[char46]3[char46]4
Open vSwitch calls these kinds of combinations inconsistencies between match and actions[char46] OpenFlow 1[char46]1 and later forbid inconsistencies, and disallow the examples described above by preventing such flows from being added[char46] All of the above, for example, will fail with an error message if one replaces OpenFlow10 by OpenFlow11[char46]
OpenFlow 1[char46]1 and later cannot detect and disallow all inconsistencies[char46] For example, the write_actions instruction arbitrarily delays execution of the actions inside it, which can even be canceled with clear_actions, so that there is no way to ensure that its actions are consistent with the packet at the time they execute[char46] Thus, actions with write_actions and some other contexts are exempt from consistency requirements[char46]
When OVS executes an action inconsistent with the packet, it treats it as a no-op[char46]
Inter-Version Compatibility
Open vSwitch supports multiple OpenFlow versions simultaneously on a single switch[char46] When actions are added with one OpenFlow version and then retrieved with another, Open vSwitch does its best to translate between them[char46]
Inter-version compatibility issues can still arise when different connections use different OpenFlow versions[char46] Backward compatibility is the most obvious case[char46] Suppose, for example, that an OpenFlow 1[char46]1 session adds a flow with a push_vlan action, for which there is no equivalent in OpenFlow 1[char46]0[char46] If an OpenFlow 1[char46]0 session retrieves this flow, Open vSwitch must somehow represent the action[char46]
Forward compatibility can also be an issue, because later OpenFlow versions sometimes remove functionality[char46] The best example is the enqueue action from OpenFlow 1[char46]0, which OpenFlow 1[char46]1 removed[char46]
In practice, Open vSwitch uses a variety of strategies for inter-version compatibility:
o | Most standard OpenFlow actions, such as output actions, translate without compatibility issues[char46] |
o | Open vSwitch supports its extension actions in every OpenFlow version, so they do not pose inter-version compatibility problems[char46] |
o | Open vSwitch sometimes adds extension actions to ensure backward or forward compatibility[char46] For example, for backward compatibility with the group action added in OpenFlow 1[char46]1, Open vSwitch includes an OpenFlow 1[char46]0 extension group action[char46] |
Perfect inter-version compatibility is not possible, so best results require OpenFlow connections to use a consistent version[char46] One may enforce use of a particular version by setting the protocols column for a bridge, e[char46]g[char46] to force br0 to use only OpenFlow 1[char46]3:
ovs-vsctl set bridge br0 protocols=OpenFlow13
Field Specifications
Many Open vSwitch actions refer to fields[char46] In such cases, fields may usually be referred to by their common names, such as eth_dst for the Ethernet destination field, or by their full OXM or NXM names, such as NXM_OF_ETH_DST or OXM_OF_ETH_DST[char46] Before Open vSwitch 2[char46]7, only OXM or NXM field names were accepted[char46]
Many actions that act on fields can also act on subfields, that is, parts of fields, written as field[start[char46][char46]end], where start is the first bit and end is the last bit to use in field, e[char46]g[char46] vlan_tci[13[char46][char46]15] for the VLAN PCP[char46] A single-bit subfield may also be written as field[offset], e[char46]g[char46] vlan_tci[13] for the least-significant bit of the VLAN PCP[char46] Empty brackets may be used to explicitly designate an entire field, e[char46]g[char46] vlan_tci[] for the entire 16-bit VLAN TCI header[char46] Before Open vSwitch 2[char46]7, brackets were required in field specifications[char46]
See ovs-fields(7) for a list of fields and their names[char46]
Port Specifications
Many Open vSwitch actions refer to OpenFlow ports[char46] In such cases, the port may be specified as a numeric port number in the range 0 to 65,535, although Open vSwitch only assigns port numbers in the range 1 through 62,279 to ports[char46] OpenFlow 1[char46]1 and later use 32-bit port numbers, but Open vSwitch never assigns a port number that requires more than 16 bits[char46]
In most contexts, the name of a port may also be used[char46] (The most obvious context where a port name may not be used is in an ovs-ofctl command along with the --no-names option[char46]) When a port\(cqs name contains punctuation or could be ambiguous with other actions, the name may be enclosed in double quotes, with JSON-like string escapes supported (see [RFC 8259])[char46]
Open vSwitch also supports the following standard OpenFlow port names (even in contexts where port names are not otherwise supported)[char46] The corresponding OpenFlow 1[char46]0 and 1[char46]1+ port numbers are listed alongside them but should not be used in flow syntax:
o | in_port (65528 or 0xfff8; 0xfffffff8) |
o | table (65529 or 0xfff9; 0xfffffff9) |
o | normal (65530 or 0xfffa; 0xfffffffa) |
o | flood (65531 or 0xfffb; 0xfffffffb) |
o | all (65532 or 0xfffc; 0xfffffffc) |
o | controller (65533 or 0xfffd; 0xfffffffd) |
o | local (65534 or 0xfffe; 0xfffffffe) |
o | any or none (65535 or 0xffff; 0xffffffff) |
o | unset (not in OpenFlow 1[char46]0; 0xfffffff7) |
OUTPUT ACTIONS
These actions send a packet to a physical port or a controller[char46] A packet that never encounters an output action on its trip through the Open vSwitch pipeline is effectively dropped[char46] Because actions are executed in order, a packet modification action that is not eventually followed by an output action will not have an externally visible effect[char46]
The output action
Syntax: | port | ||||||||||
output:port | |||||||||||
output:field | |||||||||||
output(port=port, max_len=nbytes) | |||||||||||
Outputs the packet to an OpenFlow port most commonly specified as port[char46] Alternatively, the output port may be read from field, a field or subfield in the syntax described under ‘‘Field Specifications\(cq\(cq above[char46] Either way, if the port is the packet\(cqs input port, the packet is not output[char46] | |||||||||||
The port may be one of the following standard OpenFlow ports: | |||||||||||
|
|||||||||||
The port may also be one of the following additional OpenFlow ports, unless max_len is specified: | |||||||||||
|
|||||||||||
Open vSwitch rejects output to other standard OpenFlow ports, including none, unset, and port numbers reserved for future use as standard ports, with the error OFPBAC_BAD_OUT_PORT[char46] | |||||||||||
With max_len, the packet is truncated to at most nbytes bytes before being output[char46] In this case, the output port may not be a patch port[char46] Truncation is just for the single output action, so that later actions in the OpenFlow pipeline work with the complete packet[char46] The truncation feature is meant for use in monitoring applications, e[char46]g[char46] for mirroring packets to a collector[char46] | |||||||||||
When an output action specifies the number of a port that does not currently exist (and is not in the range for standard ports), the OpenFlow specification allows but does not require OVS to reject the action[char46] All versions of Open vSwitch treat such an action as a no-op[char46] If a port with the number is created later, then the action will be honored at that point[char46] (OpenFlow requires OVS to reject output to a port number that will never be valid, with OFPBAC_BAD_OUT_PORT, but this situation does not arise when OVS is a software switch, since the user can add or renumber ports at any time[char46]) | |||||||||||
A controller can suppress output to a port by setting its OFPPC_NO_FORWARD flag using an OpenFlow OFPT_MOD_PORT request (ovs-ofctl mod-port provides a command-line interface to set this flag)[char46] When output is disabled, output actions (and other actions that output to the port) are allowed but have no effect[char46] | |||||||||||
Open vSwitch allows output to a port that does not exist, although OpenFlow allows switches to reject such actions[char46] | |||||||||||
Output to the Input Port
OpenFlow requires a switch to ignore attempts to send a packet out its ingress port in the most straightforward way[char46] For example, output:234 has no effect if the packet has ingress port 234[char46] The rationale is that dropping these packets makes it harder to loop the network[char46] Sometimes this behavior can even be convenient, e[char46]g[char46] it is often the desired behavior in a flow that forwards a packet to several ports (‘‘floods\(cq\(cq the packet)[char46]
Sometimes one really needs to send a packet out its ingress port (‘‘hairpin\(cq\(cq)[char46] In this case, use in_port to explicitly output the packet to its input port, e[char46]g[char46]:
This also works in some circumstances where the flow doesn\(cqt match on the input port[char46] For example, if you know that your switch has five ports numbered 2 through 6, then the following will send every received packet out every port, even its ingress port:
or, equivalently:
Sometimes, in complicated flow tables with multiple levels of resubmit actions, a flow needs to output to a particular port that may or may not be the ingress port[char46] It\(cqs difficult to take advantage of output to in_port in this situation[char46] To help, Open vSwitch provides, as an OpenFlow extension, the ability to modify the in_port field[char46] Whatever value is currently in the in_port field is both the port to which output will be dropped and the destination for in_port[char46] This means that the following adds flows that reliably output to port 2 or to ports 2 through 6, respectively:
If in_port is important for matching or other reasons, one may save and restore it on the stack:
The controller action
The enqueue action
Only OpenFlow 1[char46]0 supports enqueue[char46] OpenFlow 1[char46]1 added the set_queue action to use in its place along with output[char46]
Open vSwitch translates enqueue to a sequence of three actions in OpenFlow 1[char46]1 or later: set_queue:queue, output:port, pop_queue[char46] This is equivalent in behavior as long as the flow table does not otherwise use set_queue, but it relies on the pop_queue Open vSwitch extension action[char46]
The bundle and bundle_load actions
The group action
|
ENCAPSULATION AND DECAPSULATION ACTIONS
The strip_vlan and pop actions
Syntax: | strip_vlan |
pop_vlan | |
Removes the outermost VLAN tag, if any, from the packet[char46] | |
The two names for this action are synonyms with no semantic difference[char46] The OpenFlow 1[char46]0 specification uses the name strip_vlan and later versions use pop_vlan, but OVS accepts either name regardless of version[char46] | |
In OpenFlow 1[char46]1 and later, consistency rules allow strip_vlan only in a flow that matches only packets with a VLAN tag (or following an action that pushes a VLAN tag, such as push_vlan)[char46] See ‘‘Inconsistencies\(cq\(cq, above, for more information[char46] | |
Conformance: |
The push_vlan action
Syntax: | push_vlan:ethertype |
Pushes a new outermost VLAN onto the packet[char46] Uses TPID ethertype, which must be 0x8100 for an 802[char46]1Q C-tag or 0x88a8 for a 802[char46]1ad S-tag[char46] | |
Conformance: |
The push_mpls action
Syntax: | push_mpls:ethertype | ||||||
Pushes a new outermost MPLS label stack entry (LSE) onto the packet and changes the packet\(cqs Ethertype to ethertype, which must be either B0x8847 or 0x8848[char46] | |||||||
If the packet did not already contain any MPLS labels, initializes the new LSE as: | |||||||
|
|||||||
If the packet did already contain an MPLS label, initializes the new outermost label as a copy of the existing outermost label[char46] | |||||||
OVS currently supports at most 3 MPLS labels[char46] | |||||||
This action applies only to Ethernet packets[char46] | |||||||
Conformance: |
The pop_mpls action
Syntax: | pop_mpls:ethertype |
Strips the outermost MPLS label stack entry and changes the packet\(cqs Ethertype to ethertype[char46] | |
This action applies only to Ethernet packets with at least one MPLS label[char46] If there is more than one MPLS label, then ethertype should be an MPLS Ethertype (B0x8847 or 0x8848)[char46] | |
Conformance: |
The encap action
Syntax: | encap(nsh([md_type=md_type], [tlv(class,type,value)][char46][char46][char46])) | ||||||||
encap(ethernet) | |||||||||
The encap action encapsulates a packet with a specified header[char46] It has variants for different kinds of encapsulation[char46] | |||||||||
The encap(nsh([char46][char46][char46])) variant encapsulates an Ethernet frame with NSH[char46] The md_type may be 1 or 2 for metadata type 1 or 2, defaulting to 1[char46] For metadata type 2, TLVs may be specified with class as a 16-bit hexadecimal integer beginning with 0x, type as an 8-bit decimal integer, and value a sequence of pairs of hex digits beginning with 0x[char46] For example: | |||||||||
|
|||||||||
The encap(ethernet) variant encapsulate a bare L3 packet in an Ethernet frame[char46] The Ethernet type is initialized to the L3 packet\(cqs type, e[char46]g[char46] 0x0800 if the L3 packet is IPv4[char46] The Ethernet source and destination are initially zeroed[char46] | |||||||||
Conformance: |
The decap action
Syntax: | decap | ||||||
Removes an outermost encapsulation from the packet: | |||||||
|
|||||||
Conformance: |
FIELD MODIFICATION ACTIONS
These actions modify packet data and metadata fields[char46]
The set_field and load actions
Syntax: | set_field:value[/mask]->dst | ||||||
load:value->dst | |||||||
These actions loads a literal value into a field or part of a field[char46] The set_field action takes value in the customary syntax for field dst, e[char46]g[char46] 00:11:22:33:44:55 for an Ethernet address, and dst as the field\(cqs name[char46] The optional mask allows part of a field to be set[char46] | |||||||
The load action takes value as an integer value (in decimal or prefixed by 0x for hexadecimal) and dst as a field or subfield in the syntax described under ‘‘Field Specifications\(cq\(cq above[char46] | |||||||
The following all set the Ethernet source address to 00:11:22:33:44:55: | |||||||
|
|||||||
The following all set the multicast bit in the Ethernet destination address: | |||||||
|
|||||||
Open vSwitch prohibits a set_field or load action whose dst is not guaranteed to be part of the packet; for example, set_field of nw_dst is only allowed in a flow that matches on Ethernet type 0x800[char46] In some cases, such as in an action set, Open vSwitch can\(cqt statically check that dst is part of the packet, and in that case if it is not then Open vSwitch treats the action as a no-op[char46] | |||||||
Conformance: |
The move action
Syntax: | move:src->dst | ||||
Copies the named bits from field or subfield src to field or subfield dst[char46] src and dst should fields or subfields in the syntax described under ‘‘Field Specifications\(cq\(cq above[char46] The two fields or subfields must have the same width[char46] | |||||
Examples: | |||||
|
|||||
Conformance: |
The mod_dl_src and mod_dl_dst actions
Syntax: | mod_dl_src:mac |
mod_dl_dst:mac | |
Sets the Ethernet source or destination address, respectively, to mac, which should be expressed in the form xx:xx:xx:xx:xx:xx[char46] | |
For L3-only packets, that is, those that lack an Ethernet header, this action has no effect[char46] | |
Conformance: |
The mod_nw_src and mod_nw_dst actions
Syntax: | mod_nw_src:ip |
mod_nw_dst:ip | |
Sets the IPv4 source or destination address, respectively, to ip, which should be expressed in the form w[char46]x[char46]y[char46]z[char46] | |
In OpenFlow 1[char46]1 and later, consistency rules allow these actions only in a flow that matches only packets that contain an IPv4 header (or following an action that adds an IPv4 header, e[char46]g[char46] pop_mpls:0x0800)[char46] See ‘‘Inconsistencies\(cq\(cq, above, for more information[char46] | |
Conformance: |
The mod_nw_tos and mod_nw_ecn actions
Syntax: | mod_nw_tos:tos |
mod_nw_ecn:ecn | |
The mod_nw_tos action sets the DSCP bits in the IPv4 ToS/DSCP or IPv6 traffic class field to tos, which must be a multiple of 4 between 0 and 255[char46] This action does not modify the two least significant bits of the ToS field (the ECN bits)[char46] | |
The mod_nw_ecn action sets the ECN bits in the IPv4 ToS or IPv6 traffic class field to ecn, which must be a value between 0 and 3, inclusive[char46] This action does not modify the six most significant bits of the field (the DSCP bits)[char46] | |
In OpenFlow 1[char46]1 and later, consistency rules allow these actions only in a flow that matches only packets that contain an IPv4 or IPv6 header (or following an action that adds such a header)[char46] See ‘‘Inconsistencies\(cq\(cq, above, for more information[char46] | |
Conformance: |
The mod_tp_src and mod_tp_dst actions
Syntax: | mod_tp_src:port |
mod_tp_dst:port | |
Sets the TCP or UDP or SCTP source or destination port, respectively, to port[char46] Both IPv4 and IPv6 are supported[char46] | |
In OpenFlow 1[char46]1 and later, consistency rules allow these actions only in a flow that matches only packets that contain a TCP or UDP or SCTP header[char46] See ‘‘Inconsistencies\(cq\(cq, above, for more information[char46] | |
Conformance: |
The dec_ttl action
Syntax: | dec_ttl |
dec_ttl(id1, [id2][char46][char46][char46]) | |
Decrement TTL of IPv4 packet or hop limit of IPv6 packet[char46] If the TTL or hop limit is initially 0 or 1, no decrement occurs, as packets reaching TTL zero must be rejected[char46] Instead, Open vSwitch sends a ‘‘packet-in\(cq\(cq message with reason code OFPR_INVALID_TTL to each connected controller that has enabled receiving such messages, and stops processing the current set of actions[char46] (However, if the current set of actions was reached through resubmit, the remaining actions in outer levels resume processing[char46]) | |
As an Open vSwitch extension to OpenFlow, this action supports the ability to specify a list of controller IDs[char46] Open vSwitch will only send the message to controllers with the given ID or IDs[char46] Specifying no list is equivalent to specifying a single controller ID of zero[char46] | |
Sets the TCP or UDP or SCTP source or destination port, respectively, to port[char46] Both IPv4 and IPv6 are supported[char46] | |
In OpenFlow 1[char46]1 and later, consistency rules allow these actions only in a flow that matches only packets that contain an IPv4 or IPv6 header[char46] See ‘‘Inconsistencies\(cq\(cq, above, for more information[char46] | |
Conformance: |
The set_mpls_label, set_mpls_tc, and set_mpls_ttl actions
Syntax: | set_mpls_label:label |
set_mpls_tc:tc | |
set_mpls_ttl:ttl | |
The set_mpls_label action sets the label of the packet\(cqs outer MPLS label stack entry[char46] label should be a 20-bit value that is decimal by default; use a 0x prefix to specify the value in hexadecimal[char46] | |
The set_mpls_tc action sets the traffic class of the packet\(cqs outer MPLS label stack entry[char46] tc should be in the range 0 to 7, inclusive[char46] | |
The set_mpls_ttl action sets the TTL of the packet\(cqs outer MPLS label stack entry[char46] ttl should be in the range 0 to 255 inclusive[char46] | |
In OpenFlow 1[char46]1 and later, consistency rules allow these actions only in a flow that matches only packets that contain an MPLS label (or following an action that adds an MPLS label, e[char46]g[char46] push_mpls:0x8847)[char46] See ‘‘Inconsistencies\(cq\(cq, above, for more information[char46] | |
Conformance: |
The dec_mpls_ttl and dec_nsh_ttl actions
Syntax: | dec_mpls_ttl |
dec_nsh_ttl | |
These actions decrement the TTL of the packet\(cqs outer MPLS label stack entry or its NSH header, respectively[char46] If the TTL is initially 0 or 1, no decrement occurs[char46] Instead, Open vSwitch sends a ‘‘packet-in\(cq\(cq message with reason code BOFPR_INVALID_TTL to OpenFlow controllers with ID 0, if it has enabled receiving them[char46] Processing the current set of actions then stops[char46] (However, if the current set of actions was reached through resubmit, remaining actions in outer levels resume processing[char46]) | |
In OpenFlow 1[char46]1 and later, consistency rules allow this actions only in a flow that matches only packets that contain an MPLS label or an NSH header, respectively[char46] See ‘‘Inconsistencies\(cq\(cq, above, for more information[char46] | |
Conformance: |
Open vSwitch 1[char46]11 introduced support for MPLS[char46] OpenFlow 1[char46]1 and later support dec_mpls_ttl[char46] Open vSwitch implements dec_mpls_ttl as an extension to OpenFlow 1[char46]0[char46]
Open vSwitch 2[char46]8 introduced support for NSH, although the NSH draft changed after release so that only Open vSwitch 2[char46]9 and later conform to the final protocol specification[char46] The dec_nsh_ttl action and NSH support in general is an Open vSwitch extension not supported by any version of OpenFlow[char46]
METADATA ACTIONS
The set_tunnel action
Syntax: | set_tunnel:id |
set_tunnel64:id | |
Many kinds of tunnels support a tunnel ID, e[char46]g[char46] VXLAN and Geneve have a 24-bit VNI, and GRE has an optional 32-bit key[char46] This action sets the value used for tunnel ID in such tunneled packets, although whether it is used for a particular tunnel depends on the tunnel\(cqs configuration[char46] See the tunnel ID documentation in ovs-fields(7) for more information[char46] | |
Conformance: |
These actions are OpenFlow extensions[char46] set_tunnel was introduced in Open vSwitch 1[char46]0[char46] set_tunnel64, which is needed if id is wider than 32 bits, was added in Open vSwitch 1[char46]1[char46] Both actions always set the entire tunnel ID field[char46]
Open vSwitch supports these actions in all versions of OpenFlow, but in OpenFlow 1[char46]2 and later it translates them to an appropriate standardized OFPAT_SET_FIELD action[char46]
The set_queue and pop_queue actions
Syntax: | set_queue:queue |
pop_queue | |
The set_queue action sets the queue ID to be used for subsequent output actions to queue, which must be a 32-bit integer[char46] The range of meaningful values of queue, and their meanings, varies greatly from one OpenFlow implementation to another[char46] Even within a single implementation, there is no guarantee that all OpenFlow ports have the same queues configured or that all OpenFlow ports in an implementation can be configured the same way queue-wise[char46] For more information, see the documentation for the output queue field in ovs-fields(7)[char46] | |
The pop_queue restores the output queue to the default that was set when the packet entered the switch (generally 0)[char46] | |
Four billion queues ought to be enough for anyone: \(laURL: https://mailman.stanford.edu/pipermail/openflow-spec/2009-August/000394.html \(ra |
|
Conformance: |
OpenFlow 1[char46]1 introduced the set_queue action[char46] Open vSwitch also supports it as an extension in OpenFlow 1[char46]0[char46]
The pop_queue action is an Open vSwitch extension[char46]
FIREWALLING ACTIONS
Open vSwitch is often used to implement a firewall[char46] The preferred way to implement a firewall is ‘‘connection tracking,\(cq\(cq that is, to keep track of the connection state of individual TCP sessions[char46] The ct action described in this section, added in Open vSwitch 2[char46]5, implements connection tracking[char46] For new deployments, it is the recommended way to implement firewalling with Open vSwitch[char46]
Before ct was added, Open vSwitch did not have built-in support for connection tracking[char46] Instead, Open vSwitch supported the learn action, which allows a received packet to add a flow to an OpenFlow flow table[char46] This could be used to implement a primitive form of connection tracking: packets passing through the firewall in one direction could create flows that allowed response packets back through the firewall in the other direction[char46] The additional fin_timeout action allowed the learned flows to expire quickly after TCP session termination[char46]
The ct action
Syntax: | ct(argument][char46][char46][char46]) | ||||||||||||||||||||||||||||||||
ct(commit[, argument][char46][char46][char46]) | |||||||||||||||||||||||||||||||||
The action has two modes of operation, distinguished by whether commit is present[char46] The following arguments may be present in either mode: | |||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||
Without commit, this action sends the packet through the connection tracker[char46] The connection tracker keeps track of the state of TCP connections for packets passed through it[char46] For each packet through a connection, it checks that it satisfies TCP invariants and signals the connection state to later actions using the ct_state metadata field, which is documented in ovs-fields(7)[char46] | |||||||||||||||||||||||||||||||||
In this form, ct forks the OpenFlow pipeline: | |||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||
Without commit, the ct action accepts the following arguments: | |||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||
With commit, the connection tracker commits the connection to the connection tracking module[char46] The commit flag should only be used from the pipeline within the first fork of ct without commit[char46] Information about the connection is stored beyond the lifetime of the packet in the pipeline[char46] Some ct_state flags are only available for committed connections[char46] | |||||||||||||||||||||||||||||||||
The following options are available only with commit: | |||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||
With the Linux datapath, global sysctl options affect ct behavior[char46] In particular, if net[char46]netfilter[char46]nf_conntrack_helper is enabled, which it is by default until Linux 4[char46]7, then application layer gateway helpers may be executed even if alg is not specified[char46] For security reasons, the netfilter team recommends users disable this option[char46] For further details, please see \(laURL: http://www.netfilter.org/news.html#2012-04-03 \(ra [char46] |
|||||||||||||||||||||||||||||||||
The ct action may be used as a primitive to construct stateful firewalls by selectively committing some traffic, then matching ct_state to allow established connections while denying new connections[char46] The following flows provide an example of how to implement a simple firewall that allows new connections from port 1 to port 2, and only allows established connections to send traffic from port 2 to port 1: | |||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||
If ct is executed on IPv4 (or IPv6) fragments, then the message is implicitly reassembled before sending to the connection tracker and refragmented upon output, to the original maximum received fragment size[char46] Reassembly occurs within the context of the zone, meaning that IP fragments in different zones are not assembled together[char46] Pipeline processing for the initial fragments is halted[char46] When the final fragment is received, the message is assembled and pipeline processing continues for that flow[char46] Packet ordering is not guaranteed by IP protocols, so it is not possible to determine which IP fragment will cause message reassembly (and therefore continue pipeline processing)[char46] As such, it is strongly recommended that multiple flows should not execute ct to reassemble fragments from the same IP message[char46] | |||||||||||||||||||||||||||||||||
Conformance: |
The ct_clear action
Syntax: | ct_clear |
Clears connection tracking state from the flow, zeroing ct_state, ct_zone, ct_mark, and ct_label[char46]
This action was introduced in Open vSwitch 2[char46]6[char46]90[char46]
The learn action
Syntax: | learn(argument[char46][char46][char46]) | ||||||||||||||||||||||||||||||||||||||||||
The learn action adds or modifies a flow in an OpenFlow table, similar to ovs-ofctl --strict mod-flows[char46] The arguments specify the match fields, actions, and other properties of the flow to be added or modified[char46] | |||||||||||||||||||||||||||||||||||||||||||
Match fields for the new flow are specified as follows[char46] At least one match field should ordinarily be specified: | |||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
The field and src arguments above should be fields or subfields in the syntax described under ‘‘Field Specifications\(cq\(cq above[char46] | |||||||||||||||||||||||||||||||||||||||||||
Match field specifications must honor prerequisites for both the flow with the learn and the new flow that it creates[char46] Consider the following complete flow, in the syntax accepted by ovs-ofctl[char46] If the flow\(cqs match on udp were omitted, then the flow would not satisfy the prerequisites for the learn action\(cqs use of udp_src[char46] If dl_type=0x800 or nw_proto were omitted from learn, then the new flow would not satisfy the prerequisite for its match on udp_dst[char46] For more information on prerequisites, please refer to ovs-fields(7): | |||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
Actions for the new flow are specified as follows[char46] At least one action should ordinarily be specified: | |||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
The following additional arguments are optional: | |||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
By itself, the learn action can only put two kinds of actions into the flows that it creates: load and output actions[char46] If learn is used in isolation, these are severe limits[char46] | |||||||||||||||||||||||||||||||||||||||||||
However, learn is not meant to be used in isolation[char46] It is a primitive meant to be used together with other Open vSwitch features to accomplish a task[char46] Its existing features are enough to accomplish most tasks[char46] | |||||||||||||||||||||||||||||||||||||||||||
Here is an outline of a typical pipeline structure that allows for versatile behavior using learn: | |||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
This approach can be used to implement many learn-based features[char46] For example: | |||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
Conformance: |
The fin_timeout action
Syntax: | fin_timeout(key=value[char46][char46][char46]) | ||||||||
This action changes the idle timeout or hard timeout, or both, of the OpenFlow flow that contains it, when the flow matches a TCP packet with the FIN or RST flag[char46] When such a packet is observed, the action reduces the rule\(cqs timeouts to those specified on the action[char46] If the rule\(cqs existing timeout is already shorter than the one that the action specifies, then that timeout is unaffected[char46] | |||||||||
The timeouts are specified as key-value pairs: | |||||||||
|
|||||||||
This action is normally added to a learned flow by the learn action[char46] It is unlikely to be useful otherwise[char46] | |||||||||
Conformance: |
PROGRAMMING AND CONTROL FLOW ACTIONS
The resubmit action
Syntax: | resubmit:port | ||||||||||||||
resubmit([port],[table][,ct]) | |||||||||||||||
Searches an OpenFlow flow table for a matching flow and executes the actions found, if any, before continuing to the following action in the current flow entry[char46] Arguments can customize the search: | |||||||||||||||
|
|||||||||||||||
The changes, if any, to the input port and connection tracking fields are just for searching the flow table[char46] The changes are not visible to actions or to later flow table lookups[char46] | |||||||||||||||
The most common use of resubmit is to visit another flow table without port or ct, like this: resubmit(,table)[char46] | |||||||||||||||
Recursive resubmit actions are permitted[char46] | |||||||||||||||
Conformance: | |||||||||||||||
The resubmit action is an Open vSwitch extension[char46] However, the goto_table instruction in OpenFlow 1[char46]1 and later can be viewed as a kind of restricted resubmit[char46] | |||||||||||||||
Open vSwitch 1[char46]2[char46]90 added table[char46] Open vSwitch 2[char46]7 added ct[char46] | |||||||||||||||
Open vSwitch imposes a limit on resubmit recursion that varies among version: | |||||||||||||||
|
The clone action
Syntax: | clone(action[char46][char46][char46]) |
Executes each nested action, saving much of the packet and pipeline state beforehand and then restoring it afterward[char46] The state that is saved and restored includes all flow data and metadata (including, for example, in_port and ct_state), the stack accessed by push and pop actions, and the OpenFlow action set[char46]
This action was added in Open vSwitch 2[char46]6[char46]90[char46]
The push and pop actions
Syntax: | push:src | ||||
pop:dst | |||||
The push action pushes src on a general-purpose stack[char46] The pop action pops an entry off the stack into dst[char46] src and dst should be fields or subfields in the syntax described under ‘‘Field Specifications\(cq\(cq above[char46] | |||||
Controllers can use the stack for saving and restoring data or metadata around resubmit actions, for swapping or rearranging data and metadata, or for other purposes[char46] Any data or metadata field, or part of one, may be pushed, and any modifiable field or subfield may be popped[char46] | |||||
The number of bits pushed in a stack entry do not have to match the number of bits later popped from that entry[char46] If more bits are popped from an entry than were pushed, then the entry is conceptually left-padded with 0-bits as needed[char46] If fewer bits are popped than pushed, then bits are conceptually trimmed from the left side of the entry[char46] | |||||
The stack\(cqs size is limited[char46] The limit is intended to be high enough that ‘‘normal\(cq\(cq use will not pose problems[char46] Stack overflow or underflow is an error that stops action execution (see ‘‘Stack too deep\(cq\(cq under ‘‘Error Handling\(cq\(cq, above)[char46] | |||||
Examples: | |||||
|
|||||
Conformance: |
The exit action
Syntax: | exit |
This action causes Open vSwitch to immediately halt execution of further actions[char46] Actions which have already been executed are unaffected[char46] Any further actions, including those which may be in other tables, or different levels of the resubmit call stack, are ignored[char46] However, an exit action within a group bucket terminates only execution of that bucket, not other buckets or the overall pipeline[char46] Actions in the action set are still executed (specify clear_actions before exit to discard them)[char46]
The multipath action
Syntax: | multipath(fields, basis, algorithm, n_links, arg, dst) | ||||||||||||||||||||||||||||||||||||||||||
Hashes fields using basis as a universal hash parameter, then the applies multipath link selection algorithm (with parameter arg) to choose one of n_links output links numbered 0 through n_links minus 1, and stores the link into dst, which must be a field or subfield in the syntax described under ‘‘Field Specifications\(cq\(cq above[char46] | |||||||||||||||||||||||||||||||||||||||||||
The bundle or bundle_load actions are usually easier to use than multipath[char46] | |||||||||||||||||||||||||||||||||||||||||||
fields must be one of the following: | |||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
The algorithm used to compute the final result link must be one of the following: | |||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
Only the iter_hash algorithm uses arg[char46] | |||||||||||||||||||||||||||||||||||||||||||
It is an error if max_link is greater than or equal to 2**n_bits[char46] | |||||||||||||||||||||||||||||||||||||||||||
Conformance: |
OTHER ACTIONS
The conjunction action
Syntax: | conjunction(id, k/n) |
This action allows for sophisticated ‘‘conjunctive match\(cq\(cq flows[char46] Refer to ‘‘Conjunctive Match Fields\(cq\(cq in ovs-fields(7) for details[char46] | |
A flow that has one or more conjunction actions may not have any other actions except for note actions[char46] | |
Conformance: |
The note action
Syntax: | note:[hh][char46][char46][char46] |
This action does nothing at all[char46] OpenFlow controllers may use it to annotate flows with more data than can fit in a flow cookie[char46] | |
The action may include any number of bytes represented as hex digits hh[char46] Periods may separate pairs of hex digits, for readability[char46] The note action\(cqs format doesn\(cqt include an exact length for its payload, so the provided bytes will be padded on the right by enough bytes with value 0 to make the total number 6 more than a multiple of 8[char46] | |
Conformance: |
The sample action
Syntax: | sample(argument[char46][char46][char46]) | ||||||||||||||||||||||||||||
Samples packets and sends one sample for every sampled packet[char46] | |||||||||||||||||||||||||||||
The following argument forms are accepted: | |||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||
Refer to ovs-vswitchd[char46]conf[char46]db(5) for more details on configuring sample collector sets[char46] | |||||||||||||||||||||||||||||
Conformance: |
INSTRUCTIONS
Every version of OpenFlow includes actions[char46] OpenFlow 1[char46]1 introduced the higher-level, related concept of instructions[char46] In OpenFlow 1[char46]1 and later, actions within a flow are always encapsulated within an instruction[char46] Each flow has at most one instruction of each kind, which are executed in the following fixed order defined in the OpenFlow specification:
1. | Meter |
2. | Apply-Actions |
3. | Clear-Actions |
4. | Write-Actions |
5. | Write-Metadata |
6. | Stat-Trigger (not supported by Open vSwitch) |
7. | Goto-Table |
The most important instruction is Apply-Actions[char46] This instruction encapsulates any number of actions, which the instruction executes[char46] Open vSwitch does not explicitly represent Apply-Actions[char46] Instead, any action by itself is implicitly part of an Apply-Actions instructions[char46]
Open vSwitch syntax requires other instructions, if present, to be in the order listed above[char46] Otherwise it will flag an error[char46]
The meter action and instruction
Syntax: | meter:meter_id |
Apply meter meter_id[char46] If a meter band rate is exceeded, the packet may be dropped, or modified, depending on the meter band type[char46] | |
Conformance: |
OpenFlow 1[char46]3 introduced the meter instruction[char46] OpenFlow 1[char46]5 changes meter from an instruction to an action[char46]
Open vSwitch 2[char46]0 introduced OpenFlow protocol support for meters, but it did not include a datapath implementation[char46] Open vSwitch 2[char46]7 added meter support to the userspace datapath[char46] Open vSwitch 2[char46]10 added meter support to the kernel datapath[char46]
The clear_actions instruction
Syntax: | clear_actions |
Clears the action set[char46] See ‘‘Action Sets\(cq\(cq, above, for more information[char46] | |
Conformance: |
The write_actions instruction
Syntax: | write_actions(action[char46][char46][char46]) |
Adds each action to the action set[char46] The action set is carried between flow tables and then executed at the end of the pipeline[char46] Only certain actions may be written to the action set[char46] See ‘‘Action Sets\(cq\(cq, above, for more information[char46] | |
Conformance: |
The write_metadata instruction
Syntax: | write_metadata:value[/mask] |
Updates the flow\(cqs metadata field[char46] If mask is omitted, metadata is set exactly to value; if mask is specified, then a 1-bit in mask indicates that the corresponding bit in metadata will be replaced with the corresponding bit from value[char46] Both value and mask are 64-bit values that are decimal by default; use a 0x prefix to specify them in hexadecimal[char46] | |
The metadata field can also be matched in the flow table and updated with actions such as set_field and move[char46] | |
Conformance: |
The goto_table instruction
Syntax: | goto_table:table |
Jumps to table as the next table in the process pipeline[char46] The table may be a number between 0 and 254 or a table name[char46] | |
It is an error if table is less than or equal to the table of the flow that contains it; that is, goto_table must move forward in the OpenFlow pipeline[char46] Since goto_table must be the last instruction in a flow, it never leads to recursion[char46] The resubmit extension action is more flexible[char46] | |
Conformance: |