Skip to content

Commit e77978d

Browse files
sprasad-microsoftsmfrench
authored andcommitted
cifs: update ip_addr for ses only for primary chan setup
We update ses->ip_addr whenever we do a session setup. But this should happen only for primary channel in mchan scenario. Signed-off-by: Shyam Prasad N <[email protected]> Reviewed-by: Paulo Alcantara (SUSE) <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent df57109 commit e77978d

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

fs/cifs/connect.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3708,16 +3708,12 @@ cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
37083708
struct nls_table *nls_info)
37093709
{
37103710
int rc = -ENOSYS;
3711-
struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)&server->dstaddr;
3712-
struct sockaddr_in *addr = (struct sockaddr_in *)&server->dstaddr;
3711+
struct TCP_Server_Info *pserver = CIFS_SERVER_IS_CHAN(server) ? server->primary_server : server;
3712+
struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)&pserver->dstaddr;
3713+
struct sockaddr_in *addr = (struct sockaddr_in *)&pserver->dstaddr;
37133714
bool is_binding = false;
37143715

37153716
spin_lock(&ses->ses_lock);
3716-
if (server->dstaddr.ss_family == AF_INET6)
3717-
scnprintf(ses->ip_addr, sizeof(ses->ip_addr), "%pI6", &addr6->sin6_addr);
3718-
else
3719-
scnprintf(ses->ip_addr, sizeof(ses->ip_addr), "%pI4", &addr->sin_addr);
3720-
37213717
if (ses->ses_status != SES_GOOD &&
37223718
ses->ses_status != SES_NEW &&
37233719
ses->ses_status != SES_NEED_RECON) {
@@ -3741,6 +3737,14 @@ cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
37413737
ses->ses_status = SES_IN_SETUP;
37423738
spin_unlock(&ses->ses_lock);
37433739

3740+
/* update ses ip_addr only for primary chan */
3741+
if (server == pserver) {
3742+
if (server->dstaddr.ss_family == AF_INET6)
3743+
scnprintf(ses->ip_addr, sizeof(ses->ip_addr), "%pI6", &addr6->sin6_addr);
3744+
else
3745+
scnprintf(ses->ip_addr, sizeof(ses->ip_addr), "%pI4", &addr->sin_addr);
3746+
}
3747+
37443748
if (!is_binding) {
37453749
ses->capabilities = server->capabilities;
37463750
if (!linuxExtEnabled)

0 commit comments

Comments
 (0)