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>
This commit is contained in:
Stefan Metzmacher 2025-12-18 20:54:25 +01:00 committed by Steve French
parent dce268ffcd
commit ede2b44b0e
2 changed files with 18 additions and 0 deletions

View File

@ -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__ */

View File

@ -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