Skip to content

Commit 9de7499

Browse files
sprasad-microsoftSteve French
authored andcommitted
smb3: use netname when available on secondary channels
Some servers do not allow null netname contexts, which would cause multichannel to revert to single channel when mounting to some servers (e.g. Azure xSMB). The previous patch fixed that by avoiding incorrectly sending the netname context when there would be a null hostname sent in the netname context, while this patch fixes the null hostname for the secondary channel by using the hostname of the primary channel for the secondary channel. Fixes: 4c14d70 ("cifs: populate empty hostnames for extra channels") Signed-off-by: Shyam Prasad N <[email protected]> Reviewed-by: Paulo Alcantara (SUSE) <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 73130a7 commit 9de7499

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

fs/cifs/smb2pdu.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@ assemble_neg_contexts(struct smb2_negotiate_req *req,
543543
struct TCP_Server_Info *server, unsigned int *total_len)
544544
{
545545
char *pneg_ctxt;
546+
char *hostname = NULL;
546547
unsigned int ctxt_len, neg_context_count;
547548

548549
if (*total_len > 200) {
@@ -574,9 +575,15 @@ assemble_neg_contexts(struct smb2_negotiate_req *req,
574575
*total_len += sizeof(struct smb2_posix_neg_context);
575576
pneg_ctxt += sizeof(struct smb2_posix_neg_context);
576577

577-
if (server->hostname && (server->hostname[0] != 0)) {
578+
/*
579+
* secondary channels don't have the hostname field populated
580+
* use the hostname field in the primary channel instead
581+
*/
582+
hostname = CIFS_SERVER_IS_CHAN(server) ?
583+
server->primary_server->hostname : server->hostname;
584+
if (hostname && (hostname[0] != 0)) {
578585
ctxt_len = build_netname_ctxt((struct smb2_netname_neg_context *)pneg_ctxt,
579-
server->hostname);
586+
hostname);
580587
*total_len += ctxt_len;
581588
pneg_ctxt += ctxt_len;
582589
neg_context_count = 4;

0 commit comments

Comments
 (0)