ovs-ofctl(8)
๐ NAME ๐
ovs-ofctl โ administer OpenFlow switches. This is the ovs-ofctl(8) page from the Open vSwitch Manual, and bestie, we are going to get through it together. ๐
๐ฆ SYNOPSIS ๐ฆ
ovs-ofctl [options] command [switch] [args...]
โจ DESCRIPTION โจ
Okay so ovs-ofctl is a command line tool for monitoring and administering OpenFlow switches. It can also show the current state of an OpenFlow switch, including features, configuration, and table entries. And the iconic part? It should work with any OpenFlow switch, not just Open vSwitch. ๐ซถ
๐ OpenFlow Switch Management Commands ๐
These commands let ovs-ofctl monitor and administer an OpenFlow switch. It is able to show the current state of a switch, including features, configuration, and table entries. โจ
Most of these commands take an argument that specifies the method for connecting to an OpenFlow switch. The following connection methods are supported:
ssl:host[:port],tcp:host[:port]โ The specified port on the given host, which can be expressed either as a DNS name (if built with unbound library) or an IP address in IPv4 or IPv6 address format. Wrap IPv6 addresses in square brackets, e.g.tcp:[::1]:6653. On Linux, use%deviceto designate a scope for IPv6 link-level addresses, e.g.tcp:[fe80::1234%eth0]:6653. Forssl, the--private-key,--certificate, and--ca-certoptions are mandatory. If port is not specified, it defaults to6653.unix:fileโ On POSIX, a Unix domain server socket named file.fileโ This is short forunix:file, as long as file does not contain a colon.bridgeโ This is short forunix:/run/openvswitch/bridge.mgmt, as long as bridge does not contain a colon.[type@]dpโ Attempts to look up the bridge associated with dp and open as above. If type is given, it specifies the datapath provider of dp, otherwise the default providersystemis assumed.
๐ show switch ๐
Prints to the console information on switch, including information on its flow tables and ports. Show me everything, king. ๐
๐ dump-tables switch ๐
Prints to the console statistics for each of the flow tables used by switch.
๐ dump-table-features switch ๐
Prints to the console features for each of the flow tables used by switch.
๐ dump-table-desc switch ๐
Prints to the console configuration for each of the flow tables used by switch for OpenFlow 1.4+.
๐ mod-table switch table setting ๐
This command configures flow table settings in switch for OpenFlow table table, which may be expressed as a number or (unless --no-names is specified) a name.
The available settings depend on the OpenFlow version in use. In OpenFlow 1.1 and 1.2 (which must be enabled with the -O option) only, mod-table configures behavior when no flow is found when a packet is looked up in a flow table. The following setting values are available:
dropโ Drop the packet.continueโ Continue to the next table in the pipeline. (This is how an OpenFlow1.0switch always handles packets that do not match any flow, in tables other than the last one.)controllerโ Send to controller. (This is how an OpenFlow1.0switch always handles packets that do not match any flow in the last table.)
In OpenFlow 1.3 and later (which must be enabled with the -O option) and Open vSwitch 2.11 and later only, mod-table can change the name of a table:
name:new-nameโ Changes the name of the table to new-name. Use an empty new-name to clear the name. (This will be ineffective if the name is set via thenamecolumn in theFlow_Tabletable in theOpen_vSwitchdatabase as described inovs-vswitchd.conf.db(5).)
In OpenFlow 1.4 and later (which must be enabled with the -O option) only, mod-table configures the behavior when a controller attempts to add a flow to a flow table that is full. The following setting values are available:
evictโ Delete some existing flow from the flow table, according to the algorithm described for theFlow_Tabletable inovs-vswitchd.conf.db(5).noevictโ Refuse to add the new flow. (Eviction might still be enabled through theoverflow_policycolumn in theFlow_Tabletable documented inovs-vswitchd.conf.db(5).)vacancy:low,highโ Enables sending vacancy events to controllers usingTABLE_STATUSmessages, based on percentage thresholds low and high.novacancyโ Disables vacancy events.
๐ dump-ports switch [netdev] ๐
Prints to the console statistics for network devices associated with switch. If netdev is specified, only the statistics associated with that device will be printed. netdev can be an OpenFlow assigned port number or device name, e.g. eth0.
๐ dump-ports-desc switch [port] ๐
Prints to the console detailed information about network devices associated with switch. To dump only a specific port, specify its number as port. Otherwise, if port is omitted, or if it is specified as ANY, then all ports are printed. This is a subset of the information provided by the show command.
If the connection to switch negotiates OpenFlow 1.0, 1.2, or 1.2, this command uses an OpenFlow extension only implemented in Open vSwitch (version 1.7 and later).
Only OpenFlow 1.5 and later support dumping a specific port. Earlier versions of OpenFlow always dump all ports.
๐ mod-port switch port action ๐
Modify characteristics of port port in switch. port may be an OpenFlow port number or name (unless --no-names is specified) or the keyword LOCAL (the preferred way to refer to the OpenFlow local port). The action may be any one of the following:
up,downโ Enable or disable the interface. This is equivalent toip link set uporip link set downon a Unix system.stp,no-stpโ Enable or disable 802.1D spanning tree protocol (STP) on the interface. OpenFlow implementations that don't support STP will refuse to enable it.receive,no-receive,receive-stp,no-receive-stpโ Enable or disable OpenFlow processing of packets received on this interface. When packet processing is disabled, packets will be dropped instead of being processed through the OpenFlow table. Thereceiveorno-receivesetting applies to all packets except 802.1D spanning tree packets, which are separately controlled byreceive-stporno-receive-stp.forward,no-forwardโ Allow or disallow forwarding of traffic to this interface. By default, forwarding is enabled.flood,no-floodโ Controls whether an OpenFlow flood action will send traffic out this interface. By default, flooding is enabled. Disabling flooding is primarily useful to prevent loops when a spanning tree protocol is not in use.packet-in,no-packet-inโ Controls whether packets received on this interface that do not match a flow table entry generate a โpacket inโ message to the OpenFlow controller. By default, โpacket inโ messages are enabled.
The show command displays (among other information) the configuration that mod-port changes.
๐ get-frags switch ๐
Prints switch's fragment handling mode. See set-frags, below, for a description of each fragment handling mode.
The show command also prints the fragment handling mode among its other output.
๐ set-frags switch frag_mode ๐
Configures switch's treatment of IPv4 and IPv6 fragments. The choices for frag_mode are:
normalโ Fragments pass through the flow table like non-fragmented packets. The TCP ports, UDP ports, and ICMP type and code fields are always set to0, even for fragments where that information would otherwise be available (fragments with offset0). This is the default fragment handling mode for an OpenFlow switch.dropโ Fragments are dropped without passing through the flow table.reassembleโ The switch reassembles fragments into full IP packets before passing them through the flow table. Open vSwitch does not implement this fragment handling mode.nx-matchโ Fragments pass through the flow table like non-fragmented packets. The TCP ports, UDP ports, and ICMP type and code fields are available for matching for fragments with offset0, and set to0in fragments with nonzero offset. This mode is a Nicira extension.
See the description of ip_frag, in ovs-fields(7), for a way to match on whether a packet is a fragment and on its fragment offset.
๐ dump-flows switch [flows] ๐
Prints to the console all flow entries in switch's tables that match flows. If flows is omitted, all flows in the switch are retrieved. See Flow Syntax, below, for the syntax of flows. The output format is described in Table Entry Output.
By default, ovs-ofctl prints flow entries in the same order that the switch sends them, which is unlikely to be intuitive or consistent. Use --sort and --rsort to control display order. The --names/--no-names and --stats/--no-stats options also affect output formatting. See the descriptions of these options, under OPTIONS below, for more information.
๐ dump-aggregate switch [flows] ๐
Prints to the console aggregate statistics for flows in switch's tables that match flows. If flows is omitted, the statistics are aggregated across all flows in the switch's flow tables. See Flow Syntax, below, for the syntax of flows. The output format is described in Table Entry Output.
queue-stats switch [port [queue]]โ okay so this prints to the console the stats for the specified queue on port inside switch. port can be an OpenFlow port number or name, the keywordLOCAL(the preferred way to refer to the OpenFlow local port), or the keywordALL. Either port or queue or both may be omitted, or equivalently you can use the keywordALL. If both are omitted, stats are printed for all queues on all ports. If only queue is omitted, then stats are printed for all queues on port; if only port is omitted, then stats are printed for queue on every port where it exists. slay.queue-get-config switch [port [queue]]โ prints to the console the configuration of queue on port in switch. If port is omitted orANY, it reports queues for all ports. If queue is omitted orANY, it reports all queues. For OpenFlow 1.3 and earlier, the output always includes all queues, ignoring queue if specified. ngl, this command has limited usefulness, because ports often have no configured queues and because the OpenFlow protocol provides only very limited information about the configuration of a queue.dump-ipfix-bridge switchโ prints to the console the statistics of bridge IPFIX for switch. If bridge IPFIX is configured on the switch, IPFIX statistics can be retrieved. Otherwise, an error message will be printed. This command uses an Open vSwitch extension that is only in Open vSwitch 2.6 and later. iykyk.dump-ipfix-flow switchโ prints to the console the statistics of flow-based IPFIX for switch. If flow-based IPFIX is configured on the switch, statistics of all the collector set ids on the switch will be printed. Otherwise, it prints an error message. Refer toovs-vswitchd.conf.db(5)for more details on configuring flow based IPFIX and collector set ids. This command uses an Open vSwitch extension that is only in Open vSwitch 2.6 and later. obsessed with a good collector set id.ct-flush-zone switch zoneโ flushes the connection tracking entries in zone on switch. This command uses an Open vSwitch extension that is only in Open vSwitch 2.6 and later.ct-flush switch [zone=N] [mark=X[/M]] [labels=Y[/N]] [ct-orig-tuple [ct-reply-tuple]]โ flushes the connection entries on switch based on zone, mark, labels and connection tracking tuplesct-[orig|reply]-tuple.
If ct-[orig|reply]-tuple is not provided, this flushes all the connection entries. If zone is specified, it only flushes the connections in zone. If mark or labels is provided, it will flush only entries that are matching the specific mark/labels. If ct-[orig|reply]-tuple is provided, it flushes the connection entry specified by ct-[orig|reply]-tuple in zone. The zone defaults to 0 if it is not provided. The mark and labels default to "0/0" if they are not provided. The userspace connection tracker requires flushing with the original pre-NATed tuple, and a warning log will be otherwise generated. The tuple can be partial and will remove all connections that are matching on the specified fields. In order to specify only ct-reply-tuple, provide an empty string as ct-orig-tuple.
Note: Currently there is limitation for matching on ICMP. In order to partially match on ICMP parameters, the ct-[orig|reply]-tuple has to include either source or destination IP.
An example of an IPv4 ICMP ct-[orig|reply]-tuple:
"ct_nw_src=10.1.1.1,ct_nw_dst=10.1.1.2,ct_nw_proto=1,icmp_type=8,icmp_code=0,icmp_id=10"
An example of an IPv6 TCP ct-[orig|reply]-tuple:
"ct_ipv6_src=fc00::1,ct_ipv6_dst=fc00::2,ct_nw_proto=6,ct_tp_src=1,ct_tp_dst=2"
This command uses an Open vSwitch extension that is only in Open vSwitch 3.1 and later. Support for matching on mark and labels is only in Open vSwitch 3.3 and later. the way this one has lore is unreal ๐
๐ฅ OpenFlow Switch Flow Table Commands ๐ฅ
These commands manage the flow table in an OpenFlow switch. In each case, flow specifies a flow entry in the format described in Flow Syntax, below; file is a text file that contains zero or more flows in the same syntax, one per line; and the optional --bundle option operates the command as a single atomic transaction, see option --bundle, below. bestie, atomic transaction is giving main character energy.
[--bundle] add-flow switch flow[--bundle] add-flow switch - < file[--bundle] add-flows switch fileโ add each flow entry to switch's tables. Each flow specification (e.g., each line in file) may start withadd,modify,delete,modify_strict, ordelete_strictkeyword to specify whether a flow is to be added, modified, or deleted, and whether the modify or delete is strict or not. For backwards compatibility, a flow specification without one of these keywords is treated as a flow add. All flow mods are executed in the order specified.[--bundle] [--strict] mod-flows switch flow[--bundle] [--strict] mod-flows switch - < fileโ modify the actions in entries from switch's tables that match the specified flows. With--strict, wildcards are not treated as active for matching purposes.[--bundle] del-flows switch[--bundle] [--strict] del-flows switch [flow][--bundle] [--strict] del-flows switch - < fileโ deletes entries from switch's flow table. With only a switch argument, deletes all flows. Otherwise, deletes flow entries that match the specified flows. With--strict, wildcards are not treated as active for matching purposes.[--bundle] [--readd] replace-flows switch fileโ reads flow entries from file (or stdin if file is-) and queries the flow table from switch. Then it fixes up any differences, adding flows from file that are missing on switch, deleting flows from switch that are not in file, and updating flows in switch whose actions, cookie, or timeouts differ in file.
With --readd, ovs-ofctl adds all the flows from file, even those that exist with the same actions, cookie, and timeout in switch. In OpenFlow 1.0 and 1.1, re-adding a flow always resets the flow's packet and byte counters to 0, and in OpenFlow 1.2 and later, it does so only if the reset_counts flag is set. no cap, counters are precious.
diff-flows source1 source2โ reads flow entries from source1 and source2 and prints the differences. A flow that is in source1 but not in source2 is printed preceded by a-, and a flow that is in source2 but not in source1 is printed preceded by a+. If a flow exists in both source1 and source2 with different actions, cookie, or timeouts, then both versions are printed preceded by-and+, respectively.
source1 and source2 may each name a file or a switch. If a name begins with / or ., then it is considered to be a file name. A name that contains : is considered to be a switch. Otherwise, it is a file if a file by that name exists, a switch if not.
For this command, an exit status of 0 means that no differences were found, 1 means that an error occurred, and 2 means that some differences were found. exit codes ate, fr fr.
packet-out switch packet-outโ connects to switch and instructs it to execute the packet-out OpenFlow message, specified as defined in Packet-Out Syntax section.
๐ซถ Group Table Commands ๐ซถ
These commands manage the group table in an OpenFlow switch. In each case, group specifies a group entry in the format described in Group Syntax, below; file is a text file that contains zero or more groups in the same syntax, one per line; and the optional --bundle option operates the command as a single atomic transaction, see option --bundle, below.
The group commands work only with switches that support OpenFlow 1.1 or later or the Open vSwitch group extensions to OpenFlow 1.0 (added in Open vSwitch 2.9.90). For OpenFlow 1.1 or later, it is necessary to explicitly enable these protocol versions in ovs-ofctl (using -O). For more information, see Q: What versions of OpenFlow does Open vSwitch support? in the Open vSwitch FAQ. lowkey a whole vibe check for protocol versions.
[--bundle] add-group switch group[--bundle] add-group switch - < file[--bundle] add-groups switch fileโ add each group entry to switch's tables. Each group specification (e.g., each line in file) may start withadd,modify,add_or_mod,delete,insert_bucket, orremove_bucketkeyword to specify whether a flow is to be added, modified, or deleted, or whether a group bucket is to be added or removed. For backwards compatibility, a group specification without one of these keywords is treated as a group add. All group mods are executed in the order specified.[--bundle] [--may-create] mod-group switch group[--bundle] [--may-create] mod-group switch - < fileโ modify the action buckets in entries from switch's tables for each group entry. If a specified group does not already exist, then without--may-create, this command has no effect; with--may-create, it creates a new group. The--may-createoption uses an Open vSwitch extension to OpenFlow only implemented in Open vSwitch 2.6 and later.[--bundle] del-groups switch[--bundle] del-groups switch [group][--bundle] del-groups switch - < fileโ deletes entries from switch's group table. With only a switch argument, deletes all groups. Otherwise, deletes the group for each group entry.[--bundle] insert-buckets switch group[--bundle] insert-buckets switch - < fileโ add buckets to an existing group present in the switch's group table. If nocommand_bucket_idis present in the group specification, then all buckets of the group are removed. not me reading that twice, but okay periodt.[--bundle] remove-buckets switch group[--bundle] remove-buckets switch - < fileโ remove buckets to an existing group present in the switch's group table. If nocommand_bucket_idis present in the group specification, then all buckets of the group are removed.dump-groups switch [group]โ prints group entries in switch's tables to console. To dump only a specific group, specify its number as group. Otherwise, if group is omitted, or if it is specified asALL, then all groups are printed. Only OpenFlow 1.5 and later support dumping a specific group. Earlier versions of OpenFlow always dump all groups.dump-group-features switchโ prints to the console the group features of the switch. iconic little info dump.dump-group-stats switch [group]โ drops the console stats for the group you named in switch's tables. Skip the group arg and it just prints stats for, like, every group it's got. ๐
๐ OpenFlow 1.3+ Switch Meter Table Commands ๐
okay so these commands are all about managing the meter table inside an OpenFlow switch. In every single one of these, meter means a meter entry written in the format described down in Meter Syntax, below โ go look, it's there, bestie. ๐ธ
Real talk though: meters are an OpenFlow 1.3 thing, so these commands only work with switches that actually support OpenFlow 1.3 or later. Like, you have to explicitly enable those protocol versions โ both in ovs-ofctl (that's the -O option, mwah) and in the switch itself (that's the protocols column in the Bridge table). For the whole story, peep "Q: What versions of OpenFlow does Open vSwitch support?'' in the Open vSwitch FAQ. iykyk ๐
add-meter switch meterโ adds a meter entry to switch's tables. The meter syntax is, again, described in section Meter Syntax, below. go off ๐mod-meter switch meterโ modifies a meter that already exists. glow-up, not a rebirth โจdel-meters switch [meter]โ deletes entries from switch's meter table. Wanna delete just one specific meter? Pass its number as meter. Otherwise, if meter is omitted โ or if you literally write it asallโ then every single meter gets deleted. all of them. periodt ๐dump-meters switch [meter]โ prints entries from switch's meter table. Specific meter only? Give its number as meter. Otherwise, if meter is omitted, or if it's specified asall, then all meters get printed. ๐ซถmeter-stats switch [meter]โ prints meter statistics. meter can pin down a single meter with the syntaxmeter=id, or grab all of them with the syntaxmeter=all. ๐meter-features switchโ prints meter features. that's it, that's the whole vibe ๐
๐ฆ OpenFlow Switch Bundle Command ๐ฆ
So you wanna make transactional updates to both the flow table and the group table at the same time? That's literally what the bundle command is for, bestie. ๐ฅ
file is a text file containing zero or more flow mods, group mods, or packet-outs, written in Flow Syntax, Group Syntax, or Packet-Out Syntax respectively. Each line has to be preceded by the flow, group, or packet-out keyword, correspondingly. Okay and here's the cute part:
- the
flowkeyword may optionally be followed by one ofadd,modify,modify_strict,delete, ordelete_strictโ and if you just give a bareflow, thenaddis what's assumed. - same energy for the
groupkeyword: it may optionally be followed by one ofadd,modify,add_or_mod,delete,insert_bucket, orremove_bucketโ and yep,addis assumed if you give a baregroup. bundle switch fileโ executes all the flow and group mods in file as one single atomic transaction against switch's tables. Every bundled mod runs in the order you specified them. no queue-jumping, no cutting in line ๐
๐ง OpenFlow Switch Tunnel TLV Table Commands ๐ง
Open vSwitch keeps a mapping table between tunnel option TLVs (defined by <class, type, length>) and NXM fields tun_metadatan, where n ranges from 0 to 63 โ and you can operate on those bad boys for the purposes of matches, actions, etc. This TLV table works for Geneve option TLVs, or honestly any other protocol whose options are in the same TLV format as Geneve options. ๐
The thing is: this mapping has to be explicitly specified by you, the user, through the following commands. No vibes-based auto-mapping here, sorry.
A TLV mapping gets specified with this syntax:
{class=class,type=type,len=length}->tun_metadatan
Once an option mapping exists for a given tun_metadatan, matching on that defined field becomes possible. Like, for example:
ovs-ofctl add-tlv-map br0 "{class=0xffff,type=0,len=4}->tun_metadata0"
ovs-ofctl add-flow br0 tun_metadata0=1234,actions=controller
โ ๏ธ Do not change a mapping while it's actively being used by a flow. The result of doing that is undefined. like genuinely do not, bestie ๐ญ
These commands are Nicira extensions to OpenFlow and they require Open vSwitch 2.5 or later. ๐
add-tlv-map switch option[,option]...โ adds each option to switch's tables. Duplicate fields? rejected. we don't do repeats here ๐del-tlv-map switch [option[,option]]...โ deletes each option from switch's table โ or, if you don't specify any option, it deletes the whole option TLV mapping. Fields that aren't mapped are ignored, no drama. โจdump-tlv-map switchโ shows you the currently mapped fields in the switch's option table, plus the switch capabilities while it's at it. two-for-one ๐
๐ OpenFlow Switch Monitoring Commands ๐
snoop switchโ connects to switch and prints, to the console, every single OpenFlow message it receives. ๐
But here's the twist, and it's kind of the main character detail: unlike other ovs-ofctl commands, if switch is the name of a bridge, then snoop connects to a Unix domain socket named /run/openvswitch/switch.snoop. ovs-vswitchd listens on a socket like that for each bridge, and it sends to it all the OpenFlow messages sent to or received from its configured OpenFlow controller. So basically, this command lets you spy on the OpenFlow protocol activity between a switch and its controller. iconic ๐ฅ
When a switch has more than one controller configured, only the traffic to and from a single controller gets output. If none of the controllers is configured as a primary or a secondary (that's using a Nicira extension to OpenFlow 1.0 or 1.1, or a standard request in OpenFlow 1.2 or later), then a controller is chosen arbitrarily among them. The full priority list, since you asked:
- if there's a primary controller, it's the chosen one;
- otherwise, if there are any controllers that are not primaries or secondaries, one of those gets chosen arbitrarily;
- otherwise, a secondary controller gets chosen arbitrarily.
This choice is made once, at connection time, and it does not change as controllers reconfigure their roles. set it and forget it โจ
Also: if a switch has no controller configured, or if the configured controller is disconnected, then no traffic is sent โ so monitoring won't show you any traffic. it's giving silent treatment ๐ญ
monitor switch [miss-len] [invalid_ttl] [watch:[spec...]]โ connects to switch and prints every OpenFlow message received to the console. Usually, switch should be the name of a bridge in theovs-vswitchddatabase. Fair warning: this is available only in OpenFlow 1.0, as a Nicira extension. ๐ผ
If miss-len is provided, ovs-ofctl sends an OpenFlow ``"set configuration"'' message at connection setup time that requests miss-len bytes of each packet that misses the flow table. Here's the catch โ Open vSwitch does not send these (or other asynchronous messages) to an ovs-ofctl monitor client connection unless you specify a nonzero value on this argument. (So if miss-len isn't specified, very little traffic will ordinarily be printed. like, barely anything. tumbleweeds ๐)
If invalid_ttl is passed, ovs-ofctl sends an OpenFlow "set configuration"'' message at connection setup time that requests `INVALID_TTL_TO_CONTROLLER`, so that `ovs-ofctl monitor` can receive "packet-in"'' messages when TTL reaches zero on dec_ttl action. Only OpenFlow 1.1 and 1.2 support invalid_ttl; Open vSwitch also implements it for OpenFlow 1.0 as an extension. fancy ๐
watch:[spec...] causes ovs-ofctl to send a ``"monitor request"'' Nicira extension message to the switch at connection setup time. That message makes the switch send you info about flow table changes as they happen. The following comma-separated spec syntax is available, bestie:
!initialโ do not report the switch's initial flow table contents.!addโ do not report newly added flows.!deleteโ do not report deleted flows.!modifyโ do not report modifications to existing flows.!ownโ abbreviate changes made to the flow table byovs-ofctl's own connection to the switch. (These could only occur using theofctl/sendcommand described below under RUNTIME MANAGEMENT COMMANDS.)!actionsโ do not report actions as part of flow updates.table=tableโ limits the monitoring to the table with the given table, which may be expressed as a number between 0 and 254 or (unless--no-namesis specified) a name. By default, all tables are monitored. slay ๐ฆout_port=portโ if set, only flows that output to port are monitored. The port may be an OpenFlow port number or a keyword (e.g.LOCAL).out_group=groupโ if set, only flows that output to group number group are monitored. Heads up: this field requires OpenFlow 1.4 (-OOpenFlow14) or later. ๐ฅfield=valueโ monitors only flows that have field specified as the given value. Any syntax that's valid for matching ondump-flowsmay be used. ๐
This command may be useful for debugging switch or controller implementations. And with watch:, it's particularly useful for observing how a controller updates flow tables. lowkey a whole vibe for debugging ๐
๐ OpenFlow Switch and Controller Commands ๐
The following commands, just like the ones in the previous section, may be applied to OpenFlow switches using any of the connection methods described in that section. Unlike those commands though? These can also be applied to OpenFlow controllers. equal opportunity โจ
probe targetโ sends a single OpenFlow echo-request message to target and waits for the response. With the-tor--timeoutoption, this command can test whether an OpenFlow switch or controller is up and running. vibe check, literally ๐ซถping target [n]โ sends a series of 10 echo request packets to target and times each reply. Each echo request packet consists of an OpenFlow header plus n bytes (default:64) of randomly generated payload. This measures the latency of individual requests. โฑ๏ธbenchmark target n countโ sends count echo request packets, each consisting of an OpenFlow header plus n bytes of payload, and waits for each response. Then it reports the total time required. This is a measure of the maximum bandwidth to target for round-trips of n-byte messages. bandwidth queen ๐
๐ธ Other Commands ๐ธ
ofp-parse fileโ reads file (or stdin if file is-) as a series of OpenFlow messages in the binary format used on an OpenFlow connection, and prints them to the console. Super useful for printing OpenFlow messages you captured from a TCP stream. ๐ofp-parse-pcap file [port...]โ reads file, which has to be in the PCAP format used by network capture tools liketcpdumporwireshark. It extracts all the TCP streams for OpenFlow connections and prints the OpenFlow messages in those connections in human-readable format on stdout. detective mode activated ๐๐
OpenFlow connections are distinguished by TCP port number. Non-OpenFlow packets are just, like, ignored bestie. By default, data on TCP ports 6633 and 6653 are considered to be OpenFlow. Specify one or more port arguments to override the default. ๐
This command cannot usefully print SSL/TLS encrypted traffic. And it does not understand IPv6. Not even a little. ๐ญ
๐ฆ Flow Syntax ๐ฆ
Some ovs-ofctl commands accept an argument that describes a flow or flows. Such flow descriptions comprise a series of field=value assignments, separated by commas or white space. (Embedding spaces into a flow description normally requires quoting to prevent the shell from breaking the description into multiple arguments โ the shell is not a girl's girl about this, she will split on you. ๐)
Flow descriptions should be in normal form. This means that a flow may only specify a value for an L3 field if it also specifies a particular L2 protocol, and that a flow may only specify an L4 field if it also specifies particular L2 and L3 protocol types. For example, if the L2 protocol type dl_type is wildcarded, then L3 fields nw_src, nw_dst, and nw_proto must also be wildcarded. Similarly, if dl_type or nw_proto (the L3 protocol type) is wildcarded, so must be the L4 fields tcp_dst and tcp_src. ovs-ofctl will warn about flows not in normal form. Consider this your vibe check. โจ
ovs-fields(7) describes the supported fields and how to match them. In addition to match fields, commands that operate on flows accept a few additional key-value pairs:
table=tableโ for flow dump commands, limits the flows dumped to those in table, which may be expressed as a number between0and255or (unless--no-namesis specified) a name. If not specified (or if255is specified as table), then flows in all tables are dumped.
For flow table modification commands, behavior varies based on the OpenFlow version used to connect to the switch, so buckle up:
- OpenFlow 1.0 โ OpenFlow 1.0 does not support table for modifying flows.
ovs-ofctlwill exit with an error if table (other thantable=255) is specified for a switch that only supports OpenFlow 1.0.
In OpenFlow 1.0, the switch chooses the table into which to insert a new flow. The Open vSwitch software switch always chooses table 0. Other Open vSwitch datapaths and other OpenFlow implementations may choose different tables. Rude, but true. ๐คทโโ๏ธ
The OpenFlow 1.0 behavior in Open vSwitch for modifying or removing flows depends on whether --strict is used. Without --strict, the command applies to matching flows in all tables. With --strict, the command will operate on any single matching flow in any table; it will do nothing if there are matches in more than one table. (The distinction between these behaviors only matters if non-OpenFlow 1.0 commands were also used, because OpenFlow 1.0 alone cannot add flows with the same matching criteria to multiple tables.)
- OpenFlow 1.0 with table_id extension โ Open vSwitch implements an OpenFlow extension that allows the controller to specify the table on which to operate.
ovs-ofctlautomatically enables the extension when table is specified and OpenFlow 1.0 is used.ovs-ofctlautomatically detects whether the switch supports the extension. As of this writing, this extension is only known to be implemented by Open vSwitch. main character extension honestly ๐
With this extension, ovs-ofctl operates on the requested table when table is specified, and acts as described for OpenFlow 1.0 above when no table is specified (or for table=255).
- OpenFlow 1.1 โ OpenFlow 1.1 requires flow table modification commands to specify a table. When table is not specified (or
table=255is specified),ovs-ofctldefaults totable 0. - OpenFlow 1.2 and later โ OpenFlow 1.2 and later allow flow deletion commands, but not other flow table modification commands, to operate on all flow tables, with the behavior described above for OpenFlow 1.0.
duration=...,n_packet=...,n_bytes=...โovs-ofctlignores assignments to these "fields" to allow output from thedump-flowscommand to be used as input for other commands that parse flows. Iconic recycling behaviour actually ๐
The add-flow, add-flows, and mod-flows commands require an additional field, which must be the final field specified:
actions=[action][,action...]โ Specifies a comma-separated list of actions to take on a packet when the flow entry matches. If no action is specified, then packets matching the flow are dropped. Seeovs-actions(7)for details on the syntax and semantics of actions.
An opaque identifier called a cookie can be used as a handle to identify a set of flows:
cookie=valueโ a cookie can be associated with a flow using theadd-flow,add-flows, andmod-flowscommands. value can be any 64-bit number and need not be unique among flows. If this field is omitted, a default cookie value of0is used.cookie=value/maskโ when using NXM, the cookie can be used as a handle for querying, modifying, and deleting flows. value and mask may be supplied for thedel-flows,mod-flows,dump-flows, anddump-aggregatecommands to limit matching cookies. A 1-bit in mask indicates that the corresponding bit in cookie must match exactly, and a 0-bit wildcards that bit. A mask of-1may be used to exactly match a cookie.
The mod-flows command can update the cookies of flows that match a cookie by specifying the cookie field twice (once with a mask for matching and once without to indicate the new value):
ovs-ofctl mod-flows br0 cookie=1,actions=normal
Change all flows' cookies to 1 and change their actions to normal. Slay, batch edit ๐
ovs-ofctl mod-flows br0 cookie=1/-1,cookie=2,actions=normal
Update cookies with a value of 1 to 2 and change their actions to normal.
The ability to match on cookies was added in Open vSwitch 1.5.0.
The following additional field sets the priority for flows added by the add-flow and add-flows commands. For mod-flows and del-flows when --strict is specified, priority must match along with the rest of the flow specification. For mod-flows without --strict, priority is only significant if the command creates a new flow, that is, non-strict mod-flows does not match on priority and will not change the priority of existing flows. Other commands do not allow priority to be specified.
priority=valueโ the priority at which a wildcarded entry will match in comparison to others. value is a number between0and65535, inclusive. A higher value will match before a lower one. An exact-match entry will always have priority over an entry containing wildcards, so it has an implicit priority value of65535. When adding a flow, if the field is not specified, the flow's priority will default to32768.
OpenFlow leaves behavior undefined when two or more flows with the same priority can match a single packet. Some users expect "sensible" behavior, such as more specific flows taking precedence over less specific flows, but OpenFlow does not specify this and Open vSwitch does not implement it. Users should therefore take care to use priorities to ensure the behavior that they expect. So like... actually use the priorities, bestie. Don't make it weird. ๐ญ
The add-flow, add-flows, and mod-flows commands support the following additional options. These options affect only new flows. Thus, for add-flow and add-flows, these options are always significant, but for mod-flows they are significant only if the command creates a new flow, that is, their values do not update or affect existing flows.
idle_timeout=secondsโ causes the flow to expire after the given number of seconds of inactivity. A value of0(the default) prevents a flow from expiring due to inactivity.hard_timeout=secondsโ causes the flow to expire after the given number of seconds, regardless of activity. A value of0(the default) gives the flow no hard expiration deadline.importance=valueโ sets the importance of a flow. The flow entry eviction mechanism can use importance as a factor in deciding which flow to evict. A value of0(the default) makes the flow non-evictable on the basis of importance. Specify a value between0and65535.
Only OpenFlow 1.4 and later support importance. ๐ซถ
send_flow_remโ marks the flow with a flag that causes the switch to generate a "flow removed" message and send it to interested controllers when the flow later expires or is removed.check_overlapโ forces the switch to check that the flow match does not overlap that of any different flow with the same priority in the same table. (This check is expensive so it is best to avoid it. ngl, highkey expensive. ๐)reset_countsโ when this flag is specified on a flow being added to a switch, and the switch already has a flow with an identical match, an OpenFlow 1.2 (or later) switch resets the flow's packet and byte counters to0. Without the flag, the packet and byte counters are preserved.
OpenFlow 1.0 and 1.1 switches always reset counters in this situation, as if reset_counts were always specified.
Open vSwitch 1.10 added support for reset_counts.
no_packet_counts,no_byte_countsโ adding these flags to a flow advises an OpenFlow 1.3 (or later) switch that the controller does not need packet or byte counters, respectively, for the flow. Some switch implementations might achieve higher performance or reduce resource consumption when these flags are used. These flags provide no benefit to the Open vSwitch software switch implementation.
OpenFlow 1.2 and earlier do not support these flags.
Open vSwitch 1.10 added support for no_packet_counts and no_byte_counts.
The dump-flows, dump-aggregate, del-flow and del-flows commands support these additional optional fields:
out_port=portโ if set, a matching flow must include an output action to port, which must be an OpenFlow port number or name (e.g.local).out_group=group โ if you set this, then a matching flow has to include a group action naming group, and group has to be an actual OpenFlow group number ๐. This field is supported in Open vSwitch 2.5 and later, and it requires OpenFlow 1.1 or later. iykyk.
๐ธ Table Entry Output ๐ธ
The dump-tables and dump-aggregate commands spill the tea on the entries in a datapath's tables. Every line of output is a flow entry, exactly like the ones described in Flow Syntax above, plus a few extra fields:
duration=secs โ the time, in seconds, that the entry has been sitting in the table. secs gives you as much precision as the switch provides, possibly down to nanosecond resolution โจ.n_packetsโ the number of packets that have matched the entry.n_bytesโ the total number of bytes from the packets that have matched the entry ๐.
The following extra fields show up only if the switch is Open vSwitch 1.6 or later and the NXM flow format is used to dump the flow (peep the description of the --flow-format option below). Heads up bestie: the values of these extra fields are approximations only, and in particular idle_age will sometimes become nonzero even for busy flows ๐ญ.
hard_age=secs โ the integer number of seconds since the flow was added or modified.hard_ageis displayed only if it differs from the integer part ofduration. (It's separate fromdurationbecausemod-flowsrestarts thehard_timeouttimer without zeroingduration.) ๐idle_age=secs โ the integer number of seconds that have passed without any packets passing through the flow.
๐ฆ Packet-Out Syntax ๐ฆ
The ovs-ofctl bundle command accepts packet-outs to be specified in the bundle file. Each packet-out is a series of field=value assignments, separated by commas or white space. (Embedding spaces into a packet-out description normally requires quoting to prevent the shell from breaking the description into multiple arguments.) Unless noted otherwise, only the last instance of each field is honoured. This same syntax is also supported by the ovs-ofctl packet-out command ๐ซถ.
in_port=port โ the port number to be considered thein_portwhen processing actions. This can be any valid OpenFlow port number, or any ofLOCAL,CONTROLLER, orNONE. This field is required ๐.pipeline_field=value โ optionally, you can specify a list of pipeline fields for a packet-out message. The supported pipeline fields include tunnel fields and register fields as defined inovs-fields(7).packet=hex-string โ the actual packet to send, expressed as a string of hexadecimal bytes. This field is required.actions=[action][,action...]โ the syntax of actions is identical to theactions=field described in Flow Syntax above. Specifyingactions=is optional, but omitting actions is interpreted as a drop, so the packet will not be sent anywhere from the switch ๐.actionsmust be specified at the end of each line, like for flow mods.
๐ Group Syntax ๐
Some ovs-ofctl commands accept an argument that describes a group or groups. Such group descriptions are a series of field=value assignments, separated by commas or white space. (Embedding spaces into a group description normally requires quoting to prevent the shell from breaking the description into multiple arguments.) Unless noted otherwise only the last instance of each field is honoured โจ.
group_id=id โ the integer group id of the group. When this field is specified indel-groupsordump-groups, the keywordallmay be used to designate all groups. This field is required.type=type โ the type of the group. Theadd-group,add-groupsandmod-groupscommands require this field. It is prohibited for other commands. The following keywords designate the allowed types:allโ execute all buckets in the group.selectโ execute one bucket in the group, balancing across the buckets according to their weights. To select a bucket, for each live bucket, Open vSwitch hashes flow data with the bucket ID and multiplies by the bucket weight to obtain a ``score,'' and then selects the bucket with the highest score. Useselection_methodto control the flow data used for selection ๐ฏ.indirectโ executes the one bucket in the group.ff,fast_failoverโ executes the first live bucket in the group which is associated with a live port or group.
command_bucket_id=id โ the bucket to operate on. Theinsert-bucketsandremove-bucketscommands require this field. It is prohibited for other commands. id may be an integer or one of the following keywords:allโ operate on all buckets in the group. Only valid when used with theremove-bucketscommand, in which case the effect is to remove all buckets from the group.firstโ operate on the first bucket present in the group. In the case of theinsert-bucketscommand the effect is to insert new bucets just before the first bucket already present in the group; or to replace the buckets of the group if there are no buckets already present in the group. In the case of theremove-bucketscommand the effect is to remove the first bucket of the group; or do nothing if there are no buckets present in the group.lastโ operate on the last bucket present in the group. In the case of theinsert-bucketscommand the effect is to insert new bucets just after the last bucket already present in the group; or to replace the buckets of the group if there are no buckets already present in the group. In the case of theremove-bucketscommand the effect is to remove the last bucket of the group; or do nothing if there are no buckets present in the group.
If id is an integer then it should correspond to the bucket_id of a bucket present in the group. In case of the insert-buckets command the effect is to insert buckets just before the bucket in the group whose bucket_id is id. In case of the iremove-buckets command the effect is to remove the in the group whose bucket_id is id. It is an error if there is no bucket persent group in whose bucket_id is id. ๐ญ ik it's a mouthful but that's literally what it says.
selection_method=method โ the selection method used to select a bucket for aselectgroup. This is a string of 1 to 15 bytes in length known to lower layers. This field is optional foradd-group,add-groupsandmod-groupcommands on groups of typeselect. Prohibited otherwise. If no selection method is specified, Open vSwitch up to release 2.9 applies thehashmethod with default fields. From 2.10 onwards Open vSwitch defaults to thedp_hashmethod with symmetric L3/L4 hash algorithm, as long as the weighted group buckets can be mapped todp_hashvalues with sufficient accuracy. In 2.10 this was restricted to a maximum of 64 buckets, and in 2.17 the limit was raised to 256 buckets. In those rare cases Open vSwitch 2.10 and later fall back to thehashmethod with the default set of hash fields ๐.dp_hashโ use a datapath computed hash value. The hash algorithm varies across different datapath implementations.dp_hashuses the upper 32 bits of theselection_method_paramas the datapath hash algorithm selector. The supported values are0(corresponding to hash computation over the IP 5-tuple) and1(corresponding to a symmetric hash computation over the IP 5-tuple). Selecting specific fields with thefieldsoption is not supported withdp_hash). The lower 32 bits are used as the hash basis.
Using dp_hash has the advantage that it does not require the generated datapath flows to exact match any additional packet header fields. For real though โ for example, even if multiple TCP connections thus hashed to different select group buckets have different source port numbers, generally all of them would be handled with a small set of already established datapath flows, resulting in less latency for TCP SYN packets. The downside is that the shared datapath flows must match each packet twice, as the datapath hash value calculation happens only when needed, and a second match is required to match some bits of its value. This double-matching incurs a small additional latency cost for each packet, but this latency is orders of magnitude less than the latency of creating new datapath flows for new TCP connections ๐ฅ.
hashโ use a hash computed over the fields specified with thefieldsoption, see below. If no hash fields are specified,hashdefaults to a symmetric hash over the combination of MAC addresses, VLAN tags, Ether type, IP addresses and L4 port numbers.hashuses theselection_method_paramas the hash basis.
Note that the hashed fields become exact matched by the datapath flows ๐. For example, if the TCP source port is hashed, the created datapath flows will match the specific TCP source port value present in the packet received. Since each TCP connection generally has a different source port value, a separate datapath flow will be need to be inserted for each TCP connection thus hashed to a select group bucket.
This option uses a Netronome OpenFlow extension which is only supported when using Open vSwitch 2.4 and later with OpenFlow 1.5 and later.
selection_method_param=param โ 64-bit integer parameter to the selection method selected by theselection_methodfield. The parameter's use is defined by the lower-layer that implements theselection_method. It is optional if theselection_methodfield is specified as a non-empty string. Prohibited otherwise. The default value is zero ๐ซ.
Okay so this option uses a Netronome OpenFlow extension thatโs only supported when youโre using Open vSwitch 2.4 and later with OpenFlow 1.5 and later. No cap.
fields=fieldandfields(field[=mask]...)โ These are the field parameters for whatever selection method theselection_methodfield picked. The syntax is described in Flow Syntax, with the extra restrictions that if a value is provided itโs treated as a wildcard mask, and wildcard masks following a slash are prohibited. The pre-requisites of fields must be provided by any flows that output to the group. The use of the fields is defined by the lower-layer that implements theselection_method. Theyโre optional if theselection_methodfield is specified ashash, and prohibited otherwise. The default is no fields.
Heads up again, bestie: this option will use a Netronome OpenFlow extension which is only supported when using Open vSwitch 2.4 and later with OpenFlow 1.5 and later. ๐
bucket=bucket_parametersโ Theadd-group,add-groupsandmod-groupcommands require at least one bucket field. Bucket fields must appear after all other fields. Multiple bucket fields are how you specify multiple buckets. The order in which buckets are specified corresponds to their order in the group. If the type of the group isindirectthen only one group may be specified.bucket_parametersconsists of a list offield=valueassignments, separated by commas or white space, followed by a comma-separated list of actions. The fields forbucket_parametersare:bucket_id=idโ The 32-bit integer group id of the bucket. Values greater than0xffffff00are reserved. This field was added in Open vSwitch 2.4 to conform with the OpenFlow 1.5 specification. It is not supported when earlier versions of OpenFlow are used. Open vSwitch will automatically allocate bucket ids when they are not specified.actions=[action][,action...]โ The syntax of actions is identical to theactions=field described in Flow Syntax above. Specifyingactions=is optional; any unknown bucket parameter will be interpreted as an action.weight=valueโ The relative weight of the bucket as an integer. This may be used by the switch during bucket select for groups whose type isselect.watch_port=portโ Port used to determine liveness of group. This or thewatch_groupfield is required for groups whose type isfforfast_failover. This or thewatch_groupfield can also be used for groups whose type isselect.watch_group=group_idโ Group identifier of group used to determine liveness of group. This or thewatch_portfield is required for groups whose type isfforfast_failover. This or thewatch_portfield can also be used for groups whose type isselect.
๐ Meter Syntax ๐
The meter table commands accept an argument that describes a meter. Such meter descriptions comprise a series of field=value assignments, separated by commas or white space. (Embedding spaces into a group description normally requires quoting to prevent the shell from breaking the description into multiple arguments.) Unless noted otherwise, only the last instance of each field is honoured. Periodt.
meter=idโ The identifier for the meter. An integer is used to specify a user-defined meter. In addition, the keywordsall,controller, andslowpathare also supported as virtual meters. Thecontrollerandslowpathvirtual meters apply to packets sent to the controller and to the OVS userspace, respectively.
When this field is specified in del-meter, dump-meter, or meter-stats, the keyword all may be used to designate all meters. This field is required, except for meter-stats, which dumps all stats when this field is not specified.
kbps,pktpsโ The unit for therateandburst_sizeband parameters.kbpsspecifies kilobits per second, andpktpsspecifies packets per second. A unit is required for theadd-meterandmod-metercommands.burstโ If set, enables burst support for meter bands through theburst_sizeparameter.statsโ If set, enables the collection of meter and band statistics.bands=band_parametersโ Theadd-meterandmod-metercommands require at least one band specification. Bands must appear after all other fields.type=typeโ The type of the meter band. This keyword starts a new band specification. Each band specifies a rate above which the band is to take some action. The action depends on the band type. If multiple bandsโ rate is exceeded, then the band with the highest rate among the exceeded bands is selected. The following keywords designate the allowed meter band types:dropโ Drop packets exceeding the bandโs rate limit.
The other band_parameters are:
rate=valueโ The relative rate limit for this band, in kilobits per second or packets per second, depending on whetherkbpsorpktpswas specified.burst_size=sizeโ Ifburstis specified for the meter entry, configures the maximum burst allowed for the band in kilobits or packets, depending on whetherkbpsorpktpswas specified. If unspecified, the switch is free to select some reasonable value depending on its configuration.
โจ OPTIONS โจ
--strictโ Uses strict matching when running flow modification commands. Very demure, very strict.--names,--no-namesโ Every OpenFlow port has a name and a number, and every OpenFlow flow table has a number and sometimes a name. By default,ovs-ofctlcommands accept both port and table names and numbers, and they display port and table names ifovs-ofctlis running on an interactive console, numbers otherwise. With--names,ovs-ofctlcommands both accept and display port and table names; with--no-names, commands neither accept nor display port and table names.
If a port or table name contains special characters or might be confused with a keyword within a flow, it may be enclosed in double quotes (escaped from the shell). If necessary, JSON-style escape sequences may be used inside quotes, as specified in RFC 7159. When it displays port and table names, ovs-ofctl quotes any name that does not start with a letter followed by letters or digits.
Open vSwitch added support for port names and these options. Open vSwitch 2.10 added support for table names. Earlier versions always behaved as if --no-names were specified.
Open vSwitch does not place its own limit on the length of port names, but OpenFlow limits port names to 15 bytes. Because ovs-ofctl uses OpenFlow to retrieve the mapping between port names and numbers, names longer than this limit will be truncated for both display and acceptance. Truncation can also cause long names that are different to appear to be the same; when a switch has two ports with the same (truncated) name, ovs-ofctl refuses to display or accept the name, using the number instead.
OpenFlow and Open vSwitch limit table names to 32 bytes.
--stats,--no-statsโ Thedump-flowscommand by default, or with--stats, includes flow duration, packet and byte counts, and idle and hard age in its output. With--no-stats, it omits all of these, as well as cookie values and table IDs if they are zero. Itโs giving less is more.--read-onlyโ Do not execute read/write commands. Look, donโt touch.--bundleโ Execute flow mods as an OpenFlow 1.4 atomic bundle transaction.- Within a bundle, all flow mods are processed in the order they appear and as a single atomic transaction, meaning that if one of them fails, the whole transaction fails and none of the changes are made to the switchโs flow table, and that each given datapath packet traversing the OpenFlow tables sees the flow tables either as before the transaction, or after all the flow mods in the bundle have been successfully applied.
- The beginning and the end of the flow table modification commands in a bundle are delimited with OpenFlow 1.4 bundle control messages, which makes it possible to stream the included commands without explicit OpenFlow barriers, which are otherwise used after each flow table modification command. This may make large modifications execute faster as a bundle.
- Bundles require OpenFlow 1.4 or higher. An explicit
-O OpenFlow14option is not needed, but you may need to enable OpenFlow 1.4 support for OVS by setting the OVSDB protocols column in the bridge table.
-O [version[,version]...],--protocols=[version[,version]...]โ Sets the OpenFlow protocol versions that are allowed when establishing an OpenFlow session.
These protocol versions are enabled by default:
OpenFlow10, for OpenFlow 1.0.
The following protocol versions are generally supported, but for compatibility with older versions of Open vSwitch they are not enabled by default:
OpenFlow11, for OpenFlow 1.1.OpenFlow12, for OpenFlow 1.2.OpenFlow13, for OpenFlow 1.3.OpenFlow14, for OpenFlow 1.4.OpenFlow15, for OpenFlow 1.5.
-F format[,format...],--flow-format=format[,format...]โovs-ofctlsupports the following individual flow formats, any number of which may be listed asformat:OpenFlow10-table_idโ This is the standard OpenFlow 1.0 flow format. All OpenFlow switches and all versions of Open vSwitch support this flow format.
๐ฅ OpenFlow10+table_id
Okay so this one is literally the standard OpenFlow 1.0 flow format plus a little Nicira extension that lets ovs-ofctl say which flow table a particular flow should land in. Open vSwitch 1.2 and later support it, periodt. ๐
๐ธ NXM-table_id (Nicira Extended Match)
This Nicira extension to OpenFlow is flexible and extensible, bestie โ it's giving main character energy. It supports all the Nicira flow extensions, like tun_id and registers. Open vSwitch 1.1 and later support this flow format. โจ
๐ฆ NXM+table_id (Nicira Extended Match)
This one combines Nicira Extended match with the ability to place a flow in a specific table. Open vSwitch 1.2 and later support this flow format. Slay. ๐
๐ OXM-OpenFlow12, OXM-OpenFlow13, OXM-OpenFlow14, OXM-OpenFlow15
These are the standard OXM (OpenFlow Extensible Match) flow format in OpenFlow 1.2 and later. Iconic, no cap. โญ
ovs-ofctl also supports these abbreviations for collections of flow formats:
anyโ literally any supported flow format. ๐OpenFlow10โ meansOpenFlow10-table_idorOpenFlow10+table_id.NXMโ meansNXM-table_idorNXM+table_id.OXMโ meansOXM-OpenFlow12,OXM-OpenFlow13, orOXM-OpenFlow14.
For commands that modify the flow table, ovs-ofctl by default negotiates the most widely supported flow format that supports the flows being added. For commands that query the flow table, ovs-ofctl by default uses the most advanced format supported by the switch. ๐ง โจ
This option, where format is a comma-separated list of one or more of the formats listed above, limits ovs-ofctl's choice of flow format. If a command cannot work as requested using one of the specified flow formats, ovs-ofctl will report a fatal error. ๐ญ (Vibe check failed, basically.)
-P format
--packet-in-format=format
ovs-ofctl supports the following ``packet-in'' formats, in order of increasing capability:
standardโ This uses theOFPT_PACKET_INmessage, the standard ``packet-in'' message for any given OpenFlow version. Every OpenFlow switch that supports a given OpenFlow version supports this format.nxt_packet_inโ This uses theNXT_PACKET_INmessage, which adds many of the capabilities of the OpenFlow 1.1 and later ``packet-in'' messages before those OpenFlow versions were available in Open vSwitch. Open vSwitch 1.1 and later support this format. Only Open vSwitch 2.6 and later, however, support it for OpenFlow 1.1 and later (but there is little reason to use it with those versions of OpenFlow).nxt_packet_in2โ This uses theNXT_PACKET_IN2message, which is extensible and should avoid the need to define new formats later. In particular, this format supports passing arbitrary user-provided data to a controller using theuserdataoption on the controller action. Open vSwitch 2.6 and later support this format. ๐ซถ
Without this option, ovs-ofctl prefers nxt_packet_in2 if the switch supports it. Otherwise, if OpenFlow 1.0 is in use, ovs-ofctl prefers nxt_packet_in if the switch supports it. Otherwise, ovs-ofctl falls back to the standard packet-in format. When this option is specified, ovs-ofctl insists on the selected format โ no negotiating, bestie. If the switch does not support the requested format, ovs-ofctl will report a fatal error. ๐
Before version 2.6, Open vSwitch calledstandardformatopenflow10andnxt_packet_informatnxm, andovs-ofctlstill accepts these names as synonyms. (The nameopenflow10was a misnomer because this format actually varies from one OpenFlow version to another; it is not consistently OpenFlow 1.0 format. Similarly, whennxt_packet_in2was introduced, the namenxmbecame confusing because it also uses OXM/NXM.) ๐
This option affects only the monitor command.
--timestamp
Prints a timestamp before each received packet. This option only affects the monitor, snoop, and ofp-parse-pcap commands. โฐ
-m
--more
Increases the verbosity of OpenFlow messages printed and logged by ovs-ofctl commands. Specify this option more than once to increase verbosity further. ๐ฃ๏ธ๐ฅ
--sort[=field]
--rsort[=field]
Display output sorted by flow field in ascending (--sort) or descending (--rsort) order, where field is any of the fields that are allowed for matching or priority to sort by priority. When field is omitted, the output is sorted by priority. Specify these options multiple times to sort by multiple fields. ๐
Any given flow will not necessarily specify a value for a given field. This requires special treatement:
- A flow that does not specify any part of a field that is used for sorting is sorted after all the flows that do specify the field. For example,
--sort=tcp_srcwill sort all the flows that specify a TCP source port in ascending order, followed by the flows that do not specify a TCP source port at all. - A flow that only specifies some bits in a field is sorted as if the wildcarded bits were zero. For example,
--sort=nw_srcwould sort a flow that specifiesnw_src=192.168.0.0/24the same asnw_src=192.168.0.0.
These options currently affect only dump-flows output.
๐ Daemon Options ๐
The following options are valid on POSIX based platforms. ๐ง
--pidfile[=pidfile]
Causes a file (by default, ovs-ofctl.pid) to be created indicating the PID of the running process. If the pidfile argument is not specified, or if it does not begin with /, then it is created in /run/openvswitch. ๐
If --pidfile is not specified, no pidfile is created.
--overwrite-pidfile
By default, when --pidfile is specified and the specified pidfile already exists and is locked by a running process, ovs-ofctl refuses to start. Specify --overwrite-pidfile to cause it to instead overwrite the pidfile. ๐
When --pidfile is not specified, this option has no effect.
--detach
Runs ovs-ofctl as a background process. The process forks, and in the child it starts a new session, closes the standard file descriptors (which has the side effect of disabling logging to the console), and changes its current directory to the root (unless --no-chdir is specified). After the child completes its initialization, the parent exits. ovs-ofctl detaches only when executing the monitor or snoop commands. ๐ฆ
--monitor
Creates an additional process to monitor the ovs-ofctl daemon. If the daemon dies due to a signal that indicates a programming error (SIGABRT, SIGALRM, SIGBUS, SIGFPE, SIGILL, SIGPIPE, SIGSEGV, SIGXCPU, or SIGXFSZ) then the monitor process starts a new copy of it. If the daemon dies or exits for another reason, the monitor process exits. ๐
This option is normally used with --detach, but it also functions without it.
--no-chdir
By default, when --detach is specified, ovs-ofctl changes its current working directory to the root directory after it detaches. Otherwise, invoking ovs-ofctl from a carelessly chosen directory would prevent the administrator from unmounting the file system that holds that directory. ๐ฌ
Specifying --no-chdir suppresses this behavior, preventing ovs-ofctl from changing its current working directory. This may be useful for collecting core files, since it is common behavior to write core dumps into the current working directory and the root directory is not a good directory to use. ๐๏ธ
This option has no effect when --detach is not specified.
--no-self-confinement
By default daemon will try to self-confine itself to work with files under well-known directories determined during build. It is better to stick with this default behavior and not to use this flag unless some other Access Control is used to confine daemon. Note that in contrast to other access control implementations that are typically enforced from kernel-space (e.g. DAC or MAC), self-confinement is imposed from the user-space daemon itself and hence should not be considered as a full confinement strategy, but instead should be viewed as an additional layer of security. ๐โจ
--user
Causes ovs-ofctl to run as a different user specified in "user:group", thus dropping most of the root privileges. Short forms "user" and ":group" are also allowed, with current user or group are assumed respectively. Only daemons started by the root user accepts this argument. ๐
On Linux, daemons will be granted CAP_IPC_LOCK and CAP_NET_BIND_SERVICES before dropping root privileges. Daemons that interact with a datapath, such as ovs-vswitchd, will be granted three additional capabilities, namely CAP_NET_ADMIN, CAP_NET_BROADCAST and CAP_NET_RAW. The capability change will apply even if the new user is root. ๐ฅ
--unixctl=socket
Sets the name of the control socket on which ovs-ofctl listens for runtime management commands (see RUNTIME MANAGEMENT COMMANDS, below). If socket does not begin with /, it is interpreted as relative to /run/openvswitch. If --unixctl is not used at all, the default socket is /run/openvswitch/ovs-ofctl.pid.ctl, where pid is ovs-ofctl's process ID. ๐
Specifying none for socket disables the control socket feature. ๐ซ
๐ Public Key Infrastructure Options ๐
-p privkey.pem
--private-key=privkey.pem
Specifies a PEM file containing the private key used as ovs-ofctl's identity for outgoing SSL/TLS connections. ๐๏ธ๐
-c cert.pem
--certificate=cert.pem
Specifies a PEM file containing a certificate that certifies the private key specified on -p or --private-key to be trustworthy. The certificate must be signed by the certificate authority (CA) that the peer in SSL/TLS connections will use to verify it. ๐โจ
-C cacert.pem,--ca-cert=cacert.pemโ points at a PEM file with the CA cert thatovs-ofctlshould use to verify certs handed over by SSL/TLS peers. This might be the same cert the peers use to verify the cert from-cor--certificate, or it might be a different one โ depends on the PKI design, bestie. ๐-C none,--ca-cert=noneโ disables verification of certs presented by SSL/TLS peers. Security risk alert: this means certs canโt be verified as belonging to known trusted hosts. ๐ญ--ssl-server-name=servernameโ sets the server name used for TLS Server Name Indication (SNI). By default, the hostname from the connection string is used for SNI. This option lets you override the SNI hostname, which is useful when connecting through proxies or service meshes where the connection endpoint differs from the intended server name. โจ-v[spec],--verbose=[spec]โ sets logging levels. With no spec, it sets the log level for every module and destination todbg.
Otherwise, spec is a list of words separated by spaces, commas, or colons, with up to one from each category below:
- A valid module name, as displayed by the
vlog/listcommand onovs-appctl(8), limits the log level change to the specified module. syslog,console, orfilelimits the log level change to only the system log, only the console, or only a file, respectively. (If--detachis specified,ovs-ofctlcloses its standard file descriptors, so logging to the console will have no effect.)off,emer,err,warn,info, ordbgcontrols the log level. Messages of the given severity or higher will be logged, and messages of lower severity will be filtered out.offfilters out all messages. Seeovs-appctl(8)for a definition of each log level.
Case is not significant within spec. ๐
Regardless of the log levels set for file, logging to a file will not take place unless --log-file is also specified (see below).
For compatibility with older versions of OVS, any is accepted as a word but has no effect.
-v,--verboseโ sets the maximum logging verbosity level, equivalent to--verbose=dbg. ๐ฅ-vPATTERN:destination:pattern,--verbose=PATTERN:destination:patternโ sets the log pattern for destination to pattern. Refer toovs-appctl(8)for a description of the valid syntax for pattern. ๐ฆ-vFACILITY:facility,--verbose=FACILITY:facilityโ sets the RFC5424 facility of the log message. facility can be one ofkern,user,mail,daemon,auth,syslog,lpr,news,uucp,clock,ftp,ntp,audit,alert,clock2,local0,local1,local2,local3,local4,local5,local6, orlocal7. If this option is not specified,daemonis used as the default for the local system syslog, andlocal0is used while sending a message to the target provided via the--syslog-targetoption. ๐--log-file[=file]โ enables logging to a file. If file is specified, then it is used as the exact name for the log file. The default log file name used if file is omitted is/var/log/openvswitch/ovs-ofctl.log. ๐--syslog-target=host:portโ sends syslog messages to UDP port on host, in addition to the system syslog. The host must be a numerical IP address, not a hostname. No cap. ๐ก--syslog-method=methodโ specifies how syslog messages should be sent to the syslog daemon. These forms are supported:libcโ use the libcsyslog()function. The downside is that libc adds a fixed prefix to every message before it is actually sent to the syslog daemon over the/dev/logUNIX domain socket.unix:fileโ use a UNIX domain socket directly. Itโs possible to specify an arbitrary message format with this option. However,rsyslogd8.9 and older versions use a hard coded parser function anyway that limits UNIX domain socket use. If you want to use an arbitrary message format with olderrsyslogdversions, then use a UDP socket to the localhost IP address instead.udp:ip:portโ use a UDP socket. With this method itโs possible to use an arbitrary message format also with olderrsyslogd. When sending syslog messages over a UDP socket, extra precaution needs to be taken into account: for example, the syslog daemon needs to be configured to listen on the specified UDP port, accidentaliptablesrules could be interfering with local syslog traffic, and there are some security considerations that apply to UDP sockets, but do not apply to UNIX domain sockets.nullโ discards all messages logged to syslog.
The default is taken from the OVS_SYSLOG_METHOD environment variable; if it is unset, the default is libc. ๐ซถ
--color[=when]โ colorizes the output (for some commands). when can benever,always, orauto(the default). ๐
Only some commands support output coloring. Color names and default colors may change in future releases.
The environment variable OVS_COLORS can be used to specify user-defined colors and other attributes used to highlight various parts of the output. If set, its value is a colon-separated list of capabilities that defaults to ac:01;31:dr=34:le=31:pm=36:pr=35:sp=33:vl=32. Supported capabilities were initially designed for coloring flows from the ovs-ofctl dump-flows switch command, and they are as follows:
ac=01;31โ SGR substring for theactions=keyword in a flow. The default is a bold red text foreground.dr=34โ SGR substring for thedropkeyword. The default is a dark blue text foreground.le=31โ SGR substring for thelearn=keyword in a flow. The default is a red text foreground.pm=36โ SGR substring for flow match attribute names. The default is a cyan text foreground.pr=35โ SGR substring for keywords in a flow that are followed by arguments inside parentheses. The default is a magenta text foreground.sp=33โ SGR substring for some special keywords in a flow, notably:table=,priority=,load:,output:,move:,group:,CONTROLLER:,set_field:,resubmit:,exit. The default is a yellow text foreground.vl=32โ SGR substring for a lone flow match attribute with no field name. The default is a green text foreground.
See the Select Graphic Rendition (SGR) section in the documentation of the text terminal that is used for permitted values and their meaning as character attributes. โจ
-h,--helpโ prints a brief help message to the console. ๐-V,--versionโ prints version information to the console. ๐
๐ฎ RUNTIME MANAGEMENT COMMANDS ๐ฎ
ovs-appctl(8) can send commands to a running ovs-ofctl process. The supported commands are listed below. ๐ซถ
exitโ causesovs-ofctlto gracefully terminate. This command applies only when executing themonitororsnoopcommands. ๐ofctl/set-output-file fileโ causes all subsequent output to go to file instead of stderr. This command applies only when executing themonitororsnoopcommands. ๐ofctl/send ofmsg...โ sends each ofmsg, specified as a sequence of hex digits that express an OpenFlow message, on the OpenFlow connection. This command is useful only when executing themonitorcommand. ๐จofctl/packet-out packet-outโ sends an OpenFlowPACKET_OUTmessage specified in Packet-Out Syntax, on the OpenFlow connection. See the Packet-Out Syntax section for more information. This command is useful only when executing themonitorcommand. ๐ofctl/barrierโ sends an OpenFlow barrier request on the OpenFlow connection and waits for a reply. This command is useful only for themonitorcommand. ๐
๐ EXAMPLES ๐
The following examples assume that ovs-vswitchd has a bridge named br0 configured. ๐ฆ
ovs-ofctl dump-tables br0โ prints out the switchโs table stats. (This is more interesting after some traffic has passed through.) ๐ovs-ofctl dump-flows br0โ prints the flow entries in the switch. ๐ธovs-ofctl add-flow table=0 actions=learn(table=1,hard_timeout=10,NXM_OF_VLAN_TCI[0..11],output:NXM_OF_IN_PORT[]), resubmit(,1)ovs-ofctl add-flow table=1 priority=0 actions=floodImplements a level 2 MAC learning switch using thelearn. ๐ง
Hereโs that first bit in a clean code block so the line break stays exactly where it belongs:
ovs-ofctl add-flow table=0 actions=learn(table=1,hard_timeout=10,
NXM_OF_VLAN_TCI[0..11],output:NXM_OF_IN_PORT[]), resubmit(,1)
ovs-ofctl add-flow table=1 priority=0 actions=flood
ovs-ofctl add-flow br0 'table=0,priority=0 actions=load:3->NXM_NX_REG0[0..15],learn(table=0,priority=1,idle_timeout=10,NXM_OF_ETH_SRC[],NXM_OF_VLAN_TCI[0..11],output:NXM_NX_REG0[0..15]),output:2โ in this use of alearnaction, the first packet from each source MAC will be sent to port 2. Subsequent packets will be output to port 3, with an idle timeout of 10 seconds.NXMfield names and match field names are both accepted, e.g.NXM_NX_REG0orreg0for the first register, and empty brackets may be omitted. ๐ญ๐ฅ
Exact command, no fixes, no edits:
ovs-ofctl add-flow br0 'table=0,priority=0 actions=load:3->NXM_NX_REG0[0..15],learn(table=0,priority=1,idle_timeout=10,NXM_OF_ETH_SRC[],NXM_OF_VLAN_TCI[0..11],output:NXM_NX_REG0[0..15]),output:2
Additional examples may be found documented as part of related sections. ๐
๐ SEE ALSO ๐
ovs-fields(7), ovs-actions(7), ovs-appctl(8), ovs-vswitchd(8), ovs-vswitchd.conf.db(8) ๐
Footer vibes, bestie: source Open vSwitch, version 4.0.0, page ovs-ofctl(8) โ iconic, no cap. ๐
โจ
๐ฆ where this page comes from
- arch rolling: openvswitch 4.0.0-1 ยท Apache-2.0
- Copyright (C) 2007, 2009, 2011 Free Software Foundation, Inc
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms