From: Allison Henderson <achender@kernel.org>
To: netdev@vger.kernel.org, pabeni@redhat.com, edumazet@google.com,
kuba@kernel.org, horms@kernel.org, linux-rdma@vger.kernel.org,
achender@kernel.org, linux-kselftest@vger.kernel.org,
shuah@kernel.org
Subject: [PATCH net-next v1 2/3] selftests: rds: pin RDS sockets to their intended transport
Date: Fri, 22 May 2026 14:54:29 -0700 [thread overview]
Message-ID: <20260522215430.3748226-3-achender@kernel.org> (raw)
In-Reply-To: <20260522215430.3748226-1-achender@kernel.org>
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.
Signed-off-by: Allison Henderson <achender@kernel.org>
---
tools/testing/selftests/net/rds/test.py | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/tools/testing/selftests/net/rds/test.py b/tools/testing/selftests/net/rds/test.py
index 08f2a846a8ab5..9e4df01cb0d4b 100755
--- a/tools/testing/selftests/net/rds/test.py
+++ b/tools/testing/selftests/net/rds/test.py
@@ -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}")
--
2.25.1
next prev parent reply other threads:[~2026-05-22 21:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-22 21:54 [PATCH net-next v1 0/3] selftests: rds: ROCE support follow ups Allison Henderson
2026-05-22 21:54 ` [PATCH net-next v1 1/3] selftests: rds: add per-transport run wrappers Allison Henderson
2026-05-22 21:54 ` Allison Henderson [this message]
2026-05-22 21:54 ` [PATCH net-next v1 3/3] selftests: rds: support RDS built as loadable modules Allison Henderson
2026-05-23 0:46 ` [PATCH net-next v1 0/3] selftests: rds: ROCE support follow ups Jakub Kicinski
2026-05-23 1:19 ` Allison Henderson
2026-05-23 2:14 ` Jakub Kicinski
2026-05-23 2:26 ` Allison Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260522215430.3748226-3-achender@kernel.org \
--to=achender@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox