Remove the rfc1002 length from all SMB2 requests
Subsystems (2)
cover Remove the rfc1002 length from all SMB2 requests
Steve, All,
Do not merge yet. It is still WIP but I want some review.
I have been looking at compounding, but before we can do that easily we need to break the layering violation that happens between the RFC1002 SM Length field and the SMB2 PDUs.
This patch removes the 4 byte RFC1002 length header from all SMB2 request structures and at the same time also gets rid of a lot of the magic +4 / -4 tweaking that was used all over the code to cope with that the structures were actually bigger than they should be. It also gets rid of a lot of magic "tweak the first four bytes" as the dynamic parts of the SMB2 pdus are constructed.
Additionally we have a new SendReceive3() function that computes and attaches the rfc1002 length from scratch, based on the input kiov containing the smb2 pdu and data.
This will simplify later for compounding when we will use the SMB2_*() functions to create multiple SMB2 pdus that will all be wrapped inside one single rfc1002 header.
It would be nice to do the similar split of the nbss and smb2 layers for all the reply structures as well but that can go in a different patch.
A message that is not in the archive (sent off-list or not yet received): 20171101015144.2034-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
PATCH 1/1 cifs: Remove the rfc1002 header from SMB2 request structures
This header is not really part of the SMB2 header but a lower layer. Remove this field from all the request structures that we use in SMB2 and instead compute it and attach it when we build the iovec in the new function SendReceive3().
This gets rid of a lot of magic +4 / -4 in length computations and also a lot of dynamically trying to modify the value as we construct the SMB2 pdus.
At this point we now have an API where we construct SMB2 pdus without the extra rfc1002 header which will make it easier to add compounding as a future project.
In compounded commands we will have multiple SMB2 PDUs wrapped inside one single rfc1002 header.
A later patch might remove the rfc1002 header also from the response structures.
--- fs/cifs/cifsproto.h | 4 + fs/cifs/smb2misc.c | 2 +- fs/cifs/smb2pdu.c | 379 +++++++++++++++++++++++++--------------------------- fs/cifs/smb2pdu.h | 46 ++++--- fs/cifs/transport.c | 38 ++++++ 5 files changed, 254 insertions(+), 215 deletions(-)
fs/cifs/cifsproto.h +4 -0
@@ -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 SendReceive3 (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 ,
fs/cifs/smb2misc.c +1 -1
@@ -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;
fs/cifs/smb2pdu.c +182 -197
985 lines not on this page · raw message
fs/cifs/smb2pdu.h +29 -17
148 lines not on this page · raw message
fs/cifs/transport.c +38 -0
@@ -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 +SendReceive3 (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,
Signature · 1 line
2.13.3
Hi Ronnie,
I was also looking into this! I will take a look at this patch.
Signature · 4 lines
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)
A message that is not in the archive (sent off-list or not yet received): 87shdxuhbg.fsf-IBi9RG/[email protected]
I resent this as a patch series to make review easier.
Lets work together to remove the 1002 headers so that compounding will become easier to implement.
Quoted 13 lines · Aurélien Aptel
Hi Ronnie,
I was also looking into this! I will take a look at this patch.
--
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) --
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): CAN05THRMgZwUfgpXQudSzmH-8tOriv+dZnGPAK2u9h+4bmU2Mw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
This would also greatly benefit SMB Direct, which doesn't use the header at all. Long's patches currently strip it out on send, and *add it in* on receive, just to work around this.
Tom.
Quoted 46 lines
-----Original Message-----
From: [email protected] [mailto:linux-cifs- [email protected]] On Behalf Of ronnie sahlberg
Sent: Thursday, November 2, 2017 6:32 AM
To: Aurélien Aptel <[email protected]>
Cc: Ronnie Sahlberg <[email protected]>; linux-cifs <linux- [email protected]>; Steve French <[email protected]>
Subject: Re: [PATCH 0/1] Remove the rfc1002 length from all SMB2 requestsI resent this as a patch series to make review easier.
Lets work together to remove the 1002 headers so that compounding will become easier to implement.
Quoted 9 lines · Aurélien Aptel
Hi Ronnie,
I was also looking into this! I will take a look at this patch.
--
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 (AGNürnberg)
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected]
More majordomo info athttps://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fvger.kerne
l.org%2Fmajordomo- info.html&data=02%7C01%7Cttalpey%40microsoft.com%7C20a35015bbd64f3 22a9608d521dce69a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C 636452155006246266&sdata=Dz7ywk9RqIZr%2BBc00%2Bxd3BEg4QwGokoCu pFbH8PU97o%3D&reserved=0
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected]
More majordomo info at
https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fvger.kerne
l.org%2Fmajordomo- info.html&data=02%7C01%7Cttalpey%40microsoft.com%7C20a35015bbd64f3 22a9608d521dce69a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C 636452155006246266&sdata=Dz7ywk9RqIZr%2BBc00%2Bxd3BEg4QwGokoCu pFbH8PU97o%3D&reserved=0