diff options
| author | Stefan Metzmacher <metze@samba.org> | 2025-12-18 22:54:25 +0300 |
|---|---|---|
| committer | Steve French <stfrench@microsoft.com> | 2026-04-16 05:58:20 +0300 |
| commit | ede2b44b0e62378cb8585dda20a4edadbc621bb0 (patch) | |
| tree | 52efaed54e1e2d1be19348d279f307fd514e81ce | |
| parent | dce268ffcddc96f29707c1967c52b036ad92e43d (diff) | |
| download | linux-ede2b44b0e62378cb8585dda20a4edadbc621bb0.tar.xz | |
smb: smbdirect: let smbdirect_socket_set_initial_parameters() call rdma_restrict_node_type()
We allow the caller of smbdirect_socket_set_initial_parameters() to pass
SMBDIRECT_FLAG_PORT_RANGE_ONLY_{IB,IW} in order to restrict
the rdma devices for the listener or connection to either
iWarp (RDMA_NODE_RNIC) or InfiniBand/RoCEv1/RoCEv2 (RDMA_NODE_IB_CA).
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
| -rw-r--r-- | fs/smb/common/smbdirect/smbdirect.h | 7 | ||||
| -rw-r--r-- | fs/smb/common/smbdirect/smbdirect_socket.c | 11 |
2 files changed, 18 insertions, 0 deletions
diff --git a/fs/smb/common/smbdirect/smbdirect.h b/fs/smb/common/smbdirect/smbdirect.h index 821a34c4cc47..e70a21eb57f0 100644 --- a/fs/smb/common/smbdirect/smbdirect.h +++ b/fs/smb/common/smbdirect/smbdirect.h @@ -25,6 +25,9 @@ struct smbdirect_buffer_descriptor_v1 { * Some values are important for the upper layer. */ struct smbdirect_socket_parameters { + __u64 flags; +#define SMBDIRECT_FLAG_PORT_RANGE_ONLY_IB ((__u64)0x1) +#define SMBDIRECT_FLAG_PORT_RANGE_ONLY_IW ((__u64)0x2) __u32 resolve_addr_timeout_msec; __u32 resolve_route_timeout_msec; __u32 rdma_connect_timeout_msec; @@ -43,4 +46,8 @@ struct smbdirect_socket_parameters { __u32 keepalive_timeout_msec; } __packed; +#define SMBDIRECT_FLAG_PORT_RANGE_MASK ( \ + SMBDIRECT_FLAG_PORT_RANGE_ONLY_IB | \ + SMBDIRECT_FLAG_PORT_RANGE_ONLY_IW) + #endif /* __FS_SMB_COMMON_SMBDIRECT_SMBDIRECT_H__ */ diff --git a/fs/smb/common/smbdirect/smbdirect_socket.c b/fs/smb/common/smbdirect/smbdirect_socket.c index c964c5f8c724..8eb021cd7cee 100644 --- a/fs/smb/common/smbdirect/smbdirect_socket.c +++ b/fs/smb/common/smbdirect/smbdirect_socket.c @@ -114,6 +114,17 @@ static int smbdirect_socket_set_initial_parameters(struct smbdirect_socket *sc, if (sc->status != SMBDIRECT_SOCKET_CREATED) return -EINVAL; + if (sp->flags & ~SMBDIRECT_FLAG_PORT_RANGE_MASK) + return -EINVAL; + + if (sp->flags & SMBDIRECT_FLAG_PORT_RANGE_ONLY_IB && + sp->flags & SMBDIRECT_FLAG_PORT_RANGE_ONLY_IW) + return -EINVAL; + else if (sp->flags & SMBDIRECT_FLAG_PORT_RANGE_ONLY_IB) + rdma_restrict_node_type(sc->rdma.cm_id, RDMA_NODE_IB_CA); + else if (sp->flags & SMBDIRECT_FLAG_PORT_RANGE_ONLY_IW) + rdma_restrict_node_type(sc->rdma.cm_id, RDMA_NODE_RNIC); + /* * Make a copy of the callers parameters * from here we only work on the copy |
