OVS-ACTIONS(7)
π¦ OVS-ACTIONS(7) π¦
okay bestie, this is the ovs-actions(7) page from the Open vSwitch manual, and it is literally the full lore drop on OpenFlow actions and instructions β standard ones, non-standard ones, all of it. It has stuff for regular Open vSwitch users (like what each action actually means and the syntax Open vSwitch tools use) and for devs building controllers and switches that want to be compatible with Open vSwitch (like the wire format for each supported message). π«Ά
β¨ NAME β¨
ovs-actions β OpenFlow actions and instructions with Open vSwitch extensions.
πΈ INTRODUCTION πΈ
This document is aiming to be the comprehensive rundown of all the OpenFlow actions and instructions that Open vSwitch supports, standard and non-standard, no matter where they came from. It includes the stuff Open vSwitch users care about β like the semantics of each supported action and the syntax Open vSwitch tools use β and the stuff developers care about when building controllers and switches compatible with Open vSwitch, like the wire format for each supported message. π
π Actions π
In this doc, an action means an OpenFlow action: a kind of command that says what to do with a packet. Actions show up in OpenFlow flows to describe what happens when the flow matches a packet, and they also show up in a few other places in OpenFlow. Every version of the OpenFlow spec defines standard actions, and beyond that, lots of OpenFlow switches β Open vSwitch included β implement extensions to the standard. β¨
OpenFlow groups actions in two ways: as an action list or an action set, both described below.
π¦ Action Lists π¦
An action list β a concept thatβs present in every version of OpenFlow β is just an ordered sequence of actions. The OpenFlow specs require a switch to execute actions inside an action list in the order specified, and to refuse to execute the whole action list if it canβt implement the actions in that order [OpenFlow 1.0, section 3.3]. Thereβs one exception: when an action list outputs multiple packets, the switch may output those packets in an order different from the one specified. Usually that exception is not important, especially in the common case where the packets are being output to different ports. π
π Action Sets π
OpenFlow 1.1 introduced the concept of an action set. 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 specs. Because of those semantics, some standard OpenFlow actions canβt usefully be included in an action set. For some β but not all β Open vSwitch extension actions, Open vSwitch defines its own action set semantics and ordering. π
The OpenFlow pipeline has an action set associated with it while a packet is being processed. After pipeline processing is otherwise complete, the switch executes the actions in the action set. β
Open vSwitch applies actions in an action set in this 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:
strip_vlanpop_mplsdecapencappush_mplspush_vlandec_ttldec_mpls_ttldec_nsh_ttl- All of the following actions are executed in the order added to the action set, with cumulative effect. 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:
loadmovemod_dl_dstmod_dl_srcmod_nw_dstmod_nw_srcmod_nw_tosmod_nw_ecnmod_nw_ttlmod_tp_dstmod_tp_srcmod_vlan_pcpmod_vlan_vidset_fieldset_tunnelset_tunnel64
set_queuegroup,output,resubmit,ct_clear, orct. 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. (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.)
An action set may only contain the actions listed above. π
π 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, which allows the controller to interrupt and later resume the processing of a packet through the switch pipeline. This error occurs when such a packetβs processing cannot be resumed, e.g. because the bridge processing it has been destroyed. Open vSwitch reports this error to the controller as Open vSwitch extension error NXR_STALE. π
This error prevents packet processing entirely.
π 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. 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. π₯
A resubmit from one table to a later one (or, equivalently, a goto_table instruction) does not count against the depth limit because resubmits to strictly monotonically increasing tables will eventually terminate. OpenFlow tables are most commonly traversed in numerically increasing order, so this limit has little effect on conventionally designed OpenFlow pipelines. β¨
This error terminates packet processing. Any previous side effects (e.g. output actions) are retained.
Usually this error indicates a loop or other bug in the OpenFlow flow tables. To assist debugging, when this error occurs, Open vSwitch 2.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. π«Ά
π Too many resubmits
Open vSwitch limits the total number of resubmit actions that a given packet can execute to 4,096. For this purpose, goto_table instructions and output to the table port are treated like resubmit. This limits the amount of time to process a single packet. β³
Unlike the limit on recursion depth, the limit on resubmits counts all resubmits, regardless of direction.
This error has the same effect, including logging, as exceeding the recursion depth limit.
π 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.
This error terminates packet processing. Any previous side effects (e.g. output actions) are retained.
π No recirculation context / Recirculation conflict
These errors indicate internal errors inside Open vSwitch and should generally not occur. If you notice recurring log messages about these errors, please report a bug. π
π 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. 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. π
This error terminates packet processing, retaining any previous side effects (e.g. output actions). When this error arises within the execution of a group bucket, it only terminates that bucketβs execution, not packet processing overall.
π Invalid tunnel metadata
Open vSwitch raises this error when it processes a Geneve packet that has TLV options with an invalid form, e.g. where the length in a TLV would extend past the end of the options.
This error prevents packet processing entirely.
π 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. 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. π
The decap action is supported only for packet types ethernet, NSH and MPLS. Openvswitch raises this error for other packet types. When a decap action decapsulates a packet, Open vSwitch raises this error if it does not support the type of inner packet. 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. π
This error terminates packet processing, retaining any previous side effects (e.g. output actions). When this error arises within the execution of a group bucket, it only terminates that bucketβs execution, not packet processing overall.
π INCONSISTENCIES π
OpenFlow 1.0 allows any action to be part of any flow, regardless of the flowβs match. Some combinations do not make sense, e.g. 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. Other combinations have varying results depending on the kind of packet that the flow processes, e.g. 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. Nevertheless OVS allows all of the above in conformance with OpenFlow 1.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.2.3.4
Open vSwitch calls these kinds of combinations inconsistencies between match and actions. OpenFlow 1.1 and later forbid inconsistencies, and disallow the examples described above by preventing such flows from being added. All of the above, for example, will fail with an error message if one replaces OpenFlow10 by OpenFlow11. π
OpenFlow 1.1 and later literally cannot detect and disallow all inconsistencies, bestie. Take write_actions: it arbitrarily delays execution of the actions inside it, and those delayed actions can even get canceled with clear_actions. So there is no way to ensure its actions are consistent with the packet at the time they execute. Thatβs why actions with write_actions and some other contexts are exempt from consistency requirements. When OVS executes an action thatβs inconsistent with the packet, it treats it as a no-op. fr fr, thatβs the whole vibe.
β¨ Inter-Version Compatibility β¨
Open vSwitch supports multiple OpenFlow versions at the same time on a single switch. When actions are added with one OpenFlow version and then retrieved with another, Open vSwitch does its best to translate between them. slay, translator era π
Inter-version compatibility issues can still arise when different connections use different OpenFlow versions. Backward compatibility is the most obvious case. Suppose, for example, that an OpenFlow 1.1 session adds a flow with a push_vlan action, for which there is no equivalent in OpenFlow 1.0. If an OpenFlow 1.0 session retrieves this flow, Open vSwitch must somehow represent the action. the way thatβs lowkey awkward π
Forward compatibility can also be an issue, because later OpenFlow versions sometimes remove functionality. The best example is the enqueue action from OpenFlow 1.0, which OpenFlow 1.1 removed. gone, but not forgotten π¦
In practice, Open vSwitch uses a variety of strategies for inter-version compatibility:
- Most standard OpenFlow actions, such as output actions, translate without compatibility issues. iconic, no notes π
- Open vSwitch supports its extension actions in every OpenFlow version, so they do not pose inter-version compatibility problems.
- Open vSwitch sometimes adds extension actions to ensure backward or forward compatibility. For example, for backward compatibility with the
groupaction added in OpenFlow 1.1, Open vSwitch includes an OpenFlow 1.0 extensiongroupaction.
Perfect inter-version compatibility is not possible, so best results require OpenFlow connections to use a consistent version. One may enforce use of a particular version by setting the protocols column for a bridge, e.g. to force br0 to use only OpenFlow 1.3:
ovs-vsctl set bridge br0 protocols=OpenFlow13
πΈ Field Specifications πΈ
Many Open vSwitch actions refer to fields. 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. Before Open vSwitch 2.7, only OXM or NXM field names were accepted. bestie, we used to live like this π
Many actions that act on fields can also act on subfields, that is, parts of fields, written as field[start..end], where start is the first bit and end is the last bit to use in field, e.g. vlan_tci[13..15] for the VLAN PCP. A single-bit subfield may also be written as field[offset], e.g. vlan_tci[13] for the least-significant bit of the VLAN PCP. Empty brackets may be used to explicitly designate an entire field, e.g. vlan_tci[] for the entire 16-bit VLAN TCI header. Before Open vSwitch 2.7, brackets were required in field specifications.
See ovs-fields(7) for a list of fields and their names. go read the lore π
π Port Specifications π
Many Open vSwitch actions refer to OpenFlow ports. 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. OpenFlow 1.1 and later use 32-bit port numbers, but Open vSwitch never assigns a port number that requires more than 16 bits.
In most contexts, the name of a port may also be used. (The most obvious context where a port name may not be used is in an ovs-ofctl command along with the --no-names option.) When a portβs 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]). quotey vibes π
Open vSwitch also supports the following standard OpenFlow port names (even in contexts where port names are not otherwise supported). The corresponding OpenFlow 1.0 and 1.1+ port numbers are listed alongside them but should not be used in flow syntax:
in_port(65528or0xfff8;0xfffffff8)table(65529or0xfff9;0xfffffff9)normal(65530or0xfffa;0xfffffffa)flood(65531or0xfffb;0xfffffffb)all(65532or0xfffc;0xfffffffc)controller(65533or0xfffd;0xfffffffd)local(65534or0xfffe;0xfffffffe)anyornone(65535or0xffff;0xffffffff)unset(not in OpenFlow 1.0;0xfffffff7)
π«Ά OUTPUT ACTIONS π«Ά
These actions send a packet to a physical port or a controller. A packet that never encounters an output action on its trip through the Open vSwitch pipeline is effectively dropped. And 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. no output, no proof, bestie π
β¨ 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. Alternatively, the output port may be read from field, a field or subfield in the syntax described under Field Specifications above. Either way, if the port is the packetβs input port, the packet is not output.
The port may be one of the following standard OpenFlow ports:
localβ Outputs the packet on the local port that corresponds to the network device that has the same name as the bridge, unless the packet was received on the local port. OpenFlow switch implementations are not required to have a local port, but Open vSwitch bridges always do. we stay having one πin_portβ Outputs the packet on the port on which it was received. This is the only standard way to output the packet to the input port (but see Output to the Input Port, below).
The port may also be one of the following additional OpenFlow ports, unless max_len is specified:
normalβ Subjects the packet to the deviceβs normal L2/L3 processing. This action is not implemented by all OpenFlow switches, and each switch implements it differently. The section The OVS Normal Pipeline below documents the OVS implementation.floodβ Outputs the packet on all switch physical ports, except the port on which it was received and any ports on which flooding is disabled. Flooding can be disabled automatically on a port by Open vSwitch whenIEEE 802.1Dspanning tree (STP) or rapid spanning tree (RSTP) is enabled, or by a controller using an OpenFlowOFPT_MOD_PORTrequest to set the portβsOFPPC_NO_FLOODflag (ovs-ofctl mod-portprovides a command-line interface to set this flag).allβ Outputs the packet on all switch physical ports except the port on which it was received.controllerβ Sends the packet and its metadata to an OpenFlow controller or controllers encapsulated in an OpenFlow packet-in message. The separatecontrolleraction, described below, provides more options for output to a controller.
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. rejected, blocked, not the vibe π
With max_len, the packet is truncated to at most nbytes bytes before being output. In this case, the output port may not be a patch port. Truncation is just for the single output action, so that later actions in the OpenFlow pipeline work with the complete packet. The truncation feature is meant for use in monitoring applications, e.g. for mirroring packets to a collector. snip snip for the collectors βοΈ no cap.
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. All versions of Open vSwitch treat such an action as a no-op. If a port with the number is created later, then the action will be honored at that point. (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.) future port? maybe sheβll show up later π¦
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). When output is disabled, output actions (and other actions that output to the port) are allowed but have no effect. allowed but doing nothing, me on a Monday π
Open vSwitch allows output to a port that does not exist, although OpenFlow allows switches to reject such actions.
π₯ Conformance π₯
All versions of OpenFlow and Open vSwitch support output to a literal port. Output to a register is an OpenFlow extension introduced in Open vSwitch 1.3. Output with truncation is an OpenFlow extension introduced in Open vSwitch 2.6. history lesson, but make it cunty π
π¦ 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. For example, output:234 has no effect if the packet has ingress port 234. The rationale is that dropping these packets makes it harder to loop the network. Sometimes this behavior can even be convenient, e.g. it is often the desired behavior in a flow that forwards a packet to several ports (floods the packet). convenient loop-prevention era π
Sometimes one really needs to send a packet out its ingress port (hairpin). In this case, use in_port to explicitly output the packet to its input port, e.g.:
$ ovs-ofctl add-flow br0 in_port=2,actions=in_port
This also works in some circumstances where the flow doesnβt match on the input port. 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:
$ ovs-ofctl add-flow br0 actions=2,3,4,5,6,in_port
or, equivalently:
$ ovs-ofctl add-flow br0 actions=all,in_port
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. Bestie, that is lowkey awkward. Itβs difficult to take advantage of output to in_port in this situation. To help, Open vSwitch provides, as an OpenFlow extension, the ability to modify the in_port field. 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. This means that the following add flows that reliably output to port 2 or to ports 2 through 6, respectively:
$ ovs-ofctl add-flow br0 "in_port=2,actions=load:0->in_port,2"
$ ovs-ofctl add-flow br0 "actions=load:0->in_port,2,3,4,5,6"
If in_port is important for matching or other reasons, one may save and restore it on the stack:
$ ovs-ofctl add-flow br0 \
actions="push:in_port,load:0->in_port,2,3,4,5,6,pop:in_port"
π§ The OVS Normal Pipeline π§
This section documents how Open vSwitch implements output to the normal port. The OpenFlow specification places no requirements on how this port works, so all of this documentation is specific to Open vSwitch. No cap.
Open vSwitch uses the Open_vSwitch database, detailed in ovs-vswitchd.conf.db(5), to determine the details of the normal pipeline.
The normal pipeline executes the following ingress stages for each packet. Each stage either accepts the packet, in which case the packet goes on to the next stage, or drops the packet, which terminates the pipeline. The result of the ingress stages is a set of output ports, which is the empty set if some ingress stage drops the packet:
- Input port lookup: Looks up the OpenFlow
in_portfieldβs value to the correspondingPortandInterfacerecord in the database.
The in_port is normally the OpenFlow port that the packet was received on. If set_field or another action changes the in_port, the updated value is honored. Accept the packet if the lookup succeeds, which it normally will. If the lookup fails, for example because in_port was changed to an unknown value, drop the packet.
- Drop malformed packet: If the packet is malformed enough that it contains only part of an 802.1Q header, then drop the packet with an error.
- Drop packets sent to a port reserved for mirroring: If the packet was received on a port that is configured as the output port for a mirror (that is, it is the
output_portin someMirrorrecord), then drop the packet. - VLAN input processing: This stage determines what VLAN the packet is in. It also verifies that this VLAN is valid for the port; if not, drop the packet. How the VLAN is determined and which ones are valid vary based on the
vlan-modein the input portβsPortrecord:trunkβ The packet is in the VLAN specified in its 802.1Q header, or in VLAN 0 if there is no 802.1Q header. Thetrunkscolumn in thePortrecord lists the valid VLANs; if it is empty, all VLANs are valid.accessβ The packet is in the VLAN specified in thetagcolumn of itsPortrecord. The packet must not have an 802.1Q header with a nonzero VLAN ID; if it does, drop the packet.native-tagged/native-untaggedβ Same astrunkexcept that the VLAN of a packet without an 802.1Q header is not necessarily zero; instead, it is taken from thetagcolumn.dot1q-tunnelβ The packet is in the VLAN specified in thetagcolumn of itsPortrecord, which is a QinQ service VLAN with the Ethertype specified by thePortβsother_config:qinq-ethtype. If the packet has an 802.1Q header, then it specifies the customer VLAN. Thecvlanscolumn specifies the valid customer VLANs; if it is empty, all customer VLANs are valid.
- Drop reserved multicast addresses: If the packet is addressed to a reserved Ethernet multicast address and the
Bridgerecord does not haveother_config:forward-bpduset totrue, drop the packet. - LACP bond admissibility: This step applies only if the input port is a member of a bond (a
Portwith more than oneInterface) and that bond is configured to use LACP. Otherwise, skip to the next step.
The behavior here depends on the state of LACP negotiation:
- If LACP has been negotiated with the peer, accept the packet if the bond member is enabled (i.e. carrier is up and it hasnβt been administratively disabled). Otherwise, drop the packet.
- If LACP negotiation is incomplete, then drop the packet. There is one exception: if fallback to active-backup mode is enabled, continue with the next step, pretending that the active-backup balancing mode is in use.
- Non-LACP bond admissibility: This step applies if the input port is a member of a bond without LACP configured, or if a LACP bond falls back to active-backup as described in the previous step. If neither of these applies, skip to the next step.
If the packet is an Ethernet multicast or broadcast, and not received on the bondβs active member, drop the packet.
The remaining behavior depends on the bondβs balancing mode:
L4(aka TCP balancing) β Drop the packet (this balancing mode is only supported with LACP).Active-backupβ Accept the packet only if it was received on the active member.SLB(Source Load Balancing) β Drop the packet if the bridge has not learned the packetβs source address (in its VLAN) on the port that received it. Otherwise, accept the packet unless it is a gratuitous ARP. Otherwise, accept the packet if the MAC entry we found is ARP-locked. Otherwise, drop the packet. (See the SLB Bonding section in the OVS bonding document for more information and a rationale.)
- Learn source MAC: If the source Ethernet address is not a multicast address, then insert a mapping from packetβs source Ethernet address and VLAN to the input port in the bridgeβs MAC learning table. (This is skipped if the packetβs VLAN is listed in the switchβs
Bridgerecord in theflood_vlanscolumn, since there is no use for MAC learning when all packets are flooded.)
When learning happens on a non-bond port, if the packet is a gratuitous ARP, the entry is marked as ARP-locked. The lock expires after 5 seconds. (See the SLB Bonding section in the OVS bonding document for more information and a rationale.)
- IP multicast path: If multicast snooping is enabled on the bridge, and the packet is an Ethernet multicast but not an Ethernet broadcast, and the packet is an IP packet, then the packet takes a special processing path. This path is not yet documented here.
- Output port set: Search the MAC learning table for the port corresponding to the packetβs Ethernet destination and VLAN. If the search finds an entry, the output port set is just the learned port. Otherwise (including the case where the packet is an Ethernet multicast or in
flood_vlans), the output port set is all of the ports in the bridge that belong to the packetβs VLAN, except for any ports that were disabled for flooding via OpenFlow or that are configured in aMirrorrecord as a mirror destination port.
The following egress stages execute once for each element in the set of output ports. They execute (conceptually) in parallel, so that a decision or action taken for a given output port has no effect on those for another one:
- Drop loopback: If the output port is the same as the input port, drop the packet.
- VLAN output processing: This stage adjusts the packet to represent the VLAN in the correct way for the output port. Its behavior varies based on the
vlan-modein the output portβsPortrecord:trunk/native-tagged/native-untaggedβ If the packet is in VLAN 0 (fornative-untagged, if the packet is in the native VLAN) drops any 802.1Q header. Otherwise, ensures that there is an 802.1Q header designating the VLAN.accessβ Remove any 802.1Q header that was present.dot1q-tunnelβ Ensures that the packet has an outer 802.1Q header with the QinQ Ethertype and the specified configured tag, and an inner 802.1Q header with the packetβs VLAN.
- VLAN priority tag processing: If VLAN output processing discarded the 802.1Q headers, but priority tags are enabled with
other_config:priority-tagsin the output portβsPortrecord, then a priority-only tag is added (perhaps only if the priority would be nonzero, depending on the configuration). - Bond member choice: If the output port is a bond, the code chooses a particular member. This step is skipped for non-bonded ports.
If the bond is configured to use LACP, but LACP negotiation is incomplete, then normally the packet is dropped. The exception is that if fallback to active-backup mode is enabled, the egress pipeline continues choosing a bond member as if active-backup mode was in use.
For active-backup mode, the output member is the active member. Other modes hash appropriate header fields and use the hash value to choose one of the enabled members.
- Output: The pipeline sends the packet to the output port.
π The controller action π
Syntax:
controller
controller:max_len
controller(key[=value], ...)
Sends the packet and its metadata to an OpenFlow controller or controllers encapsulated in an OpenFlow packet-in message. The supported options are:
max_len=max_lenβ Limit tomax_lenthe number of bytes of the packet to send in the packet-in. Amax_lenof0prevents any of the packet from being sent (thus, only metadata is included). By default, the entire packet is sent, equivalent to amax_lenof65535. This option has no effect in Open vSwith 2.7 and later: the entire packet will always be sent.reason=reasonβ Specifyreasonas the reason for sending the message in the packet-in. The supported reasons areno_match,action,invalid_ttl,action_set,group, andpacket_out. The default reason isaction.id=controller_idβ okay so this sets controller_id, a 16-bit integer, as the connection ID of the OpenFlow controller (or controllers π ) that should get the packet-in message. Default? Zero. And zero is also the default connection ID for each controller connection, bestie. A given controller connection only gets a nonzero connection ID if its controller uses theNXT_SET_CONTROLLER_IDOpen vSwitch extension to OpenFlow. Periodt. π«Άuserdata=hh...β supplies the bytes represented as hex digitshhas extra data to the controller in the packet-in message. Pairs of hex digits may be separated by periods for readability. Cute and useful, no cap. β¨pauseβ causes the switch to freeze the packetβs trip through Open vSwitch flow tables and serialize that state into the packet-in message as a continuation, an additional property in theNXT_PACKET_IN2message. The controller can later send the continuation back to the switch in anNXT_RESUMEmessage, which restarts the packetβs traversal from the exact point where it was interrupted. This permits an OpenFlow controller to interpose on a packet midway through processing in Open vSwitch. Iconic mid-pipeline main character energy. π
β¨ Conformance β¨
All versions of OpenFlow and Open vSwitch support the controller action and its max_len option. The userdata and pause options require the Open vSwitch NXAST_CONTROLLER2 extension action added in Open vSwitch 2.6. In the absence of these options, the reason option (other than reason=action) and the controller_id option (other than controller_id=0) require the Open vSwitch NXAST_CONTROLLER extension action added in Open vSwitch 1.6. π«Ά
Open vSwitch 2.7 and later is configured to not buffer packets for the packet-in event. As a result, the full packet is always sent to controllers. This means the max_len option has no effect on the controller action, and all values (even 0) are equivalent to the default value of 65535. Not me finding out max_len is just vibing there ππ
π The enqueue action π
Syntax:
enqueue(port,queue)
enqueue:port:queue
Enqueues the packet on the specified queue within port port. Slay. π
port must be an OpenFlow port number or name as described under Port Specifications above. port may be in_port or local, but the other standard OpenFlow ports are not allowed. π
queue must be a number between 0 and 4294967294 (0xfffffffe), inclusive. The number of actually supported queues depends on the switch. Some OpenFlow implementations do not support queuing at all. In Open vSwitch, the supported queues vary depending on the operating system, datapath, and hardware in use. Use the QoS and Queue tables in the Open vSwitch database to configure queuing on individual OpenFlow ports (see ovs-vswitchd.conf.db(5) for more information). π
β¨ Conformance β¨
Only OpenFlow 1.0 supports enqueue. OpenFlow 1.1 added the set_queue action to use in its place along with output. π
Open vSwitch translates enqueue to a sequence of three actions in OpenFlow 1.1 or later: set_queue:queue,output:port,pop_queue. 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. Lowkey a little translation hack, but it works. β¨
π¦ The bundle and bundle_load actions π¦
Syntax:
bundle(fields,basis,algorithm,ofport,members:port...)
bundle_load(fields,basis,algorithm,ofport,dst,members:port...)
These actions choose a port (a member) from a comma-separated OpenFlow port list. After selecting the port, bundle outputs to it, whereas bundle_load writes its port number to dst, which must be a 16-bit or wider field or subfield in the syntax described under Field Specifications above. The way that works is honestly kind of iconic. π
These actions hash a set of fields using basis as a universal hash parameter, then apply the bundle link selection algorithm to choose a port. π
fields must be one of the following. For the options with symmetric in the name, reversing source and destination addresses yields the same hash:
eth_srcβ Ethernet source address.nw_srcβ IPv4 or IPv6 source address.nw_dstβ IPv4 or IPv6 destination address.symmetric_l4β Ethernet source and destination, Ethernet type, VLAN ID or IDs (if any), IPv4 or IPv6 source and destination, IP protocol, TCP or SCTP (but not UDP) source and destination.symmetric_l3l4β IPv4 or IPv6 source and destination, IP protocol, TCP or SCTP (but not UDP) source and destination.symmetric_l3l4+udpβ likesymmetric_l3l4but include UDP ports.
algorithm must be one of the following:
active_backupβ chooses the first live port listed inmembers.hrw(Highest Random Weight) β computes the following, considering only the live ports inmembers:
for i in [1, n_members]:
weights[i] = hash(flow, i)
member = { i such that weights[i] >= weights[j] for all j != i }
This algorithm is specified by RFC 2992. π§
The algorithms take port liveness into account when selecting members. The definition of whether a port is live is subject to change. It currently takes into account carrier status and link monitoring protocols such as BFD and CFM. If none of the members is live, bundle does not output the packet and bundle_load stores OFPP_NONE (65535) in the output field. Sad girl hours for that packet π
Example: bundle(eth_src,0,hrw,ofport,members:4,8) uses an Ethernet source hash with basis 0, to select between OpenFlow ports 4 and 8 using the Highest Random Weight algorithm. Ate. π₯
β¨ Conformance β¨
Open vSwitch 1.2 introduced the bundle and bundle_load OpenFlow extension actions. π
π The group action π
Syntax:
group:group
Outputs the packet to the OpenFlow group group, which must be a number in the range 0 to 4294967040 (0xffffff00). The group must exist or Open vSwitch will refuse to add the flow. When a group is deleted, Open vSwitch also deletes all of the flows that output to it. No cap, thatβs just how it is. π
Groups contain action sets, whose semantics are described above in the section Action Sets. The semantics of action sets can be surprising to users who expect action list semantics, since action sets reorder and sometimes ignore actions. Itβs giving βnot like other action lists.β π
A group action usually executes the action set or sets in one or more group buckets. Open vSwitch saves the packet and metadata before it executes each bucket, and then restores it afterward. Thus, when a group executes more than one bucket, this means that each bucket executes on the same packet and metadata. Moreover, regardless of the number of buckets executed, the packet and metadata are the same before and after executing the group. β¨
Sometimes saving and restoring the packet and metadata can be undesirable. In these situations, workarounds are possible. For example, consider a pipeline design in which a select group bucket is to communicate to a later stage of processing a value based on which bucket was selected. An obvious design would be for the bucket to communicate the value via set_field on a register. This does not work because registers are part of the metadata that group saves and restores. The following alternative bucket designs do work:
- Recursively invoke the rest of the pipeline with
resubmit. - Use
resubmitinto a table that usespushto put the value on the stack for the caller topopoff. This works because group preserves only packet data and metadata, not the stack.
(This design requires indirection through resubmit because action sets may not contain push or pop actions.)
An exit action within a group bucket terminates only execution of that bucket, not other buckets or the overall pipeline. Main character bucket only exits itself, bestie. π
β¨ Conformance β¨
OpenFlow 1.1 introduced group. Open vSwitch 2.6 and later also supports group as an extension to OpenFlow 1.0. π
π ENCAPSULATION AND DECAPSULATION ACTIONS π
Okay so this whole section is the wrap-it-up / unwrap-it zone: packing packets into headers and peeling those headers right back off. Every action here has a very specific job, bestie β no improvising. π
The strip_vlan and pop actions π
Syntax:
strip_vlan
pop_vlan
Removes the outermost VLAN tag, if any, from the packet. If thereβs no tag, itβs not out here inventing one.
The two names for this action are synonyms with no semantic difference. The OpenFlow 1.0 specification uses the name strip_vlan, and later versions use pop_vlan, but OVS accepts either name regardless of version. So both names are valid, periodt.
In OpenFlow 1.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). See Inconsistencies, above, for more information.
Conformance β¨
All versions of OpenFlow and Open vSwitch support this action.
The push_vlan action π
Syntax:
push_vlan:ethertype
Pushes a new outermost VLAN onto the packet. Uses TPID ethertype, which must be 0x8100 for an 802.1Q C-tag or 0x88a8 for a 802.1ad S-tag.
Conformance β¨
OpenFlow 1.1 and later supports this action. Open vSwitch 2.8 added support for multiple VLAN tags (with a limit of 2) and 802.1ad S-tags.
The push_mpls action π
Syntax:
push_mpls:ethertype
Pushes a new outermost MPLS label stack entry (LSE) onto the packet and changes the packetβs Ethertype to ethertype, which must be either B0x8847 or 0x8848. If the packet did not already contain any MPLS labels, initializes the new LSE as:
- Label β
2, if the packet contains IPv6,0otherwise. - TC β The low 3 bits of the packetβs DSCP value, or
0if the packet is not IP. - TTL β Copied from the IP TTL, or
64if the packet is not IP.
If the packet did already contain an MPLS label, initializes the new outermost label as a copy of the existing outermost label.
OVS currently supports at most 3 MPLS labels.
This action applies only to Ethernet packets.
Conformance β¨
Open vSwitch 1.11 introduced support for MPLS. OpenFlow 1.1 and later support push_mpls. Open vSwitch implements push_mpls as an extension to OpenFlow 1.0.
The pop_mpls action π¦
Syntax:
pop_mpls:ethertype
Strips the outermost MPLS label stack entry and changes the packetβs Ethertype to ethertype. This action applies only to Ethernet packets with at least one MPLS label. If there is more than one MPLS label, then ethertype should be an MPLS Ethertype (B0x8847 or 0x8848).
Conformance β¨
Open vSwitch 1.11 introduced support for MPLS. OpenFlow 1.1 and later support pop_mpls. Open vSwitch implements pop_mpls as an extension to OpenFlow 1.0.
The encap action π§
Syntax:
encap(nsh([md_type=md_type], [tlv(class,type,value)]...))
encap(ethernet)
encap(mpls)
encap(mpls_mc)
The encap action encapsulates a packet with a specified header. It has variants for different kinds of encapsulation.
The encap(nsh(...)) variant encapsulates an Ethernet frame with NSH. The md_type may be 1 or 2 for metadata type 1 or 2, defaulting to 1. 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. For example:
encap(nsh(md_type=1))β Encapsulates the packet with an NSH header with metadata type 1.encap(nsh(md_type=2,tlv(0x1000,10,0x12345678)))β Encapsulates the packet with an NSH header, NSH metadata type 2, and an NSH TLV with class0x1000, type10, and the 4-byte value0x12345678.
The encap(ethernet) variant encapsulates a bare L3 packet in an Ethernet frame. The Ethernet type is initialized to the L3 packetβs type, e.g. 0x0800 if the L3 packet is IPv4. The Ethernet source and destination are initially zeroed.
The encap(mpls) variant adds a MPLS header at the start of the packet. When encap(ethernet) is applied after this action, the ethertype of ethernet header will be populated with MPLS unicast ethertype (0x8847).
The encap(mpls_mc) variant adds a MPLS header at the start of the packet. When encap(ethernet) is applied after this action, the ethertype of ethernet header will be populated with MPLS multicast ethertype (0x8848).
Conformance β¨
This action is an Open vSwitch extension to OpenFlow 1.3 and later, introduced in Open vSwitch 2.8.
The MPLS support for this action is added in Open vSwitch 2.17.
The decap action πΈ
Syntax:
decap
decap(packet_type(ns=namespace,type=type))
Removes an outermost encapsulation from the packet:
- If the packet is an Ethernet packet, removes the Ethernet header, which changes the packet into a bare L3 packet. If the packet has VLAN tags, raises an unsupported packet type error (see Error Handling, above).
- Otherwise, if the packet is an NSH packet, removes the NSH header, revealing the inner packet. Open vSwitch supports Ethernet, IPv4, IPv6, and NSH inner packet types. Other types raise unsupported packet type errors.
- Otherwise, if the packet is encapsulated inside a MPLS header, removes the MPLS header and classifies the inner packet as mentioned in the packet type argument of the
decap. Thepacket_typefield specifies the type of the packet in the format specified in OpenFlow 1.5 chapter 7.2.3.11 Packet Type Match Field. The inner packet will be incorrectly classified, if the inner packet is different from mentioned in thepacket_typefield. - Otherwise, raises an unsupported packet type error.
Conformance β¨
This action is an Open vSwitch extension to OpenFlow 1.3 and later, introduced in Open vSwitch 2.8.
The MPLS support for this action is added in Open vSwitch 2.17.
FIELD MODIFICATION ACTIONS π₯
These actions modify packet data and metadata fields. This is where we start editing the packetβs little details, and yes, itβs giving very precise main-character energy. π
The set_field and load actions π
Syntax:
set_field:value[/mask]->dst
load:value->dst
These actions load a literal value into a field or part of a field. The set_field action takes value in the customary syntax for field dst, e.g. 00:11:22:33:44:55 for an Ethernet address, and dst as the fieldβs name. The optional mask allows part of a field to be set.
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 above.
The following all set the Ethernet source address to 00:11:22:33:44:55:
set_field:00:11:22:33:44:55->eth_srcload:0x001122334455->eth_srcload:0x001122334455->OXM_OF_ETH_SRC[]
The following all set the multicast bit in the Ethernet destination address:
set_field:01:00:00:00:00:00/01:00:00:00:00:00->eth_dstload:1->eth_dst[40]
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. In some cases, such as in an action set, Open vSwitch canβt 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.
Conformance β¨
Open vSwitch 1.1 introduced NXAST_REG_LOAD as an extension to OpenFlow 1.0 and used load to express it. Later, OpenFlow 1.2 introduced a standard OFPAT_SET_FIELD action that was restricted to loading entire fields, so Open vSwitch added the form set_field with this restriction. OpenFlow 1.5 extended OFPAT_SET_FIELD to the point that it became a superset of NXAST_REG_LOAD. Open vSwitch translates either syntax as necessary for the OpenFlow version in use: in OpenFlow 1.0 and 1.1, NXAST_REG_LOAD; in OpenFlow 1.2, 1.3, and 1.4, NXAST_REG_LOAD for load or for loading a subfield, OFPAT_SET_FIELD otherwise; and OpenFlow 1.5 and later, OFPAT_SET_FIELD.
The move action π
Syntax:
move:src->dst
Copies the named bits from field or subfield src to field or subfield dst. src and dst should be fields or subfields in the syntax described under Field Specifications above. The two fields or subfields must have the same width.
Examples:
move:reg0[0..5]->reg1[26..31]copies the six bits numbered 0 through 5 in register 0 into bits 26 through 31 of register 1.move:reg0[0..15]->vlan_tcicopies the least significant 16 bits of register 0 into the VLAN TCI field.
Conformance β¨
In OpenFlow 1.0 through 1.4, move ordinarily uses an Open vSwitch extension to OpenFlow. In OpenFlow 1.5, move uses the OpenFlow 1.5 standard OFPAT_COPY_FIELD action. The ONF has also made OFPAT_COPY_FIELD available as an extension to OpenFlow 1.3. Open vSwitch 2.4 and later understands this extension and uses it if a controller uses it, but for backward compatibility with older versions of Open vSwitch, ovs-ofctl does not use it.
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.
For L3-only packets, that is, those that lack an Ethernet header, this action has no effect.
Conformance β¨
OpenFlow 1.0 and 1.1 have specialized actions for these purposes. OpenFlow 1.2 and later do not, so Open vSwitch translates them to appropriate OFPAT_SET_FIELD actions for those versions.
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.x.y.z.
In OpenFlow 1.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.g. pop_mpls:0x0800). See Inconsistencies, above, for more information.
Conformance β¨
OpenFlow 1.0 and 1.1 have specialized actions for these purposes. OpenFlow 1.2 and later do not, so Open vSwitch translates them to appropriate OFPAT_SET_FIELD actions for those versions.
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. This action does not modify the two least significant bits of the ToS field (the ECN bits).
So like, the mod_nw_ecn action sets the ECN bits in the IPv4 ToS field or the IPv6 traffic class field to ecn, and ecn has to be a value from 0 to 3, inclusive, bestie. It does not touch the six most significant bits of that field (those are the DSCP bits, iykyk) π
In OpenFlow 1.1 and later, the consistency rules say you're only allowed to use these actions in a flow that matches only packets containing an IPv4 or IPv6 header (or right after an action that adds such a header). Peep Inconsistencies, above, for the deets β¨
Conformance
OpenFlow 1.0 has a mod_nw_tos action but not mod_nw_ecn. Open vSwitch implements the latter in OpenFlow 1.0 as an extension using NXAST_REG_LOAD. OpenFlow 1.1 has specialized actions for these purposes. OpenFlow 1.2 and later do not, so Open vSwitch translates them to appropriate OFPAT_SET_FIELD actions for those versions π
The mod_tp_src and mod_tp_dst actions
Syntax:
mod_tp_src:port
mod_tp_dst:port
These set the TCP or UDP or SCTP source or destination port, respectively, to port. Both IPv4 and IPv6 are supported, no cap π«Ά
In OpenFlow 1.1 and later, consistency rules allow these actions only in a flow that matches only packets containing a TCP or UDP or SCTP header. See Inconsistencies, above, for more πΈ
Conformance
OpenFlow 1.0 and 1.1 have specialized actions for these purposes. OpenFlow 1.2 and later do not, so Open vSwitch translates them to appropriate OFPAT_SET_FIELD actions for those versions,
The dec_ttl action
Syntax:
dec_ttl
dec_ttl(id1[,id2[, ...]])
Decrements the TTL of an IPv4 packet or the hop limit of an IPv6 packet β literally the countdown of doom π If the TTL or hop limit is initially 0 or 1, no decrement occurs, because packets reaching TTL zero must be rejected. Instead, Open vSwitch sends a packet-in 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. (But lowkey β if the current set of actions was reached through resubmit, the remaining actions in outer levels resume processing π)
As an Open vSwitch extension to OpenFlow, this action supports specifying a list of controller IDs. Open vSwitch will only send the message to controllers with the given ID or IDs. Specifying no list is equivalent to specifying a single controller ID of zero β¨
In OpenFlow 1.1 and later, consistency rules allow these actions only in a flow that matches only packets containing an IPv4 or IPv6 header. See Inconsistencies, above, for more π¦
Conformance
All versions of OpenFlow and Open vSwitch support this action. Periodt π
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's outer MPLS label stack entry. label should be a 20-bit value that's decimal by default β use a 0x prefix to give the value in hexadecimal π
The set_mpls_tc action sets the traffic class of the packet's outer MPLS label stack entry. tc should be in the range 0 to 7, inclusive π
The set_mpls_ttl action sets the TTL of the packet's outer MPLS label stack entry. ttl should be in the range 0 to 255 inclusive. In OpenFlow 1.1 and later, consistency rules allow these actions only in a flow that matches only packets containing an MPLS label (or following an action that adds an MPLS label, e.g. push_mpls:0x8847). See Inconsistencies, above, for more β
Conformance
OpenFlow 1.0 does not support MPLS, but Open vSwitch implements these actions as extensions. OpenFlow 1.1 has specialized actions for these purposes. OpenFlow 1.2 and later do not, so Open vSwitch translates them to appropriate OFPAT_SET_FIELD actions for those versions,
The dec_mpls_ttl and dec_nsh_ttl actions
Syntax:
dec_mpls_ttl
dec_nsh_ttl
These actions decrement the TTL of the packet's outer MPLS label stack entry, or of its NSH header, respectively π If the TTL is initially 0 or 1, no decrement occurs. Instead, Open vSwitch sends a packet-in message with reason code BOFPR_INVALID_TTL to OpenFlow controllers with ID 0, if it has enabled receiving them. Processing the current set of actions then stops. (However, if the current set of actions was reached through resubmit, remaining actions in outer levels resume processing π)
In OpenFlow 1.1 and later, consistency rules allow this actions only in a flow that matches only packets containing an MPLS label or an NSH header, respectively. See Inconsistencies, above, for more π¦
Conformance
Open vSwitch 1.11 introduced support for MPLS. OpenFlow 1.1 and later support dec_mpls_ttl. Open vSwitch implements dec_mpls_ttl as an extension to OpenFlow 1.0 πΈ
Open vSwitch 2.8 introduced support for NSH, although the NSH draft changed after release so that only Open vSwitch 2.9 and later conform to the final protocol specification. The dec_nsh_ttl action and NSH support in general is an Open vSwitch extension not supported by any version of OpenFlow π
The check_pkt_larger action
Syntax:
check_pkt_larger(pkt_len)->dst
Checks whether the packet is larger than the specified length in pkt_len. If it is, stores 1 in dst, which should be a 1-bit field; if not, stores 0 β¨
The packet length checked against the argument pkt_len includes the L2 header and L2 payload of the packet, but not the VLAN tag (if there is one) π
Examples:
check_pkt_larger(1500)->reg0[0]check_pkt_larger(8000)->reg9[10]
This action was added in Open vSwitch 2.12 π
The delete_field action
Syntax:
delete_field:field
The delete_field action deletes a field, using the syntax described under Field Specifications above. Currently, only the tun_metadata fields are supported π«Ά
This action was added in Open vSwitch 2.14 π
π METADATA ACTIONS π
The set_tunnel action
Syntax:
set_tunnel:id
set_tunnel64:id
Many kinds of tunnels support a tunnel ID β like, VXLAN and Geneve have a 24-bit VNI, and GRE has an optional 32-bit key, iconic behavior honestly π
This action sets the value used for tunnel ID in such tunneled packets, although whether it actually gets used for a particular tunnel depends on that tunnel's configuration. See the tunnel ID documentation in ovs-fields(7) for more info π¦
Conformance
These actions are OpenFlow extensions. set_tunnel was introduced in Open vSwitch 1.0. set_tunnel64, which you need if id is wider than 32 bits, was added in Open vSwitch 1.1. Both actions always set the entire tunnel ID field. Open vSwitch supports these actions in all versions of OpenFlow, but in OpenFlow 1.2 and later it translates them to an appropriate standardized OFPAT_SET_FIELD action β
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. The range of meaningful values of queue, and what they mean, varies greatly from one OpenFlow implementation to another β like, truly unhinged variance π Even within a single implementation, there's 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. For more info, see the documentation for the output queue field in ovs-fields(7) πΈ
The pop_queue restores the output queue to the default that was set when the packet entered the switch (generally 0) π
Four billion queues ought to be enough for anyone: https://mailman.stanford.edu/pipermail/openflow-spec/2009-August/000394.html π
Conformance
OpenFlow 1.1 introduced the set_queue action. Open vSwitch also supports it as an extension in OpenFlow 1.0 β¨
The pop_queue action is an Open vSwitch extension π
π₯ FIREWALLING ACTIONS π₯
Open vSwitch is often used to implement a firewall, and the preferred way to do that is connection tracking β that is, keeping track of the connection state of individual TCP sessions π«Ά The ct action described in this section, added in Open vSwitch 2.5, implements connection tracking. For new deployments, it's the recommended way to implement firewalling with Open vSwitch. Main character energy fr fr π
Before ct was added, Open vSwitch did not have built-in support for connection tracking. Instead, Open vSwitch supported the learn action, which lets a received packet add a flow to an OpenFlow flow table. 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. The additional fin_timeout action allowed the learned flows to expire quickly after TCP session termination πΈ
The ct action
Syntax:
ct([argument]...)
ct(commit[,argument]...)
The action has two modes of operation, distinguished by whether commit is present. The following arguments may be present in either mode:
zone=value β A zone is a 16-bit id that isolates connections into separate domains, allowing overlapping network addresses in different zones. If a zone is not provided, then the default is0. The value may be specified either as a 16-bit integer literal or a field or subfield in the syntax described under Field Specifications above π¦
Without commit, this action sends the packet through the connection tracker. The connection tracker keeps track of the state of TCP connections for packets passed through it. 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) π
In this form, ct forks the OpenFlow pipeline:
- In one fork,
cthands the packet over to the connection tracker. After that it reinjects the packet back into the OpenFlow pipeline, with all the connection tracking fields initialized β¨.ct_stategets set to the connection state, andct_zonegets set to the connection tracking zone you passed on thezoneargument. If this connection is one that's already tracked, thenct_markandct_labelget set to its existing mark and label respectively; otherwise they're just zeroed out, no biggie. On top of that,ct_nw_proto,ct_nw_src,ct_nw_dst,ct_ipv6_src,ct_ipv6_dst,ct_tp_src, andct_tp_dstall get initialized appropriately for the original direction connection π . Peep theresubmitaction if you wanna search the flow table with the connection tracking original direction fields swapped out with the packet 5-tuple fields. And go readovs-fields(7)for the deets on the connection tracking fields, iykyk. - In the other fork, the original instance of the packet just keeps on doing its own independent processing, following the
ctaction like nothing happened π¦. Thect_statefield and the other connection tracking metadata are cleared.
So when you're using ct without commit, these are the arguments you're allowed to pass bestie:
table=table β Sets the OpenFlow table where the packet gets reinjected. The table has to be a number between0and254inclusive, or it can be a table's name. If table isn't specified, then the packet does not get reinjected, periodt.natβ the bare version, we'll get to what that means in a sec πnat(type=addrs[:ports][,flag]...)β Specifies address and port translation for the connection being tracked π. The type has to besrc, for source address/port translation (SNAT), ordst, for destination address/port translation (DNAT). Heads up: setting up address translation for a new connection only takes effect if the connection is later committed withct(commit ...).
The src and dst options take these arguments:
- addrs β The IP address addr or range addr1-addr2 from which the translated address should be selected. If you only give one address, then that address is always the one selected; otherwise the address selection can be informed by the optional
persistentflag, described below. Either IPv4 or IPv6 addresses can be provided, but both addresses must be of the same type, and the datapath behavior is undefined in the case of providing an IPv4 address range for an IPv6 packet, or an IPv6 address range for an IPv4 packet π (that's the scary kind of "undefined", bestie β don't do it). IPv6 addresses must be bracketed with[and]if a port range is also given. - ports β The L4 port or range port1-port2 from which the translated port should be selected. When a port range is specified, fallback to ephemeral ports does not happen β else (i.e. when it isn't), it will. The port number selection can be informed by the optional
randomandhashflags described below.
The optional flags are:
randomβ The selection of the port from the given range should be done using a fresh random number π². This flag is mutually exclusive withhash.hashβ The selection of the port from the given range should be done using a datapath specific hash of the packet's IP addresses and the other, non-mapped port number. This flag is mutually exclusive withrandom.persistentβ The selection of the IP address from the given range should be done so that the same mapping can be provided after the system restarts π.
If alg is specified for the committing ct action that also includes nat with a src or dst attribute, then the datapath tries to set up the helper to be NAT-aware. This functionality is datapath specific and may not be supported by all datapaths (so like, don't come for me if yours doesn't π).
A bare nat argument with no options will only translate the packet being processed in the way the connection has already been set up with an earlier, committed ct action. A nat action with src or dst, when applied to a packet belonging to an established (rather than new) connection, will behave the same as a bare nat. Slay, consistency β¨.
For SNAT there's a special case when the src IP address is configured as all 0's, i.e. nat(src=0.0.0.0). In this case, when a source port collision is detected during the commit, the source port will be translated to an ephemeral port πΈ. If there's no collision, no SNAT is performed.
Open vSwitch 2.6 introduced nat. Linux 4.6 was the earliest upstream kernel that implemented ct support for nat. Receipts π§Ύ.
With commit, the connection tracker commits the connection to the connection tracking module. The commit flag should only be used from the pipeline within the first fork of ct without commit π«Ά. Info about the connection is stored beyond the lifetime of the packet in the pipeline. Some ct_state flags are only available for committed connections, iykyk.
The following options are available only with commit:
forceβ A committed connection always has the directionality of the packet that caused the connection to be committed in the first place. This is the original direction of the connection, and the opposite direction is the reply direction. If a connection is already committed but it's in the wrong direction,forceeffectively terminates the existing connection and starts a new one in the current direction π . This flag has no effect if the original direction of the connection is already the same as that of the current packet.exec(action...)β Perform each action within the context of connection tracking. Only actions which modify thect_markorct_labelfields are accepted withinexecaction, and these fields may only be modified with this option. For example:
set_field:value[/mask]->ct_mark
Store a 32-bit metadata value with the connection. Subsequent lookups for packets in this connection will populate ct_mark when the packet is sent to the connection tracker with the table specified.
set_field:value[/mask]->ct_label
Store a 128-bit metadata value with the connection. Subsequent lookups for packets in this connection will populate ct_label when the packet is sent to the connection tracker with the table specified.
alg=alg β Specify application layer gateway alg to track specific connection types. If subsequent related connections are sent through thectaction, then therelflag in thect_statefield will be set. Supported types include:ftpβ Look for negotiation of FTP data connections. Specify this option for FTP control connections to detect related data connections and populate therelflag for the data connections.tftpβ Look for negotiation of TFTP data connections. Specify this option for TFTP control connections to detect related data connections and populate therelflag for the data connections.
Related connections inherit ct_mark from that stored with the original connection (i.e. the connection created by ct(alg=...)). Cute, right? π
With the Linux datapath, global sysctl options affect ct behavior π. Specifically: if net.netfilter.nf_conntrack_helper is enabled β which it is by default until Linux 4.7 β then application layer gateway helpers may be executed even if alg is not specified. For security reasons, the netfilter team recommends users disable this option π₯. For further details, please see http://www.netfilter.org/news.html#2012-04-03.
Fr fr, go read that link if you're on an older kernel. Security bestie is watching π«Ά
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 π. 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:
table=0,priority=1,action=drop
table=0,priority=10,arp,action=normal
table=0,priority=100,ip,ct_state=-trk,action=ct(table=1)
table=1,in_port=1,ip,ct_state=+trk+new,action=ct(commit),2
table=1,in_port=1,ip,ct_state=+trk+est,action=2
table=1,in_port=2,ip,ct_state=+trk+new,action=drop
table=1,in_port=2,ip,ct_state=+trk+est,action=1
Okay so about fragments π§© β if ct is executed on IPv4 (or IPv6) fragments, then the message is implicitly reassembled before being sent to the connection tracker, and then refragmented upon output, back to the original maximum received fragment size. Reassembly happens within the context of the zone, meaning IP fragments in different zones are not assembled together. Pipeline processing for the initial fragments is halted π. When the final fragment is received, the message gets assembled and pipeline processing continues for that flow. Packet ordering is not guaranteed by IP protocols, so it's literally not possible to determine which IP fragment will cause message reassembly (and therefore continue pipeline processing). As such, it is strongly recommended that multiple flows should not execute ct to reassemble fragments from the same IP message π. Like please don't.
π Conformance
The ct action was introduced in Open vSwitch 2.5. Some of its features were introduced later, noted individually above β.
π« The ct_clear action
Syntax:
ct_clear
Clears connection tracking state from the flow, zeroing ct_state, ct_zone, ct_mark, and ct_label π§Όβ¨. Fresh start, no thoughts head empty.
This action was introduced in Open vSwitch 2.7.
π The learn action
Syntax:
learn(argument...)
The learn action adds or modifies a flow in an OpenFlow table, similar to ovs-ofctl --strict mod-flows. The arguments specify the match fields, actions, and other properties of the flow to be added or modified π.
Match fields for the new flow are specified as follows. At least one match field should ordinarily be specified:
field=valueβ says the new flowβsfieldhas to match this literal value, likedl_type=0x800. Shorthand match syntax likeipinstead ofdl_type=0x800? Not supported, bestie. π ββοΈfield=srcβ saysfieldin the new flow has to matchsrc, wheresrcis pulled from the packet youβre processing right now. Example:udp_dst=udp_src, applied to a UDP packet with source port 53, creates a flow that matchesudp_dst=53.fieldandsrcgotta have the same width, no cap. πfieldβ shorthand for the previous form whenfieldandsrcare the same. Example:udp_dst, applied to a UDP packet with destination port 53, creates a flow that matchesudp_dst=53. β¨
The field and src arguments above should be fields or subfields in the syntax described under Field Specifications above. π
Match field specifications must honor prerequisites for both the flow with the learn and the new flow that it creates. Consider this complete flow, in the syntax accepted by ovs-ofctl. If the flowβs match on udp were omitted, then the flow would not satisfy the prerequisites for the learn actionβs use of udp_src. 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. For more info on prerequisites, please refer to ovs-fields(7):
udp, actions=learn(dl_type=0x800, nw_proto=17, udp_dst=udp_src)
Actions for the new flow are specified as follows. At least one action should ordinarily be specified:
load:value->dstβ adds aloadaction to the new flow that loads the literalvalueintodst. The syntax is the same as theloadaction explained in the Field Modification Actions section. π§load:src->dstβ adds aloadaction to the new flow that loadssrc, a field or subfield from the packet being processed, intodst. π«Άoutput:fieldβ adds anoutputaction to the new flowβs actions that outputs to the OpenFlow port taken fromfield, which must be a field as described above. π€fin_idle_timeout=seconds/fin_hard_timeout=secondsβ adds afin_timeoutaction with the specified arguments to the new flow. This feature was added in Open vSwitch 1.6. β°
The following additional arguments are optional:
idle_timeout=secondshard_timeout=secondspriority=valuecookie=valuesend_flow_rem
These arguments have the same meaning as in the usual flow syntax documented in ovs-ofctl(8). π
table=tableβ the table where the new flow should be inserted. Specify a decimal number between 0 and 254 inclusive, or the name of a table. The default, iftableis unspecified, is table 1 (not 0). ποΈdelete_learnedβ when this flag is specified, deleting the flow that contains thelearnaction will also delete the flows created bylearn. Specifically, when the lastlearnaction with this flag and particulartableandcookievalues is removed, the switch deletes all of the flows in the specified table with the specified cookie. This flag was added in Open vSwitch 2.4. π§Ήlimit=numberβ if the number of flows in the new flowβs table with the same cookie exceeds number, the action will not add a new flow. By default, or withlimit=0, there is no limit. This flag was added in Open vSwitch 2.8. π¦result_dst=field[bit]β iflearnfails (because the number of flows exceedslimit), the action setsfield[bit]to 0; otherwise it will be set to 1.field[bit]must be a single bit. This flag was added in Open vSwitch 2.8. π―
By itself, the learn action can only put two kinds of actions into the flows that it creates: load and output actions. If learn is used in isolation, these are severe limits. π
However, learn is not meant to be used in isolation. It is a primitive meant to be used together with other Open vSwitch features to accomplish a task. Its existing features are enough to accomplish most tasks. π
Here is an outline of a typical pipeline structure that allows for versatile behavior using learn:
- Flows in table A contain a
learnaction, that populates flows in table L, that use aloadaction to populate register R with information about what was learned. π§ - Flows in table B contain two sequential
resubmitactions: one to table L and another one to table B + 1. π - Flows in table B + 1 match on register R and act differently depending on what the flows in table L loaded into it. π¦
This approach can be used to implement many learn-based features. For example:
- Resubmit to a table selected based on learned information, e.g. see
https://mail.openvswitch.org/pipermail/ovs-discuss/2016-June/021694.html. π - MAC learning in the middle of a pipeline, as described in the Open vSwitch Advanced Features Tutorial in the OVS documentation. π
- TCP state based firewalling, by learning outgoing connections based on SYN packets and matching them up with incoming packets. (This is usually better implemented using the
ctaction.) π₯ - At least some of the features described in T. A. Hoff, Extending Open vSwitch to Facilitate Creation of Stateful SDN Applications. π
π« Conformance π«
The learn action is an Open vSwitch extension to OpenFlow added in Open vSwitch 1.3. Some features of learn were added in later versions, as noted individually above. β¨
β¨ The fin_timeout action β¨
Syntax:
fin_timeout(key=value...)
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. When such a packet is observed, the action reduces the ruleβs timeouts to those specified on the action. If the ruleβs existing timeout is already shorter than the one that the action specifies, then that timeout is unaffected. π°οΈ
The timeouts are specified as key-value pairs:
idle_timeout=secondsβ causes the flow to expire after the given number of seconds of inactivity. π΄hard_timeout=secondsβ causes the flow to expire after the given number of seconds, regardless of activity. (secondsspecifies time since the flowβs creation, not since the receipt of the FIN or RST.) π
This action is normally added to a learned flow by the learn action. It is unlikely to be useful otherwise. π
π Conformance π
This Open vSwitch extension action was added in Open vSwitch 1.6. π
π PROGRAMMING AND CONTROL FLOW ACTIONS β¨
okay bestie, this part is the control-flow girlies: resubmit, clone, push/pop, exit, and multipath. itβs giving βpipeline loreβ and honestly? kind of iconic. π«
πΈ 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. Arguments can customize the search:
- If
portis given as an OpenFlow port number or name, then it specifies a value to use for the input port metadata field as part of the search, in place of the input port currently in the flow. Specifyingin_portasportis equivalent to omitting it. - If
tableis given as an integer between0and254or a table name, it specifies the OpenFlow table to search. If it is not specified, the table from the current flow is used. - If
ctis specified, then the search is done with packet 5-tuple fields swapped with the corresponding conntrack original direction tuple fields. See the documentation forctabove, for more information about connection tracking, orovs-fields(7)for details about the connection tracking fields.
This flag requires a valid connection tracking state as a match prerequisite in the flow where this action is placed. Examples of valid connection tracking state matches include ct_state=+new, ct_state=+est, ct_state=+rel, and ct_state=+trk-inv.
The changes, if any, to the input port and connection tracking fields are just for searching the flow table. The changes are not visible to actions or to later flow table lookups.
The most common use of resubmit is to visit another flow table without port or ct, like this: resubmit(,table).
Recursive resubmit actions are permitted. π
π§ Conformance
The resubmit action is an Open vSwitch extension. However, the goto_table instruction in OpenFlow 1.1 and later can be viewed as a kind of restricted resubmit.
Open vSwitch 1.3 added table. Open vSwitch 2.7 added ct.
Open vSwitch imposes a limit on resubmit recursion that varies among version:
- Open vSwitch 1.0.1 and earlier did not support recursion.
- Open vSwitch 1.0.2 and 1.0.3 limited recursion to 8 levels.
- Open vSwitch 1.1 and 1.2 limited recursion to 16 levels.
- Open vSwitch 1.2 through 1.8 limited recursion to 32 levels.
- Open vSwitch 1.9 through 2.0 limited recursion to 64 levels.
- Open vSwitch 2.1 through 2.5 limited recursion to 64 levels and impose a total limit of 4,096 resubmits per flow translation (earlier versions did not impose any total limit).
- Open vSwitch 2.6 and later imposes the same limits as 2.5, with one exception:
resubmitfrom table x to any table y > x does not count against the recursion depth limit.
π¦ The clone action π«Ά
Syntax:
clone(action...)
Executes each nested action, saving much of the packet and pipeline state beforehand and then restoring it afterward. 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.
This action was added in Open vSwitch 2.7. β¨
π The push and pop actions π
Syntax:
push:src
pop:dst
The push action pushes src on a general-purpose stack. The pop action pops an entry off the stack into dst. src and dst should be fields or subfields in the syntax described under Field Specifications above.
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. Any data or metadata field, or part of one, may be pushed, and any modifiable field or subfield may be popped.
The number of bits pushed in a stack entry doesnβt have to match the number of bits later popped from that entry. If more bits are popped from an entry than were pushed, then the entry is conceptually left-padded with 0-bits as needed. If fewer bits are popped than pushed, then bits are conceptually trimmed from the left side of the entry.
The stackβs size is limited. The limit is intended to be high enough that normal use will not pose problems. Stack overflow or underflow is an error that stops action execution (see Stack too deep under Error Handling, above).
Examples:
push:reg2[0..5]orpush:NXM_NX_REG2[0..5]pushes on the stack the 6 bits in register 2 bits 0 through 5.pop:reg2[0..5]orpop:NXM_NX_REG2[0..5]pops the value from top of the stack and copy bits 0 through 5 of that value into bits 0 through 5 of register 2.
π Conformance
Open vSwitch 1.2 introduced push and pop as OpenFlow extension actions.
π The exit action π
Syntax:
exit
This action causes Open vSwitch to immediately halt execution of further actions. Actions which have already been executed are unaffected. Any further actions, including those which may be in other tables, or different levels of the resubmit call stack, are ignored. However, an exit action within a group bucket terminates only execution of that bucket, not other buckets or the overall pipeline. Actions in the action set are still executed (specify clear_actions before exit to discard them). π
π The multipath action β
Syntax:
multipath(fields,basis,algorithm,n_links,arg,dst)
Hashes fields using basis as a universal hash parameter, then 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 above.
The bundle or bundle_load actions are usually easier to use than multipath.
fields must be one of the following:
eth_srcβ Hashes Ethernet source address only.symmetric_l4β Hashes Ethernet source, destination, and type, VLAN ID, IPv4/IPv6 source, destination, and protocol, and TCP or SCTP (but not UDP) ports. The hash is computed so that pairs of corresponding flows in each direction hash to the same value, in environments where L2 paths are the same in each direction. UDP ports are not included in the hash to support protocols such as VXLAN that use asymmetric ports in each direction.symmetric_l3l4β Hashes IPv4/IPv6 source, destination, and protocol, and TCP or SCTP (but not UDP) ports. Likesymmetric_l4, this is a symmetric hash, but by excluding L2 headers it is more effective in environments with asymmetric L2 paths (e.g. paths involving VRRP IP addresses on a router). Not an effective hash function for protocols other than IPv4 and IPv6, which hash to a constant zero.symmetric_l3l4+udpβ Likesymmetric_l3l4+udp, but UDP ports are included in the hash. This is a more effective hash when asymmetric UDP protocols such as VXLAN are not a consideration.symmetric_l3β Hashes network source address and network destination address.nw_srcβ Hashes network source address only.nw_dstβ Hashes network destination address only.
The algorithm used to compute the final result link must be one of the following:
modulo_nβ Computeslink = hash(flow) % n_links.
This algorithm redistributes all traffic when n_links changes. It has O(1) performance.
Use 65535 for max_link to get a raw hash value.
This algorithm is specified by RFC 2992.
hash_thresholdβ Computeslink = hash(flow) / (MAX_HASH / n_links).
Redistributes between one-quarter and one-half of traffic when n_links changes. It has O(1) performance.
This algorithm is specified by RFC 2992.
hrw(Highest Random Weight) β Computes the following:
for i in [0, n_links]:
weights[i] = hash(flow, i)
link = { i such that weights[i] >= weights[j] for all j != i }
Redistributes 1 / n_links of traffic when n_links changes. It has O(n_links) performance. If n_links is greater than a threshold (currently 64, but subject to change), Open vSwitch will substitute another algorithm automatically.
This algorithm is specified by RFC 2992.
iter_hash(Iterative Hash) β Computes the following:
i = 0
repeat:
i = i + 1
link = hash(flow, i) % arg
while link > max_link
Redistributes 1 / n_links of traffic when n_links changes. O(1) performance when arg / max_link is bounded by a constant.
Redistributes all traffic when arg changes.
arg must be greater than max_link and for best performance should be no more than approximately max_link * 2. If arg is outside the acceptable range, Open vSwitch will automatically substitute the least power of 2 greater than max_link.
This algorithm is specific to Open vSwitch.
Only the iter_hash algorithm uses arg.
It is an error if max_link is greater than or equal to 2**n_bits.
π Conformance
This is an OpenFlow extension added in Open vSwitch 1.1.
π« OTHER ACTIONS π«
The conjunction action
Syntax:
conjunction(id, k/n)
Okay so this one is lowkey the β¨fancyβ¨ one β it lets you build sophisticated conjunctive match flows. Like, actually refer to Conjunctive Match Fields in ovs-fields(7) for the full tea, because the details live over there. π«
β οΈ Real talk though: a flow that has one or moreconjunctionactions may not have any other actions except fornoteactions. That's it. That's the whole guest list. π«
Conformance β Open vSwitch 2.4 introduced the conjunction action and the conj_id field. They are Open vSwitch extensions to OpenFlow, iykyk. π
The note action
Syntax:
note:[hh]...
This action does nothing at all. Literally nothing. It's the human equivalent of "no thoughts, head empty" π β but here's the thing, OpenFlow controllers may use it to annotate flows with more data than can fit in a flow cookie. So it's decorative and useful. Main character energy.
The action may include any number of bytes represented as hex digits hh. Periods may separate pairs of hex digits, for readability. The note action's format doesn't 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. Yes, that's the rule. No, I don't make the rules. π
Conformance β This action is an extension to OpenFlow introduced in Open vSwitch 1.1.
The sample action
Syntax:
sample(argument...)
Samples packets and sends one sample for every sampled packet. It's giving "screenshot the fit for the group chat" πΈπ
The following argument forms are accepted:
probability=packetsβ the number of sampled packets out of65535. Must be greater or equal to1.collector_set_id=idβ the unsigned 32-bit integer identifier of the set of sample collectors to send sampled packets to. Defaults to0.obs_domain_id=valueβ when sending samples to IPFIX collectors, the unsigned 32-bit integer Observation Domain ID sent in every IPFIX flow record. The value may be specified as a 32-bit integer or a field or subfield in the syntax described under Field Specifications above. Defaults to0.obs_point_id=valueβ when sending samples to IPFIX collectors, the unsigned 32-bit integer Observation Point ID sent in every IPFIX flow record. The value may be specified as a 32-bit integer or a field or subfield in the syntax described under Field Specifications above. Defaults to0.sampling_port=portβ sample packets on port, which should be the ingress or egress port. This option, which was added in Open vSwitch 2.6, allows the IPFIX implementation to export egress tunnel information.ingressegressβ specifies explicitly that the packet is being sampled on ingress to or egress from the switch. IPFIX reports sent by Open vSwitch before version 2.6 did not include a direction. From 2.6 until 2.7, IPFIX reports inferred a direction fromsampling_port: if it was the packet's output port, then the direction was reported asegress, otherwise asingress. Open vSwitch 2.7 introduced these options, which allow the inferred direction to be overridden. This is particularly useful when the ingress (or egress) port is not a tunnel.
Refer to ovs-vswitchd.conf.db(5) for more details on configuring sample collector sets. ποΈ
Conformance β This action is an OpenFlow extension added in Open vSwitch 2.4.
Support for subfields in obs_domain_id and obs_point_id was added in Open vSwitch 3.4.
π§ INSTRUCTIONS π§
Every version of OpenFlow includes actions. OpenFlow 1.1 introduced the higher-level, related concept of instructions. In OpenFlow 1.1 and later, actions within a flow are always encapsulated within an instruction. Each flow has at most one instruction of each kind, which are executed in the following fixed order defined in the OpenFlow specification:
- Meter
- Apply-Actions
- Clear-Actions
- Write-Actions
- Write-Metadata
- Stat-Trigger (not supported by Open vSwitch)
- Goto-Table
The most important instruction is Apply-Actions. This instruction encapsulates any number of actions, which the instruction executes. Open vSwitch does not explicitly represent Apply-Actions. Instead, any action by itself is implicitly part of an Apply-Actions instructions. Sneaky? A little. Convenient? Very. π
Open vSwitch syntax requires other instructions, if present, to be in the order listed above. Otherwise it will flag an error. So bestie, order matters β no cap. π₯
The meter action and instruction
Syntax:
meter:meter_id
Apply meter meter_id. If a meter band rate is exceeded, the packet may be dropped, or modified, depending on the meter band type. It's giving bouncer at the club π§ β behave or get handled.
Conformance β OpenFlow 1.3 introduced the meter instruction. OpenFlow 1.5 changes meter from an instruction to an action.
OpenFlow 1.5 allows implementations to restrict meter to be the first action in an action list and to exclude meter from action sets, for better compatibility with OpenFlow 1.3 and 1.4. Open vSwitch restricts the meter action both ways.
Open vSwitch 2.0 introduced OpenFlow protocol support for meters, but it did not include a datapath implementation. Open vSwitch 2.7 added meter support to the userspace datapath. Open vSwitch 2.10 added meter support to the kernel datapath. Open vSwitch 2.12 added support for meter as an action in OpenFlow 1.5. The glow-up is real. π
The clear_actions instruction
Syntax:
clear_actions
Clears the action set. See Action Sets, above, for more information. Poof. Gone. πͺ
Conformance β OpenFlow 1.1 introduced clear_actions. Open vSwitch 2.1 added support for clear_actions.
The write_actions instruction
Syntax:
write_actions(action...)
Adds each action to the action set. The action set is carried between flow tables and then executed at the end of the pipeline. Only certain actions may be written to the action set. See Action Sets, above, for more information. Think of it like a lil shopping bag ποΈ that travels through the pipeline with you.
Conformance β OpenFlow 1.1 introduced write_actions. Open vSwitch 2.1 added support for write_actions.
The write_metadata instruction
Syntax:
write_metadata:value[/mask]
Updates the flow's metadata field. 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. Both value and mask are 64-bit values that are decimal by default; use a 0x prefix to specify them in hexadecimal. π’
The metadata field can also be matched in the flow table and updated with actions such as set_field and move. So many ways to touch the same field, honestly iconic. β¨
Conformance β OpenFlow 1.1 introduced write_metadata. Open vSwitch 2.1 added support for write_metadata.
The goto_table instruction
Syntax:
goto_table:table
Jumps to table as the next table in the process pipeline. The table may be a number between 0 and 254 or a table name. π¦
π Careful, bestie: 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. No going backwards, we don't do that here.
Since goto_table must be the last instruction in a flow, it never leads to recursion. The resubmit extension action is more flexible. Fancy but with rules. π
Conformance β OpenFlow 1.1 introduced goto_table. Open vSwitch 2.1 added support for goto_table.
πΈ AUTHOR πΈ
The Open vSwitch Development Community β legends, all of them. π«Ά
π COPYRIGHT π
2016-2024, The Open vSwitch Development Community
And that's the whole page, bestie β you made it to the end! π This was ovs-actions(7), version 3.6, dated Feb 13, 2026. Go forth and write some absolutely immaculate flows. Periodt. ππ¦
π¦ where this page comes from
- fedora 43: openvswitch 3.6.2-1.fc43 Β· Apache-2.0 AND LGPL-2.0-or-later AND SISSL
- fedora 43: openvswitch 3.6.2-1.fc43 Β· Apache-2.0 AND LGPL-2.0-or-later AND SISSL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms