Skip to contentSkip to conversation

selftests: rds: ROCE support follow ups

PATCH Superseded Allison Henderson 2 participants 8 messages May 27 – Jun 2

Subsystems (5)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Allison Henderson

author maintainer
#0 lore raw

v2 cover selftests: rds: ROCE support follow ups

Hi all,

This is a follow up series to the "Add ROCE support to rds selftests" series. The first patch renames run.sh to rds_run.sh, which provides a self-describing name that appears on the netdev CI dashboard.

The second patch addresses a sashiko complaint that I thought was worth circling back for. In the patch "pin RDS sockets to their intended transport," sockets are pinned to the specific transport they are meant to test. By default, socket transports are implicitly selected based on the network topology, but it is possible that they can fail back to other transports if the underlying connection could not be established. So the patch pins them to the intended transport to avoid false positives.

The third patch "support RDS built as loadable modules," lifts the CONFIG_MODULES=n requirement, and updates the check_*conf_enabled() to allow modules set to "=m" and further load the backing modules for any component set as such.

The fourth patch converts the rdma-prerequisite checks to return XFAIL rather than SKIP, since the RDMA datapath is not run in netdev CI.

Questions, comments and feedback appreciated!

Thanks everyone!
Allison

Change log:
v2:
[PATCH net-next v1 1/3] selftests: rds: add per-transport run wrappers
- Renamed to "selftests: rds: Rename run.sh to rds_run.sh"
- Removed rds_*_run.sh wrappers

[PATCH net-next v1 3/3] selftests: rds: support RDS built as loadable modules
- Fixed long line length warning

[PATCH net-next v2 4/4] selftests: rds: report missing RDMA prereqs as XFAIL
- NEW

Allison Henderson (4):
selftests: rds: Rename run.sh to rds_run.sh
selftests: rds: pin RDS sockets to their intended transport
selftests: rds: support RDS built as loadable modules
selftests: rds: report missing RDMA prereqs as XFAIL

 tools/testing/selftests/net/rds/Makefile      |  2 +-
 tools/testing/selftests/net/rds/README.txt    |  8 +--
 tools/testing/selftests/net/rds/config        |  1 -
 .../selftests/net/rds/{run.sh => rds_run.sh}  | 72 ++++++++++++-------
 tools/testing/selftests/net/rds/test.py       | 18 +++++
 5 files changed, 69 insertions(+), 32 deletions(-)
 rename tools/testing/selftests/net/rds/{run.sh => rds_run.sh} (78%)
Signature · 1 line
2.25.1
author maintainer
#1 lore raw

PATCH v2 1/4 selftests: rds: Rename run.sh to rds_run.sh

This patch renames run.sh to rds_run.sh. This gives the test a self-describing name that appears in the netdev CI dashboard.

---
 tools/testing/selftests/net/rds/Makefile               | 2 +-
 tools/testing/selftests/net/rds/README.txt             | 8 ++++----
 tools/testing/selftests/net/rds/{run.sh => rds_run.sh} | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)
tools/testing/selftests/net/rds/Makefile +1 -1
index fe363be8e3586..ec10ae24e4cf1 100644
@@ -3,7 +3,7 @@
 all:
 	@echo mk_build_dir="$(shell pwd)" > include.sh
 
-TEST_PROGS := run.sh
+TEST_PROGS := rds_run.sh
 
 TEST_FILES := \
 	include.sh \
tools/testing/selftests/net/rds/README.txt +4 -4
index bac6f15a80d52..8aa41148b1b5c 100644
@@ -14,9 +14,9 @@ configs required for the RDMA transport.  The kernel may optionally be
 configured to omit the coverage report as well.
 
 USAGE:
-	run.sh [-d logdir] [-l packet_loss] [-c packet_corruption]
-	       [-u packet_duplicate] [-t timeout]
-	       [-T tcp|rdma|tcp,rdma]
+	rds_run.sh [-d logdir] [-l packet_loss] [-c packet_corruption]
+	           [-u packet_duplicate] [-t timeout]
+	           [-T tcp|rdma|tcp,rdma]
 
 OPTIONS:
 	-d	Log directory.  If set, logs will be stored in the
@@ -73,5 +73,5 @@ EXAMPLE:
         "export PYTHONPATH=tools/testing/selftests/net/; \
          export SUDO_USER=example_user; \
          export RDS_LOG_DIR=tools/testing/selftests/net/rds/rds_logs; \
-         tools/testing/selftests/net/rds/run.sh -T tcp,rdma"
+         tools/testing/selftests/net/rds/rds_run.sh -T tcp,rdma"
 
tools/testing/selftests/net/rds/rds_run.sh renamed from tools/testing/selftests/net/rds/run.sh +2 -2
similarity index 98%
rename from tools/testing/selftests/net/rds/run.sh
rename to tools/testing/selftests/net/rds/rds_run.sh
index 07af2f927a2a7..ef16039be1ae5 100755
@@ -209,7 +209,7 @@ while getopts "d:l:c:u:t:T:" opt; do
       TRANSPORT=${OPTARG}
       ;;
     :)
-      echo "USAGE: run.sh [-d logdir] [-l packet_loss] [-c packet_corruption]" \
+      echo "USAGE: rds_run.sh [-d logdir] [-l packet_loss] [-c packet_corruption]" \
            "[-u packet_duplicate] [-t timeout] [-T tcp|rdma|tcp,rdma]"
       exit 1
       ;;
@@ -224,7 +224,7 @@ done
 IFS=',' read -ra transports <<< "$TRANSPORT"
 for t in "${transports[@]}"; do
     if [ "$t" != "tcp" ] && [ "$t" != "rdma" ]; then
-        echo "run.sh: unknown transport '$t' (expected tcp or rdma)"
+        echo "rds_run.sh: unknown transport '$t' (expected tcp or rdma)"
         exit 1
     fi
 done
Signature · 1 line
2.25.1
author maintainer
#2 lore raw

PATCH v2 2/4 selftests: rds: pin RDS sockets to their intended transport

In reply to Allison Henderson

The RDS selftests create AF_RDS sockets but never selects a transport, so the transport is chosen implicitly based on network topology when the socket is bound. If underlying connection establishment fails, RDS can fall back to another transport (e.g. loopback) and the test still passes, silently bypassing the intended datapath it is meant to exercise.

Set SO_RDS_TRANSPORT to the proper RDS_TRANS_IB or RDS_TRANS_TCP before they are bound, so the test fails loudly if the intended transport is unavailable rather than passing on a different path.

---
 tools/testing/selftests/net/rds/test.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
tools/testing/selftests/net/rds/test.py +18 -0
index 08f2a846a8ab5..9e4df01cb0d4b 100755
@@ -59,6 +59,14 @@ rdma_addrs = [
 OP_FLAG_TCP     = 0x1
 OP_FLAG_RDMA    = 0x2
 
+# from include/uapi/linux/rds.h: SO_RDS_TRANSPORT pins a socket to a
+# specific RDS transport so connection setup cannot silently fall back
+# to another (e.g. loopback) transport.
+SOL_RDS          = 276
+SO_RDS_TRANSPORT = 8
+RDS_TRANS_TCP    = 2
+RDS_TRANS_IB     = 0
+
 signal_handler_label = ""
 
 tap_idx = 0
@@ -214,11 +222,21 @@ def snd_rcv_packets(env):
             netns_socket(netns_list[0], socket.AF_RDS, socket.SOCK_SEQPACKET),
             netns_socket(netns_list[1], socket.AF_RDS, socket.SOCK_SEQPACKET),
         ]
+
+        # Pin the sockets to the TCP transport so it doesn't fail over to a
+        # different transport during this test
+        for s in sockets:
+            s.setsockopt(SOL_RDS, SO_RDS_TRANSPORT, RDS_TRANS_TCP)
     elif flags & OP_FLAG_RDMA:
         sockets = [
             socket.socket(socket.AF_RDS, socket.SOCK_SEQPACKET),
             socket.socket(socket.AF_RDS, socket.SOCK_SEQPACKET),
         ]
+
+        # Pin the sockets to the RDMA transport so it doesn't fail over to a
+        # different transport during this test
+        for s in sockets:
+            s.setsockopt(SOL_RDS, SO_RDS_TRANSPORT, RDS_TRANS_IB)
     else:
         raise RuntimeError(f"Invalid transport flag sets no transports: {flags}")
 
Signature · 1 line
2.25.1
author maintainer
#3 lore raw

PATCH v2 3/4 selftests: rds: support RDS built as loadable modules

In reply to Allison Henderson

Commit 92cc6708f4a2 ("selftests: rds: config: disable modules") set CONFIG_MODULES=n since run.sh required this kconfig. But disabling modules also forces every =m option to =n rather than =y, which can silently drop unrelated features.

This patch removes CONFIG_MODULES=n from the rds selftest config and updates the check_*conf_enabled() routines to accept a config as either built-in (=y) or modular (=m). A new probe_module() function is added to load the backing module when a component is set to be modular (=m).

rds.ko itself is auto-loaded on socket creation, and rds_rdma.ko is auto-loaded when SO_RDS_TRANSPORT is set with RDS_TRANS_IB, but the TCP transport (rds_tcp.ko) is not auto-loaded on the bind path, so the backing modules are loaded explicitly here.

---
 tools/testing/selftests/net/rds/config     |  1 -
 tools/testing/selftests/net/rds/rds_run.sh | 60 ++++++++++++++--------
 2 files changed, 40 insertions(+), 21 deletions(-)
tools/testing/selftests/net/rds/config +0 -1
index 3d62d0c750a80..97db7ecb892aa 100644
@@ -1,4 +1,3 @@
-CONFIG_MODULES=n
 CONFIG_NET_NS=y
 CONFIG_NET_SCH_NETEM=y
 CONFIG_RDS=y
tools/testing/selftests/net/rds/rds_run.sh +40 -20

86 lines not on this page · raw message

Signature · 1 line
2.25.1
author maintainer
#5 lore raw

PATCH v2 4/4 selftests: rds: report missing RDMA prereqs as XFAIL

In reply to Allison Henderson

Make the RDMA test return XFAIL rather than skip when RXE is not available, since the RDMA datapath is not run in netdev CI.

Change the three RDMA-prerequisite checks in check_rdma_conf() and check_rdma_conf_enabled() to exit with the XFAIL code (5) and tag their messages [XFAIL] instead of [SKIP].

---
 tools/testing/selftests/net/rds/rds_run.sh | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
tools/testing/selftests/net/rds/rds_run.sh +6 -6
index c16b30dbdd169..ba957a2257c91 100755
@@ -123,10 +123,10 @@ check_rdma_conf_enabled() {
 		probe_module "$2"
 		return
 	fi
-	echo "selftests: [SKIP] rdma transport requires $1 enabled"
+	echo "selftests: [XFAIL] rdma transport requires $1 enabled"
 	echo "To enable, run" \
 	     "tools/testing/selftests/net/rds/config.sh -r and rebuild"
-	exit 4
+	exit 5
 }
 
 # Load the module backing a config that is built as a loadable module
@@ -148,7 +148,7 @@ check_conf() {
 }
 
 # Check kernel config and host environment for RDS-RDMA support.
-# Exits with SKIP (4) if the user requested rdma but prerequisites
+# Exits with XFAIL (5) if the user requested rdma but prerequisites
 # are not met.
 check_rdma_conf()
 {
@@ -163,9 +163,9 @@ check_rdma_conf()
 	check_rdma_conf_enabled CONFIG_RDS_RDMA rds_rdma
 
 	if ! which rdma > /dev/null 2>&1; then
-		echo "selftests: [SKIP] rdma transport requires the 'rdma'" \
-		      " tool (iproute2)"
-		exit 4
+		echo "selftests: [XFAIL] rdma transport requires the 'rdma'" \
+		      "tool (iproute2)"
+		exit 5
 	fi
 }
 
Signature · 1 line
2.25.1
maintainer
#4 lore raw

Re: [PATCH net-next v2 3/4] selftests: rds: support RDS built as loadable modules

In reply to Allison Henderson

This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible.
---
selftests: rds: support RDS built as loadable modules

This commit removes CONFIG_MODULES=n from the rds selftest config to prevent unrelated features from being silently dropped. It updates the configuration check routines to accept options built as either modules or built-in, and adds support for probing the backing modules.

Quoted 4 lines
tools/testing/selftests/net/rds/rds_run.sh +0 -0
index ef16039be1ae5..c16b30dbdd169 100755

[ ... ]

Quoted 17 lines
tools/testing/selftests/net/rds/rds_run.sh +7 -4
@@ -93,38 +93,58 @@ check_gcov_conf()
 	fi
 }
 
