diff mbox

Removing endian warning due to mixed endian use by cifs of smb_buf_length

Message ID AANLkTikJM39qVWtUa2uU4+zyUSYc0X+56q04vFzV61NN@mail.gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Steve French March 15, 2011, 10:58 p.m. UTC
None
diff mbox

Patch

diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index 1a2930d..6085ac3 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -119,8 +119,7 @@  delete_mid(struct mid_q_entry *mid)
 	DeleteMidQEntry(mid);
 }

-static int
-smb_sendv(struct TCP_Server_Info *server, struct kvec *iov, int n_vec)
+int smb_sendv(struct TCP_Server_Info *server, struct kvec *iov, int n_vec)
 {
 	int rc = 0;
 	int i = 0;
@@ -154,7 +153,17 @@  smb_sendv(struct TCP_Server_Info *server, struct
kvec *iov, int n_vec)
 	for (i = 0; i < n_vec; i++)
 		total_len += iov[i].iov_len;

-	smb_buffer->smb_buf_length = cpu_to_be32(smb_buffer->smb_buf_length);
+	/* In SMB2 we treat the buffer length in its native form
+	   (always be32 for RFC1001 length), but in all of the cifs
+	   callers the equivalent, smb_buf_length, is treated
+	   as host endian until right before we send it (here) so
+	   has to be converted to big endian below.  Would be
+	   too big a change for cifspdu.c to change the many
+	   dozen places that treat it as host endian for cifs, but
+	   at least for smb2 we can treat it as host endian */
+	if (server->is_smb2 == false)
+		smb_buffer->smb_buf_length = (__force __u32)
+			cpu_to_be32(smb_buffer->smb_buf_length);
 	cFYI(1, "Sending smb:  total_len %d", total_len);
 	dump_smb(smb_buffer, len);