* [PATCH 00/19] Remove rfc1002 header from smb2 request structs @ 2017-11-09 1:14 Ronnie Sahlberg [not found] ` <20171109011433.14468-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 0 siblings, 1 reply; 52+ messages in thread From: Ronnie Sahlberg @ 2017-11-09 1:14 UTC (permalink / raw) To: linux-cifs; +Cc: Steve French Steve, All, Please find an updated version of the patch series to get rid of the rfc1002 header from all request structures in SMB2. Version 2: * changed SendReceive3 to smb2_send_recv * fixed a Buffer[1] error that aaptel-IBi9RG/b67k@public.gmane.org reported ^ permalink raw reply [flat|nested] 52+ messages in thread
[parent not found: <20171109011433.14468-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* [PATCH 01/19] cifs: Add smb2_send_recv [not found] ` <20171109011433.14468-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2017-11-09 1:14 ` Ronnie Sahlberg [not found] ` <20171109011433.14468-2-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 1:14 ` [PATCH 02/19] cifs: remove rfc1002 header from smb2_negotiate_req Ronnie Sahlberg ` (17 subsequent siblings) 18 siblings, 1 reply; 52+ messages in thread From: Ronnie Sahlberg @ 2017-11-09 1:14 UTC (permalink / raw) To: linux-cifs; +Cc: Steve French This function is similar to SendReceive2 except it does not expect a 4 byte rfc1002 length header in the first io vector. Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> --- fs/cifs/cifsproto.h | 4 ++++ fs/cifs/transport.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index 4143c9dec463..6d86cd120349 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h @@ -106,6 +106,10 @@ extern int SendReceive2(const unsigned int /* xid */ , struct cifs_ses *, struct kvec *, int /* nvec to send */, int * /* type of buf returned */, const int flags, struct kvec * /* resp vec */); +extern int smb2_send_recv(const unsigned int /* xid */ , struct cifs_ses *, + struct kvec *, int /* nvec to send */, + int * /* type of buf returned */, const int flags, + struct kvec * /* resp vec */); extern int SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *ptcon, struct smb_hdr *in_buf , diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index 7efbab013957..e678307bb7a0 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c @@ -827,6 +827,44 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses, return rc; } +/* Like SendReceive2 but iov[0] does not contain an rfc1002 header */ +int +smb2_send_recv(const unsigned int xid, struct cifs_ses *ses, + struct kvec *iov, int n_vec, int *resp_buf_type /* ret */, + const int flags, struct kvec *resp_iov) +{ + struct smb_rqst rqst; + struct kvec *new_iov; + int rc; + int i; + __u32 count; + __be32 rfc1002_marker; + + new_iov = kmalloc(sizeof(struct kvec) * (n_vec + 1), GFP_KERNEL); + if (!new_iov) + return -ENOMEM; + + /* 1st iov is an RFC1002 Session Message length */ + memcpy(new_iov + 1, iov, (sizeof(struct kvec) * n_vec)); + + count = 0; + for (i = 1; i < n_vec + 1; i++) + count += new_iov[i].iov_len; + + rfc1002_marker = cpu_to_be32(count); + + new_iov[0].iov_base = &rfc1002_marker; + new_iov[0].iov_len = 4; + + memset(&rqst, 0, sizeof(struct smb_rqst)); + rqst.rq_iov = new_iov; + rqst.rq_nvec = n_vec + 1; + + rc = cifs_send_recv(xid, ses, &rqst, resp_buf_type, flags, resp_iov); + kfree(new_iov); + return rc; +} + int SendReceive(const unsigned int xid, struct cifs_ses *ses, struct smb_hdr *in_buf, struct smb_hdr *out_buf, -- 2.13.3 ^ permalink raw reply related [flat|nested] 52+ messages in thread
[parent not found: <20171109011433.14468-2-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 01/19] cifs: Add smb2_send_recv [not found] ` <20171109011433.14468-2-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2017-11-09 14:09 ` Aurélien Aptel 2017-11-17 18:05 ` Steve French 1 sibling, 0 replies; 52+ messages in thread From: Aurélien Aptel @ 2017-11-09 14:09 UTC (permalink / raw) To: Ronnie Sahlberg, linux-cifs; +Cc: Steve French Reviewed-by: Aurelien Aptel <aaptel-IBi9RG/b67k@public.gmane.org> -- Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Linux GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) ^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 01/19] cifs: Add smb2_send_recv [not found] ` <20171109011433.14468-2-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 14:09 ` Aurélien Aptel @ 2017-11-17 18:05 ` Steve French [not found] ` <CAH2r5mvLvAfO3eU2f73ebk2XSJiQvzamWi9FxDqNCU67=Pm8bQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 1 sibling, 1 reply; 52+ messages in thread From: Steve French @ 2017-11-17 18:05 UTC (permalink / raw) To: Ronnie Sahlberg; +Cc: linux-cifs Note checkpatch warnings (I have fixed some up) ./scripts/checkpatch.pl ~/Downloads/01-19-cifs-Add-smb2_send_recv.patch ERROR: space prohibited before that ',' (ctx:WxW) #31: FILE: fs/cifs/cifsproto.h:109: +extern int smb2_send_recv(const unsigned int /* xid */ , struct cifs_ses *, ^ WARNING: function definition argument 'const unsigned int' should also have an identifier name #31: FILE: fs/cifs/cifsproto.h:109: +extern int smb2_send_recv(const unsigned int /* xid */ , struct cifs_ses *, WARNING: function definition argument 'struct cifs_ses *' should also have an identifier name #31: FILE: fs/cifs/cifsproto.h:109: +extern int smb2_send_recv(const unsigned int /* xid */ , struct cifs_ses *, WARNING: function definition argument 'struct kvec *' should also have an identifier name #31: FILE: fs/cifs/cifsproto.h:109: +extern int smb2_send_recv(const unsigned int /* xid */ , struct cifs_ses *, WARNING: function definition argument 'int' should also have an identifier name #31: FILE: fs/cifs/cifsproto.h:109: +extern int smb2_send_recv(const unsigned int /* xid */ , struct cifs_ses *, WARNING: function definition argument 'int *' should also have an identifier name #31: FILE: fs/cifs/cifsproto.h:109: +extern int smb2_send_recv(const unsigned int /* xid */ , struct cifs_ses *, WARNING: function definition argument 'struct kvec *' should also have an identifier name #31: FILE: fs/cifs/cifsproto.h:109: +extern int smb2_send_recv(const unsigned int /* xid */ , struct cifs_ses *, On Wed, Nov 8, 2017 at 7:14 PM, Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote: > This function is similar to SendReceive2 except it does not expect > a 4 byte rfc1002 length header in the first io vector. > > Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> > --- > fs/cifs/cifsproto.h | 4 ++++ > fs/cifs/transport.c | 38 ++++++++++++++++++++++++++++++++++++++ > 2 files changed, 42 insertions(+) > > diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h > index 4143c9dec463..6d86cd120349 100644 > --- a/fs/cifs/cifsproto.h > +++ b/fs/cifs/cifsproto.h > @@ -106,6 +106,10 @@ extern int SendReceive2(const unsigned int /* xid */ , struct cifs_ses *, > struct kvec *, int /* nvec to send */, > int * /* type of buf returned */, const int flags, > struct kvec * /* resp vec */); > +extern int smb2_send_recv(const unsigned int /* xid */ , struct cifs_ses *, > + struct kvec *, int /* nvec to send */, > + int * /* type of buf returned */, const int flags, > + struct kvec * /* resp vec */); > extern int SendReceiveBlockingLock(const unsigned int xid, > struct cifs_tcon *ptcon, > struct smb_hdr *in_buf , > diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c > index 7efbab013957..e678307bb7a0 100644 > --- a/fs/cifs/transport.c > +++ b/fs/cifs/transport.c > @@ -827,6 +827,44 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses, > return rc; > } > > +/* Like SendReceive2 but iov[0] does not contain an rfc1002 header */ > +int > +smb2_send_recv(const unsigned int xid, struct cifs_ses *ses, > + struct kvec *iov, int n_vec, int *resp_buf_type /* ret */, > + const int flags, struct kvec *resp_iov) > +{ > + struct smb_rqst rqst; > + struct kvec *new_iov; > + int rc; > + int i; > + __u32 count; > + __be32 rfc1002_marker; > + > + new_iov = kmalloc(sizeof(struct kvec) * (n_vec + 1), GFP_KERNEL); > + if (!new_iov) > + return -ENOMEM; > + > + /* 1st iov is an RFC1002 Session Message length */ > + memcpy(new_iov + 1, iov, (sizeof(struct kvec) * n_vec)); > + > + count = 0; > + for (i = 1; i < n_vec + 1; i++) > + count += new_iov[i].iov_len; > + > + rfc1002_marker = cpu_to_be32(count); > + > + new_iov[0].iov_base = &rfc1002_marker; > + new_iov[0].iov_len = 4; > + > + memset(&rqst, 0, sizeof(struct smb_rqst)); > + rqst.rq_iov = new_iov; > + rqst.rq_nvec = n_vec + 1; > + > + rc = cifs_send_recv(xid, ses, &rqst, resp_buf_type, flags, resp_iov); > + kfree(new_iov); > + return rc; > +} > + > int > SendReceive(const unsigned int xid, struct cifs_ses *ses, > struct smb_hdr *in_buf, struct smb_hdr *out_buf, > -- > 2.13.3 > -- Thanks, Steve ^ permalink raw reply [flat|nested] 52+ messages in thread
[parent not found: <CAH2r5mvLvAfO3eU2f73ebk2XSJiQvzamWi9FxDqNCU67=Pm8bQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH 01/19] cifs: Add smb2_send_recv [not found] ` <CAH2r5mvLvAfO3eU2f73ebk2XSJiQvzamWi9FxDqNCU67=Pm8bQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2017-11-17 18:11 ` Steve French 0 siblings, 0 replies; 52+ messages in thread From: Steve French @ 2017-11-17 18:11 UTC (permalink / raw) To: Ronnie Sahlberg; +Cc: linux-cifs I fixed up checkpatch warnings in the first patch - and after reviewing merged the first three (so far) On Fri, Nov 17, 2017 at 12:05 PM, Steve French <smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > Note checkpatch warnings (I have fixed some up) > > ./scripts/checkpatch.pl ~/Downloads/01-19-cifs-Add-smb2_send_recv.patch > ERROR: space prohibited before that ',' (ctx:WxW) > #31: FILE: fs/cifs/cifsproto.h:109: > +extern int smb2_send_recv(const unsigned int /* xid */ , struct cifs_ses *, > ^ > > WARNING: function definition argument 'const unsigned int' should also > have an identifier name > #31: FILE: fs/cifs/cifsproto.h:109: > +extern int smb2_send_recv(const unsigned int /* xid */ , struct cifs_ses *, > > WARNING: function definition argument 'struct cifs_ses *' should also > have an identifier name > #31: FILE: fs/cifs/cifsproto.h:109: > +extern int smb2_send_recv(const unsigned int /* xid */ , struct cifs_ses *, > > WARNING: function definition argument 'struct kvec *' should also have > an identifier name > #31: FILE: fs/cifs/cifsproto.h:109: > +extern int smb2_send_recv(const unsigned int /* xid */ , struct cifs_ses *, > > WARNING: function definition argument 'int' should also have an identifier name > #31: FILE: fs/cifs/cifsproto.h:109: > +extern int smb2_send_recv(const unsigned int /* xid */ , struct cifs_ses *, > > WARNING: function definition argument 'int *' should also have an > identifier name > #31: FILE: fs/cifs/cifsproto.h:109: > +extern int smb2_send_recv(const unsigned int /* xid */ , struct cifs_ses *, > > WARNING: function definition argument 'struct kvec *' should also have > an identifier name > #31: FILE: fs/cifs/cifsproto.h:109: > +extern int smb2_send_recv(const unsigned int /* xid */ , struct cifs_ses *, > > On Wed, Nov 8, 2017 at 7:14 PM, Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote: >> This function is similar to SendReceive2 except it does not expect >> a 4 byte rfc1002 length header in the first io vector. >> >> Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> >> --- >> fs/cifs/cifsproto.h | 4 ++++ >> fs/cifs/transport.c | 38 ++++++++++++++++++++++++++++++++++++++ >> 2 files changed, 42 insertions(+) >> >> diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h >> index 4143c9dec463..6d86cd120349 100644 >> --- a/fs/cifs/cifsproto.h >> +++ b/fs/cifs/cifsproto.h >> @@ -106,6 +106,10 @@ extern int SendReceive2(const unsigned int /* xid */ , struct cifs_ses *, >> struct kvec *, int /* nvec to send */, >> int * /* type of buf returned */, const int flags, >> struct kvec * /* resp vec */); >> +extern int smb2_send_recv(const unsigned int /* xid */ , struct cifs_ses *, >> + struct kvec *, int /* nvec to send */, >> + int * /* type of buf returned */, const int flags, >> + struct kvec * /* resp vec */); >> extern int SendReceiveBlockingLock(const unsigned int xid, >> struct cifs_tcon *ptcon, >> struct smb_hdr *in_buf , >> diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c >> index 7efbab013957..e678307bb7a0 100644 >> --- a/fs/cifs/transport.c >> +++ b/fs/cifs/transport.c >> @@ -827,6 +827,44 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses, >> return rc; >> } >> >> +/* Like SendReceive2 but iov[0] does not contain an rfc1002 header */ >> +int >> +smb2_send_recv(const unsigned int xid, struct cifs_ses *ses, >> + struct kvec *iov, int n_vec, int *resp_buf_type /* ret */, >> + const int flags, struct kvec *resp_iov) >> +{ >> + struct smb_rqst rqst; >> + struct kvec *new_iov; >> + int rc; >> + int i; >> + __u32 count; >> + __be32 rfc1002_marker; >> + >> + new_iov = kmalloc(sizeof(struct kvec) * (n_vec + 1), GFP_KERNEL); >> + if (!new_iov) >> + return -ENOMEM; >> + >> + /* 1st iov is an RFC1002 Session Message length */ >> + memcpy(new_iov + 1, iov, (sizeof(struct kvec) * n_vec)); >> + >> + count = 0; >> + for (i = 1; i < n_vec + 1; i++) >> + count += new_iov[i].iov_len; >> + >> + rfc1002_marker = cpu_to_be32(count); >> + >> + new_iov[0].iov_base = &rfc1002_marker; >> + new_iov[0].iov_len = 4; >> + >> + memset(&rqst, 0, sizeof(struct smb_rqst)); >> + rqst.rq_iov = new_iov; >> + rqst.rq_nvec = n_vec + 1; >> + >> + rc = cifs_send_recv(xid, ses, &rqst, resp_buf_type, flags, resp_iov); >> + kfree(new_iov); >> + return rc; >> +} >> + >> int >> SendReceive(const unsigned int xid, struct cifs_ses *ses, >> struct smb_hdr *in_buf, struct smb_hdr *out_buf, >> -- >> 2.13.3 >> > > > > -- > Thanks, > > Steve -- Thanks, Steve ^ permalink raw reply [flat|nested] 52+ messages in thread
* [PATCH 02/19] cifs: remove rfc1002 header from smb2_negotiate_req [not found] ` <20171109011433.14468-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 1:14 ` [PATCH 01/19] cifs: Add smb2_send_recv Ronnie Sahlberg @ 2017-11-09 1:14 ` Ronnie Sahlberg [not found] ` <20171109011433.14468-3-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 1:14 ` [PATCH 03/19] cifs: remove rfc1002 header from smb2_logoff_req Ronnie Sahlberg ` (16 subsequent siblings) 18 siblings, 1 reply; 52+ messages in thread From: Ronnie Sahlberg @ 2017-11-09 1:14 UTC (permalink / raw) To: linux-cifs; +Cc: Steve French Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> --- fs/cifs/smb2pdu.c | 26 +++++++++++--------------- fs/cifs/smb2pdu.h | 2 +- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 5331631386a2..f5cf9953955c 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -398,8 +398,8 @@ small_smb2_init(__le16 smb2_command, struct cifs_tcon *tcon, } #ifdef CONFIG_CIFS_SMB311 -/* offset is sizeof smb2_negotiate_req - 4 but rounded up to 8 bytes */ -#define OFFSET_OF_NEG_CONTEXT 0x68 /* sizeof(struct smb2_negotiate_req) - 4 */ +/* offset is sizeof smb2_negotiate_req but rounded up to 8 bytes */ +#define OFFSET_OF_NEG_CONTEXT 0x68 /* sizeof(struct smb2_negotiate_req) */ #define SMB2_PREAUTH_INTEGRITY_CAPABILITIES cpu_to_le16(1) @@ -429,9 +429,7 @@ build_encrypt_ctxt(struct smb2_encryption_neg_context *pneg_ctxt) static void assemble_neg_contexts(struct smb2_negotiate_req *req) { - - /* +4 is to account for the RFC1001 len field */ - char *pneg_ctxt = (char *)req + OFFSET_OF_NEG_CONTEXT + 4; + char *pneg_ctxt = (char *)req + OFFSET_OF_NEG_CONTEXT; build_preauth_ctxt((struct smb2_preauth_neg_context *)pneg_ctxt); /* Add 2 to size to round to 8 byte boundary */ @@ -439,8 +437,6 @@ assemble_neg_contexts(struct smb2_negotiate_req *req) build_encrypt_ctxt((struct smb2_encryption_neg_context *)pneg_ctxt); req->NegotiateContextOffset = cpu_to_le32(OFFSET_OF_NEG_CONTEXT); req->NegotiateContextCount = cpu_to_le16(2); - inc_rfc1001_len(req, 4 + sizeof(struct smb2_preauth_neg_context) - + sizeof(struct smb2_encryption_neg_context)); /* calculate hash */ } #else static void assemble_neg_contexts(struct smb2_negotiate_req *req) @@ -477,6 +473,7 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) int blob_offset, blob_length; char *security_blob; int flags = CIFS_NEG_OP; + unsigned int total_len; cifs_dbg(FYI, "Negotiate protocol\n"); @@ -485,30 +482,30 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) return -EIO; } - rc = small_smb2_init(SMB2_NEGOTIATE, NULL, (void **) &req); + rc = smb2_plain_req_init(SMB2_NEGOTIATE, NULL, (void **) &req, &total_len); if (rc) return rc; - req->hdr.sync_hdr.SessionId = 0; + req->sync_hdr.SessionId = 0; if (strcmp(ses->server->vals->version_string, SMB3ANY_VERSION_STRING) == 0) { req->Dialects[0] = cpu_to_le16(SMB30_PROT_ID); req->Dialects[1] = cpu_to_le16(SMB302_PROT_ID); req->DialectCount = cpu_to_le16(2); - inc_rfc1001_len(req, 4); + total_len += 4; } else if (strcmp(ses->server->vals->version_string, SMBDEFAULT_VERSION_STRING) == 0) { req->Dialects[0] = cpu_to_le16(SMB21_PROT_ID); req->Dialects[1] = cpu_to_le16(SMB30_PROT_ID); req->Dialects[2] = cpu_to_le16(SMB302_PROT_ID); req->DialectCount = cpu_to_le16(3); - inc_rfc1001_len(req, 6); + total_len += 6; } else { /* otherwise send specific dialect */ req->Dialects[0] = cpu_to_le16(ses->server->vals->protocol_id); req->DialectCount = cpu_to_le16(1); - inc_rfc1001_len(req, 2); + total_len += 2; } /* only one of SMB2 signing flags may be set in SMB2 request */ @@ -531,10 +528,9 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) assemble_neg_contexts(req); } iov[0].iov_base = (char *)req; - /* 4 for rfc1002 length field */ - iov[0].iov_len = get_rfc1002_length(req) + 4; + iov[0].iov_len = total_len; - rc = SendReceive2(xid, ses, iov, 1, &resp_buftype, flags, &rsp_iov); + rc = smb2_send_recv(xid, ses, iov, 1, &resp_buftype, flags, &rsp_iov); cifs_small_buf_release(req); rsp = (struct smb2_negotiate_rsp *)rsp_iov.iov_base; /* diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index c2ec934be968..0fe2382597ad 100644 --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h @@ -195,7 +195,7 @@ struct smb2_symlink_err_rsp { #define SMB2_CLIENT_GUID_SIZE 16 struct smb2_negotiate_req { - struct smb2_hdr hdr; + struct smb2_sync_hdr sync_hdr; __le16 StructureSize; /* Must be 36 */ __le16 DialectCount; __le16 SecurityMode; -- 2.13.3 ^ permalink raw reply related [flat|nested] 52+ messages in thread
[parent not found: <20171109011433.14468-3-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 02/19] cifs: remove rfc1002 header from smb2_negotiate_req [not found] ` <20171109011433.14468-3-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2017-11-09 14:10 ` Aurélien Aptel 2017-11-17 1:24 ` Pavel Shilovsky 2017-11-17 19:02 ` Pavel Shilovsky 2 siblings, 0 replies; 52+ messages in thread From: Aurélien Aptel @ 2017-11-09 14:10 UTC (permalink / raw) To: Ronnie Sahlberg, linux-cifs; +Cc: Steve French Reviewed-by: Aurelien Aptel <aaptel-IBi9RG/b67k@public.gmane.org> -- Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Linux GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) ^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 02/19] cifs: remove rfc1002 header from smb2_negotiate_req [not found] ` <20171109011433.14468-3-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 14:10 ` Aurélien Aptel @ 2017-11-17 1:24 ` Pavel Shilovsky [not found] ` <CAKywueRFOZroCmp9nhr22PGE0R31peFr6j8A2mGVQSEP07bqLQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2017-11-17 19:02 ` Pavel Shilovsky 2 siblings, 1 reply; 52+ messages in thread From: Pavel Shilovsky @ 2017-11-17 1:24 UTC (permalink / raw) To: Ronnie Sahlberg; +Cc: linux-cifs, Steve French 2017-11-08 17:14 GMT-08:00 Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>: > Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> > --- > fs/cifs/smb2pdu.c | 26 +++++++++++--------------- > fs/cifs/smb2pdu.h | 2 +- > 2 files changed, 12 insertions(+), 16 deletions(-) > > diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c > index 5331631386a2..f5cf9953955c 100644 > --- a/fs/cifs/smb2pdu.c > +++ b/fs/cifs/smb2pdu.c > @@ -398,8 +398,8 @@ small_smb2_init(__le16 smb2_command, struct cifs_tcon *tcon, > } > > #ifdef CONFIG_CIFS_SMB311 > -/* offset is sizeof smb2_negotiate_req - 4 but rounded up to 8 bytes */ > -#define OFFSET_OF_NEG_CONTEXT 0x68 /* sizeof(struct smb2_negotiate_req) - 4 */ > +/* offset is sizeof smb2_negotiate_req but rounded up to 8 bytes */ > +#define OFFSET_OF_NEG_CONTEXT 0x68 /* sizeof(struct smb2_negotiate_req) */ > > > #define SMB2_PREAUTH_INTEGRITY_CAPABILITIES cpu_to_le16(1) > @@ -429,9 +429,7 @@ build_encrypt_ctxt(struct smb2_encryption_neg_context *pneg_ctxt) > static void > assemble_neg_contexts(struct smb2_negotiate_req *req) > { > - > - /* +4 is to account for the RFC1001 len field */ > - char *pneg_ctxt = (char *)req + OFFSET_OF_NEG_CONTEXT + 4; > + char *pneg_ctxt = (char *)req + OFFSET_OF_NEG_CONTEXT; > > build_preauth_ctxt((struct smb2_preauth_neg_context *)pneg_ctxt); > /* Add 2 to size to round to 8 byte boundary */ > @@ -439,8 +437,6 @@ assemble_neg_contexts(struct smb2_negotiate_req *req) > build_encrypt_ctxt((struct smb2_encryption_neg_context *)pneg_ctxt); > req->NegotiateContextOffset = cpu_to_le32(OFFSET_OF_NEG_CONTEXT); > req->NegotiateContextCount = cpu_to_le16(2); > - inc_rfc1001_len(req, 4 + sizeof(struct smb2_preauth_neg_context) > - + sizeof(struct smb2_encryption_neg_context)); /* calculate hash */ Why do we need to remove this? > } > #else > static void assemble_neg_contexts(struct smb2_negotiate_req *req) > @@ -477,6 +473,7 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) > int blob_offset, blob_length; > char *security_blob; > int flags = CIFS_NEG_OP; > + unsigned int total_len; > > cifs_dbg(FYI, "Negotiate protocol\n"); > > @@ -485,30 +482,30 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) > return -EIO; > } > > - rc = small_smb2_init(SMB2_NEGOTIATE, NULL, (void **) &req); > + rc = smb2_plain_req_init(SMB2_NEGOTIATE, NULL, (void **) &req, &total_len); > if (rc) > return rc; > > - req->hdr.sync_hdr.SessionId = 0; > + req->sync_hdr.SessionId = 0; > > if (strcmp(ses->server->vals->version_string, > SMB3ANY_VERSION_STRING) == 0) { > req->Dialects[0] = cpu_to_le16(SMB30_PROT_ID); > req->Dialects[1] = cpu_to_le16(SMB302_PROT_ID); > req->DialectCount = cpu_to_le16(2); > - inc_rfc1001_len(req, 4); > + total_len += 4; > } else if (strcmp(ses->server->vals->version_string, > SMBDEFAULT_VERSION_STRING) == 0) { > req->Dialects[0] = cpu_to_le16(SMB21_PROT_ID); > req->Dialects[1] = cpu_to_le16(SMB30_PROT_ID); > req->Dialects[2] = cpu_to_le16(SMB302_PROT_ID); > req->DialectCount = cpu_to_le16(3); > - inc_rfc1001_len(req, 6); > + total_len += 6; > } else { > /* otherwise send specific dialect */ > req->Dialects[0] = cpu_to_le16(ses->server->vals->protocol_id); > req->DialectCount = cpu_to_le16(1); > - inc_rfc1001_len(req, 2); > + total_len += 2; > } > > /* only one of SMB2 signing flags may be set in SMB2 request */ > @@ -531,10 +528,9 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) > assemble_neg_contexts(req); > } > iov[0].iov_base = (char *)req; > - /* 4 for rfc1002 length field */ > - iov[0].iov_len = get_rfc1002_length(req) + 4; > + iov[0].iov_len = total_len; > > - rc = SendReceive2(xid, ses, iov, 1, &resp_buftype, flags, &rsp_iov); > + rc = smb2_send_recv(xid, ses, iov, 1, &resp_buftype, flags, &rsp_iov); > cifs_small_buf_release(req); > rsp = (struct smb2_negotiate_rsp *)rsp_iov.iov_base; > /* > diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h > index c2ec934be968..0fe2382597ad 100644 > --- a/fs/cifs/smb2pdu.h > +++ b/fs/cifs/smb2pdu.h > @@ -195,7 +195,7 @@ struct smb2_symlink_err_rsp { > #define SMB2_CLIENT_GUID_SIZE 16 > > struct smb2_negotiate_req { > - struct smb2_hdr hdr; > + struct smb2_sync_hdr sync_hdr; > __le16 StructureSize; /* Must be 36 */ > __le16 DialectCount; > __le16 SecurityMode; > -- > 2.13.3 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-cifs" in > the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 52+ messages in thread
[parent not found: <CAKywueRFOZroCmp9nhr22PGE0R31peFr6j8A2mGVQSEP07bqLQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH 02/19] cifs: remove rfc1002 header from smb2_negotiate_req [not found] ` <CAKywueRFOZroCmp9nhr22PGE0R31peFr6j8A2mGVQSEP07bqLQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2017-11-17 1:44 ` Leif Sahlberg [not found] ` <1978629070.27950035.1510883055312.JavaMail.zimbra-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 0 siblings, 1 reply; 52+ messages in thread From: Leif Sahlberg @ 2017-11-17 1:44 UTC (permalink / raw) To: Pavel Shilovsky; +Cc: linux-cifs, Steve French ----- Original Message ----- From: "Pavel Shilovsky" <piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> To: "Ronnie Sahlberg" <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> Cc: "linux-cifs" <linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>, "Steve French" <smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Sent: Friday, 17 November, 2017 12:24:59 PM Subject: Re: [PATCH 02/19] cifs: remove rfc1002 header from smb2_negotiate_req 2017-11-08 17:14 GMT-08:00 Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>: > Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> > --- > fs/cifs/smb2pdu.c | 26 +++++++++++--------------- > fs/cifs/smb2pdu.h | 2 +- > 2 files changed, 12 insertions(+), 16 deletions(-) > > diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c > index 5331631386a2..f5cf9953955c 100644 > --- a/fs/cifs/smb2pdu.c > +++ b/fs/cifs/smb2pdu.c > @@ -398,8 +398,8 @@ small_smb2_init(__le16 smb2_command, struct cifs_tcon *tcon, > } > > #ifdef CONFIG_CIFS_SMB311 > -/* offset is sizeof smb2_negotiate_req - 4 but rounded up to 8 bytes */ > -#define OFFSET_OF_NEG_CONTEXT 0x68 /* sizeof(struct smb2_negotiate_req) - 4 */ > +/* offset is sizeof smb2_negotiate_req but rounded up to 8 bytes */ > +#define OFFSET_OF_NEG_CONTEXT 0x68 /* sizeof(struct smb2_negotiate_req) */ > > > #define SMB2_PREAUTH_INTEGRITY_CAPABILITIES cpu_to_le16(1) > @@ -429,9 +429,7 @@ build_encrypt_ctxt(struct smb2_encryption_neg_context *pneg_ctxt) > static void > assemble_neg_contexts(struct smb2_negotiate_req *req) > { > - > - /* +4 is to account for the RFC1001 len field */ > - char *pneg_ctxt = (char *)req + OFFSET_OF_NEG_CONTEXT + 4; > + char *pneg_ctxt = (char *)req + OFFSET_OF_NEG_CONTEXT; > > build_preauth_ctxt((struct smb2_preauth_neg_context *)pneg_ctxt); > /* Add 2 to size to round to 8 byte boundary */ > @@ -439,8 +437,6 @@ assemble_neg_contexts(struct smb2_negotiate_req *req) > build_encrypt_ctxt((struct smb2_encryption_neg_context *)pneg_ctxt); > req->NegotiateContextOffset = cpu_to_le32(OFFSET_OF_NEG_CONTEXT); > req->NegotiateContextCount = cpu_to_le16(2); > - inc_rfc1001_len(req, 4 + sizeof(struct smb2_preauth_neg_context) > - + sizeof(struct smb2_encryption_neg_context)); /* calculate hash */ > Why do we need to remove this? Because req no longer contains a rfc1002 length field any more. We now compute the rfc1002 length during smb2_send_recv() and thus we don't need to modify it using inc_rfc1001_len() any more. > } > #else > static void assemble_neg_contexts(struct smb2_negotiate_req *req) > @@ -477,6 +473,7 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) > int blob_offset, blob_length; > char *security_blob; > int flags = CIFS_NEG_OP; > + unsigned int total_len; > > cifs_dbg(FYI, "Negotiate protocol\n"); > > @@ -485,30 +482,30 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) > return -EIO; > } > > - rc = small_smb2_init(SMB2_NEGOTIATE, NULL, (void **) &req); > + rc = smb2_plain_req_init(SMB2_NEGOTIATE, NULL, (void **) &req, &total_len); > if (rc) > return rc; > > - req->hdr.sync_hdr.SessionId = 0; > + req->sync_hdr.SessionId = 0; > > if (strcmp(ses->server->vals->version_string, > SMB3ANY_VERSION_STRING) == 0) { > req->Dialects[0] = cpu_to_le16(SMB30_PROT_ID); > req->Dialects[1] = cpu_to_le16(SMB302_PROT_ID); > req->DialectCount = cpu_to_le16(2); > - inc_rfc1001_len(req, 4); > + total_len += 4; > } else if (strcmp(ses->server->vals->version_string, > SMBDEFAULT_VERSION_STRING) == 0) { > req->Dialects[0] = cpu_to_le16(SMB21_PROT_ID); > req->Dialects[1] = cpu_to_le16(SMB30_PROT_ID); > req->Dialects[2] = cpu_to_le16(SMB302_PROT_ID); > req->DialectCount = cpu_to_le16(3); > - inc_rfc1001_len(req, 6); > + total_len += 6; > } else { > /* otherwise send specific dialect */ > req->Dialects[0] = cpu_to_le16(ses->server->vals->protocol_id); > req->DialectCount = cpu_to_le16(1); > - inc_rfc1001_len(req, 2); > + total_len += 2; > } > > /* only one of SMB2 signing flags may be set in SMB2 request */ > @@ -531,10 +528,9 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) > assemble_neg_contexts(req); > } > iov[0].iov_base = (char *)req; > - /* 4 for rfc1002 length field */ > - iov[0].iov_len = get_rfc1002_length(req) + 4; > + iov[0].iov_len = total_len; > > - rc = SendReceive2(xid, ses, iov, 1, &resp_buftype, flags, &rsp_iov); > + rc = smb2_send_recv(xid, ses, iov, 1, &resp_buftype, flags, &rsp_iov); > cifs_small_buf_release(req); > rsp = (struct smb2_negotiate_rsp *)rsp_iov.iov_base; > /* > diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h > index c2ec934be968..0fe2382597ad 100644 > --- a/fs/cifs/smb2pdu.h > +++ b/fs/cifs/smb2pdu.h > @@ -195,7 +195,7 @@ struct smb2_symlink_err_rsp { > #define SMB2_CLIENT_GUID_SIZE 16 > > struct smb2_negotiate_req { > - struct smb2_hdr hdr; > + struct smb2_sync_hdr sync_hdr; > __le16 StructureSize; /* Must be 36 */ > __le16 DialectCount; > __le16 SecurityMode; > -- > 2.13.3 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-cifs" in > the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 52+ messages in thread
[parent not found: <1978629070.27950035.1510883055312.JavaMail.zimbra-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 02/19] cifs: remove rfc1002 header from smb2_negotiate_req [not found] ` <1978629070.27950035.1510883055312.JavaMail.zimbra-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2017-11-17 1:47 ` Pavel Shilovsky 0 siblings, 0 replies; 52+ messages in thread From: Pavel Shilovsky @ 2017-11-17 1:47 UTC (permalink / raw) To: Leif Sahlberg; +Cc: linux-cifs, Steve French 2017-11-16 17:44 GMT-08:00 Leif Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>: > > > ----- Original Message ----- > From: "Pavel Shilovsky" <piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > To: "Ronnie Sahlberg" <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> > Cc: "linux-cifs" <linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>, "Steve French" <smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > Sent: Friday, 17 November, 2017 12:24:59 PM > Subject: Re: [PATCH 02/19] cifs: remove rfc1002 header from smb2_negotiate_req > > 2017-11-08 17:14 GMT-08:00 Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>: >> Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> >> --- >> fs/cifs/smb2pdu.c | 26 +++++++++++--------------- >> fs/cifs/smb2pdu.h | 2 +- >> 2 files changed, 12 insertions(+), 16 deletions(-) >> >> diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c >> index 5331631386a2..f5cf9953955c 100644 >> --- a/fs/cifs/smb2pdu.c >> +++ b/fs/cifs/smb2pdu.c >> @@ -398,8 +398,8 @@ small_smb2_init(__le16 smb2_command, struct cifs_tcon *tcon, >> } >> >> #ifdef CONFIG_CIFS_SMB311 >> -/* offset is sizeof smb2_negotiate_req - 4 but rounded up to 8 bytes */ >> -#define OFFSET_OF_NEG_CONTEXT 0x68 /* sizeof(struct smb2_negotiate_req) - 4 */ >> +/* offset is sizeof smb2_negotiate_req but rounded up to 8 bytes */ >> +#define OFFSET_OF_NEG_CONTEXT 0x68 /* sizeof(struct smb2_negotiate_req) */ >> >> >> #define SMB2_PREAUTH_INTEGRITY_CAPABILITIES cpu_to_le16(1) >> @@ -429,9 +429,7 @@ build_encrypt_ctxt(struct smb2_encryption_neg_context *pneg_ctxt) >> static void >> assemble_neg_contexts(struct smb2_negotiate_req *req) >> { >> - >> - /* +4 is to account for the RFC1001 len field */ >> - char *pneg_ctxt = (char *)req + OFFSET_OF_NEG_CONTEXT + 4; >> + char *pneg_ctxt = (char *)req + OFFSET_OF_NEG_CONTEXT; >> >> build_preauth_ctxt((struct smb2_preauth_neg_context *)pneg_ctxt); >> /* Add 2 to size to round to 8 byte boundary */ >> @@ -439,8 +437,6 @@ assemble_neg_contexts(struct smb2_negotiate_req *req) >> build_encrypt_ctxt((struct smb2_encryption_neg_context *)pneg_ctxt); >> req->NegotiateContextOffset = cpu_to_le32(OFFSET_OF_NEG_CONTEXT); >> req->NegotiateContextCount = cpu_to_le16(2); >> - inc_rfc1001_len(req, 4 + sizeof(struct smb2_preauth_neg_context) >> - + sizeof(struct smb2_encryption_neg_context)); /* calculate hash */ > >> Why do we need to remove this? > > Because req no longer contains a rfc1002 length field any more. > > We now compute the rfc1002 length during smb2_send_recv() and thus we don't need to > modify it using inc_rfc1001_len() any more. Ok. I misread it. Makes sense then. -- Best regards, Pavel Shilovsky ^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 02/19] cifs: remove rfc1002 header from smb2_negotiate_req [not found] ` <20171109011433.14468-3-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 14:10 ` Aurélien Aptel 2017-11-17 1:24 ` Pavel Shilovsky @ 2017-11-17 19:02 ` Pavel Shilovsky 2 siblings, 0 replies; 52+ messages in thread From: Pavel Shilovsky @ 2017-11-17 19:02 UTC (permalink / raw) To: Ronnie Sahlberg; +Cc: linux-cifs, Steve French 2017-11-08 17:14 GMT-08:00 Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>: > Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> > --- > fs/cifs/smb2pdu.c | 26 +++++++++++--------------- > fs/cifs/smb2pdu.h | 2 +- > 2 files changed, 12 insertions(+), 16 deletions(-) > > diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c > index 5331631386a2..f5cf9953955c 100644 > --- a/fs/cifs/smb2pdu.c > +++ b/fs/cifs/smb2pdu.c > @@ -398,8 +398,8 @@ small_smb2_init(__le16 smb2_command, struct cifs_tcon *tcon, > } > > #ifdef CONFIG_CIFS_SMB311 > -/* offset is sizeof smb2_negotiate_req - 4 but rounded up to 8 bytes */ > -#define OFFSET_OF_NEG_CONTEXT 0x68 /* sizeof(struct smb2_negotiate_req) - 4 */ > +/* offset is sizeof smb2_negotiate_req but rounded up to 8 bytes */ > +#define OFFSET_OF_NEG_CONTEXT 0x68 /* sizeof(struct smb2_negotiate_req) */ > > > #define SMB2_PREAUTH_INTEGRITY_CAPABILITIES cpu_to_le16(1) > @@ -429,9 +429,7 @@ build_encrypt_ctxt(struct smb2_encryption_neg_context *pneg_ctxt) > static void > assemble_neg_contexts(struct smb2_negotiate_req *req) > { > - > - /* +4 is to account for the RFC1001 len field */ > - char *pneg_ctxt = (char *)req + OFFSET_OF_NEG_CONTEXT + 4; > + char *pneg_ctxt = (char *)req + OFFSET_OF_NEG_CONTEXT; > > build_preauth_ctxt((struct smb2_preauth_neg_context *)pneg_ctxt); > /* Add 2 to size to round to 8 byte boundary */ > @@ -439,8 +437,6 @@ assemble_neg_contexts(struct smb2_negotiate_req *req) > build_encrypt_ctxt((struct smb2_encryption_neg_context *)pneg_ctxt); > req->NegotiateContextOffset = cpu_to_le32(OFFSET_OF_NEG_CONTEXT); > req->NegotiateContextCount = cpu_to_le16(2); > - inc_rfc1001_len(req, 4 + sizeof(struct smb2_preauth_neg_context) > - + sizeof(struct smb2_encryption_neg_context)); /* calculate hash */ Ok. I still think something is not right here. We added 2 contexts of "4 + sizeof(struct smb2_preauth_neg_context) + sizeof(struct smb2_encryption_neg_context)" size to the req buffer... > } > #else > static void assemble_neg_contexts(struct smb2_negotiate_req *req) > @@ -477,6 +473,7 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) > int blob_offset, blob_length; > char *security_blob; > int flags = CIFS_NEG_OP; > + unsigned int total_len; > > cifs_dbg(FYI, "Negotiate protocol\n"); > > @@ -485,30 +482,30 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) > return -EIO; > } > > - rc = small_smb2_init(SMB2_NEGOTIATE, NULL, (void **) &req); > + rc = smb2_plain_req_init(SMB2_NEGOTIATE, NULL, (void **) &req, &total_len); > if (rc) > return rc; > > - req->hdr.sync_hdr.SessionId = 0; > + req->sync_hdr.SessionId = 0; > > if (strcmp(ses->server->vals->version_string, > SMB3ANY_VERSION_STRING) == 0) { > req->Dialects[0] = cpu_to_le16(SMB30_PROT_ID); > req->Dialects[1] = cpu_to_le16(SMB302_PROT_ID); > req->DialectCount = cpu_to_le16(2); > - inc_rfc1001_len(req, 4); > + total_len += 4; > } else if (strcmp(ses->server->vals->version_string, > SMBDEFAULT_VERSION_STRING) == 0) { > req->Dialects[0] = cpu_to_le16(SMB21_PROT_ID); > req->Dialects[1] = cpu_to_le16(SMB30_PROT_ID); > req->Dialects[2] = cpu_to_le16(SMB302_PROT_ID); > req->DialectCount = cpu_to_le16(3); > - inc_rfc1001_len(req, 6); > + total_len += 6; > } else { > /* otherwise send specific dialect */ > req->Dialects[0] = cpu_to_le16(ses->server->vals->protocol_id); > req->DialectCount = cpu_to_le16(1); > - inc_rfc1001_len(req, 2); > + total_len += 2; > } > > /* only one of SMB2 signing flags may be set in SMB2 request */ > @@ -531,10 +528,9 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) > assemble_neg_contexts(req); ... but we do not update total_len variable, > } > iov[0].iov_base = (char *)req; > - /* 4 for rfc1002 length field */ > - iov[0].iov_len = get_rfc1002_length(req) + 4; > + iov[0].iov_len = total_len; ^^^ which is later used here to set iov_len. So, as a result we are missing those 2 negotiate contexts. > - rc = SendReceive2(xid, ses, iov, 1, &resp_buftype, flags, &rsp_iov); > + rc = smb2_send_recv(xid, ses, iov, 1, &resp_buftype, flags, &rsp_iov); > cifs_small_buf_release(req); > rsp = (struct smb2_negotiate_rsp *)rsp_iov.iov_base; > /* > diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h > index c2ec934be968..0fe2382597ad 100644 > --- a/fs/cifs/smb2pdu.h > +++ b/fs/cifs/smb2pdu.h > @@ -195,7 +195,7 @@ struct smb2_symlink_err_rsp { > #define SMB2_CLIENT_GUID_SIZE 16 > > struct smb2_negotiate_req { > - struct smb2_hdr hdr; > + struct smb2_sync_hdr sync_hdr; > __le16 StructureSize; /* Must be 36 */ > __le16 DialectCount; > __le16 SecurityMode; > -- > 2.13.3 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-cifs" in > the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Best regards, Pavel Shilovsky ^ permalink raw reply [flat|nested] 52+ messages in thread
* [PATCH 03/19] cifs: remove rfc1002 header from smb2_logoff_req [not found] ` <20171109011433.14468-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 1:14 ` [PATCH 01/19] cifs: Add smb2_send_recv Ronnie Sahlberg 2017-11-09 1:14 ` [PATCH 02/19] cifs: remove rfc1002 header from smb2_negotiate_req Ronnie Sahlberg @ 2017-11-09 1:14 ` Ronnie Sahlberg [not found] ` <20171109011433.14468-4-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 1:14 ` [PATCH 04/19] cifs: remove rfc1002 header from smb2_tree_disconnect_req Ronnie Sahlberg ` (15 subsequent siblings) 18 siblings, 1 reply; 52+ messages in thread From: Ronnie Sahlberg @ 2017-11-09 1:14 UTC (permalink / raw) To: linux-cifs; +Cc: Steve French Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> --- fs/cifs/smb2pdu.c | 17 +++++++++++++---- fs/cifs/smb2pdu.h | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index f5cf9953955c..02ad55aef029 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -1198,6 +1198,10 @@ SMB2_logoff(const unsigned int xid, struct cifs_ses *ses) int rc = 0; struct TCP_Server_Info *server; int flags = 0; + unsigned int total_len; + struct kvec iov[1]; + struct kvec rsp_iov; + int resp_buf_type; cifs_dbg(FYI, "disconnect session %p\n", ses); @@ -1210,19 +1214,24 @@ SMB2_logoff(const unsigned int xid, struct cifs_ses *ses) if (ses->need_reconnect) goto smb2_session_already_dead; - rc = small_smb2_init(SMB2_LOGOFF, NULL, (void **) &req); + rc = smb2_plain_req_init(SMB2_LOGOFF, NULL, (void **) &req, &total_len); if (rc) return rc; /* since no tcon, smb2_init can not do this, so do here */ - req->hdr.sync_hdr.SessionId = ses->Suid; + req->sync_hdr.SessionId = ses->Suid; if (ses->session_flags & SMB2_SESSION_FLAG_ENCRYPT_DATA) flags |= CIFS_TRANSFORM_REQ; else if (server->sign) - req->hdr.sync_hdr.Flags |= SMB2_FLAGS_SIGNED; + req->sync_hdr.Flags |= SMB2_FLAGS_SIGNED; + + flags |= CIFS_NO_RESP; + + iov[0].iov_base = (char *)req; + iov[0].iov_len = total_len; - rc = SendReceiveNoRsp(xid, ses, (char *) req, flags); + rc = smb2_send_recv(xid, ses, iov, 1, &resp_buf_type, flags, &rsp_iov); cifs_small_buf_release(req); /* * No tcon so can't do diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index 0fe2382597ad..0799e0957499 100644 --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h @@ -308,7 +308,7 @@ struct smb2_sess_setup_rsp { } __packed; struct smb2_logoff_req { - struct smb2_hdr hdr; + struct smb2_sync_hdr sync_hdr; __le16 StructureSize; /* Must be 4 */ __le16 Reserved; } __packed; -- 2.13.3 ^ permalink raw reply related [flat|nested] 52+ messages in thread
[parent not found: <20171109011433.14468-4-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 03/19] cifs: remove rfc1002 header from smb2_logoff_req [not found] ` <20171109011433.14468-4-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2017-11-09 14:10 ` Aurélien Aptel 0 siblings, 0 replies; 52+ messages in thread From: Aurélien Aptel @ 2017-11-09 14:10 UTC (permalink / raw) To: Ronnie Sahlberg, linux-cifs; +Cc: Steve French Reviewed-by: Aurelien Aptel <aaptel-IBi9RG/b67k@public.gmane.org> -- Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Linux GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) ^ permalink raw reply [flat|nested] 52+ messages in thread
* [PATCH 04/19] cifs: remove rfc1002 header from smb2_tree_disconnect_req [not found] ` <20171109011433.14468-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> ` (2 preceding siblings ...) 2017-11-09 1:14 ` [PATCH 03/19] cifs: remove rfc1002 header from smb2_logoff_req Ronnie Sahlberg @ 2017-11-09 1:14 ` Ronnie Sahlberg [not found] ` <20171109011433.14468-5-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 1:14 ` [PATCH 05/19] cifs: remove rfc1002 header from smb2_close_req Ronnie Sahlberg ` (14 subsequent siblings) 18 siblings, 1 reply; 52+ messages in thread From: Ronnie Sahlberg @ 2017-11-09 1:14 UTC (permalink / raw) To: linux-cifs; +Cc: Steve French Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> --- fs/cifs/smb2pdu.c | 14 ++++++++++++-- fs/cifs/smb2pdu.h | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 02ad55aef029..3c3a267f6c85 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -1394,6 +1394,10 @@ SMB2_tdis(const unsigned int xid, struct cifs_tcon *tcon) int rc = 0; struct cifs_ses *ses = tcon->ses; int flags = 0; + unsigned int total_len; + struct kvec iov[1]; + struct kvec rsp_iov; + int resp_buf_type; cifs_dbg(FYI, "Tree Disconnect\n"); @@ -1403,14 +1407,20 @@ SMB2_tdis(const unsigned int xid, struct cifs_tcon *tcon) if ((tcon->need_reconnect) || (tcon->ses->need_reconnect)) return 0; - rc = small_smb2_init(SMB2_TREE_DISCONNECT, tcon, (void **) &req); + rc = smb2_plain_req_init(SMB2_TREE_DISCONNECT, tcon, (void **) &req, + &total_len); if (rc) return rc; if (encryption_required(tcon)) flags |= CIFS_TRANSFORM_REQ; - rc = SendReceiveNoRsp(xid, ses, (char *)req, flags); + flags |= CIFS_NO_RESP; + + iov[0].iov_base = (char *)req; + iov[0].iov_len = total_len; + + rc = smb2_send_recv(xid, ses, iov, 1, &resp_buf_type, flags, &rsp_iov); cifs_small_buf_release(req); if (rc) cifs_stats_fail_inc(tcon, SMB2_TREE_DISCONNECT_HE); diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index 0799e0957499..8b7aadefd4a5 100644 --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h @@ -375,7 +375,7 @@ struct smb2_tree_connect_rsp { #define SMB2_SHARE_CAP_ASYMMETRIC cpu_to_le32(0x00000080) /* 3.02 */ struct smb2_tree_disconnect_req { - struct smb2_hdr hdr; + struct smb2_sync_hdr sync_hdr; __le16 StructureSize; /* Must be 4 */ __le16 Reserved; } __packed; -- 2.13.3 ^ permalink raw reply related [flat|nested] 52+ messages in thread
[parent not found: <20171109011433.14468-5-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 04/19] cifs: remove rfc1002 header from smb2_tree_disconnect_req [not found] ` <20171109011433.14468-5-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2017-11-09 14:10 ` Aurélien Aptel 0 siblings, 0 replies; 52+ messages in thread From: Aurélien Aptel @ 2017-11-09 14:10 UTC (permalink / raw) To: Ronnie Sahlberg, linux-cifs; +Cc: Steve French Reviewed-by: Aurelien Aptel <aaptel-IBi9RG/b67k@public.gmane.org> -- Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Linux GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) ^ permalink raw reply [flat|nested] 52+ messages in thread
* [PATCH 05/19] cifs: remove rfc1002 header from smb2_close_req [not found] ` <20171109011433.14468-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> ` (3 preceding siblings ...) 2017-11-09 1:14 ` [PATCH 04/19] cifs: remove rfc1002 header from smb2_tree_disconnect_req Ronnie Sahlberg @ 2017-11-09 1:14 ` Ronnie Sahlberg [not found] ` <20171109011433.14468-6-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 1:14 ` [PATCH 06/19] cifs: remove rfc1002 header from smb2_ioctl_req Ronnie Sahlberg ` (13 subsequent siblings) 18 siblings, 1 reply; 52+ messages in thread From: Ronnie Sahlberg @ 2017-11-09 1:14 UTC (permalink / raw) To: linux-cifs; +Cc: Steve French Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> --- fs/cifs/smb2pdu.c | 8 ++++---- fs/cifs/smb2pdu.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 3c3a267f6c85..2b31c6011591 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -2088,13 +2088,14 @@ SMB2_close(const unsigned int xid, struct cifs_tcon *tcon, int resp_buftype; int rc = 0; int flags = 0; + unsigned int total_len; cifs_dbg(FYI, "Close\n"); if (!ses || !(ses->server)) return -EIO; - rc = small_smb2_init(SMB2_CLOSE, tcon, (void **) &req); + rc = smb2_plain_req_init(SMB2_CLOSE, tcon, (void **) &req, &total_len); if (rc) return rc; @@ -2105,10 +2106,9 @@ SMB2_close(const unsigned int xid, struct cifs_tcon *tcon, req->VolatileFileId = volatile_fid; iov[0].iov_base = (char *)req; - /* 4 for rfc1002 length field */ - iov[0].iov_len = get_rfc1002_length(req) + 4; + iov[0].iov_len = total_len; - rc = SendReceive2(xid, ses, iov, 1, &resp_buftype, flags, &rsp_iov); + rc = smb2_send_recv(xid, ses, iov, 1, &resp_buftype, flags, &rsp_iov); cifs_small_buf_release(req); rsp = (struct smb2_close_rsp *)rsp_iov.iov_base; diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index 8b7aadefd4a5..5404207d9ee7 100644 --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h @@ -789,7 +789,7 @@ struct smb2_ioctl_rsp { /* Currently defined values for close flags */ #define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB cpu_to_le16(0x0001) struct smb2_close_req { - struct smb2_hdr hdr; + struct smb2_sync_hdr sync_hdr; __le16 StructureSize; /* Must be 24 */ __le16 Flags; __le32 Reserved; -- 2.13.3 ^ permalink raw reply related [flat|nested] 52+ messages in thread
[parent not found: <20171109011433.14468-6-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 05/19] cifs: remove rfc1002 header from smb2_close_req [not found] ` <20171109011433.14468-6-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2017-11-09 14:10 ` Aurélien Aptel 0 siblings, 0 replies; 52+ messages in thread From: Aurélien Aptel @ 2017-11-09 14:10 UTC (permalink / raw) To: Ronnie Sahlberg, linux-cifs; +Cc: Steve French Reviewed-by: Aurelien Aptel <aaptel-IBi9RG/b67k@public.gmane.org> -- Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Linux GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) ^ permalink raw reply [flat|nested] 52+ messages in thread
* [PATCH 06/19] cifs: remove rfc1002 header from smb2_ioctl_req [not found] ` <20171109011433.14468-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> ` (4 preceding siblings ...) 2017-11-09 1:14 ` [PATCH 05/19] cifs: remove rfc1002 header from smb2_close_req Ronnie Sahlberg @ 2017-11-09 1:14 ` Ronnie Sahlberg [not found] ` <20171109011433.14468-7-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 1:14 ` [PATCH 07/19] cifs: remove rfc1002 header from smb2_echo_req Ronnie Sahlberg ` (12 subsequent siblings) 18 siblings, 1 reply; 52+ messages in thread From: Ronnie Sahlberg @ 2017-11-09 1:14 UTC (permalink / raw) To: linux-cifs; +Cc: Steve French Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> --- fs/cifs/smb2pdu.c | 22 +++++++++++----------- fs/cifs/smb2pdu.h | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 2b31c6011591..1e2d231305fa 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -1906,6 +1906,7 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, int n_iov; int rc = 0; int flags = 0; + unsigned int total_len; cifs_dbg(FYI, "SMB2 IOCTL\n"); @@ -1924,7 +1925,7 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, if (!ses || !(ses->server)) return -EIO; - rc = small_smb2_init(SMB2_IOCTL, tcon, (void **) &req); + rc = smb2_plain_req_init(SMB2_IOCTL, tcon, (void **) &req, &total_len); if (rc) return rc; @@ -1935,8 +1936,8 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, } cifs_dbg(FYI, "replacing tid 0x%x with IPC tid 0x%x\n", - req->hdr.sync_hdr.TreeId, ses->ipc_tid); - req->hdr.sync_hdr.TreeId = ses->ipc_tid; + req->sync_hdr.TreeId, ses->ipc_tid); + req->sync_hdr.TreeId = ses->ipc_tid; } if (encryption_required(tcon)) flags |= CIFS_TRANSFORM_REQ; @@ -1949,7 +1950,7 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, req->InputCount = cpu_to_le32(indatalen); /* do not set InputOffset if no input data */ req->InputOffset = - cpu_to_le32(offsetof(struct smb2_ioctl_req, Buffer) - 4); + cpu_to_le32(offsetof(struct smb2_ioctl_req, Buffer)); iov[1].iov_base = in_data; iov[1].iov_len = indatalen; n_iov = 2; @@ -1984,21 +1985,20 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, * but if input data passed to ioctl, we do not * want to double count this, so we do not send * the dummy one byte of data in iovec[0] if sending - * input data (in iovec[1]). We also must add 4 bytes - * in first iovec to allow for rfc1002 length field. + * input data (in iovec[1]). */ if (indatalen) { - iov[0].iov_len = get_rfc1002_length(req) + 4 - 1; - inc_rfc1001_len(req, indatalen - 1); + iov[0].iov_len = total_len - 1; } else - iov[0].iov_len = get_rfc1002_length(req) + 4; + iov[0].iov_len = total_len; /* validate negotiate request must be signed - see MS-SMB2 3.2.5.5 */ if (opcode == FSCTL_VALIDATE_NEGOTIATE_INFO) - req->hdr.sync_hdr.Flags |= SMB2_FLAGS_SIGNED; + req->sync_hdr.Flags |= SMB2_FLAGS_SIGNED; - rc = SendReceive2(xid, ses, iov, n_iov, &resp_buftype, flags, &rsp_iov); + rc = smb2_send_recv(xid, ses, iov, n_iov, &resp_buftype, flags, + &rsp_iov); cifs_small_buf_release(req); rsp = (struct smb2_ioctl_rsp *)rsp_iov.iov_base; diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index 5404207d9ee7..2c743d338a11 100644 --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h @@ -753,7 +753,7 @@ struct duplicate_extents_to_file { } __packed; struct smb2_ioctl_req { - struct smb2_hdr hdr; + struct smb2_sync_hdr sync_hdr; __le16 StructureSize; /* Must be 57 */ __u16 Reserved; __le32 CtlCode; -- 2.13.3 ^ permalink raw reply related [flat|nested] 52+ messages in thread
[parent not found: <20171109011433.14468-7-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 06/19] cifs: remove rfc1002 header from smb2_ioctl_req [not found] ` <20171109011433.14468-7-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2017-11-09 14:10 ` Aurélien Aptel 0 siblings, 0 replies; 52+ messages in thread From: Aurélien Aptel @ 2017-11-09 14:10 UTC (permalink / raw) To: Ronnie Sahlberg, linux-cifs; +Cc: Steve French Reviewed-by: Aurelien Aptel <aaptel-IBi9RG/b67k@public.gmane.org> -- Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Linux GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) ^ permalink raw reply [flat|nested] 52+ messages in thread
* [PATCH 07/19] cifs: remove rfc1002 header from smb2_echo_req [not found] ` <20171109011433.14468-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> ` (5 preceding siblings ...) 2017-11-09 1:14 ` [PATCH 06/19] cifs: remove rfc1002 header from smb2_ioctl_req Ronnie Sahlberg @ 2017-11-09 1:14 ` Ronnie Sahlberg [not found] ` <20171109011433.14468-8-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 1:14 ` [PATCH 08/19] cifs: remove rfc1002 header from smb2_sess_setup_req Ronnie Sahlberg ` (11 subsequent siblings) 18 siblings, 1 reply; 52+ messages in thread From: Ronnie Sahlberg @ 2017-11-09 1:14 UTC (permalink / raw) To: linux-cifs; +Cc: Steve French Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> --- fs/cifs/smb2pdu.c | 14 ++++++++------ fs/cifs/smb2pdu.h | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 1e2d231305fa..6e08b609d9c0 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -2391,6 +2391,8 @@ SMB2_echo(struct TCP_Server_Info *server) struct kvec iov[2]; struct smb_rqst rqst = { .rq_iov = iov, .rq_nvec = 2 }; + unsigned int total_len; + __be32 rfc1002_marker; cifs_dbg(FYI, "In echo request\n"); @@ -2400,17 +2402,17 @@ SMB2_echo(struct TCP_Server_Info *server) return rc; } - rc = small_smb2_init(SMB2_ECHO, NULL, (void **)&req); + rc = smb2_plain_req_init(SMB2_ECHO, NULL, (void **)&req, &total_len); if (rc) return rc; - req->hdr.sync_hdr.CreditRequest = cpu_to_le16(1); + req->sync_hdr.CreditRequest = cpu_to_le16(1); - /* 4 for rfc1002 length field */ iov[0].iov_len = 4; - iov[0].iov_base = (char *)req; - iov[1].iov_len = get_rfc1002_length(req); - iov[1].iov_base = (char *)req + 4; + rfc1002_marker = cpu_to_be32(total_len); + iov[0].iov_base = &rfc1002_marker; + iov[1].iov_len = total_len; + iov[1].iov_base = (char *)req; rc = cifs_call_async(server, &rqst, NULL, smb2_echo_callback, NULL, server, CIFS_ECHO_OP); diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index 2c743d338a11..b22bf8c6753e 100644 --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h @@ -924,7 +924,7 @@ struct smb2_lock_rsp { } __packed; struct smb2_echo_req { - struct smb2_hdr hdr; + struct smb2_sync_hdr sync_hdr; __le16 StructureSize; /* Must be 4 */ __u16 Reserved; } __packed; -- 2.13.3 ^ permalink raw reply related [flat|nested] 52+ messages in thread
[parent not found: <20171109011433.14468-8-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 07/19] cifs: remove rfc1002 header from smb2_echo_req [not found] ` <20171109011433.14468-8-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2017-11-09 14:10 ` Aurélien Aptel 0 siblings, 0 replies; 52+ messages in thread From: Aurélien Aptel @ 2017-11-09 14:10 UTC (permalink / raw) To: Ronnie Sahlberg, linux-cifs; +Cc: Steve French Reviewed-by: Aurelien Aptel <aaptel-IBi9RG/b67k@public.gmane.org> -- Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Linux GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) ^ permalink raw reply [flat|nested] 52+ messages in thread
* [PATCH 08/19] cifs: remove rfc1002 header from smb2_sess_setup_req [not found] ` <20171109011433.14468-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> ` (6 preceding siblings ...) 2017-11-09 1:14 ` [PATCH 07/19] cifs: remove rfc1002 header from smb2_echo_req Ronnie Sahlberg @ 2017-11-09 1:14 ` Ronnie Sahlberg [not found] ` <20171109011433.14468-9-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 1:14 ` [PATCH 09/19] cifs: remove rfc1002 header from smb2_tree_connect_req Ronnie Sahlberg ` (10 subsequent siblings) 18 siblings, 1 reply; 52+ messages in thread From: Ronnie Sahlberg @ 2017-11-09 1:14 UTC (permalink / raw) To: linux-cifs; +Cc: Steve French Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> --- fs/cifs/smb2pdu.c | 27 +++++++++++++-------------- fs/cifs/smb2pdu.h | 2 +- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 6e08b609d9c0..7c281af5f37f 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -802,20 +802,22 @@ SMB2_sess_alloc_buffer(struct SMB2_sess_data *sess_data) struct cifs_ses *ses = sess_data->ses; struct smb2_sess_setup_req *req; struct TCP_Server_Info *server = ses->server; + unsigned int total_len; - rc = small_smb2_init(SMB2_SESSION_SETUP, NULL, (void **) &req); + rc = smb2_plain_req_init(SMB2_SESSION_SETUP, NULL, (void **) &req, + &total_len); if (rc) return rc; /* First session, not a reauthenticate */ - req->hdr.sync_hdr.SessionId = 0; + req->sync_hdr.SessionId = 0; /* if reconnect, we need to send previous sess id, otherwise it is 0 */ req->PreviousSessionId = sess_data->previous_session; req->Flags = 0; /* MBZ */ /* to enable echos and oplocks */ - req->hdr.sync_hdr.CreditRequest = cpu_to_le16(3); + req->sync_hdr.CreditRequest = cpu_to_le16(3); /* only one of SMB2 signing flags may be set in SMB2 request */ if (server->sign) @@ -829,8 +831,8 @@ SMB2_sess_alloc_buffer(struct SMB2_sess_data *sess_data) req->Channel = 0; /* MBZ */ sess_data->iov[0].iov_base = (char *)req; - /* 4 for rfc1002 length field and 1 for pad */ - sess_data->iov[0].iov_len = get_rfc1002_length(req) + 4 - 1; + /* 1 for pad */ + sess_data->iov[0].iov_len = total_len - 1; /* * This variable will be used to clear the buffer * allocated above in case of any error in the calling function. @@ -856,18 +858,15 @@ SMB2_sess_sendreceive(struct SMB2_sess_data *sess_data) /* Testing shows that buffer offset must be at location of Buffer[0] */ req->SecurityBufferOffset = - cpu_to_le16(sizeof(struct smb2_sess_setup_req) - - 1 /* pad */ - 4 /* rfc1001 len */); + cpu_to_le16(sizeof(struct smb2_sess_setup_req) - 1 /* pad */); req->SecurityBufferLength = cpu_to_le16(sess_data->iov[1].iov_len); - inc_rfc1001_len(req, sess_data->iov[1].iov_len - 1 /* pad */); - /* BB add code to build os and lm fields */ - rc = SendReceive2(sess_data->xid, sess_data->ses, - sess_data->iov, 2, - &sess_data->buf0_type, - CIFS_LOG_ERROR | CIFS_NEG_OP, &rsp_iov); + rc = smb2_send_recv(sess_data->xid, sess_data->ses, + sess_data->iov, 2, + &sess_data->buf0_type, + CIFS_LOG_ERROR | CIFS_NEG_OP, &rsp_iov); cifs_small_buf_release(sess_data->iov[0].iov_base); memcpy(&sess_data->iov[0], &rsp_iov, sizeof(struct kvec)); @@ -1088,7 +1087,7 @@ SMB2_sess_auth_rawntlmssp_authenticate(struct SMB2_sess_data *sess_data) goto out; req = (struct smb2_sess_setup_req *) sess_data->iov[0].iov_base; - req->hdr.sync_hdr.SessionId = ses->Suid; + req->sync_hdr.SessionId = ses->Suid; rc = build_ntlmssp_auth_blob(&ntlmssp_blob, &blob_length, ses, sess_data->nls_cp); diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index b22bf8c6753e..e7acfa5e3fa6 100644 --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h @@ -282,7 +282,7 @@ struct smb2_negotiate_rsp { #define SMB2_SESSION_REQ_FLAG_ENCRYPT_DATA 0x04 struct smb2_sess_setup_req { - struct smb2_hdr hdr; + struct smb2_sync_hdr sync_hdr; __le16 StructureSize; /* Must be 25 */ __u8 Flags; __u8 SecurityMode; -- 2.13.3 ^ permalink raw reply related [flat|nested] 52+ messages in thread
[parent not found: <20171109011433.14468-9-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 08/19] cifs: remove rfc1002 header from smb2_sess_setup_req [not found] ` <20171109011433.14468-9-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2017-11-09 14:10 ` Aurélien Aptel 0 siblings, 0 replies; 52+ messages in thread From: Aurélien Aptel @ 2017-11-09 14:10 UTC (permalink / raw) To: Ronnie Sahlberg, linux-cifs; +Cc: Steve French Reviewed-by: Aurelien Aptel <aaptel-IBi9RG/b67k@public.gmane.org> -- Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Linux GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) ^ permalink raw reply [flat|nested] 52+ messages in thread
* [PATCH 09/19] cifs: remove rfc1002 header from smb2_tree_connect_req [not found] ` <20171109011433.14468-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> ` (7 preceding siblings ...) 2017-11-09 1:14 ` [PATCH 08/19] cifs: remove rfc1002 header from smb2_sess_setup_req Ronnie Sahlberg @ 2017-11-09 1:14 ` Ronnie Sahlberg [not found] ` <20171109011433.14468-10-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 1:14 ` [PATCH 10/19] cifs: remove rfc1002 header from smb2_create_req Ronnie Sahlberg ` (9 subsequent siblings) 18 siblings, 1 reply; 52+ messages in thread From: Ronnie Sahlberg @ 2017-11-09 1:14 UTC (permalink / raw) To: linux-cifs; +Cc: Steve French Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> --- fs/cifs/smb2pdu.c | 18 +++++++++--------- fs/cifs/smb2pdu.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 7c281af5f37f..7badd3b28c99 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -1269,6 +1269,7 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree, int unc_path_len; __le16 *unc_path = NULL; int flags = 0; + unsigned int total_len; cifs_dbg(FYI, "TCON\n"); @@ -1290,7 +1291,8 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree, if (tcon) tcon->tid = 0; - rc = small_smb2_init(SMB2_TREE_CONNECT, tcon, (void **) &req); + rc = smb2_plain_req_init(SMB2_TREE_CONNECT, tcon, (void **) &req, + &total_len); if (rc) { kfree(unc_path); return rc; @@ -1301,26 +1303,24 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree, flags |= CIFS_TRANSFORM_REQ; /* since no tcon, smb2_init can not do this, so do here */ - req->hdr.sync_hdr.SessionId = ses->Suid; + req->sync_hdr.SessionId = ses->Suid; if (ses->server->sign) - req->hdr.sync_hdr.Flags |= SMB2_FLAGS_SIGNED; + req->sync_hdr.Flags |= SMB2_FLAGS_SIGNED; } else if (encryption_required(tcon)) flags |= CIFS_TRANSFORM_REQ; iov[0].iov_base = (char *)req; - /* 4 for rfc1002 length field and 1 for pad */ - iov[0].iov_len = get_rfc1002_length(req) + 4 - 1; + /* 1 for pad */ + iov[0].iov_len = total_len - 1; /* Testing shows that buffer offset must be at location of Buffer[0] */ req->PathOffset = cpu_to_le16(sizeof(struct smb2_tree_connect_req) - - 1 /* pad */ - 4 /* do not count rfc1001 len field */); + - 1 /* pad */); req->PathLength = cpu_to_le16(unc_path_len - 2); iov[1].iov_base = unc_path; iov[1].iov_len = unc_path_len; - inc_rfc1001_len(req, unc_path_len - 1 /* pad */); - - rc = SendReceive2(xid, ses, iov, 2, &resp_buftype, flags, &rsp_iov); + rc = smb2_send_recv(xid, ses, iov, 2, &resp_buftype, flags, &rsp_iov); cifs_small_buf_release(req); rsp = (struct smb2_tree_connect_rsp *)rsp_iov.iov_base; diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index e7acfa5e3fa6..4f80b95d02ae 100644 --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h @@ -323,7 +323,7 @@ struct smb2_logoff_rsp { #define SMB2_SHAREFLAG_CLUSTER_RECONNECT 0x0001 struct smb2_tree_connect_req { - struct smb2_hdr hdr; + struct smb2_sync_hdr sync_hdr; __le16 StructureSize; /* Must be 9 */ __le16 Reserved; /* Flags in SMB3.1.1 */ __le16 PathOffset; -- 2.13.3 ^ permalink raw reply related [flat|nested] 52+ messages in thread
[parent not found: <20171109011433.14468-10-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 09/19] cifs: remove rfc1002 header from smb2_tree_connect_req [not found] ` <20171109011433.14468-10-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2017-11-09 14:10 ` Aurélien Aptel 0 siblings, 0 replies; 52+ messages in thread From: Aurélien Aptel @ 2017-11-09 14:10 UTC (permalink / raw) To: Ronnie Sahlberg, linux-cifs; +Cc: Steve French Reviewed-by: Aurelien Aptel <aaptel-IBi9RG/b67k@public.gmane.org> -- Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Linux GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) ^ permalink raw reply [flat|nested] 52+ messages in thread
* [PATCH 10/19] cifs: remove rfc1002 header from smb2_create_req [not found] ` <20171109011433.14468-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> ` (8 preceding siblings ...) 2017-11-09 1:14 ` [PATCH 09/19] cifs: remove rfc1002 header from smb2_tree_connect_req Ronnie Sahlberg @ 2017-11-09 1:14 ` Ronnie Sahlberg [not found] ` <20171109011433.14468-11-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 1:14 ` [PATCH 11/19] cifs: remove rfc1002 header from smb2_flush_req Ronnie Sahlberg ` (8 subsequent siblings) 18 siblings, 1 reply; 52+ messages in thread From: Ronnie Sahlberg @ 2017-11-09 1:14 UTC (permalink / raw) To: linux-cifs; +Cc: Steve French Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> --- fs/cifs/smb2pdu.c | 30 ++++++++++++------------------ fs/cifs/smb2pdu.h | 2 +- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 7badd3b28c99..a9726a2b7b88 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -1519,11 +1519,10 @@ add_lease_context(struct TCP_Server_Info *server, struct kvec *iov, req->RequestedOplockLevel = SMB2_OPLOCK_LEVEL_LEASE; if (!req->CreateContextsOffset) req->CreateContextsOffset = cpu_to_le32( - sizeof(struct smb2_create_req) - 4 + + sizeof(struct smb2_create_req) + iov[num - 1].iov_len); le32_add_cpu(&req->CreateContextsLength, server->vals->create_lease_size); - inc_rfc1001_len(&req->hdr, server->vals->create_lease_size); *num_iovec = num + 1; return 0; } @@ -1603,10 +1602,9 @@ add_durable_v2_context(struct kvec *iov, unsigned int *num_iovec, iov[num].iov_len = sizeof(struct create_durable_v2); if (!req->CreateContextsOffset) req->CreateContextsOffset = - cpu_to_le32(sizeof(struct smb2_create_req) - 4 + + cpu_to_le32(sizeof(struct smb2_create_req) + iov[1].iov_len); le32_add_cpu(&req->CreateContextsLength, sizeof(struct create_durable_v2)); - inc_rfc1001_len(&req->hdr, sizeof(struct create_durable_v2)); *num_iovec = num + 1; return 0; } @@ -1627,12 +1625,10 @@ add_durable_reconnect_v2_context(struct kvec *iov, unsigned int *num_iovec, iov[num].iov_len = sizeof(struct create_durable_handle_reconnect_v2); if (!req->CreateContextsOffset) req->CreateContextsOffset = - cpu_to_le32(sizeof(struct smb2_create_req) - 4 + + cpu_to_le32(sizeof(struct smb2_create_req) + iov[1].iov_len); le32_add_cpu(&req->CreateContextsLength, sizeof(struct create_durable_handle_reconnect_v2)); - inc_rfc1001_len(&req->hdr, - sizeof(struct create_durable_handle_reconnect_v2)); *num_iovec = num + 1; return 0; } @@ -1663,10 +1659,9 @@ add_durable_context(struct kvec *iov, unsigned int *num_iovec, iov[num].iov_len = sizeof(struct create_durable); if (!req->CreateContextsOffset) req->CreateContextsOffset = - cpu_to_le32(sizeof(struct smb2_create_req) - 4 + + cpu_to_le32(sizeof(struct smb2_create_req) + iov[1].iov_len); le32_add_cpu(&req->CreateContextsLength, sizeof(struct create_durable)); - inc_rfc1001_len(&req->hdr, sizeof(struct create_durable)); *num_iovec = num + 1; return 0; } @@ -1737,6 +1732,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, __u32 file_attributes = 0; char *dhc_buf = NULL, *lc_buf = NULL; int flags = 0; + unsigned int total_len; cifs_dbg(FYI, "create/open\n"); @@ -1745,7 +1741,8 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, else return -EIO; - rc = small_smb2_init(SMB2_CREATE, tcon, (void **) &req); + rc = smb2_plain_req_init(SMB2_CREATE, tcon, (void **) &req, &total_len); + if (rc) return rc; @@ -1766,12 +1763,10 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, req->CreateOptions = cpu_to_le32(oparms->create_options & CREATE_OPTIONS_MASK); iov[0].iov_base = (char *)req; - /* 4 for rfc1002 length field */ - iov[0].iov_len = get_rfc1002_length(req) + 4; /* -1 since last byte is buf[0] which is sent below (path) */ - iov[0].iov_len--; + iov[0].iov_len = total_len - 1; - req->NameOffset = cpu_to_le16(sizeof(struct smb2_create_req) - 4); + req->NameOffset = cpu_to_le16(sizeof(struct smb2_create_req)); /* [MS-SMB2] 2.2.13 NameOffset: * If SMB2_FLAGS_DFS_OPERATIONS is set in the Flags field of @@ -1784,7 +1779,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, if (tcon->share_flags & SHI1005_FLAGS_DFS) { int name_len; - req->hdr.sync_hdr.Flags |= SMB2_FLAGS_DFS_OPERATIONS; + req->sync_hdr.Flags |= SMB2_FLAGS_DFS_OPERATIONS; rc = alloc_path_with_tree_prefix(©_path, ©_size, &name_len, tcon->treeName, path); @@ -1811,8 +1806,6 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, iov[1].iov_len = uni_path_len; iov[1].iov_base = path; - /* -1 since last byte is buf[0] which was counted in smb2_buf_len */ - inc_rfc1001_len(req, uni_path_len - 1); if (!server->oplocks) *oplock = SMB2_OPLOCK_LEVEL_NONE; @@ -1850,7 +1843,8 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, dhc_buf = iov[n_iov-1].iov_base; } - rc = SendReceive2(xid, ses, iov, n_iov, &resp_buftype, flags, &rsp_iov); + rc = smb2_send_recv(xid, ses, iov, n_iov, &resp_buftype, flags, + &rsp_iov); cifs_small_buf_release(req); rsp = (struct smb2_create_rsp *)rsp_iov.iov_base; diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index 4f80b95d02ae..6e1874a81014 100644 --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h @@ -496,7 +496,7 @@ struct smb2_tree_disconnect_rsp { #define SVHDX_OPEN_DEVICE_CONTEXT 0x83CE6F1AD851E0986E34401CC9BCFCE9 struct smb2_create_req { - struct smb2_hdr hdr; + struct smb2_sync_hdr sync_hdr; __le16 StructureSize; /* Must be 57 */ __u8 SecurityFlags; __u8 RequestedOplockLevel; -- 2.13.3 ^ permalink raw reply related [flat|nested] 52+ messages in thread
[parent not found: <20171109011433.14468-11-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 10/19] cifs: remove rfc1002 header from smb2_create_req [not found] ` <20171109011433.14468-11-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2017-11-09 14:10 ` Aurélien Aptel 0 siblings, 0 replies; 52+ messages in thread From: Aurélien Aptel @ 2017-11-09 14:10 UTC (permalink / raw) To: Ronnie Sahlberg, linux-cifs; +Cc: Steve French Reviewed-by: Aurelien Aptel <aaptel-IBi9RG/b67k@public.gmane.org> -- Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Linux GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) ^ permalink raw reply [flat|nested] 52+ messages in thread
* [PATCH 11/19] cifs: remove rfc1002 header from smb2_flush_req [not found] ` <20171109011433.14468-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> ` (9 preceding siblings ...) 2017-11-09 1:14 ` [PATCH 10/19] cifs: remove rfc1002 header from smb2_create_req Ronnie Sahlberg @ 2017-11-09 1:14 ` Ronnie Sahlberg [not found] ` <20171109011433.14468-12-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 1:14 ` [PATCH 12/19] cifs: remove rfc1002 header from smb2_lock_req Ronnie Sahlberg ` (7 subsequent siblings) 18 siblings, 1 reply; 52+ messages in thread From: Ronnie Sahlberg @ 2017-11-09 1:14 UTC (permalink / raw) To: linux-cifs; +Cc: Steve French Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> --- fs/cifs/smb2pdu.c | 8 ++++---- fs/cifs/smb2pdu.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index a9726a2b7b88..144395bab5c1 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -2427,13 +2427,14 @@ SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, int resp_buftype; int rc = 0; int flags = 0; + unsigned int total_len; cifs_dbg(FYI, "Flush\n"); if (!ses || !(ses->server)) return -EIO; - rc = small_smb2_init(SMB2_FLUSH, tcon, (void **) &req); + rc = smb2_plain_req_init(SMB2_FLUSH, tcon, (void **) &req, &total_len); if (rc) return rc; @@ -2444,10 +2445,9 @@ SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, req->VolatileFileId = volatile_fid; iov[0].iov_base = (char *)req; - /* 4 for rfc1002 length field */ - iov[0].iov_len = get_rfc1002_length(req) + 4; + iov[0].iov_len = total_len; - rc = SendReceive2(xid, ses, iov, 1, &resp_buftype, flags, &rsp_iov); + rc = smb2_send_recv(xid, ses, iov, 1, &resp_buftype, flags, &rsp_iov); cifs_small_buf_release(req); if (rc != 0) diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index 6e1874a81014..a8102e5f4ebb 100644 --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h @@ -812,7 +812,7 @@ struct smb2_close_rsp { } __packed; struct smb2_flush_req { - struct smb2_hdr hdr; + struct smb2_sync_hdr sync_hdr; __le16 StructureSize; /* Must be 24 */ __le16 Reserved1; __le32 Reserved2; -- 2.13.3 ^ permalink raw reply related [flat|nested] 52+ messages in thread
[parent not found: <20171109011433.14468-12-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 11/19] cifs: remove rfc1002 header from smb2_flush_req [not found] ` <20171109011433.14468-12-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2017-11-09 14:11 ` Aurélien Aptel 0 siblings, 0 replies; 52+ messages in thread From: Aurélien Aptel @ 2017-11-09 14:11 UTC (permalink / raw) To: Ronnie Sahlberg, linux-cifs; +Cc: Steve French Reviewed-by: Aurelien Aptel <aaptel-IBi9RG/b67k@public.gmane.org> -- Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Linux GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) ^ permalink raw reply [flat|nested] 52+ messages in thread
* [PATCH 12/19] cifs: remove rfc1002 header from smb2_lock_req [not found] ` <20171109011433.14468-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> ` (10 preceding siblings ...) 2017-11-09 1:14 ` [PATCH 11/19] cifs: remove rfc1002 header from smb2_flush_req Ronnie Sahlberg @ 2017-11-09 1:14 ` Ronnie Sahlberg [not found] ` <20171109011433.14468-13-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 1:14 ` [PATCH 13/19] cifs: remove rfc1002 header from smb2 read/write requests Ronnie Sahlberg ` (6 subsequent siblings) 18 siblings, 1 reply; 52+ messages in thread From: Ronnie Sahlberg @ 2017-11-09 1:14 UTC (permalink / raw) To: linux-cifs; +Cc: Steve French Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> --- fs/cifs/smb2pdu.c | 13 ++++++------- fs/cifs/smb2pdu.h | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 144395bab5c1..a44d54ea946b 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -3515,34 +3515,33 @@ smb2_lockv(const unsigned int xid, struct cifs_tcon *tcon, int resp_buf_type; unsigned int count; int flags = CIFS_NO_RESP; + unsigned int total_len; cifs_dbg(FYI, "smb2_lockv num lock %d\n", num_lock); - rc = small_smb2_init(SMB2_LOCK, tcon, (void **) &req); + rc = smb2_plain_req_init(SMB2_LOCK, tcon, (void **) &req, &total_len); if (rc) return rc; if (encryption_required(tcon)) flags |= CIFS_TRANSFORM_REQ; - req->hdr.sync_hdr.ProcessId = cpu_to_le32(pid); + req->sync_hdr.ProcessId = cpu_to_le32(pid); req->LockCount = cpu_to_le16(num_lock); req->PersistentFileId = persist_fid; req->VolatileFileId = volatile_fid; count = num_lock * sizeof(struct smb2_lock_element); - inc_rfc1001_len(req, count - sizeof(struct smb2_lock_element)); iov[0].iov_base = (char *)req; - /* 4 for rfc1002 length field and count for all locks */ - iov[0].iov_len = get_rfc1002_length(req) + 4 - count; + iov[0].iov_len = total_len; iov[1].iov_base = (char *)buf; iov[1].iov_len = count; cifs_stats_inc(&tcon->stats.cifs_stats.num_locks); - rc = SendReceive2(xid, tcon->ses, iov, 2, &resp_buf_type, flags, - &rsp_iov); + rc = smb2_send_recv(xid, tcon->ses, iov, 2, &resp_buf_type, flags, + &rsp_iov); cifs_small_buf_release(req); if (rc) { cifs_dbg(FYI, "Send error in smb2_lockv = %d\n", rc); diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index a8102e5f4ebb..0c33fc8cce71 100644 --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h @@ -907,7 +907,7 @@ struct smb2_lock_element { } __packed; struct smb2_lock_req { - struct smb2_hdr hdr; + struct smb2_sync_hdr sync_hdr; __le16 StructureSize; /* Must be 48 */ __le16 LockCount; __le32 Reserved; -- 2.13.3 ^ permalink raw reply related [flat|nested] 52+ messages in thread
[parent not found: <20171109011433.14468-13-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 12/19] cifs: remove rfc1002 header from smb2_lock_req [not found] ` <20171109011433.14468-13-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2017-11-09 14:11 ` Aurélien Aptel 0 siblings, 0 replies; 52+ messages in thread From: Aurélien Aptel @ 2017-11-09 14:11 UTC (permalink / raw) To: Ronnie Sahlberg, linux-cifs; +Cc: Steve French Reviewed-by: Aurelien Aptel <aaptel-IBi9RG/b67k@public.gmane.org> -- Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Linux GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) ^ permalink raw reply [flat|nested] 52+ messages in thread
* [PATCH 13/19] cifs: remove rfc1002 header from smb2 read/write requests [not found] ` <20171109011433.14468-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> ` (11 preceding siblings ...) 2017-11-09 1:14 ` [PATCH 12/19] cifs: remove rfc1002 header from smb2_lock_req Ronnie Sahlberg @ 2017-11-09 1:14 ` Ronnie Sahlberg [not found] ` <20171109011433.14468-14-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 1:14 ` [PATCH 14/19] cifs: remove rfc1002 header from smb2_lease_ack Ronnie Sahlberg ` (5 subsequent siblings) 18 siblings, 1 reply; 52+ messages in thread From: Ronnie Sahlberg @ 2017-11-09 1:14 UTC (permalink / raw) To: linux-cifs; +Cc: Steve French Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> --- fs/cifs/smb2pdu.c | 42 ++++++++++++++++++++---------------------- fs/cifs/smb2pdu.h | 2 +- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index a44d54ea946b..3ba9b2853902 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -2471,7 +2471,7 @@ smb2_new_read_req(void **buf, unsigned int *total_len, struct smb2_sync_hdr *shdr; rc = smb2_plain_req_init(SMB2_READ, io_parms->tcon, (void **) &req, - total_len); + total_len); if (rc) return rc; if (io_parms->tcon->ses->server == NULL) @@ -2681,7 +2681,7 @@ SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms, iov[0].iov_base = &req_len; iov[0].iov_len = sizeof(__be32); - iov[1].iov_base = req; + iov[1].iov_base = (char *)req; iov[1].iov_len = total_len; rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov); @@ -2786,8 +2786,10 @@ smb2_async_writev(struct cifs_writedata *wdata, struct TCP_Server_Info *server = tcon->ses->server; struct kvec iov[2]; struct smb_rqst rqst = { }; + unsigned int total_len; + __be32 rfc1002_marker; - rc = small_smb2_init(SMB2_WRITE, tcon, (void **) &req); + rc = smb2_plain_req_init(SMB2_WRITE, tcon, (void **) &req, &total_len); if (rc) { if (rc == -EAGAIN && wdata->credits) { /* credits was reset by reconnect */ @@ -2803,7 +2805,7 @@ smb2_async_writev(struct cifs_writedata *wdata, if (encryption_required(tcon)) flags |= CIFS_TRANSFORM_REQ; - shdr = get_sync_hdr(req); + shdr = (struct smb2_sync_hdr *)req; shdr->ProcessId = cpu_to_le32(wdata->cfile->pid); req->PersistentFileId = wdata->cfile->fid.persistent_fid; @@ -2812,16 +2814,16 @@ smb2_async_writev(struct cifs_writedata *wdata, req->WriteChannelInfoLength = 0; req->Channel = 0; req->Offset = cpu_to_le64(wdata->offset); - /* 4 for rfc1002 length field */ req->DataOffset = cpu_to_le16( - offsetof(struct smb2_write_req, Buffer) - 4); + offsetof(struct smb2_write_req, Buffer)); req->RemainingBytes = 0; /* 4 for rfc1002 length field and 1 for Buffer */ iov[0].iov_len = 4; - iov[0].iov_base = req; - iov[1].iov_len = get_rfc1002_length(req) - 1; - iov[1].iov_base = (char *)req + 4; + rfc1002_marker = cpu_to_be32(total_len - 1 + wdata->bytes); + iov[0].iov_base = &rfc1002_marker; + iov[1].iov_len = total_len - 1; + iov[1].iov_base = (char *)req; rqst.rq_iov = iov; rqst.rq_nvec = 2; @@ -2835,8 +2837,6 @@ smb2_async_writev(struct cifs_writedata *wdata, req->Length = cpu_to_le32(wdata->bytes); - inc_rfc1001_len(&req->hdr, wdata->bytes - 1 /* Buffer */); - if (wdata->credits) { shdr->CreditCharge = cpu_to_le16(DIV_ROUND_UP(wdata->bytes, SMB2_MAX_BUFFER_SIZE)); @@ -2879,13 +2879,15 @@ SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms, int resp_buftype; struct kvec rsp_iov; int flags = 0; + unsigned int total_len; *nbytes = 0; if (n_vec < 1) return rc; - rc = small_smb2_init(SMB2_WRITE, io_parms->tcon, (void **) &req); + rc = smb2_plain_req_init(SMB2_WRITE, io_parms->tcon, (void **) &req, + &total_len); if (rc) return rc; @@ -2895,7 +2897,7 @@ SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms, if (encryption_required(io_parms->tcon)) flags |= CIFS_TRANSFORM_REQ; - req->hdr.sync_hdr.ProcessId = cpu_to_le32(io_parms->pid); + req->sync_hdr.ProcessId = cpu_to_le32(io_parms->pid); req->PersistentFileId = io_parms->persistent_fid; req->VolatileFileId = io_parms->volatile_fid; @@ -2904,20 +2906,16 @@ SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms, req->Channel = 0; req->Length = cpu_to_le32(io_parms->length); req->Offset = cpu_to_le64(io_parms->offset); - /* 4 for rfc1002 length field */ req->DataOffset = cpu_to_le16( - offsetof(struct smb2_write_req, Buffer) - 4); + offsetof(struct smb2_write_req, Buffer)); req->RemainingBytes = 0; iov[0].iov_base = (char *)req; - /* 4 for rfc1002 length field and 1 for Buffer */ - iov[0].iov_len = get_rfc1002_length(req) + 4 - 1; - - /* length of entire message including data to be written */ - inc_rfc1001_len(req, io_parms->length - 1 /* Buffer */); + /* 1 for Buffer */ + iov[0].iov_len = total_len - 1; - rc = SendReceive2(xid, io_parms->tcon->ses, iov, n_vec + 1, - &resp_buftype, flags, &rsp_iov); + rc = smb2_send_recv(xid, io_parms->tcon->ses, iov, n_vec + 1, + &resp_buftype, flags, &rsp_iov); cifs_small_buf_release(req); rsp = (struct smb2_write_rsp *)rsp_iov.iov_base; diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index 0c33fc8cce71..3c856f058be7 100644 --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h @@ -868,7 +868,7 @@ struct smb2_read_rsp { #define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002 /* SMB3.02 or later */ struct smb2_write_req { - struct smb2_hdr hdr; + struct smb2_sync_hdr sync_hdr; __le16 StructureSize; /* Must be 49 */ __le16 DataOffset; /* offset from start of SMB2 header to write data */ __le32 Length; -- 2.13.3 ^ permalink raw reply related [flat|nested] 52+ messages in thread
[parent not found: <20171109011433.14468-14-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 13/19] cifs: remove rfc1002 header from smb2 read/write requests [not found] ` <20171109011433.14468-14-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2017-11-09 14:11 ` Aurélien Aptel 2017-11-17 1:42 ` Pavel Shilovsky 1 sibling, 0 replies; 52+ messages in thread From: Aurélien Aptel @ 2017-11-09 14:11 UTC (permalink / raw) To: Ronnie Sahlberg, linux-cifs; +Cc: Steve French Reviewed-by: Aurelien Aptel <aaptel-IBi9RG/b67k@public.gmane.org> -- Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Linux GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) ^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 13/19] cifs: remove rfc1002 header from smb2 read/write requests [not found] ` <20171109011433.14468-14-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 14:11 ` Aurélien Aptel @ 2017-11-17 1:42 ` Pavel Shilovsky [not found] ` <CAKywueRU_HM44i04yv_gKza=tgsuxwfF4h-XfstbXTZe3AZQeg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 1 sibling, 1 reply; 52+ messages in thread From: Pavel Shilovsky @ 2017-11-17 1:42 UTC (permalink / raw) To: Ronnie Sahlberg; +Cc: linux-cifs, Steve French 2017-11-08 17:14 GMT-08:00 Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>: > Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> > --- > fs/cifs/smb2pdu.c | 42 ++++++++++++++++++++---------------------- > fs/cifs/smb2pdu.h | 2 +- > 2 files changed, 21 insertions(+), 23 deletions(-) > > diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c > index a44d54ea946b..3ba9b2853902 100644 > --- a/fs/cifs/smb2pdu.c > +++ b/fs/cifs/smb2pdu.c > @@ -2471,7 +2471,7 @@ smb2_new_read_req(void **buf, unsigned int *total_len, > struct smb2_sync_hdr *shdr; > > rc = smb2_plain_req_init(SMB2_READ, io_parms->tcon, (void **) &req, > - total_len); > + total_len); > if (rc) > return rc; > if (io_parms->tcon->ses->server == NULL) > @@ -2681,7 +2681,7 @@ SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms, > > iov[0].iov_base = &req_len; > iov[0].iov_len = sizeof(__be32); > - iov[1].iov_base = req; > + iov[1].iov_base = (char *)req; > iov[1].iov_len = total_len; > > rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov); Why do not convert it to use new smb2_send_recv() function? -- Best regards, Pavel Shilovsky ^ permalink raw reply [flat|nested] 52+ messages in thread
[parent not found: <CAKywueRU_HM44i04yv_gKza=tgsuxwfF4h-XfstbXTZe3AZQeg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH 13/19] cifs: remove rfc1002 header from smb2 read/write requests [not found] ` <CAKywueRU_HM44i04yv_gKza=tgsuxwfF4h-XfstbXTZe3AZQeg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2017-11-17 1:45 ` Leif Sahlberg [not found] ` <546793899.27950063.1510883138100.JavaMail.zimbra-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 0 siblings, 1 reply; 52+ messages in thread From: Leif Sahlberg @ 2017-11-17 1:45 UTC (permalink / raw) To: Pavel Shilovsky; +Cc: linux-cifs, Steve French ----- Original Message ----- From: "Pavel Shilovsky" <piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> To: "Ronnie Sahlberg" <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> Cc: "linux-cifs" <linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>, "Steve French" <smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Sent: Friday, 17 November, 2017 12:42:07 PM Subject: Re: [PATCH 13/19] cifs: remove rfc1002 header from smb2 read/write requests 2017-11-08 17:14 GMT-08:00 Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>: > Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> > --- > fs/cifs/smb2pdu.c | 42 ++++++++++++++++++++---------------------- > fs/cifs/smb2pdu.h | 2 +- > 2 files changed, 21 insertions(+), 23 deletions(-) > > diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c > index a44d54ea946b..3ba9b2853902 100644 > --- a/fs/cifs/smb2pdu.c > +++ b/fs/cifs/smb2pdu.c > @@ -2471,7 +2471,7 @@ smb2_new_read_req(void **buf, unsigned int *total_len, > struct smb2_sync_hdr *shdr; > > rc = smb2_plain_req_init(SMB2_READ, io_parms->tcon, (void **) &req, > - total_len); > + total_len); > if (rc) > return rc; > if (io_parms->tcon->ses->server == NULL) > @@ -2681,7 +2681,7 @@ SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms, > > iov[0].iov_base = &req_len; > iov[0].iov_len = sizeof(__be32); > - iov[1].iov_base = req; > + iov[1].iov_base = (char *)req; > iov[1].iov_len = total_len; > > rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov); > Why do not convert it to use new smb2_send_recv() function? Good point. Do you want me to do that change as a follow up patch or should I edit and re-send the patch series ? -- Best regards, Pavel Shilovsky -- To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 52+ messages in thread
[parent not found: <546793899.27950063.1510883138100.JavaMail.zimbra-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 13/19] cifs: remove rfc1002 header from smb2 read/write requests [not found] ` <546793899.27950063.1510883138100.JavaMail.zimbra-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2017-11-17 1:48 ` Pavel Shilovsky 0 siblings, 0 replies; 52+ messages in thread From: Pavel Shilovsky @ 2017-11-17 1:48 UTC (permalink / raw) To: Leif Sahlberg; +Cc: linux-cifs, Steve French 2017-11-16 17:45 GMT-08:00 Leif Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>: > > > ----- Original Message ----- > From: "Pavel Shilovsky" <piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > To: "Ronnie Sahlberg" <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> > Cc: "linux-cifs" <linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>, "Steve French" <smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > Sent: Friday, 17 November, 2017 12:42:07 PM > Subject: Re: [PATCH 13/19] cifs: remove rfc1002 header from smb2 read/write requests > > 2017-11-08 17:14 GMT-08:00 Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>: >> Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> >> --- >> fs/cifs/smb2pdu.c | 42 ++++++++++++++++++++---------------------- >> fs/cifs/smb2pdu.h | 2 +- >> 2 files changed, 21 insertions(+), 23 deletions(-) >> >> diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c >> index a44d54ea946b..3ba9b2853902 100644 >> --- a/fs/cifs/smb2pdu.c >> +++ b/fs/cifs/smb2pdu.c >> @@ -2471,7 +2471,7 @@ smb2_new_read_req(void **buf, unsigned int *total_len, >> struct smb2_sync_hdr *shdr; >> >> rc = smb2_plain_req_init(SMB2_READ, io_parms->tcon, (void **) &req, >> - total_len); >> + total_len); >> if (rc) >> return rc; >> if (io_parms->tcon->ses->server == NULL) >> @@ -2681,7 +2681,7 @@ SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms, >> >> iov[0].iov_base = &req_len; >> iov[0].iov_len = sizeof(__be32); >> - iov[1].iov_base = req; >> + iov[1].iov_base = (char *)req; >> iov[1].iov_len = total_len; >> >> rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov); > >> Why do not convert it to use new smb2_send_recv() function? > > Good point. > Do you want me to do that change as a follow up patch or should I edit and re-send the patch series ? A follow up patch is fine. -- Best regards, Pavel Shilovsky ^ permalink raw reply [flat|nested] 52+ messages in thread
* [PATCH 14/19] cifs: remove rfc1002 header from smb2_lease_ack [not found] ` <20171109011433.14468-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> ` (12 preceding siblings ...) 2017-11-09 1:14 ` [PATCH 13/19] cifs: remove rfc1002 header from smb2 read/write requests Ronnie Sahlberg @ 2017-11-09 1:14 ` Ronnie Sahlberg [not found] ` <20171109011433.14468-15-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 1:14 ` [PATCH 15/19] cifs: remove rfc1002 header from smb2_oplock_break we get from server Ronnie Sahlberg ` (4 subsequent siblings) 18 siblings, 1 reply; 52+ messages in thread From: Ronnie Sahlberg @ 2017-11-09 1:14 UTC (permalink / raw) To: linux-cifs; +Cc: Steve French Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> --- fs/cifs/smb2pdu.c | 18 ++++++++++++++---- fs/cifs/smb2pdu.h | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 3ba9b2853902..d5c295cd44ea 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -3572,24 +3572,34 @@ SMB2_lease_break(const unsigned int xid, struct cifs_tcon *tcon, { int rc; struct smb2_lease_ack *req = NULL; + struct cifs_ses *ses = tcon->ses; int flags = CIFS_OBREAK_OP; + unsigned int total_len; + struct kvec iov[1]; + struct kvec rsp_iov; + int resp_buf_type; cifs_dbg(FYI, "SMB2_lease_break\n"); - rc = small_smb2_init(SMB2_OPLOCK_BREAK, tcon, (void **) &req); + rc = smb2_plain_req_init(SMB2_OPLOCK_BREAK, tcon, (void **) &req, + &total_len); if (rc) return rc; if (encryption_required(tcon)) flags |= CIFS_TRANSFORM_REQ; - req->hdr.sync_hdr.CreditRequest = cpu_to_le16(1); + req->sync_hdr.CreditRequest = cpu_to_le16(1); req->StructureSize = cpu_to_le16(36); - inc_rfc1001_len(req, 12); memcpy(req->LeaseKey, lease_key, 16); req->LeaseState = lease_state; - rc = SendReceiveNoRsp(xid, tcon->ses, (char *) req, flags); + flags |= CIFS_NO_RESP; + + iov[0].iov_base = (char *)req; + iov[0].iov_len = total_len; + + rc = smb2_send_recv(xid, ses, iov, 1, &resp_buf_type, flags, &rsp_iov); cifs_small_buf_release(req); if (rc) { diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index 3c856f058be7..32f0f633b614 100644 --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h @@ -1057,7 +1057,7 @@ struct smb2_lease_break { } __packed; struct smb2_lease_ack { - struct smb2_hdr hdr; + struct smb2_sync_hdr sync_hdr; __le16 StructureSize; /* Must be 36 */ __le16 Reserved; __le32 Flags; -- 2.13.3 ^ permalink raw reply related [flat|nested] 52+ messages in thread
[parent not found: <20171109011433.14468-15-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 14/19] cifs: remove rfc1002 header from smb2_lease_ack [not found] ` <20171109011433.14468-15-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2017-11-09 14:11 ` Aurélien Aptel 2017-11-17 22:56 ` Pavel Shilovsky 1 sibling, 0 replies; 52+ messages in thread From: Aurélien Aptel @ 2017-11-09 14:11 UTC (permalink / raw) To: Ronnie Sahlberg, linux-cifs; +Cc: Steve French Reviewed-by: Aurelien Aptel <aaptel-IBi9RG/b67k@public.gmane.org> -- Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Linux GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) ^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 14/19] cifs: remove rfc1002 header from smb2_lease_ack [not found] ` <20171109011433.14468-15-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 14:11 ` Aurélien Aptel @ 2017-11-17 22:56 ` Pavel Shilovsky 1 sibling, 0 replies; 52+ messages in thread From: Pavel Shilovsky @ 2017-11-17 22:56 UTC (permalink / raw) To: Ronnie Sahlberg; +Cc: linux-cifs, Steve French 2017-11-08 17:14 GMT-08:00 Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>: > Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> > --- > fs/cifs/smb2pdu.c | 18 ++++++++++++++---- > fs/cifs/smb2pdu.h | 2 +- > 2 files changed, 15 insertions(+), 5 deletions(-) > > diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c > index 3ba9b2853902..d5c295cd44ea 100644 > --- a/fs/cifs/smb2pdu.c > +++ b/fs/cifs/smb2pdu.c > @@ -3572,24 +3572,34 @@ SMB2_lease_break(const unsigned int xid, struct cifs_tcon *tcon, > { > int rc; > struct smb2_lease_ack *req = NULL; > + struct cifs_ses *ses = tcon->ses; > int flags = CIFS_OBREAK_OP; > + unsigned int total_len; > + struct kvec iov[1]; > + struct kvec rsp_iov; > + int resp_buf_type; > > cifs_dbg(FYI, "SMB2_lease_break\n"); > - rc = small_smb2_init(SMB2_OPLOCK_BREAK, tcon, (void **) &req); > + rc = smb2_plain_req_init(SMB2_OPLOCK_BREAK, tcon, (void **) &req, > + &total_len); > if (rc) > return rc; > > if (encryption_required(tcon)) > flags |= CIFS_TRANSFORM_REQ; > > - req->hdr.sync_hdr.CreditRequest = cpu_to_le16(1); > + req->sync_hdr.CreditRequest = cpu_to_le16(1); > req->StructureSize = cpu_to_le16(36); > - inc_rfc1001_len(req, 12); Originally, we increased length to 12 for lease break. > > memcpy(req->LeaseKey, lease_key, 16); > req->LeaseState = lease_state; > > - rc = SendReceiveNoRsp(xid, tcon->ses, (char *) req, flags); > + flags |= CIFS_NO_RESP; > + > + iov[0].iov_base = (char *)req; > + iov[0].iov_len = total_len; > + Don't we need to increase iov_len as well above? -- Best regards, Pavel Shilovsky ^ permalink raw reply [flat|nested] 52+ messages in thread
* [PATCH 15/19] cifs: remove rfc1002 header from smb2_oplock_break we get from server [not found] ` <20171109011433.14468-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> ` (13 preceding siblings ...) 2017-11-09 1:14 ` [PATCH 14/19] cifs: remove rfc1002 header from smb2_lease_ack Ronnie Sahlberg @ 2017-11-09 1:14 ` Ronnie Sahlberg [not found] ` <20171109011433.14468-16-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 1:14 ` [PATCH 16/19] cifs: remove rfc1002 header from smb2_set_info_req Ronnie Sahlberg ` (3 subsequent siblings) 18 siblings, 1 reply; 52+ messages in thread From: Ronnie Sahlberg @ 2017-11-09 1:14 UTC (permalink / raw) To: linux-cifs; +Cc: Steve French Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> --- fs/cifs/smb2misc.c | 2 +- fs/cifs/smb2pdu.c | 19 +++++++++++++++---- fs/cifs/smb2pdu.h | 14 +++++++++++++- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/fs/cifs/smb2misc.c b/fs/cifs/smb2misc.c index 7b08a1446a7f..76d03abaa38c 100644 --- a/fs/cifs/smb2misc.c +++ b/fs/cifs/smb2misc.c @@ -578,7 +578,7 @@ smb2_is_valid_lease_break(char *buffer) bool smb2_is_valid_oplock_break(char *buffer, struct TCP_Server_Info *server) { - struct smb2_oplock_break *rsp = (struct smb2_oplock_break *)buffer; + struct smb2_oplock_break_rsp *rsp = (struct smb2_oplock_break_rsp *)buffer; struct list_head *tmp, *tmp1, *tmp2; struct cifs_ses *ses; struct cifs_tcon *tcon; diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index d5c295cd44ea..192b07bcc330 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -3318,11 +3318,17 @@ SMB2_oplock_break(const unsigned int xid, struct cifs_tcon *tcon, __u8 oplock_level) { int rc; - struct smb2_oplock_break *req = NULL; + struct smb2_oplock_break_req *req = NULL; + struct cifs_ses *ses = tcon->ses; int flags = CIFS_OBREAK_OP; + unsigned int total_len; + struct kvec iov[1]; + struct kvec rsp_iov; + int resp_buf_type; cifs_dbg(FYI, "SMB2_oplock_break\n"); - rc = small_smb2_init(SMB2_OPLOCK_BREAK, tcon, (void **) &req); + rc = smb2_plain_req_init(SMB2_OPLOCK_BREAK, tcon, (void **) &req, + &total_len); if (rc) return rc; @@ -3332,9 +3338,14 @@ SMB2_oplock_break(const unsigned int xid, struct cifs_tcon *tcon, req->VolatileFid = volatile_fid; req->PersistentFid = persistent_fid; req->OplockLevel = oplock_level; - req->hdr.sync_hdr.CreditRequest = cpu_to_le16(1); + req->sync_hdr.CreditRequest = cpu_to_le16(1); + + flags |= CIFS_NO_RESP; - rc = SendReceiveNoRsp(xid, tcon->ses, (char *) req, flags); + iov[0].iov_base = (char *)req; + iov[0].iov_len = total_len; + + rc = smb2_send_recv(xid, ses, iov, 1, &resp_buf_type, flags, &rsp_iov); cifs_small_buf_release(req); if (rc) { diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index 32f0f633b614..7f2a7639ea15 100644 --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h @@ -1031,7 +1031,19 @@ struct smb2_set_info_rsp { __le16 StructureSize; /* Must be 2 */ } __packed; -struct smb2_oplock_break { +/* oplock break without an rfc1002 header */ +struct smb2_oplock_break_req { + struct smb2_sync_hdr sync_hdr; + __le16 StructureSize; /* Must be 24 */ + __u8 OplockLevel; + __u8 Reserved; + __le32 Reserved2; + __u64 PersistentFid; + __u64 VolatileFid; +} __packed; + +/* oplock break with an rfc1002 header */ +struct smb2_oplock_break_rsp { struct smb2_hdr hdr; __le16 StructureSize; /* Must be 24 */ __u8 OplockLevel; -- 2.13.3 ^ permalink raw reply related [flat|nested] 52+ messages in thread
[parent not found: <20171109011433.14468-16-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 15/19] cifs: remove rfc1002 header from smb2_oplock_break we get from server [not found] ` <20171109011433.14468-16-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2017-11-09 14:11 ` Aurélien Aptel 0 siblings, 0 replies; 52+ messages in thread From: Aurélien Aptel @ 2017-11-09 14:11 UTC (permalink / raw) To: Ronnie Sahlberg, linux-cifs; +Cc: Steve French Reviewed-by: Aurelien Aptel <aaptel-IBi9RG/b67k@public.gmane.org> -- Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Linux GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) ^ permalink raw reply [flat|nested] 52+ messages in thread
* [PATCH 16/19] cifs: remove rfc1002 header from smb2_set_info_req [not found] ` <20171109011433.14468-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> ` (14 preceding siblings ...) 2017-11-09 1:14 ` [PATCH 15/19] cifs: remove rfc1002 header from smb2_oplock_break we get from server Ronnie Sahlberg @ 2017-11-09 1:14 ` Ronnie Sahlberg [not found] ` <20171109011433.14468-17-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 1:14 ` [PATCH 17/19] cifs: remove rfc1002 header from smb2_query_directory_req Ronnie Sahlberg ` (2 subsequent siblings) 18 siblings, 1 reply; 52+ messages in thread From: Ronnie Sahlberg @ 2017-11-09 1:14 UTC (permalink / raw) To: linux-cifs; +Cc: Steve French Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> --- fs/cifs/smb2pdu.c | 19 +++++++++---------- fs/cifs/smb2pdu.h | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 192b07bcc330..af807b7417b4 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -3118,6 +3118,7 @@ send_set_info(const unsigned int xid, struct cifs_tcon *tcon, unsigned int i; struct cifs_ses *ses = tcon->ses; int flags = 0; + unsigned int total_len; if (!ses || !(ses->server)) return -EIO; @@ -3129,7 +3130,7 @@ send_set_info(const unsigned int xid, struct cifs_tcon *tcon, if (!iov) return -ENOMEM; - rc = small_smb2_init(SMB2_SET_INFO, tcon, (void **) &req); + rc = smb2_plain_req_init(SMB2_SET_INFO, tcon, (void **) &req, &total_len); if (rc) { kfree(iov); return rc; @@ -3138,7 +3139,7 @@ send_set_info(const unsigned int xid, struct cifs_tcon *tcon, if (encryption_required(tcon)) flags |= CIFS_TRANSFORM_REQ; - req->hdr.sync_hdr.ProcessId = cpu_to_le32(pid); + req->sync_hdr.ProcessId = cpu_to_le32(pid); req->InfoType = info_type; req->FileInfoClass = info_class; @@ -3146,27 +3147,25 @@ send_set_info(const unsigned int xid, struct cifs_tcon *tcon, req->VolatileFileId = volatile_fid; req->AdditionalInformation = cpu_to_le32(additional_info); - /* 4 for RFC1001 length and 1 for Buffer */ req->BufferOffset = - cpu_to_le16(sizeof(struct smb2_set_info_req) - 1 - 4); + cpu_to_le16(sizeof(struct smb2_set_info_req) - 1); req->BufferLength = cpu_to_le32(*size); - inc_rfc1001_len(req, *size - 1 /* Buffer */); - memcpy(req->Buffer, *data, *size); + total_len += *size; iov[0].iov_base = (char *)req; - /* 4 for RFC1001 length */ - iov[0].iov_len = get_rfc1002_length(req) + 4; + /* 1 for Buffer */ + iov[0].iov_len = total_len - 1; for (i = 1; i < num; i++) { - inc_rfc1001_len(req, size[i]); le32_add_cpu(&req->BufferLength, size[i]); iov[i].iov_base = (char *)data[i]; iov[i].iov_len = size[i]; } - rc = SendReceive2(xid, ses, iov, num, &resp_buftype, flags, &rsp_iov); + rc = smb2_send_recv(xid, ses, iov, num, &resp_buftype, flags, + &rsp_iov); cifs_small_buf_release(req); rsp = (struct smb2_set_info_rsp *)rsp_iov.iov_base; diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index 7f2a7639ea15..f0d6e637b95f 100644 --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h @@ -1013,7 +1013,7 @@ struct smb2_query_info_rsp { } __packed; struct smb2_set_info_req { - struct smb2_hdr hdr; + struct smb2_sync_hdr sync_hdr; __le16 StructureSize; /* Must be 33 */ __u8 InfoType; __u8 FileInfoClass; -- 2.13.3 ^ permalink raw reply related [flat|nested] 52+ messages in thread
[parent not found: <20171109011433.14468-17-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 16/19] cifs: remove rfc1002 header from smb2_set_info_req [not found] ` <20171109011433.14468-17-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2017-11-09 14:11 ` Aurélien Aptel 0 siblings, 0 replies; 52+ messages in thread From: Aurélien Aptel @ 2017-11-09 14:11 UTC (permalink / raw) To: Ronnie Sahlberg, linux-cifs; +Cc: Steve French Reviewed-by: Aurelien Aptel <aaptel-IBi9RG/b67k@public.gmane.org> -- Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Linux GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) ^ permalink raw reply [flat|nested] 52+ messages in thread
* [PATCH 17/19] cifs: remove rfc1002 header from smb2_query_directory_req [not found] ` <20171109011433.14468-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> ` (15 preceding siblings ...) 2017-11-09 1:14 ` [PATCH 16/19] cifs: remove rfc1002 header from smb2_set_info_req Ronnie Sahlberg @ 2017-11-09 1:14 ` Ronnie Sahlberg [not found] ` <20171109011433.14468-18-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 1:14 ` [PATCH 18/19] cifs: remove rfc1002 header from smb2_query_info_req Ronnie Sahlberg 2017-11-09 1:14 ` [PATCH 19/19] cifs: remove small_smb2_init Ronnie Sahlberg 18 siblings, 1 reply; 52+ messages in thread From: Ronnie Sahlberg @ 2017-11-09 1:14 UTC (permalink / raw) To: linux-cifs; +Cc: Steve French Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> --- fs/cifs/smb2pdu.c | 14 +++++++------- fs/cifs/smb2pdu.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index af807b7417b4..673eea319cbf 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -2992,13 +2992,15 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon, unsigned int output_size = CIFSMaxBufSize; size_t info_buf_size; int flags = 0; + unsigned int total_len; if (ses && (ses->server)) server = ses->server; else return -EIO; - rc = small_smb2_init(SMB2_QUERY_DIRECTORY, tcon, (void **) &req); + rc = smb2_plain_req_init(SMB2_QUERY_DIRECTORY, tcon, (void **) &req, + &total_len); if (rc) return rc; @@ -3030,7 +3032,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon, memcpy(bufptr, &asteriks, len); req->FileNameOffset = - cpu_to_le16(sizeof(struct smb2_query_directory_req) - 1 - 4); + cpu_to_le16(sizeof(struct smb2_query_directory_req) - 1); req->FileNameLength = cpu_to_le16(len); /* * BB could be 30 bytes or so longer if we used SMB2 specific @@ -3041,15 +3043,13 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon, req->OutputBufferLength = cpu_to_le32(output_size); iov[0].iov_base = (char *)req; - /* 4 for RFC1001 length and 1 for Buffer */ - iov[0].iov_len = get_rfc1002_length(req) + 4 - 1; + /* 1 for Buffer */ + iov[0].iov_len = total_len - 1; iov[1].iov_base = (char *)(req->Buffer); iov[1].iov_len = len; - inc_rfc1001_len(req, len - 1 /* Buffer */); - - rc = SendReceive2(xid, ses, iov, 2, &resp_buftype, flags, &rsp_iov); + rc = smb2_send_recv(xid, ses, iov, 2, &resp_buftype, flags, &rsp_iov); cifs_small_buf_release(req); rsp = (struct smb2_query_directory_rsp *)rsp_iov.iov_base; diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index f0d6e637b95f..630a5c064f0c 100644 --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h @@ -942,7 +942,7 @@ struct smb2_echo_rsp { #define SMB2_REOPEN 0x10 struct smb2_query_directory_req { - struct smb2_hdr hdr; + struct smb2_sync_hdr sync_hdr; __le16 StructureSize; /* Must be 33 */ __u8 FileInformationClass; __u8 Flags; -- 2.13.3 ^ permalink raw reply related [flat|nested] 52+ messages in thread
[parent not found: <20171109011433.14468-18-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 17/19] cifs: remove rfc1002 header from smb2_query_directory_req [not found] ` <20171109011433.14468-18-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2017-11-09 14:11 ` Aurélien Aptel 0 siblings, 0 replies; 52+ messages in thread From: Aurélien Aptel @ 2017-11-09 14:11 UTC (permalink / raw) To: Ronnie Sahlberg, linux-cifs; +Cc: Steve French Reviewed-by: Aurelien Aptel <aaptel-IBi9RG/b67k@public.gmane.org> -- Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Linux GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) ^ permalink raw reply [flat|nested] 52+ messages in thread
* [PATCH 18/19] cifs: remove rfc1002 header from smb2_query_info_req [not found] ` <20171109011433.14468-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> ` (16 preceding siblings ...) 2017-11-09 1:14 ` [PATCH 17/19] cifs: remove rfc1002 header from smb2_query_directory_req Ronnie Sahlberg @ 2017-11-09 1:14 ` Ronnie Sahlberg [not found] ` <20171109011433.14468-19-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 1:14 ` [PATCH 19/19] cifs: remove small_smb2_init Ronnie Sahlberg 18 siblings, 1 reply; 52+ messages in thread From: Ronnie Sahlberg @ 2017-11-09 1:14 UTC (permalink / raw) To: linux-cifs; +Cc: Steve French Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> --- fs/cifs/smb2pdu.c | 26 ++++++++++++++------------ fs/cifs/smb2pdu.h | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 673eea319cbf..62b8b08e9b13 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -2188,13 +2188,15 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon, int resp_buftype; struct cifs_ses *ses = tcon->ses; int flags = 0; + unsigned int total_len; cifs_dbg(FYI, "Query Info\n"); if (!ses || !(ses->server)) return -EIO; - rc = small_smb2_init(SMB2_QUERY_INFO, tcon, (void **) &req); + rc = smb2_plain_req_init(SMB2_QUERY_INFO, tcon, (void **) &req, + &total_len); if (rc) return rc; @@ -2211,15 +2213,14 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon, * We do not use the input buffer (do not send extra byte) */ req->InputBufferOffset = 0; - inc_rfc1001_len(req, -1); req->OutputBufferLength = cpu_to_le32(output_len); iov[0].iov_base = (char *)req; - /* 4 for rfc1002 length field */ - iov[0].iov_len = get_rfc1002_length(req) + 4; + /* 1 for Buffer */ + iov[0].iov_len = total_len - 1; - rc = SendReceive2(xid, ses, iov, 1, &resp_buftype, flags, &rsp_iov); + rc = smb2_send_recv(xid, ses, iov, 1, &resp_buftype, flags, &rsp_iov); cifs_small_buf_release(req); rsp = (struct smb2_query_info_rsp *)rsp_iov.iov_base; @@ -3373,13 +3374,15 @@ build_qfs_info_req(struct kvec *iov, struct cifs_tcon *tcon, int level, { int rc; struct smb2_query_info_req *req; + unsigned int total_len; cifs_dbg(FYI, "Query FSInfo level %d\n", level); if ((tcon->ses == NULL) || (tcon->ses->server == NULL)) return -EIO; - rc = small_smb2_init(SMB2_QUERY_INFO, tcon, (void **) &req); + rc = smb2_plain_req_init(SMB2_QUERY_INFO, tcon, (void **) &req, + &total_len); if (rc) return rc; @@ -3387,15 +3390,14 @@ build_qfs_info_req(struct kvec *iov, struct cifs_tcon *tcon, int level, req->FileInfoClass = level; req->PersistentFileId = persistent_fid; req->VolatileFileId = volatile_fid; - /* 4 for rfc1002 length field and 1 for pad */ + /* 1 for pad */ req->InputBufferOffset = - cpu_to_le16(sizeof(struct smb2_query_info_req) - 1 - 4); + cpu_to_le16(sizeof(struct smb2_query_info_req) - 1); req->OutputBufferLength = cpu_to_le32( outbuf_len + sizeof(struct smb2_query_info_rsp) - 1 - 4); iov->iov_base = (char *)req; - /* 4 for rfc1002 length field */ - iov->iov_len = get_rfc1002_length(req) + 4; + iov->iov_len = total_len; return 0; } @@ -3421,7 +3423,7 @@ SMB2_QFS_info(const unsigned int xid, struct cifs_tcon *tcon, if (encryption_required(tcon)) flags |= CIFS_TRANSFORM_REQ; - rc = SendReceive2(xid, ses, &iov, 1, &resp_buftype, flags, &rsp_iov); + rc = smb2_send_recv(xid, ses, &iov, 1, &resp_buftype, flags, &rsp_iov); cifs_small_buf_release(iov.iov_base); if (rc) { cifs_stats_fail_inc(tcon, SMB2_QUERY_INFO_HE); @@ -3477,7 +3479,7 @@ SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon, if (encryption_required(tcon)) flags |= CIFS_TRANSFORM_REQ; - rc = SendReceive2(xid, ses, &iov, 1, &resp_buftype, flags, &rsp_iov); + rc = smb2_send_recv(xid, ses, &iov, 1, &resp_buftype, flags, &rsp_iov); cifs_small_buf_release(iov.iov_base); if (rc) { cifs_stats_fail_inc(tcon, SMB2_QUERY_INFO_HE); diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index 630a5c064f0c..19d34881815f 100644 --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h @@ -989,7 +989,7 @@ struct smb2_query_directory_rsp { #define SL_INDEX_SPECIFIED 0x00000004 struct smb2_query_info_req { - struct smb2_hdr hdr; + struct smb2_sync_hdr sync_hdr; __le16 StructureSize; /* Must be 41 */ __u8 InfoType; __u8 FileInfoClass; -- 2.13.3 ^ permalink raw reply related [flat|nested] 52+ messages in thread
[parent not found: <20171109011433.14468-19-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 18/19] cifs: remove rfc1002 header from smb2_query_info_req [not found] ` <20171109011433.14468-19-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2017-11-09 14:11 ` Aurélien Aptel 0 siblings, 0 replies; 52+ messages in thread From: Aurélien Aptel @ 2017-11-09 14:11 UTC (permalink / raw) To: Ronnie Sahlberg, linux-cifs; +Cc: Steve French Reviewed-by: Aurelien Aptel <aaptel-IBi9RG/b67k@public.gmane.org> -- Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Linux GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) ^ permalink raw reply [flat|nested] 52+ messages in thread
* [PATCH 19/19] cifs: remove small_smb2_init [not found] ` <20171109011433.14468-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> ` (17 preceding siblings ...) 2017-11-09 1:14 ` [PATCH 18/19] cifs: remove rfc1002 header from smb2_query_info_req Ronnie Sahlberg @ 2017-11-09 1:14 ` Ronnie Sahlberg [not found] ` <20171109011433.14468-20-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 18 siblings, 1 reply; 52+ messages in thread From: Ronnie Sahlberg @ 2017-11-09 1:14 UTC (permalink / raw) To: linux-cifs; +Cc: Steve French Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> --- fs/cifs/smb2pdu.c | 53 ++++++----------------------------------------------- 1 file changed, 6 insertions(+), 47 deletions(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 62b8b08e9b13..553d574940b9 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -319,54 +319,16 @@ fill_small_buf(__le16 smb2_command, struct cifs_tcon *tcon, void *buf, *total_len = parmsize + sizeof(struct smb2_sync_hdr); } -/* init request without RFC1001 length at the beginning */ -static int -smb2_plain_req_init(__le16 smb2_command, struct cifs_tcon *tcon, - void **request_buf, unsigned int *total_len) -{ - int rc; - struct smb2_sync_hdr *shdr; - - rc = smb2_reconnect(smb2_command, tcon); - if (rc) - return rc; - - /* BB eventually switch this to SMB2 specific small buf size */ - *request_buf = cifs_small_buf_get(); - if (*request_buf == NULL) { - /* BB should we add a retry in here if not a writepage? */ - return -ENOMEM; - } - - shdr = (struct smb2_sync_hdr *)(*request_buf); - - fill_small_buf(smb2_command, tcon, shdr, total_len); - - if (tcon != NULL) { -#ifdef CONFIG_CIFS_STATS2 - uint16_t com_code = le16_to_cpu(smb2_command); - - cifs_stats_inc(&tcon->stats.smb2_stats.smb2_com_sent[com_code]); -#endif - cifs_stats_inc(&tcon->num_smbs_sent); - } - - return rc; -} - /* * Allocate and return pointer to an SMB request hdr, and set basic * SMB information in the SMB header. If the return code is zero, this - * function must have filled in request_buf pointer. The returned buffer - * has RFC1001 length at the beginning. + * function must have filled in request_buf pointer. */ static int -small_smb2_init(__le16 smb2_command, struct cifs_tcon *tcon, - void **request_buf) +smb2_plain_req_init(__le16 smb2_command, struct cifs_tcon *tcon, + void **request_buf, unsigned int *total_len) { int rc; - unsigned int total_len; - struct smb2_pdu *pdu; rc = smb2_reconnect(smb2_command, tcon); if (rc) @@ -379,12 +341,9 @@ small_smb2_init(__le16 smb2_command, struct cifs_tcon *tcon, return -ENOMEM; } - pdu = (struct smb2_pdu *)(*request_buf); - - fill_small_buf(smb2_command, tcon, get_sync_hdr(pdu), &total_len); - - /* Note this is only network field converted to big endian */ - pdu->hdr.smb2_buf_length = cpu_to_be32(total_len); + fill_small_buf(smb2_command, tcon, + (struct smb2_sync_hdr *)(*request_buf), + total_len); if (tcon != NULL) { #ifdef CONFIG_CIFS_STATS2 -- 2.13.3 ^ permalink raw reply related [flat|nested] 52+ messages in thread
[parent not found: <20171109011433.14468-20-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 19/19] cifs: remove small_smb2_init [not found] ` <20171109011433.14468-20-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2017-11-09 14:11 ` Aurélien Aptel 0 siblings, 0 replies; 52+ messages in thread From: Aurélien Aptel @ 2017-11-09 14:11 UTC (permalink / raw) To: Ronnie Sahlberg, linux-cifs; +Cc: Steve French Reviewed-by: Aurelien Aptel <aaptel-IBi9RG/b67k@public.gmane.org> -- Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Linux GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) ^ permalink raw reply [flat|nested] 52+ messages in thread
* [PATCH 00/19 Version 4] cifs: remove rfc1002 from smb2 requests @ 2017-11-21 0:04 Ronnie Sahlberg [not found] ` <20171121000442.24888-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 0 siblings, 1 reply; 52+ messages in thread From: Ronnie Sahlberg @ 2017-11-21 0:04 UTC (permalink / raw) To: linux-cifs; +Cc: Steve French Steve, All, Please find an updated version of the patch series to get rid of the rfc1002 header from all request structures in SMB2. Version 2: * changed SendReceive3 to smb2_send_recv * fixed a Buffer[1] error that aaptel@xxxxxxxx reported Version 3: * Change SMB2_read() to use smb2_send_recv instead of cifs_send_recv * Fix smb2_negotiate_req where we didnt update the total length to accomodate smb2 contexts. * Fix smb2_lease_ack where I forgot to bump total length by 12. Version 4: * Fix incorrect length in smb2_lockv ^ permalink raw reply [flat|nested] 52+ messages in thread
[parent not found: <20171121000442.24888-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* [PATCH 14/19] cifs: remove rfc1002 header from smb2_lease_ack [not found] ` <20171121000442.24888-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2017-11-21 0:04 ` Ronnie Sahlberg 0 siblings, 0 replies; 52+ messages in thread From: Ronnie Sahlberg @ 2017-11-21 0:04 UTC (permalink / raw) To: linux-cifs; +Cc: Steve French Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> --- fs/cifs/smb2pdu.c | 19 +++++++++++++++---- fs/cifs/smb2pdu.h | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index cc619c19be28..2042c2bc99e2 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -3573,24 +3573,35 @@ SMB2_lease_break(const unsigned int xid, struct cifs_tcon *tcon, { int rc; struct smb2_lease_ack *req = NULL; + struct cifs_ses *ses = tcon->ses; int flags = CIFS_OBREAK_OP; + unsigned int total_len; + struct kvec iov[1]; + struct kvec rsp_iov; + int resp_buf_type; cifs_dbg(FYI, "SMB2_lease_break\n"); - rc = small_smb2_init(SMB2_OPLOCK_BREAK, tcon, (void **) &req); + rc = smb2_plain_req_init(SMB2_OPLOCK_BREAK, tcon, (void **) &req, + &total_len); if (rc) return rc; if (encryption_required(tcon)) flags |= CIFS_TRANSFORM_REQ; - req->hdr.sync_hdr.CreditRequest = cpu_to_le16(1); + req->sync_hdr.CreditRequest = cpu_to_le16(1); req->StructureSize = cpu_to_le16(36); - inc_rfc1001_len(req, 12); + total_len += 12; memcpy(req->LeaseKey, lease_key, 16); req->LeaseState = lease_state; - rc = SendReceiveNoRsp(xid, tcon->ses, (char *) req, flags); + flags |= CIFS_NO_RESP; + + iov[0].iov_base = (char *)req; + iov[0].iov_len = total_len; + + rc = smb2_send_recv(xid, ses, iov, 1, &resp_buf_type, flags, &rsp_iov); cifs_small_buf_release(req); if (rc) { diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index 3c856f058be7..32f0f633b614 100644 --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h @@ -1057,7 +1057,7 @@ struct smb2_lease_break { } __packed; struct smb2_lease_ack { - struct smb2_hdr hdr; + struct smb2_sync_hdr sync_hdr; __le16 StructureSize; /* Must be 36 */ __le16 Reserved; __le32 Flags; -- 2.13.3 ^ permalink raw reply related [flat|nested] 52+ messages in thread
* [PATCH 00/10] cifs: Remove rfc1002 header from smb2 request structs @ 2017-11-20 0:24 Ronnie Sahlberg [not found] ` <20171120002447.32322-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 0 siblings, 1 reply; 52+ messages in thread From: Ronnie Sahlberg @ 2017-11-20 0:24 UTC (permalink / raw) To: linux-cifs; +Cc: Steve French Steve, All, Please find an updated version of the patch series to get rid of the rfc1002 header from all request structures in SMB2. Version 2: * changed SendReceive3 to smb2_send_recv * fixed a Buffer[1] error that aaptel-IBi9RG/b67k@public.gmane.org reported Version 3: * Change SMB2_read() to use smb2_send_recv instead of cifs_send_recv * Fix smb2_negotiate_req where we didnt update the total length to accomodate smb2 contexts. * Fix smb2_lease_ack where I forgot to bump total length by 12. ^ permalink raw reply [flat|nested] 52+ messages in thread
[parent not found: <20171120002447.32322-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* [PATCH 14/19] cifs: remove rfc1002 header from smb2_lease_ack [not found] ` <20171120002447.32322-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2017-11-20 0:24 ` Ronnie Sahlberg 0 siblings, 0 replies; 52+ messages in thread From: Ronnie Sahlberg @ 2017-11-20 0:24 UTC (permalink / raw) To: linux-cifs; +Cc: Steve French Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> --- fs/cifs/smb2pdu.c | 19 +++++++++++++++---- fs/cifs/smb2pdu.h | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 58f02213696a..42fc53f0c90d 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -3573,24 +3573,35 @@ SMB2_lease_break(const unsigned int xid, struct cifs_tcon *tcon, { int rc; struct smb2_lease_ack *req = NULL; + struct cifs_ses *ses = tcon->ses; int flags = CIFS_OBREAK_OP; + unsigned int total_len; + struct kvec iov[1]; + struct kvec rsp_iov; + int resp_buf_type; cifs_dbg(FYI, "SMB2_lease_break\n"); - rc = small_smb2_init(SMB2_OPLOCK_BREAK, tcon, (void **) &req); + rc = smb2_plain_req_init(SMB2_OPLOCK_BREAK, tcon, (void **) &req, + &total_len); if (rc) return rc; if (encryption_required(tcon)) flags |= CIFS_TRANSFORM_REQ; - req->hdr.sync_hdr.CreditRequest = cpu_to_le16(1); + req->sync_hdr.CreditRequest = cpu_to_le16(1); req->StructureSize = cpu_to_le16(36); - inc_rfc1001_len(req, 12); + total_len += 12; memcpy(req->LeaseKey, lease_key, 16); req->LeaseState = lease_state; - rc = SendReceiveNoRsp(xid, tcon->ses, (char *) req, flags); + flags |= CIFS_NO_RESP; + + iov[0].iov_base = (char *)req; + iov[0].iov_len = total_len; + + rc = smb2_send_recv(xid, ses, iov, 1, &resp_buf_type, flags, &rsp_iov); cifs_small_buf_release(req); if (rc) { diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index 3c856f058be7..32f0f633b614 100644 --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h @@ -1057,7 +1057,7 @@ struct smb2_lease_break { } __packed; struct smb2_lease_ack { - struct smb2_hdr hdr; + struct smb2_sync_hdr sync_hdr; __le16 StructureSize; /* Must be 36 */ __le16 Reserved; __le32 Flags; -- 2.13.3 ^ permalink raw reply related [flat|nested] 52+ messages in thread
* [PATCH 00/19] cifs: remove rfc1002 header from all smb2 requests @ 2017-11-02 7:02 Ronnie Sahlberg [not found] ` <20171102070312.18903-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 0 siblings, 1 reply; 52+ messages in thread From: Ronnie Sahlberg @ 2017-11-02 7:02 UTC (permalink / raw) To: linux-cifs; +Cc: Steve French Steve, all I split the !1002 patch into a small serie for easier review. This patch series removes the NBSS 4 byte header from all the smb2 request structures. Instead of computing and tweaking the header as part of composing the SMB2 request, we now compute it in the new SendReceive3() function that is used by all of SMB2. This eliminates a huge amount of magic +4 / -4 in the code and all the ugly inc_rfc1002.... stuff where the old code would constantly tweak the length field as it was building the PDU. So overall it also simplifies the code in some places I think. This series is to prepare for and make it easier to add smb2 compounding in the future as then we will need to construct multiple SMB2 pdus and wrap them all insode one single rfc1002 header. As a later series, before we get to the actual compounding, I plan to do a similar change to all the reply structures and remove the rfc1002 header from them all too. Please review, and test. ^ permalink raw reply [flat|nested] 52+ messages in thread
[parent not found: <20171102070312.18903-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* [PATCH 14/19] cifs: remove rfc1002 header from smb2_lease_ack [not found] ` <20171102070312.18903-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2017-11-02 7:03 ` Ronnie Sahlberg 0 siblings, 0 replies; 52+ messages in thread From: Ronnie Sahlberg @ 2017-11-02 7:03 UTC (permalink / raw) To: linux-cifs; +Cc: Steve French Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> --- fs/cifs/smb2pdu.c | 18 ++++++++++++++---- fs/cifs/smb2pdu.h | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index b0d4e9d15e29..84e71f6bc9eb 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -3570,24 +3570,34 @@ SMB2_lease_break(const unsigned int xid, struct cifs_tcon *tcon, { int rc; struct smb2_lease_ack *req = NULL; + struct cifs_ses *ses = tcon->ses; int flags = CIFS_OBREAK_OP; + unsigned int total_len; + struct kvec iov[1]; + struct kvec rsp_iov; + int resp_buf_type; cifs_dbg(FYI, "SMB2_lease_break\n"); - rc = small_smb2_init(SMB2_OPLOCK_BREAK, tcon, (void **) &req); + rc = smb2_plain_req_init(SMB2_OPLOCK_BREAK, tcon, (void **) &req, + &total_len); if (rc) return rc; if (encryption_required(tcon)) flags |= CIFS_TRANSFORM_REQ; - req->hdr.sync_hdr.CreditRequest = cpu_to_le16(1); + req->sync_hdr.CreditRequest = cpu_to_le16(1); req->StructureSize = cpu_to_le16(36); - inc_rfc1001_len(req, 12); memcpy(req->LeaseKey, lease_key, 16); req->LeaseState = lease_state; - rc = SendReceiveNoRsp(xid, tcon->ses, (char *) req, flags); + flags |= CIFS_NO_RESP; + + iov[0].iov_base = (char *)req; + iov[0].iov_len = total_len; + + rc = SendReceive3(xid, ses, iov, 1, &resp_buf_type, flags, &rsp_iov); cifs_small_buf_release(req); if (rc) { diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index 3c856f058be7..32f0f633b614 100644 --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h @@ -1057,7 +1057,7 @@ struct smb2_lease_break { } __packed; struct smb2_lease_ack { - struct smb2_hdr hdr; + struct smb2_sync_hdr sync_hdr; __le16 StructureSize; /* Must be 36 */ __le16 Reserved; __le32 Flags; -- 2.13.3 ^ permalink raw reply related [flat|nested] 52+ messages in thread
end of thread, other threads:[~2017-11-21 0:04 UTC | newest] Thread overview: 52+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-11-09 1:14 [PATCH 00/19] Remove rfc1002 header from smb2 request structs Ronnie Sahlberg [not found] ` <20171109011433.14468-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 1:14 ` [PATCH 01/19] cifs: Add smb2_send_recv Ronnie Sahlberg [not found] ` <20171109011433.14468-2-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 14:09 ` Aurélien Aptel 2017-11-17 18:05 ` Steve French [not found] ` <CAH2r5mvLvAfO3eU2f73ebk2XSJiQvzamWi9FxDqNCU67=Pm8bQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2017-11-17 18:11 ` Steve French 2017-11-09 1:14 ` [PATCH 02/19] cifs: remove rfc1002 header from smb2_negotiate_req Ronnie Sahlberg [not found] ` <20171109011433.14468-3-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 14:10 ` Aurélien Aptel 2017-11-17 1:24 ` Pavel Shilovsky [not found] ` <CAKywueRFOZroCmp9nhr22PGE0R31peFr6j8A2mGVQSEP07bqLQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2017-11-17 1:44 ` Leif Sahlberg [not found] ` <1978629070.27950035.1510883055312.JavaMail.zimbra-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-17 1:47 ` Pavel Shilovsky 2017-11-17 19:02 ` Pavel Shilovsky 2017-11-09 1:14 ` [PATCH 03/19] cifs: remove rfc1002 header from smb2_logoff_req Ronnie Sahlberg [not found] ` <20171109011433.14468-4-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 14:10 ` Aurélien Aptel 2017-11-09 1:14 ` [PATCH 04/19] cifs: remove rfc1002 header from smb2_tree_disconnect_req Ronnie Sahlberg [not found] ` <20171109011433.14468-5-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 14:10 ` Aurélien Aptel 2017-11-09 1:14 ` [PATCH 05/19] cifs: remove rfc1002 header from smb2_close_req Ronnie Sahlberg [not found] ` <20171109011433.14468-6-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 14:10 ` Aurélien Aptel 2017-11-09 1:14 ` [PATCH 06/19] cifs: remove rfc1002 header from smb2_ioctl_req Ronnie Sahlberg [not found] ` <20171109011433.14468-7-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 14:10 ` Aurélien Aptel 2017-11-09 1:14 ` [PATCH 07/19] cifs: remove rfc1002 header from smb2_echo_req Ronnie Sahlberg [not found] ` <20171109011433.14468-8-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 14:10 ` Aurélien Aptel 2017-11-09 1:14 ` [PATCH 08/19] cifs: remove rfc1002 header from smb2_sess_setup_req Ronnie Sahlberg [not found] ` <20171109011433.14468-9-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 14:10 ` Aurélien Aptel 2017-11-09 1:14 ` [PATCH 09/19] cifs: remove rfc1002 header from smb2_tree_connect_req Ronnie Sahlberg [not found] ` <20171109011433.14468-10-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 14:10 ` Aurélien Aptel 2017-11-09 1:14 ` [PATCH 10/19] cifs: remove rfc1002 header from smb2_create_req Ronnie Sahlberg [not found] ` <20171109011433.14468-11-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 14:10 ` Aurélien Aptel 2017-11-09 1:14 ` [PATCH 11/19] cifs: remove rfc1002 header from smb2_flush_req Ronnie Sahlberg [not found] ` <20171109011433.14468-12-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 14:11 ` Aurélien Aptel 2017-11-09 1:14 ` [PATCH 12/19] cifs: remove rfc1002 header from smb2_lock_req Ronnie Sahlberg [not found] ` <20171109011433.14468-13-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 14:11 ` Aurélien Aptel 2017-11-09 1:14 ` [PATCH 13/19] cifs: remove rfc1002 header from smb2 read/write requests Ronnie Sahlberg [not found] ` <20171109011433.14468-14-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 14:11 ` Aurélien Aptel 2017-11-17 1:42 ` Pavel Shilovsky [not found] ` <CAKywueRU_HM44i04yv_gKza=tgsuxwfF4h-XfstbXTZe3AZQeg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2017-11-17 1:45 ` Leif Sahlberg [not found] ` <546793899.27950063.1510883138100.JavaMail.zimbra-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-17 1:48 ` Pavel Shilovsky 2017-11-09 1:14 ` [PATCH 14/19] cifs: remove rfc1002 header from smb2_lease_ack Ronnie Sahlberg [not found] ` <20171109011433.14468-15-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 14:11 ` Aurélien Aptel 2017-11-17 22:56 ` Pavel Shilovsky 2017-11-09 1:14 ` [PATCH 15/19] cifs: remove rfc1002 header from smb2_oplock_break we get from server Ronnie Sahlberg [not found] ` <20171109011433.14468-16-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 14:11 ` Aurélien Aptel 2017-11-09 1:14 ` [PATCH 16/19] cifs: remove rfc1002 header from smb2_set_info_req Ronnie Sahlberg [not found] ` <20171109011433.14468-17-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 14:11 ` Aurélien Aptel 2017-11-09 1:14 ` [PATCH 17/19] cifs: remove rfc1002 header from smb2_query_directory_req Ronnie Sahlberg [not found] ` <20171109011433.14468-18-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 14:11 ` Aurélien Aptel 2017-11-09 1:14 ` [PATCH 18/19] cifs: remove rfc1002 header from smb2_query_info_req Ronnie Sahlberg [not found] ` <20171109011433.14468-19-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 14:11 ` Aurélien Aptel 2017-11-09 1:14 ` [PATCH 19/19] cifs: remove small_smb2_init Ronnie Sahlberg [not found] ` <20171109011433.14468-20-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-09 14:11 ` Aurélien Aptel -- strict thread matches above, loose matches on Subject: below -- 2017-11-21 0:04 [PATCH 00/19 Version 4] cifs: remove rfc1002 from smb2 requests Ronnie Sahlberg [not found] ` <20171121000442.24888-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-21 0:04 ` [PATCH 14/19] cifs: remove rfc1002 header from smb2_lease_ack Ronnie Sahlberg 2017-11-20 0:24 [PATCH 00/10] cifs: Remove rfc1002 header from smb2 request structs Ronnie Sahlberg [not found] ` <20171120002447.32322-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-20 0:24 ` [PATCH 14/19] cifs: remove rfc1002 header from smb2_lease_ack Ronnie Sahlberg 2017-11-02 7:02 [PATCH 00/19] cifs: remove rfc1002 header from all smb2 requests Ronnie Sahlberg [not found] ` <20171102070312.18903-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2017-11-02 7:03 ` [PATCH 14/19] cifs: remove rfc1002 header from smb2_lease_ack Ronnie Sahlberg
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.