Skip to content

Commit 07e0b72

Browse files
metze-sambasmfrench
authored andcommitted
smb: client: make use of rdma_restrict_node_type()
For smbdirect it required to use different ports depending on the RDMA protocol. E.g. for iWarp 5445 is needed (as tcp port 445 already used by the raw tcp transport for SMB), while InfiniBand, RoCEv1 and RoCEv2 use port 445, as they use an independent port range (even for RoCEv2, which uses udp port 4791 itself). And cifs.ko uses 5445 with a fallback to 445, which means depending on the available interfaces, it tries 5445 in the RoCE range or may tries iWarp with 445 as a fallback. This leads to strange error messages and strange network captures. To avoid these problems they will be able to use rdma_restrict_node_type(RDMA_NODE_RNIC) before trying port 5445 and rdma_restrict_node_type(RDMA_NODE_IB_CA) before trying port 445. It means we'll get early -ENODEV early from rdma_resolve_addr() without any network traffic and timeouts. Cc: Jason Gunthorpe <jgg@ziepe.ca> Cc: Leon Romanovsky <leon@kernel.org> Cc: Steve French <smfrench@gmail.com> Cc: Tom Talpey <tom@talpey.com> Cc: Long Li <longli@microsoft.com> Acked-by: Namjae Jeon <linkinjeon@kernel.org> Cc: linux-rdma@vger.kernel.org Cc: linux-cifs@vger.kernel.org Cc: samba-technical@lists.samba.org Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent a760e80 commit 07e0b72

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

fs/smb/client/smbdirect.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,7 @@ static struct rdma_cm_id *smbd_create_id(
907907
{
908908
struct smbdirect_socket_parameters *sp = &sc->parameters;
909909
struct rdma_cm_id *id;
910+
u8 node_type = RDMA_NODE_UNSPECIFIED;
910911
int rc;
911912
__be16 *sport;
912913

@@ -918,6 +919,31 @@ static struct rdma_cm_id *smbd_create_id(
918919
return id;
919920
}
920921

922+
switch (port) {
923+
case SMBD_PORT:
924+
/*
925+
* only allow iWarp devices
926+
* for port 5445.
927+
*/
928+
node_type = RDMA_NODE_RNIC;
929+
break;
930+
case SMB_PORT:
931+
/*
932+
* only allow InfiniBand, RoCEv1 or RoCEv2
933+
* devices for port 445.
934+
*
935+
* (Basically don't allow iWarp devices)
936+
*/
937+
node_type = RDMA_NODE_IB_CA;
938+
break;
939+
}
940+
rc = rdma_restrict_node_type(id, node_type);
941+
if (rc) {
942+
log_rdma_event(ERR, "rdma_restrict_node_type(%u) failed %i\n",
943+
node_type, rc);
944+
goto out;
945+
}
946+
921947
if (dstaddr->sa_family == AF_INET6)
922948
sport = &((struct sockaddr_in6 *)dstaddr)->sin6_port;
923949
else

0 commit comments

Comments
 (0)