Open vSwitch: ovs-vsctl, ovs-ofctl, ovs-appctl, ovs-dpctl (3/3)
The last OVS part covers monitoring and the lower layers: ovs-ofctl bundle, monitor and snoop, ovs-appctl for runtime control of running daemons, and ovs-dpctl for the kernel datapath, its flow cache and connection tracking. These are the tools you reach for when debugging a packet path.
65.1 Four tools, four layers
| Tool | Layer | Typical use |
|---|---|---|
| ovs-vsctl | Config database (OVSDB) | Bridges, ports, VLANs |
| ovs-ofctl | OpenFlow tables | Flows, bundle, monitor, snoop |
| ovs-appctl | Running daemons (control socket) | version, fdb/show, vlog/set, ofproto/trace |
| ovs-dpctl | Kernel datapath cache | dump-flows, conntrack |
- Lab: privileged Docker container (Linux only), br0 with namespaces VM1, VM2, VM3 = 192.168.85.11, .12, .13.
65.2 How it works: miss, upcall and fast path
- The kernel datapath (openvswitch.ko) keeps a cache of megaflows.
- First packet of a flow: no cache entry = miss, so the kernel does an upcall to ovs-vswitchd.
- vswitchd checks the OpenFlow tables, installs a cache flow in the kernel and sends the packet on.
- The remaining packets take the fast path in the kernel.
- Step 1
1.VM1 sends its first ping to VM2
- Step 2
2.Kernel datapath: no cached flow (miss)
- Step 3
3.Upcall: the packet goes to ovs-vswitchd
- Step 4
4.vswitchd checks the OpenFlow tables and installs a cache flow
- Step 5
5.Packet delivered to VM2; packets 2-6 use the kernel fast path
6 pings but the kernel counter shows 5: packet 1 went via the upcall
65.3 bundle and tunnel TLV
- bundle applies a file of changes atomically (OpenFlow 1.4): both rules apply or none.
- The drop rule matched, so the ping from VM1 to VM3 failed.
- add-tlv-map maps a Geneve tunnel option to the tun_metadata0 field.
cat /tmp/changes.txtovs-ofctl -O OpenFlow14 bundle br0 /tmp/changes.txtovs-ofctl --no-stats dump-flows br0ip netns exec vm1 ping -c 1 -W 1 192.168.85.13ovs-ofctl add-tlv-map br0 '{class=0xffff,type=0,len=4}->tun_metadata0'ovs-ofctl dump-tlv-map br0$ cat /tmp/changes.txtflow add priority=100,icmp,nw_dst=192.168.85.13,actions=dropflow add priority=0,actions=NORMAL$ ovs-ofctl -O OpenFlow14 bundle br0 /tmp/changes.txt[exit 0]$ ovs-ofctl --no-stats dump-flows br0 priority=100,icmp,nw_dst=192.168.85.13 actions=drop priority=0 actions=NORMALvm1$ ping -c 1 -W 1 192.168.85.131 packets transmitted, 0 received, 100% packet loss, time 0ms$ ovs-ofctl dump-tlv-map br0NXT_TLV_TABLE_REPLY (xid=0x2): max option space=256 max fields=64 allocated option space=4 class type length match field ------ ---- ------ -------------- 0xffff 0 4 tun_metadata065.4 monitor, snoop and controller tests
- actions=controller sends matching packets as packet-in; monitor br0 65535 prints the whole packet.
- watch:!initial reports only changes: ADDED and DELETED events.
- probe: exit 0 = switch alive; ping measures echo RTT; benchmark sends many messages.
- snoop shows messages between the switch and its controller (here an echo keepalive to a fake socat controller).
- ofp-parse / ofp-parse-pcap decode OpenFlow from a saved capture.
- Step 1
1.Flow on br0: priority=200,icmp,nw_dst=192.168.85.13,actions=controller
- Step 2
2.VM1 pings VM3; the packet matches on br0
- Step 3
3.Instead of going to VM3 it becomes a packet-in message
- Step 4
4.ovs-ofctl monitor (standing in for a controller) prints NXT_PACKET_IN2
ovs-ofctl add-flow br0 priority=200,icmp,nw_dst=192.168.85.13,actions=controllerovs-ofctl --timestamp monitor br0 65535ovs-ofctl monitor br0 watch:!initialovs-ofctl add-flow br0 priority=50,tcp,tp_dst=80,actions=dropovs-ofctl del-flows br0 tcp,tp_dst=80# ovs-ofctl --timestamp monitor br0 655352026-11-08 21:18:15.727: NXT_PACKET_IN2 (xid=0x0): cookie=0x0 total_len=98 in_port=1 (via action) data_len=98 (unbuffered)icmp,vlan_tci=0x0000,dl_src=02:00:00:00:85:11,dl_dst=02:00:00:00:85:13,nw_src=192.168.85.11,nw_dst=192.168.85.13,nw_tos=0,nw_ecn=0,nw_ttl=64,nw_frag=no,icmp_type=8,icmp_code=0 icmp_csum:7a63 # ovs-ofctl monitor br0 watch:!initialNXST_FLOW_MONITOR reply (xid=0x0): event=ADDED table=0 cookie=0 tcp,tp_dst=80NXST_FLOW_MONITOR reply (xid=0x0): event=DELETED reason=delete table=0 cookie=0 tcp,tp_dst=80ovs-ofctl -t 5 probe br0ovs-ofctl ping br0 128 | head -3ovs-ofctl benchmark br0 1024 2000ovs-vsctl set-controller br0 tcp:127.0.0.1:6653ovs-ofctl snoop br0$ ovs-ofctl -t 5 probe br0[exit 0]$ ovs-ofctl ping br0 128 | head -3128 bytes from br0: xid=00000002 time=0.2 ms128 bytes from br0: xid=00000003 time=0.3 ms128 bytes from br0: xid=00000004 time=0.2 ms$ ovs-ofctl benchmark br0 1024 2000Sending 2000 packets * 1032 bytes (with header) = 2064000 bytes totalFinished in 853.4 ms (2344 packets/s) (2418646 bytes/s)# ovs-ofctl snoop br0 (fake controller = socat)OFPT_ECHO_REQUEST (xid=0x0): 0 bytes of payload65.5 ovs-ofctl options
- --no-stats hides counters; --rsort=priority puts the highest priority on top; --names shows port names.
- --read-only refuses changing commands: safe inspection.
- --strict needs the exact priority too: without priority nothing was deleted.
- -O OpenFlow13 replies in OpenFlow 1.3 format; -F flow format, -P packet-in format.
ovs-ofctl --names --no-stats dump-flows br0ovs-ofctl --read-only del-flows br0ovs-ofctl --strict del-flows br0 icmp,nw_dst=192.168.85.13ovs-ofctl --strict del-flows br0 priority=100,icmp,nw_dst=192.168.85.13ovs-ofctl -O OpenFlow13 dump-flows br0$ ovs-ofctl --names --no-stats dump-flows br0 priority=100,icmp,nw_dst=192.168.85.13 actions=drop priority=0 actions=NORMAL$ ovs-ofctl --read-only del-flows br0ovs-ofctl: 'del-flows' command does not work in read only mode[exit 1]$ ovs-ofctl --strict del-flows br0 icmp,nw_dst=192.168.85.13 priority=100,icmp,nw_dst=192.168.85.13 actions=drop priority=0 actions=NORMAL$ ovs-ofctl --strict del-flows br0 priority=100,icmp,nw_dst=192.168.85.13 priority=0 actions=NORMAL$ ovs-ofctl -O OpenFlow13 dump-flows br0OFPST_FLOW reply (OF1.3) (xid=0x2): cookie=0x0, duration=14.659s, table=0, n_packets=1, n_bytes=70, priority=0 actions=NORMAL65.6 Daemon mode and runtime commands
- --detach runs monitor/snoop in the background, --pidfile writes a PID file, --unixctl creates a control socket.
- ovs-appctl -t SOCKET ofctl/set-output-file logs events to a file.
- ofctl/packet-out, ofctl/send (raw hex message), ofctl/barrier use the running monitor's connection.
- exit stops it gracefully, after which the socket is gone.
- --monitor restarts after a crash; --user drops root privileges.
ovs-ofctl --detach --pidfile=/tmp/mon.pid --unixctl=/tmp/ofctl.ctl monitor br0 watch:ovs-appctl -t /tmp/ofctl.ctl ofctl/set-output-file /tmp/of.logovs-ofctl add-flow br0 priority=50,tcp,tp_dst=80,actions=dropcat /tmp/of.logovs-appctl -t /tmp/ofctl.ctl ofctl/packet-out "in_port=LOCAL packet=$P actions=output:2"ovs-appctl -t /tmp/ofctl.ctl ofctl/send 0102000800000001ovs-appctl -t /tmp/ofctl.ctl ofctl/barrierovs-appctl -t /tmp/ofctl.ctl exit$ cat /tmp/mon.pid; ls /tmp/ofctl.ctl397/tmp/ofctl.ctl$ cat /tmp/of.logNXST_FLOW_MONITOR reply (xid=0x0): event=ADDED table=0 cookie=0 tcp,tp_dst=80# vm2: tcpdump -nn -c 1 -i eth0 arp21:19:39.949264 ARP, Request who-has 192.168.85.12 tell 192.168.85.11, length 28$ ovs-appctl -t /tmp/ofctl.ctl ofctl/send 0102000800000001sent$ ovs-appctl -t /tmp/ofctl.ctl exit[exit 0]$ ovs-appctl -t /tmp/ofctl.ctl ofctl/barrierovs-appctl: cannot connect to "/tmp/ofctl.ctl" (No such file or directory)65.7 ovs-appctl
- Talks to a running daemon over its control socket; the default target is ovs-vswitchd.
- -t ovsdb-server (or any socket) changes the target; -T 5 gives up after 5 s.
- list-commands showed 134 commands; fdb/show br0 is the MAC learning table.
ovs-appctl versionovs-appctl -t ovsdb-server versionovs-appctl -T 5 list-commands | head -4ovs-appctl list-commands | wc -lovs-appctl fdb/show br0$ ovs-appctl versionovs-vswitchd (Open vSwitch) 4.0.0$ ovs-appctl -t ovsdb-server versionovsdb-server (Open vSwitch) 4.0.0$ ovs-appctl -T 5 list-commands | head -4The available commands are: autoattach/show-isid [bridge] autoattach/statistics [bridge] autoattach/status [bridge]$ ovs-appctl list-commands | wc -l134$ ovs-appctl fdb/show br0 Port VLAN MAC Age 1 0 02:00:00:00:85:11 53 3 0 02:00:00:00:85:13 35 2 0 02:00:00:00:85:12 2965.8 Logging with vlog
- vlog/list shows console, syslog and file levels per module.
- vlog/set MODULE:DEST:LEVEL changes a level without restarting the daemon.
- Levels: off, emer, err, warn, info, dbg; run vlog/reopen after log rotation.
ovs-appctl vlog/list | grep -E '^(bridge|dpif|ofproto) 'ovs-appctl vlog/list-patternovs-appctl vlog/set bridge:file:dbgovs-appctl vlog/list | grep '^bridge 'ovs-appctl vlog/set bridge:file:infoovs-appctl vlog/reopen$ ovs-appctl vlog/list console syslog file ------- ------ ------backtrace OFF INFO INFObridge OFF INFO INFOdpif OFF INFO INFOofproto OFF INFO INFO$ ovs-appctl vlog/list-pattern prefix formatCONSOLE none %D{%Y-%m-%dT%H:%M:%SZ}|%05N|%c%T|%p|%mFILE none %D{%Y-%m-%dT%H:%M:%S.###Z}|%05N|%c%T|%p|%m$ ovs-appctl vlog/set bridge:file:dbg$ ovs-appctl vlog/list | grep '^bridge 'bridge OFF INFO DBG$ ovs-appctl vlog/reopen[exit 0]65.9 ovs-dpctl: datapath management
- dump-dps: one datapath system@ovs-system, created by ovs-vswitchd.
- show: lookups hit/missed and port numbers.
- add-dp / add-if built a practice datapath dp0 with dpa and dpb (port 5).
ovs-dpctl dump-dpsovs-dpctl showovs-dpctl add-dp dp0ovs-dpctl add-if dp0 dpaovs-dpctl add-if dp0 dpb,port_no=5ovs-dpctl show dp0$ ovs-dpctl dump-dpssystem@ovs-system$ ovs-dpctl showsystem@ovs-system: lookups: hit:4 missed:21 lost:0 flows: 4 masks: hit:35 total:3 hit/pkt:1.40 port 0: ovs-system (internal) port 1: br0 (internal) port 2: vm1-p port 3: vm2-p port 4: vm3-p$ ovs-dpctl show dp0system@dp0: lookups: hit:0 missed:0 lost:0 flows: 0 port 0: dp0 (internal) port 1: dpa port 5: dpb65.10 Datapath flow table
- dump-flows shows the cached megaflows (e.g. IPv4 from port 2 -> action 3, 5 packets).
- --names shows port names; filter=icmp shows matching flows; -m adds the ufid; get-flow fetches by ufid.
- On dp0: add-flow sent ARP from port 1 to port 5 and tcpdump on dpb's peer saw it; mod-flow changes action, --may-create adds, -s del-flow prints final stats.
- Never make manual flow changes on the vswitchd datapath; del-flows without a file deletes all cache flows.
ovs-dpctl dump-flowsovs-dpctl --names dump-flows filter=icmpovs-dpctl -m dump-flows filter=icmp | head -1ovs-dpctl get-flow ufid:2fc25d1d-d1a7-4329-a4bf-bd4fe9a74807$ ovs-dpctl dump-flowsrecirc_id(0),in_port(2),eth(src=02:00:00:00:85:11,dst=02:00:00:00:85:12),eth_type(0x0800),ipv4(frag=no), packets:5, bytes:490, used:1.864s, actions:3recirc_id(0),in_port(3),eth(src=02:00:00:00:85:12,dst=02:00:00:00:85:11),eth_type(0x0800),ipv4(frag=no), packets:5, bytes:490, used:1.864s, actions:2$ ovs-dpctl --names dump-flows filter=icmprecirc_id(0),in_port(vm1-p),eth(src=02:00:00:00:85:11,dst=02:00:00:00:85:12),eth_type(0x0800),ipv4(frag=no), packets:5, bytes:490, used:3.878s, actions:vm2-p$ ovs-dpctl get-flow ufid:2fc25d1d-d1a7-4329-a4bf-bd4fe9a74807recirc_id(0),in_port(2),eth(src=02:00:00:00:85:11,dst=02:00:00:00:85:12),eth_type(0x0800),ipv4(frag=no), packets:7, bytes:686, used:5.896s, actions:3ovs-dpctl add-flow dp0 'in_port(1),eth(),eth_type(0x0806),arp()' 5arping -c 2 -I dpax 192.168.85.99ovs-dpctl dump-flows dp0ovs-dpctl mod-flow dp0 'in_port(1),eth(),eth_type(0x0806),arp()' 1ovs-dpctl --may-create mod-flow dp0 'in_port(5),eth(),eth_type(0x0806),arp()' 1ovs-dpctl -s del-flow dp0 'in_port(1),eth(),eth_type(0x0806),arp()'ovs-dpctl del-if dp0 dpbovs-dpctl del-dp dp0$ arping -c 2 -I dpax 192.168.85.99Sent 2 probes (2 broadcast(s))# tcpdump -nn -c 2 -i dpbx arp21:20:52.854809 ARP, Request who-has 192.168.85.99 (ff:ff:ff:ff:ff:ff) tell 192.168.85.98, length 2821:20:53.854955 ARP, Request who-has 192.168.85.99 (ff:ff:ff:ff:ff:ff) tell 192.168.85.98, length 282 packets captured$ ovs-dpctl dump-flows dp0in_port(1),eth(),eth_type(0x0806), packets:2, bytes:84, used:9.712s, actions:5$ ovs-dpctl dump-flows dp0 (after mod-flow + --may-create)in_port(1),eth(),eth_type(0x0806), packets:2, bytes:84, used:13.320s, actions:1in_port(5),eth(),eth_type(0x0806), packets:0, bytes:0, used:never, actions:1$ ovs-dpctl -s del-flow dp0 'in_port(1),eth(),eth_type(0x0806),arp()'packets:2, bytes:84, used:14.872s$ ovs-dpctl del-if dp0 dpb; ovs-dpctl del-dp dp0; ovs-dpctl dump-dpssystem@ovs-system65.11 Flow cache and IP fragments
- cache-get-size: masks-cache default 256; cache-set-size changed it to 512.
- dpctl/ipf-* (fragment reassembly) works only on the userspace datapath: Not supported on the kernel datapath.
ovs-dpctl cache-get-sizeovs-dpctl cache-set-size system@ovs-system masks-cache 512ovs-dpctl cache-get-sizeovs-appctl dpctl/ipf-get-status$ ovs-dpctl cache-get-sizesystem@ovs-system: caches: masks-cache: size:256Setting cache size successful, new size 512$ ovs-dpctl cache-get-sizesystem@ovs-system: caches: masks-cache: size:512$ ovs-appctl dpctl/ipf-get-statusovs-vswitchd: ipf status could not be retrieved (Not supported)ovs-appctl: ovs-vswitchd: server returned an error65.12 Connection tracking
- ct(commit,zone=5) records every IP connection in zone 5.
- ct-set-limits caps a zone; dump-conntrack (-s adds timeouts); ct-stats-show; ct-get-limits shows the count.
- flush-conntrack with a tuple deletes only that entry (VM1's), VM2's stays.
- Several commands (ct-bkts, maxconns...) are userspace-only; the kernel shares its conntrack table with iptables/nftables.
- Step 1
1.br0 flow: ip,actions=ct(commit,zone=5),NORMAL
- Step 2
2.VM1 pings VM3: entry 1 created in zone 5
- Step 3
3.VM2 pings VM3: entry 2 created
- Step 4
4.ovs-dpctl dump-conntrack zone=5 shows both; ct-get-limits count=2
- Step 5
5.flush-conntrack with VM1's tuple removes only that entry
ovs-ofctl add-flow br0 ip,actions='ct(commit,zone=5),NORMAL'ovs-dpctl ct-set-limits default=100000 zone=5,limit=1000ovs-dpctl dump-conntrack zone=5ovs-dpctl -s dump-conntrack zone=5ovs-dpctl ct-stats-show zone=5ovs-dpctl ct-get-limits zone=5T=ct_nw_src=192.168.85.11T=$T,ct_nw_dst=192.168.85.13,ct_nw_proto=1T=$T,icmp_type=8,icmp_code=0,icmp_id=775ovs-dpctl flush-conntrack zone=5 "$T"ovs-dpctl dump-conntrack zone=5$ ovs-dpctl -s dump-conntrack zone=5icmp,orig=(src=192.168.85.12,dst=192.168.85.13,id=781,type=8,code=0),reply=(src=192.168.85.13,dst=192.168.85.12,id=781,type=0,code=0),zone=5,timeout=27icmp,orig=(src=192.168.85.11,dst=192.168.85.13,id=775,type=8,code=0),reply=(src=192.168.85.13,dst=192.168.85.11,id=775,type=0,code=0),zone=5,timeout=26$ ovs-dpctl ct-stats-show zone=5Connections Stats: Total: 2 ICMP: 2$ ovs-dpctl ct-get-limits zone=5default limit=100000zone=5,limit=1000,count=2$ ovs-dpctl flush-conntrack zone=5 "$T"[exit 0]$ ovs-dpctl dump-conntrack zone=5icmp,orig=(src=192.168.85.12,dst=192.168.85.13,id=781,type=8,code=0),reply=(src=192.168.85.13,dst=192.168.85.12,id=781,type=0,code=0),zone=5$ ovs-dpctl ct-bkts gt=0Command is available for UserSpace ConnTracker only.$ ovs-appctl dpctl/ct-get-maxconnsovs-vswitchd: maxconns could not be retrieved (Not supported)65.13 ovs-dpctl options
- --timeout=5: exit if not done in 5 s (scripts).
- -v maximum debug logging; --log-file also writes logs to a file; -h short help.
ovs-dpctl --timeout=5 dump-dpsovs-dpctl --log-file=/tmp/dpctl.log -v dump-dps >/dev/null 2>&1head -2 /tmp/dpctl.logovs-dpctl -h | head -3$ ovs-dpctl --timeout=5 dump-dpssystem@ovs-system$ head -2 /tmp/dpctl.log2026-11-08T21:21:43.684Z|00001|vlog|INFO|opened log file /tmp/dpctl.log2026-11-08T21:21:43.684Z|00002|hmap|DBG|lib/shash.c:114: 1 bucket with 6+ nodes, including 1 bucket with 7 nodes (64 nodes total across 64 buckets)$ ovs-dpctl -h | head -3ovs-dpctl: Open vSwitch datapath management utilityusage: ovs-dpctl [OPTIONS] COMMAND [ARG...] add-dp DP [IFACE...] add new datapath DP (with IFACEs)65.14 Common mistakes
- Thinking ovs-ofctl dump-flows and ovs-dpctl dump-flows show the same thing: ofctl = your OpenFlow rules; dpctl = kernel cache built by traffic, expires when idle.
- Editing rules with ovs-dpctl: always change rules with ovs-ofctl.
- Expecting userspace-only commands (ipf, ct-bkts) to work on the kernel datapath.
- Leaving debug logging on: set it back to info.
65.15 Interview tips
- Debugging an OVS packet path: ovs-ofctl dump-flows (rules + n_packets) -> ovs-appctl ofproto/trace (dry run) -> ovs-dpctl dump-flows (kernel cache) -> ovs-appctl vlog/set for debug logs.
- First packet = miss + upcall; the rest use the fast path.
- bundle = atomic multi-change (OpenFlow 1.4).
- ovs-appctl changes a live daemon (logs, fdb) without restart.