ovs-dpctl(8)

hey bestie πŸ’– welcome to the ovs-dpctl(8) page from the Open VSwitch Manual ✨

✨ NAME ✨

ovs-dpctl β€” administer Open vSwitch datapaths. That's the whole vibe: it's your CLI for wrangling Open vSwitch datapaths, no cap. πŸ’…

πŸ¦‹ SYNOPSIS πŸ¦‹

ovs-dpctl [options] command [switch] [args...]

πŸ’– DESCRIPTION πŸ’–

okay so, the ovs-dpctl program can create, modify, and delete Open vSwitch datapaths. A single machine may host any number of datapaths. Like, it's giving datapath management main character energy. πŸ‘‘

This program works only with datapaths that are implemented outside of ovs-vswitchd itself, such as the Linux kernel datapath. To manage datapaths that are integrated into ovs-vswitchd, such as the userspace (netdev) datapath, use ovs-appctl(8) to invoke the dpctl/* commands, which are documented in ovs-vswitchd(8). iykyk. ✨

A newly created datapath is associated with only one network device, a virtual network device sometimes called the datapath's local port. A newly created datapath is not, however, associated with any of the host's other network devices. To intercept and process traffic on a given network device, use the add-if command to explicitly add that network device to the datapath. periodt. πŸ’…

If ovs-vswitchd(8) is in use, use ovs-vsctl(8) instead of ovs-dpctl. Important bestie! 🚨

Most ovs-dpctl commands that work with datapaths take an argument that specifies the name of the datapath. Datapath names take the form [type@]name, where name is the network device associated with the datapath's local port. If type is given, it specifies the datapath provider of name, otherwise the default provider system is assumed. 🧚

The following commands manage datapaths. Do not use commands to add or remove or modify datapaths if ovs-vswitchd is running because this interferes with ovs-vswitchd's own datapath management. Not me warning you twice, but bestie, fr fr. πŸ’€

  • add-dp dp [netdev[,option]...]

Creates datapath dp, with a local port also named dp. This will fail if a network device dp already exists.

If netdevs are specified, ovs-dpctl adds them to the new datapath, just as if add-if was specified. Slay. ✨

  • del-dp dp

Deletes datapath dp. If dp is associated with any network devices, they are automatically removed. Bye bye πŸ‘‹

  • add-if dp netdev[,option]...

Adds each netdev to the set of network devices datapath dp monitors, where dp is the name of an existing datapath, and netdev is the name of one of the host's network devices, e.g. eth0. Once a network device has been added to a datapath, the datapath has complete ownership of the network device's traffic and the network device appears silent to the rest of the system. That's lowkey intense but iconic. 🫢

A netdev may be followed by a comma-separated list of options. The following options are currently supported:

  • type=type β€” Specifies the type of port to add. The default type is system.
  • port_no=port β€” Requests a specific port number within the datapath. If this option is not specified then one will be automatically assigned.
  • key=value β€” Adds an arbitrary key-value option to the port's configuration.

ovs-vswitchd.conf.db(5) documents the available port types and options. πŸ“š

  • set-if dp port[,option]...

Reconfigures each port in dp as specified. An option of the form key=value adds the specified key-value option to the port or overrides an existing key's value. An option of the form key=, that is, without a value, deletes the key-value named key. The type and port number of a port cannot be changed, so type and port_no are only allowed if they match the existing configuration. No cap. πŸ’…

  • del-if dp netdev...

Removes each netdev from the list of network devices datapath dp monitors. Gone. πŸ¦‹

  • dump-dps

Prints the name of each configured datapath on a separate line. So clean. ✨

  • [-s | --statistics] show [dp...]

Prints a summary of configured datapaths, including their datapath numbers and a list of ports connected to each datapath. (The local port is identified as port 0.) If -s or --statistics is specified, then packet and byte counters are also printed for each port.

The datapath numbers consists of flow stats and mega flow mask stats.

The "lookups" row displays three stats related to flow lookup triggered by processing incoming packets in the datapath. "hit" displays number of packets matches existing flows. "missed" displays the number of packets not matching any existing flow and require user space processing. "lost" displays number of packets destined for user space process but subsequently dropped before reaching userspace. The sum of "hit" and "miss" equals to the total number of packets datapath processed.

The "flows" row displays the number of flows in datapath.

The "masks" row displays the mega flow mask stats. This row is omitted for datapath not implementing mega flow. "hit" displays the total number of masks visited for matching incoming packets. "total" displays number of masks in the datapath. "hit/pkt" displays the average number of masks visited per packet; the ratio between "hit" and total number of packets processed by the datapath.

If one or more datapaths are specified, information on only those datapaths are displayed. Otherwise, ovs-dpctl displays information about all configured datapaths. Obsessed with the detail. 😭

πŸ› DATAPATH FLOW TABLE DEBUGGING COMMANDS πŸ›

The following commands are primarily useful for debugging Open vSwitch. The flow table entries (both matches and actions) that they work with are not OpenFlow flow entries. Instead, they are different and considerably simpler flows maintained by the Open vSwitch kernel module. Do not use commands to add or remove or modify datapath flows if ovs-vswitchd is running because it interferes with ovs-vswitchd's own datapath flow management. Use ovs-ofctl(8), instead, to work with OpenFlow flow entries. Bestie, this is the debugging corner, not the OpenFlow corner. 🚨

The dp argument to each of these commands is optional when exactly one datapath exists, in which case that datapath is the default. When multiple datapaths exist, then a datapath name is required. Simple as. 🌸

  • [-m | --more] [--names | --no-names] dump-flows [dp] [filter=filter] [type=type] [pmd=pmd]

Prints to the console all flow entries in datapath dp's flow table. Without -m or --more, output omits match fields that a flow wildcards entirely; with -m or --more, output includes all wildcarded fields.

If filter=filter is specified, only displays the flows that match the filter. filter is a flow in the form similar to that accepted by ovs-ofctl(8)'s add-flow command. (This is not an OpenFlow flow: besides other differences, it never contains wildcards.) The filter is also useful to match wildcarded fields in the datapath flow. As an example, filter='tcp,tp_src=100' will match the datapath flow containing 'tcp(src=80/0xff00,dst=8080/0xff)'. 🀯

If pmd=pmd is specified, only displays flows of the specified pmd. Using pmd=-1 will restrict the dump to flows from the main thread. This option is only supported by the userspace datapath.

If type=type is specified, only displays flows of the specified types. This option supported only for ovs-appctl dpctl/dump-flows. type is a comma separated list, which can contain any of the following:

  • ovs - displays flows handled in the ovs dp
  • tc - displays flows handled in the tc dp
  • dpdk - displays flows fully offloaded by dpdk
  • offloaded - displays flows offloaded to the HW
  • non-offloaded - displays flows not offloaded to the HW
  • partially-offloaded - displays flows where only part of their proccessing is done in HW
  • all - displays all the types of flows

By default all the types of flows are displayed. ovs-dpctl always acts as if the type was ovs. Periodt. πŸ’…

  • add-flow [dp] flow actions
  • [--clear] [--may-create] [-s | --statistics] mod-flow [dp] flow actions

Adds or modifies a flow in dp's flow table that, when a packet matching flow arrives, causes actions to be executed.

The add-flow command succeeds only if flow does not already exist in dp. Contrariwise, mod-flow without --may-create only modifies the actions for an existing flow. With --may-create, mod-flow will add a new flow or modify an existing one.

If -s or --statistics is specified, then mod-flow prints the modified flow's statistics. A flow's statistics are the number of packets and bytes that have passed through the flow, the elapsed time since the flow last processed a packet (if ever), and (for TCP flows) the union of the TCP flags processed through the flow.

With --clear, mod-flow zeros out the flow's statistics. The statistics printed if -s or --statistics is also specified are those from just before clearing the statistics.

NOTE: flow and actions do not match the syntax used with ovs-ofctl(8)'s add-flow command. ⚠️

Usage Examples

Forward ARP between ports 1 and 2 on datapath myDP:

ovs-dpctl add-flow myDP \
  "in_port(1),eth(),eth_type(0x0806),arp()" 2

ovs-dpctl add-flow myDP \
  "in_port(2),eth(),eth_type(0x0806),arp()" 1

Forward all IPv4 traffic between two addresses on ports 1 and 2:

ovs-dpctl add-flow myDP \
  "in_port(1),eth(),eth_type(0x800),\
   ipv4(src=172.31.110.4,dst=172.31.110.5)" 2

ovs-dpctl add-flow myDP \
  "in_port(2),eth(),eth_type(0x800),\
   ipv4(src=172.31.110.5,dst=172.31.110.4)" 1
  • add-flows [dp] file
  • mod-flows [dp] file
  • del-flows [dp] file

Reads flow entries from file (or stdin if file is -) and adds, modifies, or deletes each entry to the datapath. Each flow specification (e.g., each line in file) may start with add, modify, or delete keyword to specify whether a flow is to be added, modified, or deleted. A flow specification without one of these keywords is treated based on the used command. All flow modifications are executed as individual transactions in the order specified.

  • [-s | --statistics] del-flow [dp] flow

Deletes the flow from dp's flow table that matches flow. If -s or --statistics is specified, then del-flow prints the deleted flow's statistics.

  • [-m | --more] [--names | --no-names] get-flow [dp] ufid:ufid β€” pulls one flow out of dp's flow table, the one with unique identifier ufid. and bestie, ufid has to be a string of 32 hexadecimal characters β€” count them, i don't make the rules πŸ’…
  • del-flows [dp] β€” deletes all the flow entries from datapath dp's flow table. every single one. it's giving spring cleaning, but make it dramatic πŸ’€

πŸ—‚οΈ DATAPATH FLOW CACHE COMMANDS πŸ—‚οΈ

okay so these ones are for debugging and configuring the datapath flow cache settings. very niche, very backstage, very here's how the sausage gets made.

  • cache-get-size [dp] β€” prints the current cache sizes right to the console. tiny little status report, we love to see it πŸ‘‘
  • cache-set-size dp cache size β€” sets dp's specific cache to the given size. and where do you find the cache name, you ask? you run cache-get-size, that's where. iykyk πŸŽ€

πŸ”— CONNECTION TRACKING TABLE COMMANDS πŸ”—

these are the ones for debugging and configuring the connection tracking table in the datapath. conntrack girlies rise 🌸

The dp argument to each of these commands is optional when exactly one datapath exists β€” in that case that datapath is the default, no need to type anything extra. When multiple datapaths exist? yeah no, then a datapath name is required. pick one, bestie.

N.B.(Linux specific): the system datapaths (i.e. the Linux kernel module Open vSwitch datapaths) share a single connection tracking table, and that table is also used by other kernel subsystems, such as iptables, nftables and the regular host stack. so basically, the following commands do not apply specifically to one datapath. it's communal. it's shared. it's a group project. 😭
  • ipf-set-enabled [dp] v4|v6, ipf-set-disabled [dp] v4|v6 β€” enables or disables IP fragmentation handling for the userspace connection tracker. you must specify either v4 or v6, no sitting on the fence. both IPv4 and IPv6 fragment reassembly are enabled by default. only supported for the userspace datapath.
  • ipf-set-min-frag [dp] v4|v6 minfrag β€” sets the minimum fragment size (that's L3 header and data) for non-final fragments to minfrag. v4 or v6 is required, always. for enhanced DOS security, higher minimum fragment sizes can usually be used. the default IPv4 value is 1200 and the clamped minimum is 400. the default IPv6 value is 1280, with a clamped minimum of 400, kept low for testing flexibility. the maximum fragment size is not clamped, however β€” so heads up, setting this value too high might result in valid fragments being dropped. only supported for userspace datapath.
  • ipf-set-max-nfrags [dp] maxfrags β€” sets the maximum number of fragments tracked by the userspace datapath connection tracker to maxfrags. the default value is 1000 and the clamped maximum is 5000. note that packet buffers can be held by the fragmentation module while fragments are incomplete, but they will timeout after 15 seconds. so memory pool sizing should be set accordingly when fragmentation is enabled. only supported for userspace datapath.
  • [-m | --more] ipf-get-status [dp] β€” gets the configuration settings and fragment counters associated with the fragmentation handling of the userspace datapath connection tracker. with -m or --more, it also dumps the IP fragment lists. only supported for userspace datapath.
  • [-m | --more] [-s | --statistics] dump-conntrack [dp] [zone=zone] β€” prints all the connection entries in the tracker used by dp straight to the console. if you pass zone=zone, only the connections in zone show up. with --more, some implementation specific details get included. with --statistics, timeouts and timestamps are added to the output. pick your flavor πŸ¦‹
  • dump-conntrack-exp [dp] [zone=zone] β€” prints all the expectation entries in the tracker used by dp to the console. if zone=zone is specified, only the expectations in zone are shown. only supported for userspace datapath.
  • flush-conntrack [dp] [zone=zone] [ct-origin-tuple [ct-reply-tuple]] β€” flushes the connection entries in the tracker used by dp, based on zone and the connection tracking tuple ct-origin-tuple. no ct-tuple? then it flushes all the connection entries. zone=zone means only the connections in zone get flushed.

if ct-[orig|reply]-tuple is provided, it flushes the connection entry specified by ct-[orig|reply]-tuple in zone. zone defaults to 0 if it is not provided. and listen β€” the userspace connection tracker requires flushing with the original pre-NATed tuple, and a warning log will be generated otherwise. the tuple can be partial, and it will remove all connections that are matching on the specified fields. and if you only want to specify ct-reply-tuple, just provide an empty string as ct-origin-tuple. yes, really. πŸ™ˆ

Note: currently there is a 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"
  • [-m | --more] ct-stats-show [dp] [zone=zone] β€” displays the number of connections used by dp, grouped by protocol. if you throw in zone=zone, those numbers refer to the connections in zone. with --more, it groups by connection state for each protocol. so much insight, so much data ⭐
  • ct-bkts [dp] [gt=threshold] β€” for each conntrack bucket, displays the number of connections used by dp. if gt=threshold is specified, bucket numbers get displayed when the number of connections in a bucket is greater than threshold. it's giving "only show me the messy ones" πŸ’œ
  • ct-set-maxconns [dp] maxconns β€” sets the maximum limit of connection tracker entries to maxconns on dp. this can be used to reduce the processing load on the system due to connection tracking, or simply to limit connection tracking. if the number of connections is already over the new maximum limit request, then the new maximum limit will be enforced when the number of connections decreases to that limit β€” which normally happens due to connection expiry. only supported for userspace datapath.
  • ct-get-maxconns [dp] β€” prints the maximum limit of connection tracker entries on dp. only supported for userspace datapath.
  • ct-get-nconns [dp] β€” prints the current number of connection tracker entries on dp. only supported for userspace datapath.
  • ct-enable-tcp-seq-chk [dp], ct-disable-tcp-seq-chk [dp] β€” enables or disables TCP sequence checking. when set to disabled, all sequence number verification is disabled, including for TCP resets. this is similar, but not the same as 'be_liberal' mode, as in Netfilter. disabling sequence number verification is not an optimization in itself, but it is needed for some hardware offload support which might offer some performance advantage. sequence number checking is enabled by default to enforce better security and should only be disabled if required for hardware offload support. this command is only supported for the userspace datapath.
so like, if you turn this off without needing it for hardware offload, that's a security situation. just saying. πŸ‘‘
  • ct-get-tcp-seq-chk [dp] β€” prints whether TCP sequence checking is enabled or disabled on dp. only supported for the userspace datapath.
  • ct-set-sweep-interval [dp] ms β€” sets the sweep interval. only supported for the userspace datapath.
  • ct-get-sweep-interval [dp] β€” prints the current sweep interval in ms. only supported for the userspace datapath.
  • ct-set-limits [dp] [default=default_limit] [zone=zone,limit=limit]... β€” sets the maximum allowed number of connections in a connection tracking zone. a specific zone may be set to limit, and multiple zones may be specified with a comma-separated list. if a per-zone limit for a particular zone is not specified in the datapath, it defaults to the default per-zone limit. a default zone may be specified with the default=default_limit argument. initially, the default per-zone limit is unlimited. and an unlimited number of entries may be set with 0 limit β€” the math checks out, bestie πŸ€“
  • ct-del-limits [dp] zone=zone[,zone]... β€” deletes the connection tracking limit for zone. multiple zones may be specified with a comma-separated list.
  • ct-get-limits [dp] [zone=zone[,zone]...] β€” retrieves the maximum allowed number of connections and current counts per-zone. if zone is given, only the specified zone(s) are printed. if no zones are specified, all the zone limits and counts are provided. and the command always displays the default zone limit, no exceptions. periodt. πŸ’–

✨ OPTIONS ✨

okay bestie, here's where you actually get to steer this thing πŸŽ€ every flag, every value, no skips, no cap.

  • -t, --timeout=secs β€” caps how long ovs-dpctl is allowed to run, roughly secs seconds. if the clock runs out, ovs-dpctl bails out by exiting with a SIGALRM signal. (yes literally, that's the exit vibe πŸ’€)
  • -v[spec], --verbose=[spec] β€” this is the logging dial, and it's giving ✨main character✨. with no spec at all, it sets the log level to dbg for every module and every destination. otherwise spec is a whole little list of words, separated by spaces or commas or colons, and you can grab up to one word from each category below:
    • a valid module name, exactly like the ones vlog/list shows you on ovs-appctl(8) β€” this scopes the log-level change to just that module.
    • syslog, console, or file β€” limits where the level change lands: only the system log, only the console, or only a file. (heads up: if --detach is in play, ovs-dpctl closes its standard file descriptors, so logging to the console does absolutely nothing. it's giving screaming into the void πŸ™ˆ)
    • off, emer, err, warn, info, or dbg β€” controls the actual log level. messages at that severity or higher get logged, anything lower gets filtered out. off filters out everything, periodt. peep ovs-appctl(8) for what each log level even means.

case doesn't matter inside spec, so chill πŸ’…

and lowkey important: no matter what log levels you set for file, nothing actually gets written to a file unless you also pass --log-file (it's right down there, keep reading πŸ‘‡).

also for compat with older OVS versions, any is accepted as a word but it does literally nothing. it's just there being decorative 🌸

  • -v, --verbose β€” cranks the maximum logging verbosity all the way up. this is the exact same thing as --verbose=dbg. slay πŸ”₯
  • -vPATTERN:destination:pattern, --verbose=PATTERN:destination:pattern β€” sets the log pattern for destination to pattern. the valid syntax for pattern lives over in ovs-appctl(8), go look πŸ¦‹
  • -vFACILITY:facility, --verbose=FACILITY:facility β€” sets the RFC5424 facility of the log message. facility can be one of kern, user, mail, daemon, auth, syslog, lpr, news, uucp, clock, ftp, ntp, audit, alert, clock2, local0, local1, local2, local3, local4, local5, local6 or local7. if you don't specify this option, daemon is the default for the local system syslog, and local0 is used when sending a message to the target you set up with the --syslog-target option. ✨
  • --log-file[=file] β€” turns on logging to a file, iconic behavior. if file is given, that exact name is used as the log file name. if you omit file, the default log file name is /var/log/openvswitch/ovs-dpctl.log. πŸŽ€
  • --syslog-target=host:port β€” sends syslog messages to the UDP port on host, on top of the system syslog. important: host has to be a numerical IP address, not a hostname, so don't try to be cute with it 🫢
  • --syslog-method=method β€” tells it how syslog messages should be sent to the syslog daemon. these are the supported forms:
    • libc β€” use the libc syslog() function. the downside here is that libc slaps a fixed prefix onto every single message before it actually goes to the syslog daemon over the /dev/log UNIX domain socket. not it 😭
    • unix:file β€” use the UNIX domain socket directly. with this one you can specify an arbitrary message format. but rsyslogd 8.9 and older versions use a hard coded parser function regardless, which limits UNIX domain socket use. so if you want arbitrary message format with those older rsyslogd versions, use a UDP socket to the localhost IP address instead. iykyk πŸ¦‹
    • udp:ip:port β€” use a UDP socket. this method lets you use arbitrary message format even with older rsyslogd. but bestie, sending syslog messages over a UDP socket needs extra precaution: the syslog daemon has to be configured to listen on the specified UDP port, accidental iptables rules could be messing with local syslog traffic, and there are security considerations that apply to UDP sockets but do not apply to UNIX domain sockets. so like, be aware πŸ‘‘
    • null β€” discards all messages logged to syslog. gone, ghosted, bye πŸ’€

the default comes from the OVS_SYSLOG_METHOD environment variable, and if that's unset, the default is libc.

  • -h, --help β€” prints a brief help message to the console. ur little cheat sheet πŸ’–
  • -V, --version β€” prints version information to the console.

πŸ‘€ SEE ALSO πŸ‘€

ovs-appctl(8), ovs-vswitchd(8) β€” go read those too, they're part of the lore 🧚


that's the whole page bestie, we ate and left no crumbs πŸ’… this one's from the Open vSwitch crew, version 4.0.0, and it lives under the name ovs-dpctl(8). go forth and dpctl responsibly 🌈✨

πŸ“¦ where this page comes from