summaryrefslogtreecommitdiff
path: root/fs/cifs/smb2pdu.c
diff options
context:
space:
mode:
authorSteve French <stfrench@microsoft.com>2019-06-25 04:39:51 -0500
committerSteve French <stfrench@microsoft.com>2019-07-07 22:37:43 -0500
commit96d3cca1241d6e56910b74435301e095705e1ebc (patch)
treeb57e925dc5f4490848b6cd7f15c8b431449d3185 /fs/cifs/smb2pdu.c
parent9fe5ff1c5d6a2a6c4ed4ba051a858571fdb7834c (diff)
downloadlwn-96d3cca1241d6e56910b74435301e095705e1ebc.tar.gz
lwn-96d3cca1241d6e56910b74435301e095705e1ebc.zip
smb3: Send netname context during negotiate protocol
See MS-SMB2 2.2.3.1.4 Allows hostname to be used by load balancers Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/cifs/smb2pdu.c')
-rw-r--r--fs/cifs/smb2pdu.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 8e289404f6b0..34d5397a1989 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -495,6 +495,21 @@ build_encrypt_ctxt(struct smb2_encryption_neg_context *pneg_ctxt)
pneg_ctxt->Ciphers[1] = SMB2_ENCRYPTION_AES128_CCM;
}
+static unsigned int
+build_netname_ctxt(struct smb2_netname_neg_context *pneg_ctxt, char *hostname)
+{
+ struct nls_table *cp = load_nls_default();
+
+ pneg_ctxt->ContextType = SMB2_NETNAME_NEGOTIATE_CONTEXT_ID;
+
+ /* copy up to max of first 100 bytes of server name to NetName field */
+ pneg_ctxt->DataLength = cpu_to_le16(2 +
+ (2 * cifs_strtoUTF16(pneg_ctxt->NetName, hostname, 100, cp)));
+ /* context size is DataLength + minimal smb2_neg_context */
+ return DIV_ROUND_UP(le16_to_cpu(pneg_ctxt->DataLength) +
+ sizeof(struct smb2_neg_context), 8) * 8;
+}
+
static void
build_posix_ctxt(struct smb2_posix_neg_context *pneg_ctxt)
{
@@ -559,9 +574,15 @@ assemble_neg_contexts(struct smb2_negotiate_req *req,
8) * 8;
*total_len += ctxt_len;
pneg_ctxt += ctxt_len;
- req->NegotiateContextCount = cpu_to_le16(4);
+ req->NegotiateContextCount = cpu_to_le16(5);
} else
- req->NegotiateContextCount = cpu_to_le16(3);
+ req->NegotiateContextCount = cpu_to_le16(4);
+
+ ctxt_len = build_netname_ctxt((struct smb2_netname_neg_context *)pneg_ctxt,
+ server->hostname);
+ *total_len += ctxt_len;
+ pneg_ctxt += ctxt_len;
+
build_posix_ctxt((struct smb2_posix_neg_context *)pneg_ctxt);
*total_len += sizeof(struct smb2_posix_neg_context);
}