From: Stefan Metzmacher <metze@samba.org>
To: linux-cifs@vger.kernel.org, samba-technical@lists.samba.org
Cc: metze@samba.org, stable@vger.kernel.org,
Paulo Alcantara <pc@manguebit.org>,
Namjae Jeon <linkinjeon@kernel.org>,
Ronnie Sahlberg <ronniesahlberg@gmail.com>,
Shyam Prasad N <sprasad@microsoft.com>,
Tom Talpey <tom@talpey.com>, Bharath SM <bharathsm@microsoft.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 11/12] smb: client: let SMB Direct connections use the srcaddr= mount option
Date: Fri, 4 Dec 2026 14:33:36 +0100 [thread overview]
Message-ID: <c19a52be413b3f68510107973a9e3abe71c99148.1796391093.git.metze@samba.org> (raw)
In-Reply-To: <cover.1796391093.git.metze@samba.org>
The TCP connect binds the socket to the local address given with the
srcaddr= mount option in bind_socket(), but SMB Direct ignored it, so
rdma_resolve_addr() picked the source address and with it the RDMA
device from the routing table.
Bind the smbdirect socket to srcaddr before connecting, so that
rdma_resolve_addr() uses it. rdma_bind_addr() fails if it isn't a
local address (anymore), like the bind() of the TCP connect, or if
there is no RDMA device for it, and smbdirect_connect() fails with
-EAFNOSUPPORT if it has another family than the server address, since
the previous patch.
Note that this changes the behavior of existing mounts with rdma and
a srcaddr= that has no RDMA device, e.g. an address of another NIC:
they connected before, as srcaddr= was ignored, now they fail with
-ENODEV. As such a srcaddr= never had an effect, this should be rare.
This also lets the following patch, which checks whether there is a
usable route to the server with the source address after a reconnect
attempt failed, look at the address actually used for SMB Direct.
Fixes: 2f8946464b11 ("CIFS: SMBD: Upper layer connects to SMBDirect session")
Cc: stable@vger.kernel.org
Cc: Paulo Alcantara <pc@manguebit.org>
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Cc: Shyam Prasad N <sprasad@microsoft.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Bharath SM <bharathsm@microsoft.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
---
fs/smb/client/smbdirect.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/fs/smb/client/smbdirect.c b/fs/smb/client/smbdirect.c
index 5cc199fca558..bb2ffb1601c5 100644
--- a/fs/smb/client/smbdirect.c
+++ b/fs/smb/client/smbdirect.c
@@ -343,6 +343,21 @@ static struct smbd_connection *_smbd_get_connection(
*sport = htons(port);
+ /*
+ * Use the local address given with the srcaddr= mount option,
+ * like the TCP connect in bind_socket(). rdma_bind_addr() fails
+ * if it's not a local address (anymore).
+ */
+ if (server->srcaddr.ss_family != AF_UNSPEC) {
+ ret = smbdirect_socket_bind(sc,
+ (struct sockaddr *)&server->srcaddr);
+ if (ret) {
+ log_rdma_event(ERR, "bind to %pISpsfc failed: %1pe\n",
+ &server->srcaddr, ERR_PTR(ret));
+ goto bind_failed;
+ }
+ }
+
ret = smbdirect_connect_sync(sc, dstaddr);
if (ret) {
log_rdma_event(ERR, "connect to %pISpsfc failed: %1pe\n",
@@ -354,6 +369,7 @@ static struct smbd_connection *_smbd_get_connection(
return info;
connect_failed:
+bind_failed:
set_settings_failed:
set_params_failed:
smbdirect_socket_release(sc);
--
2.43.0
next prev parent reply other threads:[~2026-12-04 13:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 13:33 [PATCH 0/12] smb: client: don't sleep through reconnects and umount Stefan Metzmacher
2026-12-04 13:33 ` [PATCH v2 01/12] smb: client: don't add a decrypted mid back to an exiting server Stefan Metzmacher
2026-12-04 13:33 ` [PATCH v2 02/12] smb: client: use kref for the TCP_Server_Info object references Stefan Metzmacher
2026-12-04 13:33 ` [PATCH v2 03/12] smb: client: let in-flight requests hold a TCP_Server_Info reference Stefan Metzmacher
2026-12-04 13:33 ` [PATCH v2 04/12] smb: client: let the decrypt offload work " Stefan Metzmacher
2026-12-04 13:33 ` [PATCH v2 05/12] smb: client: let channels hold a reference of the primary server struct Stefan Metzmacher
2026-12-04 13:33 ` [PATCH v2 06/12] smb: client: stop waiting between reconnect attempts once the server exits Stefan Metzmacher
2026-12-04 13:33 ` [PATCH v2 07/12] smb: client: wait for pending mids instead of sleeping 46 seconds Stefan Metzmacher
2026-12-04 13:33 ` [PATCH v2 08/12] smb: client: add cifs_server_wait_for_exit_ms() Stefan Metzmacher
2026-12-04 13:33 ` [PATCH v2 09/12] smb: client: use cifs_server_wait_for_exit_ms() for the replay back-off Stefan Metzmacher
2026-12-04 13:33 ` [PATCH v2 10/12] smb: smbdirect: fail a connect from another address family Stefan Metzmacher
2026-12-04 13:33 ` Stefan Metzmacher [this message]
2026-12-04 13:33 ` [PATCH v2 12/12] smb: client: soft mounts only wait until a reconnect attempt failed locally Stefan Metzmacher
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=c19a52be413b3f68510107973a9e3abe71c99148.1796391093.git.metze@samba.org \
--to=metze@samba.org \
--cc=bharathsm@microsoft.com \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pc@manguebit.org \
--cc=ronniesahlberg@gmail.com \
--cc=samba-technical@lists.samba.org \
--cc=sprasad@microsoft.com \
--cc=stable@vger.kernel.org \
--cc=tom@talpey.com \
/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
all inboxes | Powered by JetHome®