We should use the per connection value.
And for TCP return NT_STATUS_INVALID_PARAMETER if any
SMB2_CHANNEL_RDMA_V1* is used.
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
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>
if (req->Channel == SMB2_CHANNEL_RDMA_V1_INVALIDATE ||
req->Channel == SMB2_CHANNEL_RDMA_V1) {
is_rdma_channel = true;
- max_read_size = get_smbd_max_read_write_size();
+ max_read_size = get_smbd_max_read_write_size(work->conn->transport);
+ if (max_read_size == 0) {
+ err = -EINVAL;
+ goto out;
+ }
}
if (is_rdma_channel == true) {
if (req->Channel == SMB2_CHANNEL_RDMA_V1 ||
req->Channel == SMB2_CHANNEL_RDMA_V1_INVALIDATE) {
is_rdma_channel = true;
- max_write_size = get_smbd_max_read_write_size();
+ max_write_size = get_smbd_max_read_write_size(work->conn->transport);
+ if (max_write_size == 0) {
+ err = -EINVAL;
+ goto out;
+ }
length = le32_to_cpu(req->RemainingBytes);
}
smb_direct_max_read_write_size = sz;
}
-unsigned int get_smbd_max_read_write_size(void)
+unsigned int get_smbd_max_read_write_size(struct ksmbd_transport *kt)
{
- return smb_direct_max_read_write_size;
+ struct smb_direct_transport *t;
+ struct smbdirect_socket *sc;
+ struct smbdirect_socket_parameters *sp;
+
+ if (kt->ops != &ksmbd_smb_direct_transport_ops)
+ return 0;
+
+ t = SMBD_TRANS(kt);
+ sc = &t->socket;
+ sp = &sc->parameters;
+
+ return sp->max_read_write_size;
}
static inline int get_buf_page_count(void *buf, int size)
void ksmbd_rdma_destroy(void);
bool ksmbd_rdma_capable_netdev(struct net_device *netdev);
void init_smbd_max_io_size(unsigned int sz);
-unsigned int get_smbd_max_read_write_size(void);
+unsigned int get_smbd_max_read_write_size(struct ksmbd_transport *kt);
#else
static inline int ksmbd_rdma_init(void) { return 0; }
static inline void ksmbd_rdma_stop_listening(void) { }
static inline void ksmbd_rdma_destroy(void) { }
static inline bool ksmbd_rdma_capable_netdev(struct net_device *netdev) { return false; }
static inline void init_smbd_max_io_size(unsigned int sz) { }
-static inline unsigned int get_smbd_max_read_write_size(void) { return 0; }
+static inline unsigned int get_smbd_max_read_write_size(struct ksmbd_transport *kt) { return 0; }
#endif
#endif /* __KSMBD_TRANSPORT_RDMA_H__ */