Commit 0d35e382 authored by Ronnie Sahlberg's avatar Ronnie Sahlberg Committed by Steve French
Browse files

cifs: Create a new shared file holding smb2 pdu definitions



This file will contain all the definitions we need for SMB2 packets
and will follow the naming convention of MS-SMB2.PDF as closely
as possible to make it easier to cross-reference beween the definitions
and the standard.

The content of this file will mostly consist of migration of existing
definitions in the cifs/smb2.pdu.h and ksmbd/smb2pdu.h files
with some additional tweaks as the two files have diverged.

This patch introduces the new smbfs_common/smb2pdu.h file
and migrates the SMB2 header as well as TREE_CONNECT and TREE_DISCONNECT
to the shared file.

Signed-off-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
Reviewed-by: default avatarNamjae Jeon <linkinjeon@kernel.org>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 7ae5e588
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@
#include <linux/key-type.h>
#include "cifs_spnego.h"
#include "fscache.h"
#include "smb2pdu.h"
#ifdef CONFIG_CIFS_DFS_UPCALL
#include "dfs_cache.h"
#endif
+2 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <crypto/internal/hash.h>
#include <linux/scatterlist.h>
#include <uapi/linux/cifs/cifs_mount.h>
#include "../smbfs_common/smb2pdu.h"
#include "smb2pdu.h"

#define CIFS_MAGIC_NUMBER 0xFF534D42      /* the first four bytes of SMB PDUs */
@@ -776,7 +777,7 @@ revert_current_mid(struct TCP_Server_Info *server, const unsigned int val)

static inline void
revert_current_mid_from_hdr(struct TCP_Server_Info *server,
			    const struct smb2_sync_hdr *shdr)
			    const struct smb2_hdr *shdr)
{
	unsigned int num = le16_to_cpu(shdr->CreditCharge);

+2 −2
Original line number Diff line number Diff line
@@ -677,7 +677,7 @@ dequeue_mid(struct mid_q_entry *mid, bool malformed)
static unsigned int
smb2_get_credits_from_hdr(char *buffer, struct TCP_Server_Info *server)
{
	struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buffer;
	struct smb2_hdr *shdr = (struct smb2_hdr *)buffer;

	/*
	 * SMB1 does not use credits.
@@ -877,7 +877,7 @@ cifs_handle_standard(struct TCP_Server_Info *server, struct mid_q_entry *mid)
static void
smb2_add_credits_from_hdr(char *buffer, struct TCP_Server_Info *server)
{
	struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buffer;
	struct smb2_hdr *shdr = (struct smb2_hdr *)buffer;
	int scredits, in_flight;

	/*
+1 −1
Original line number Diff line number Diff line
@@ -152,7 +152,7 @@ cifs_buf_get(void)
	 * SMB2 header is bigger than CIFS one - no problems to clean some
	 * more bytes for CIFS.
	 */
	size_t buf_size = sizeof(struct smb2_sync_hdr);
	size_t buf_size = sizeof(struct smb2_hdr);

	/*
	 * We could use negotiated size instead of max_msgsize -
+10 −6
Original line number Diff line number Diff line
@@ -2439,14 +2439,16 @@ smb2_print_status(__le32 status)
int
map_smb2_to_linux_error(char *buf, bool log_err)
{
	struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buf;
	struct smb2_hdr *shdr = (struct smb2_hdr *)buf;
	unsigned int i;
	int rc = -EIO;
	__le32 smb2err = shdr->Status;

	if (smb2err == 0) {
		trace_smb3_cmd_done(shdr->TreeId, shdr->SessionId,
			le16_to_cpu(shdr->Command), le64_to_cpu(shdr->MessageId));
		trace_smb3_cmd_done(le32_to_cpu(shdr->Id.SyncId.TreeId),
			      le64_to_cpu(shdr->SessionId),
			      le16_to_cpu(shdr->Command),
			      le64_to_cpu(shdr->MessageId));
		return 0;
	}

@@ -2470,8 +2472,10 @@ map_smb2_to_linux_error(char *buf, bool log_err)
	cifs_dbg(FYI, "Mapping SMB2 status code 0x%08x to POSIX err %d\n",
		 __le32_to_cpu(smb2err), rc);

	trace_smb3_cmd_err(shdr->TreeId, shdr->SessionId,
	trace_smb3_cmd_err(le32_to_cpu(shdr->Id.SyncId.TreeId),
			   le64_to_cpu(shdr->SessionId),
			   le16_to_cpu(shdr->Command),
			le64_to_cpu(shdr->MessageId), le32_to_cpu(smb2err), rc);
			   le64_to_cpu(shdr->MessageId),
			   le32_to_cpu(smb2err), rc);
	return rc;
}
Loading