+# Checks if a kconfig is enabled (set to =y or =m)
+# $1: kconfig symbol to check
+# $2: (optional) module name backing $1
+#     Ex: check_conf_enabled CONFIG_RDS_TCP rds_tcp
+#     Modules for configs set to  =m will be probed
+#     If omitted, only a built-in (=y) config is accepted.
+# Returns on success.  exits 4 on failure
 # Kselftest framework requirement - SKIP code is 4.
 check_conf_enabled() {
-	if ! grep -x "$1=y" "$kconfig" > /dev/null 2>&1; then
-		echo "selftests: [SKIP] This test requires $1 enabled"
-		echo "Please run tools/testing/selftests/net/rds/config.sh and rebuild the kernel"
-		exit 4

tools/testing/selftests/net/rds/rds_run.sh check_gcov_conf() · line 114

Quoted 10 lines
tools/testing/selftests/net/rds/rds_run.sh +9 -0
+	if grep -x "$1=y" "$kconfig" > /dev/null 2>&1; then
+		return
 	fi
+	if [ -n "${2:-}" ] && grep -x "$1=m" "$kconfig" > /dev/null 2>&1; then
+		probe_module "$2"
+		return
+	fi
+	echo "selftests: [SKIP] This test requires $1 enabled"
+	echo "Please run" \
+	     "tools/testing/selftests/net/rds/config.sh and rebuild the kernel"

[Severity: Medium]
Should tools/testing/selftests/net/rds/config.sh also be updated to reflect the new module support?

If a user follows these instructions to run config.sh for missing dependencies, that script still explicitly disables CONFIG_MODULES via scripts/config --disable CONFIG_MODULES.

Could this undermine the goal of this patch by forcefully disabling modules in the user's kernel configuration anyway?

Quoted 2 lines
tools/testing/selftests/net/rds/rds_run.sh +1 -0
+	exit 4
 }
maintainer
#6 lore raw

Re: [PATCH net-next v2 4/4] selftests: rds: report missing RDMA prereqs as XFAIL

In reply to Allison Henderson

This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible.
---
selftests: rds: report missing RDMA prereqs as XFAIL

This commit changes the exit code and message tag for RDMA prerequisites in the RDS selftests to report as an expected failure instead of a skip.

tools/testing/selftests/net/rds/rds_run.sh check_rdma_conf_enabled() { · line 129

Quoted 13 lines
tools/testing/selftests/net/rds/rds_run.sh +2 -2
@@ -123,10 +123,10 @@ check_rdma_conf_enabled() {
 		probe_module "$2"
 		return
 	fi
-	echo "selftests: [SKIP] rdma transport requires $1 enabled"
+	echo "selftests: [XFAIL] rdma transport requires $1 enabled"
 	echo "To enable, run" \
 	     "tools/testing/selftests/net/rds/config.sh -r and rebuild"
-	exit 4
+	exit 5

[Severity: High]
Is exit code 5 the correct value for an expected failure in the kselftest framework?

Looking at the kselftest framework in tools/testing/selftests/kselftest.h and ktap_helpers.sh, the expected failure code (KSFT_XFAIL) is defined as 2.

When runner.sh receives an exit code of 5, it does not match KSFT_XFAIL. Instead, it falls through to the default case and calls ktap_test_fail, which logs a hard test failure.

Could this actively fail the test in the continuous integration environments rather than marking it as an expected failure?

[ ... ]

author maintainer
#7 lore raw

Re: [PATCH net-next v2 4/4] selftests: rds: report missing RDMA prereqs as XFAIL

Quoted 29 lines · Jakub Kicinski

This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible.
---
selftests: rds: report missing RDMA prereqs as XFAIL

This commit changes the exit code and message tag for RDMA prerequisites in the RDS selftests to report as an expected failure instead of a skip.

tools/testing/selftests/net/rds/rds_run.sh check_rdma_conf_enabled() { · line 129

Quoted 13 lines
tools/testing/selftests/net/rds/rds_run.sh +2 -2
@@ -123,10 +123,10 @@ check_rdma_conf_enabled() {
 		probe_module "$2"
 		return
 	fi
-	echo "selftests: [SKIP] rdma transport requires $1 enabled"
+	echo "selftests: [XFAIL] rdma transport requires $1 enabled"
 	echo "To enable, run" \
 	     "tools/testing/selftests/net/rds/config.sh -r and rebuild"
-	exit 4
+	exit 5

[Severity: High]
Is exit code 5 the correct value for an expected failure in the kselftest framework?

Looking at the kselftest framework in tools/testing/selftests/kselftest.h and ktap_helpers.sh, the expected failure code (KSFT_XFAIL) is defined as 2.

Quoted 6 lines

When runner.sh receives an exit code of 5, it does not match KSFT_XFAIL. Instead, it falls through to the default case and calls ktap_test_fail, which logs a hard test failure.

Could this actively fail the test in the continuous integration environments rather than marking it as an expected failure?

You're right its 2, good catch. I will fix that and config.sh in a v3. Thanks! Allison

Quoted 2 lines

[ ... ]