selftests: mptcp: add test for IPv6 subflow SLAB placement
Subsystems (4)
PATCH 1/1 selftests: mptcp: add test for IPv6 subflow SLAB placement
Add mptcp_v6_initcall.sh to verify that MPTCP IPv6 subflow child sockets are allocated from the TCPv6 SLAB cache, not the kmalloc-4k fallback.
tcpv6_prot_override must copy tcpv6_prot after proto_register(&tcpv6_prot) populates tcpv6_prot.slab. If the copy runs too early, override.slab stays NULL (frozen by __ro_after_init) and subflow children fall back to kmalloc-4k. This lacks SLAB_TYPESAFE_BY_RCU, allowing lockless ehash lookups in __inet_lookup_established to read freed memory.
The test exercises the IPv6 accept path via MPTCP connections between two network namespaces, then checks that the TCPv6 slab active object count grew. On a fixed kernel, the delta is ~2 * NR_CONNS (one subflow per side per connection); on a broken kernel, it stays near zero because children land in kmalloc-4k instead.
Topology: two netns connected via veth pair with /64 ULA addresses; NR_CONNS parallel short-lived MPTCP connections are established and held open long enough to sample /proc/slabinfo. The test skips if CONFIG_MPTCP_IPV6 is absent (checked via kallsyms) or /proc/slabinfo is unreadable.
Verified on Ubuntu 6.17 kernel predating the fix: TAP "not ok 1 ... TCPv6 slab gains MPTCPv6 subflow children" with delta=0. On kernels with the fix, delta is well above the threshold of NR_CONNS/2.
--- tools/testing/selftests/net/mptcp/Makefile | 1 + .../selftests/net/mptcp/mptcp_v6_initcall.sh | 140 ++++++++++++++++++ 2 files changed, 141 insertions(+) create mode 100644 tools/testing/selftests/net/mptcp/mptcp_v6_initcall.sh
tools/testing/selftests/net/mptcp/Makefile +1 -0
@@ -14,6 +14,7 @@ TEST_PROGS := \ mptcp_connect_splice.sh \ mptcp_join.sh \ mptcp_sockopt.sh \ + mptcp_v6_initcall.sh \ pm_netlink.sh \ simult_flows.sh \ userspace_pm.sh \
tools/testing/selftests/net/mptcp/mptcp_v6_initcall.sh new file +140 -0
140 lines not on this page · raw message
Signature · 1 line
2.51.0