diff options
author | Steve French <stfrench@microsoft.com> | 2019-06-25 05:39:51 -0400 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2019-07-07 23:37:43 -0400 |
commit | 96d3cca1241d6e56910b74435301e095705e1ebc (patch) | |
tree | b57e925dc5f4490848b6cd7f15c8b431449d3185 /fs/cifs | |
parent | 9fe5ff1c5d6a2a6c4ed4ba051a858571fdb7834c (diff) |
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')
-rw-r--r-- | fs/cifs/smb2pdu.c | 25 | ||||
-rw-r--r-- | fs/cifs/smb2pdu.h | 6 |
2 files changed, 29 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) | |||
495 | pneg_ctxt->Ciphers[1] = SMB2_ENCRYPTION_AES128_CCM; | 495 | pneg_ctxt->Ciphers[1] = SMB2_ENCRYPTION_AES128_CCM; |
496 | } | 496 | } |
497 | 497 | ||
498 | static unsigned int | ||
499 | build_netname_ctxt(struct smb2_netname_neg_context *pneg_ctxt, char *hostname) | ||
500 | { | ||
501 | struct nls_table *cp = load_nls_default(); | ||
502 | |||
503 | pneg_ctxt->ContextType = SMB2_NETNAME_NEGOTIATE_CONTEXT_ID; | ||
504 | |||
505 | /* copy up to max of first 100 bytes of server name to NetName field */ | ||
506 | pneg_ctxt->DataLength = cpu_to_le16(2 + | ||
507 | (2 * cifs_strtoUTF16(pneg_ctxt->NetName, hostname, 100, cp))); | ||
508 | /* context size is DataLength + minimal smb2_neg_context */ | ||
509 | return DIV_ROUND_UP(le16_to_cpu(pneg_ctxt->DataLength) + | ||
510 | sizeof(struct smb2_neg_context), 8) * 8; | ||
511 | } | ||
512 | |||
498 | static void | 513 | static void |
499 | build_posix_ctxt(struct smb2_posix_neg_context *pneg_ctxt) | 514 | build_posix_ctxt(struct smb2_posix_neg_context *pneg_ctxt) |
500 | { | 515 | { |
@@ -559,9 +574,15 @@ assemble_neg_contexts(struct smb2_negotiate_req *req, | |||
559 | 8) * 8; | 574 | 8) * 8; |
560 | *total_len += ctxt_len; | 575 | *total_len += ctxt_len; |
561 | pneg_ctxt += ctxt_len; | 576 | pneg_ctxt += ctxt_len; |
562 | req->NegotiateContextCount = cpu_to_le16(4); | 577 | req->NegotiateContextCount = cpu_to_le16(5); |
563 | } else | 578 | } else |
564 | req->NegotiateContextCount = cpu_to_le16(3); | 579 | req->NegotiateContextCount = cpu_to_le16(4); |
580 | |||
581 | ctxt_len = build_netname_ctxt((struct smb2_netname_neg_context *)pneg_ctxt, | ||
582 | server->hostname); | ||
583 | *total_len += ctxt_len; | ||
584 | pneg_ctxt += ctxt_len; | ||
585 | |||
565 | build_posix_ctxt((struct smb2_posix_neg_context *)pneg_ctxt); | 586 | build_posix_ctxt((struct smb2_posix_neg_context *)pneg_ctxt); |
566 | *total_len += sizeof(struct smb2_posix_neg_context); | 587 | *total_len += sizeof(struct smb2_posix_neg_context); |
567 | } | 588 | } |
diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index e5f7e8135a39..053ec621e7b9 100644 --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h | |||
@@ -317,6 +317,12 @@ struct smb2_compression_capabilities_context { | |||
317 | * For smb2_netname_negotiate_context_id See MS-SMB2 2.2.3.1.4. | 317 | * For smb2_netname_negotiate_context_id See MS-SMB2 2.2.3.1.4. |
318 | * Its struct simply contains NetName, an array of Unicode characters | 318 | * Its struct simply contains NetName, an array of Unicode characters |
319 | */ | 319 | */ |
320 | struct smb2_netname_neg_context { | ||
321 | __le16 ContextType; /* 0x100 */ | ||
322 | __le16 DataLength; | ||
323 | __le32 Reserved; | ||
324 | __le16 NetName[0]; /* hostname of target converted to UCS-2 */ | ||
325 | } __packed; | ||
320 | 326 | ||
321 | #define POSIX_CTXT_DATA_LEN 16 | 327 | #define POSIX_CTXT_DATA_LEN 16 |
322 | struct smb2_posix_neg_context { | 328 | struct smb2_posix_neg_context { |