From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=144.76.82.148 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796391295; b=5EDyEnhZyhbZf/emr4clg7+hH70b1q7RzjYW6WPPMVfoK3h+l+j985qS6HmUforHtp/7 zRq0l73tV/tWQKDGb/c+WwUBPPJnAT2e8onqvoMxwAeB7Rzy+vNcquKBzk9zLx2PXfz4y 1CEp8AbpAU5gzfffhj5BoWeXaDMyPZGvz+ORWsq7pJRmt389fTb/sTNwQKUUfni69Jjvq xw2g0tzppH4E039FsxQ7Jzu1job/LmDlagwOFe6IfX9y/kQVqLKkPulk50K5QwNGnwxiX x5Q1U91C3M+0rrUYxd9CK9GOR1KQjg1qfQDKnVnR9nuFfXRILdsV6dW3s0cp/yu6DeA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796391295; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=xtbPFkmYBxgv676LYkVPGI+ikQVQ3gtsTSsZAfj331U=; b=B24SIhFBi9VnHMA+3TlwxktDptBBS93fohMBjW5BMeXEWQk/gQZGs56zm1PqmIdjMeoU blKHjLP+GCWY6wF3nTHJU6BS3friB9ZX14MwRfNIyoHjQg7HH+pbl5O5Byd7e5fbbVU4G RLNPHnwOp8jOE6iEsChmAPNwFKosq7yOydcOjP/mV0i+pGnOSjb4bTKX6YOfeaylj3YjG MVyvstQlAdqfPZBUK7kg2fPxypSaXdcmFDFrmTE9I19qdaKiMSkrtZ94JU7OBMoaU00PN kvnBn76vPEZdmIES9YhI33XJBSaJD0bthXRXvaawMl2DtUirwbk0vSDzJfv2Kt7swHQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=samba.org; spf=pass smtp.mailfrom=samba.org; dkim=pass header.d=samba.org header.i=@samba.org header.a=rsa-sha256 header.s=42 header.b=i8NCSHkb; arc=none smtp.remote-ip=144.76.82.148 Received: from hr2.samba.org (hr2.samba.org [144.76.82.148]) (using TLSv1.3 with cipher TLS_CHACHA20_POLY1305_SHA256 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B222606A32F; Fri, 4 Dec 2026 13:34:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9B222606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=samba.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samba.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (3072-bit key) header.d=samba.org header.i=@samba.org header.a=rsa-sha256 header.s=42 header.b=i8NCSHkb DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org; s=42; h=Message-ID:Date:Cc:To:From; bh=xtbPFkmYBxgv676LYkVPGI+ikQVQ3gtsTSsZAfj331U=; b=i8NCSHkbQd28g0KrMWVB9QyCF8 uAOnmSIpVFoMdKxdRWOk2PXvDM6g0dvoGf7YkRLe4pD7HUD8/2A53tq21viJkXTO5fzeTBQTr5oQ5 8zWy80Wp8i9Nnwuq6ja9kpnKB+sPQNxNXo+jawy7HiFxkbtvssDFdlzJfIJSKaiqKUtCvCU4nzDCT Ac4R4SalkEdR/sltaqKP8BAZsMLtsjTg5/QNZicz3MC/BoQk9fQuXwJWFcBvvfoPcf6MBxfPrhIoh rl50wu73EENPYicuM/tCGZxcSkewxrUGq0lhED3xrW0cMn957Bp4GT2O1cZrHZJWv7FlgnaIhwvOt rlLIlIuOrQOd0PeNmI0d6L2fSa0slcklE48MMi8YMENKE7Yn4OOkpDowtTzTboTuitoQfubevbGfW qQLwDAbvPxmcjuhoF3iyjzYodT2k96Rj3eRa2MFWd0thUBb/nsUqxKwcVqYbY9YjvGSDF+ZjzYOay eo4k+XcRN+gLlUpiRPaUjA/1; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_SECP256R1__ECDSA_SECP256R1_SHA256__CHACHA20_POLY1305:256) (Exim) id 1xZTR3-00000000IGY-2b7B; Fri, 04 Dec 2026 13:34:50 +0000 From: Stefan Metzmacher To: linux-cifs@vger.kernel.org, samba-technical@lists.samba.org Cc: metze@samba.org, stable@vger.kernel.org, Paulo Alcantara , Namjae Jeon , Ronnie Sahlberg , Shyam Prasad N , Tom Talpey , Bharath SM , 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 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Cc: Namjae Jeon Cc: Ronnie Sahlberg Cc: Shyam Prasad N Cc: Tom Talpey Cc: Bharath SM Cc: linux-cifs@vger.kernel.org Cc: samba-technical@lists.samba.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Stefan Metzmacher --- 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