Commit cb097b3d authored by Namjae Jeon's avatar Namjae Jeon Committed by Steve French

ksmbd: set 445 port to smbdirect port by default

When SMB Direct is used with iWARP, Windows use 5445 port for smb direct
port, 445 port for SMB. This patch check ib_device using ib_client to
know if NICs type is iWARP or Infiniband.
Signed-off-by: default avatarNamjae Jeon <linkinjeon@kernel.org>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 31928a00
...@@ -34,7 +34,8 @@ ...@@ -34,7 +34,8 @@
#include "smbstatus.h" #include "smbstatus.h"
#include "transport_rdma.h" #include "transport_rdma.h"
#define SMB_DIRECT_PORT 5445 #define SMB_DIRECT_PORT_IWARP 5445
#define SMB_DIRECT_PORT_INFINIBAND 445
#define SMB_DIRECT_VERSION_LE cpu_to_le16(0x0100) #define SMB_DIRECT_VERSION_LE cpu_to_le16(0x0100)
...@@ -60,6 +61,10 @@ ...@@ -60,6 +61,10 @@
* as defined in [MS-SMBD] 3.1.1.1 * as defined in [MS-SMBD] 3.1.1.1
* Those may change after a SMB_DIRECT negotiation * Those may change after a SMB_DIRECT negotiation
*/ */
/* Set 445 port to SMB Direct port by default */
static int smb_direct_port = SMB_DIRECT_PORT_INFINIBAND;
/* The local peer's maximum number of credits to grant to the peer */ /* The local peer's maximum number of credits to grant to the peer */
static int smb_direct_receive_credit_max = 255; static int smb_direct_receive_credit_max = 255;
...@@ -1942,7 +1947,7 @@ static int smb_direct_handle_connect_request(struct rdma_cm_id *new_cm_id) ...@@ -1942,7 +1947,7 @@ static int smb_direct_handle_connect_request(struct rdma_cm_id *new_cm_id)
KSMBD_TRANS(t)->handler = kthread_run(ksmbd_conn_handler_loop, KSMBD_TRANS(t)->handler = kthread_run(ksmbd_conn_handler_loop,
KSMBD_TRANS(t)->conn, "ksmbd:r%u", KSMBD_TRANS(t)->conn, "ksmbd:r%u",
SMB_DIRECT_PORT); smb_direct_port);
if (IS_ERR(KSMBD_TRANS(t)->handler)) { if (IS_ERR(KSMBD_TRANS(t)->handler)) {
int ret = PTR_ERR(KSMBD_TRANS(t)->handler); int ret = PTR_ERR(KSMBD_TRANS(t)->handler);
...@@ -2019,6 +2024,10 @@ static int smb_direct_ib_client_add(struct ib_device *ib_dev) ...@@ -2019,6 +2024,10 @@ static int smb_direct_ib_client_add(struct ib_device *ib_dev)
{ {
struct smb_direct_device *smb_dev; struct smb_direct_device *smb_dev;
/* Set 5445 port if device type is iWARP(No IB) */
if (ib_dev->node_type != RDMA_NODE_IB_CA)
smb_direct_port = SMB_DIRECT_PORT_IWARP;
if (!ib_dev->ops.get_netdev || if (!ib_dev->ops.get_netdev ||
!rdma_frwr_is_supported(&ib_dev->attrs)) !rdma_frwr_is_supported(&ib_dev->attrs))
return 0; return 0;
...@@ -2080,7 +2089,7 @@ int ksmbd_rdma_init(void) ...@@ -2080,7 +2089,7 @@ int ksmbd_rdma_init(void)
if (!smb_direct_wq) if (!smb_direct_wq)
return -ENOMEM; return -ENOMEM;
ret = smb_direct_listen(SMB_DIRECT_PORT); ret = smb_direct_listen(smb_direct_port);
if (ret) { if (ret) {
destroy_workqueue(smb_direct_wq); destroy_workqueue(smb_direct_wq);
smb_direct_wq = NULL; smb_direct_wq = NULL;
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
#ifndef __KSMBD_TRANSPORT_RDMA_H__ #ifndef __KSMBD_TRANSPORT_RDMA_H__
#define __KSMBD_TRANSPORT_RDMA_H__ #define __KSMBD_TRANSPORT_RDMA_H__
#define SMB_DIRECT_PORT 5445
/* SMB DIRECT negotiation request packet [MS-SMBD] 2.2.1 */ /* SMB DIRECT negotiation request packet [MS-SMBD] 2.2.1 */
struct smb_direct_negotiate_req { struct smb_direct_negotiate_req {
__le16 min_version; __le16 min_version;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment