cifs: update ip_addr for ses only for primary chan setup
authorShyam Prasad N <sprasad@microsoft.com>
Fri, 10 Feb 2023 17:41:17 +0000 (17:41 +0000)
committerSteve French <stfrench@microsoft.com>
Tue, 21 Feb 2023 07:25:11 +0000 (01:25 -0600)
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 <sprasad@microsoft.com>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/connect.c

index 6831eb8..61872db 100644 (file)
@@ -3708,16 +3708,12 @@ cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
                   struct nls_table *nls_info)
 {
        int rc = -ENOSYS;
-       struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)&server->dstaddr;
-       struct sockaddr_in *addr = (struct sockaddr_in *)&server->dstaddr;
+       struct TCP_Server_Info *pserver = CIFS_SERVER_IS_CHAN(server) ? server->primary_server : server;
+       struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)&pserver->dstaddr;
+       struct sockaddr_in *addr = (struct sockaddr_in *)&pserver->dstaddr;
        bool is_binding = false;
 
        spin_lock(&ses->ses_lock);
-       if (server->dstaddr.ss_family == AF_INET6)
-               scnprintf(ses->ip_addr, sizeof(ses->ip_addr), "%pI6", &addr6->sin6_addr);
-       else
-               scnprintf(ses->ip_addr, sizeof(ses->ip_addr), "%pI4", &addr->sin_addr);
-
        if (ses->ses_status != SES_GOOD &&
            ses->ses_status != SES_NEW &&
            ses->ses_status != SES_NEED_RECON) {
@@ -3741,6 +3737,14 @@ cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
                ses->ses_status = SES_IN_SETUP;
        spin_unlock(&ses->ses_lock);
 
+       /* update ses ip_addr only for primary chan */
+       if (server == pserver) {
+               if (server->dstaddr.ss_family == AF_INET6)
+                       scnprintf(ses->ip_addr, sizeof(ses->ip_addr), "%pI6", &addr6->sin6_addr);
+               else
+                       scnprintf(ses->ip_addr, sizeof(ses->ip_addr), "%pI4", &addr->sin_addr);
+       }
+
        if (!is_binding) {
                ses->capabilities = server->capabilities;
                if (!linuxExtEnabled)