selftests/net/openvswitch: add SCTP flow key support and test
Subsystems (4)
PATCH v9 1/1 selftests/net/openvswitch: add SCTP flow key support and test
The ovskey flow-string parser has no OVS_KEY_ATTR_SCTP entry, so a flow string containing sctp(src=.../dst=...) parses without error but silently drops the L4 key. The resulting flow carries only ipv4(proto=132), and the kernel rejects it: match_validate() in flow_netlink.c requires OVS_KEY_ATTR_SCTP when the IP protocol is IPPROTO_SCTP and returns -EINVAL for the missing key.
Register OVS_KEY_ATTR_SCTP in the parse table and add a matching selftest that verifies SCTP flow key matching (sctp src/dst port).
One listener serves the whole test. socat's fork option handles each association in a child, so the flow rules are the only thing that changes between the three phases and the listener is never restarted underneath them.
A forking daemon outlives the pid ovs_netns_spawn_daemon captures, because the child handling an association is not signalled when only that pid is killed. Start spawned daemons in their own session so each leads its own process group, and signal the group on cleanup. setsid ships in util-linux-core; selftests/vsock/vmtest.sh already calls it unconditionally in this same tree, so this isn't a new class of dependency for a kselftest shell script.
Also enable CONFIG_IP_SCTP in the selftest kernel config. The config checker strips underscores before comparing keys, so the entry sorts before CONFIG_IPV6 rather than after it.
---
v9:
- one forking listener for the whole test instead of restarting it between phases (Aaron)
- signal the daemon's process group on cleanup so the children a forking listener leaves behind are reaped
- sort CONFIG_IP_SCTP the way the config checker compares keys
One property of the test worth stating, found by removing the parse-table hunk and re-running. The probe at the top of test_sctp_connect_v4 adds a flow with an sctp() key and skips when that fails. A parser that drops the key gives the same -EINVAL as a kernel without SCTP flow key support, so a missing parse-table entry makes this test skip rather than fail: v5 dropped the ovs-dpctl.py hunk while keeping the test, and that gap is exactly why the loss did not show up as a failure. dec_ttl, icmpv6, psample and drop_reason probe the same way, so I kept the pattern rather than diverge from them here.
v8: https://lore.kernel.org/netdev/[email protected]/
v7: https://lore.kernel.org/netdev/[email protected]/
v6: https://lore.kernel.org/netdev/[email protected]/
v5: https://lore.kernel.org/netdev/[email protected]/
v4: https://lore.kernel.org/netdev/[email protected]/
v3: https://lore.kernel.org/netdev/[email protected]/
v2: https://lore.kernel.org/netdev/[email protected]/
v1: https://lore.kernel.org/netdev/[email protected]/
--- .../testing/selftests/net/openvswitch/config | 1 + .../selftests/net/openvswitch/openvswitch.sh | 110 +++++++++++++++++- .../selftests/net/openvswitch/ovs-dpctl.py | 5 + 3 files changed, 113 insertions(+), 3 deletions(-)
tools/testing/selftests/net/openvswitch/config +1 -0
@@ -1,5 +1,6 @@ CONFIG_GENEVE=m CONFIG_INET_DIAG=y +CONFIG_IP_SCTP=y CONFIG_IPV6=y CONFIG_NETFILTER=y CONFIG_NET_IPGRE=m
tools/testing/selftests/net/openvswitch/openvswitch.sh +107 -3
132 lines not on this page · raw message
tools/testing/selftests/net/openvswitch/ovs-dpctl.py +5 -0
@@ -1984,6 +1984,11 @@ class ovskey(nla): "udp", ovskey.ovs_key_udp, ), + ( + "OVS_KEY_ATTR_SCTP", + "sctp", + ovskey.ovs_key_sctp, + ), ( "OVS_KEY_ATTR_ICMP", "icmp",
Signature · 1 line
2.55.0
Jakub Kicinski
maintainerQuoted 5 lines · On Tue, 4 Aug 2026 23:44:59 -0400 Minxi Hou wrote:
One listener serves the whole test. socat's fork option handles each association in a child, so the flow rules are the only thing that changes between the three phases and the listener is never restarted underneath them.
Quoted 7 lines
A forking daemon outlives the pid
ovs_netns_spawn_daemoncaptures, because the child handling an association is not signalled when only that pid is killed. Start spawned daemons in their own session so each leads its own process group, and signal the group on cleanup. setsid ships in util-linux-core;selftests/vsock/vmtest.shalready calls it unconditionally in this same tree, so this isn't a new class of dependency for a kselftest shell script.
Did someone request this? It seems like an overkill just to make sure socat has exited, no? There's plenty of socat *,fork use in selftests without setsid. Maybe just set -T/-t to make sure the children exit in reasonable time?
tools/testing/selftests/net/openvswitch/openvswitch.sh test_icmpv6() { · line 653
Quoted 5 lines
tools/testing/selftests/net/openvswitch/openvswitch.sh +5
-0+ # Probe: check if kernel supports sctp flow key. + ovs_add_flow "$t" sctp4 \ + 'in_port(1),eth(),eth_type(0x0800),ipv4(proto=132),sctp(dst=4443)' \ + '2' &>/dev/null + if [ $? -ne 0 ]; then
AI says this is pointless, SCTP support is always built into ovs. Please drop unless some human explicitly asked for this.
Quoted 4 lines
tools/testing/selftests/net/openvswitch/openvswitch.sh +4
-0+ info "no support for sctp key - skipping" + ovs_exit_sig + return $ksft_skip + fi
Signature · 1 line
pw-bot: cr