Commit cb7691b6 authored by Jeff Layton's avatar Jeff Layton Committed by Steve French

cifs: add local server pointer to cifs_setup_session

cifs_setup_session references pSesInfo->server several times. That
pointer shouldn't change during the life of the function so grab it
once and store it in a local var. This makes the code look a little
cleaner too.
Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent aab3a8c7
...@@ -3598,19 +3598,21 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, ...@@ -3598,19 +3598,21 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo,
char ntlm_session_key[CIFS_SESS_KEY_SIZE]; char ntlm_session_key[CIFS_SESS_KEY_SIZE];
bool ntlmv2_flag = false; bool ntlmv2_flag = false;
int first_time = 0; int first_time = 0;
struct TCP_Server_Info *server = pSesInfo->server;
/* what if server changes its buffer size after dropping the session? */ /* what if server changes its buffer size after dropping the session? */
if (pSesInfo->server->maxBuf == 0) /* no need to send on reconnect */ { if (server->maxBuf == 0) /* no need to send on reconnect */ {
rc = CIFSSMBNegotiate(xid, pSesInfo); rc = CIFSSMBNegotiate(xid, pSesInfo);
if (rc == -EAGAIN) /* retry only once on 1st time connection */ { if (rc == -EAGAIN) {
/* retry only once on 1st time connection */
rc = CIFSSMBNegotiate(xid, pSesInfo); rc = CIFSSMBNegotiate(xid, pSesInfo);
if (rc == -EAGAIN) if (rc == -EAGAIN)
rc = -EHOSTDOWN; rc = -EHOSTDOWN;
} }
if (rc == 0) { if (rc == 0) {
spin_lock(&GlobalMid_Lock); spin_lock(&GlobalMid_Lock);
if (pSesInfo->server->tcpStatus != CifsExiting) if (server->tcpStatus != CifsExiting)
pSesInfo->server->tcpStatus = CifsGood; server->tcpStatus = CifsGood;
else else
rc = -EHOSTDOWN; rc = -EHOSTDOWN;
spin_unlock(&GlobalMid_Lock); spin_unlock(&GlobalMid_Lock);
...@@ -3623,23 +3625,22 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, ...@@ -3623,23 +3625,22 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo,
goto ss_err_exit; goto ss_err_exit;
pSesInfo->flags = 0; pSesInfo->flags = 0;
pSesInfo->capabilities = pSesInfo->server->capabilities; pSesInfo->capabilities = server->capabilities;
if (linuxExtEnabled == 0) if (linuxExtEnabled == 0)
pSesInfo->capabilities &= (~CAP_UNIX); pSesInfo->capabilities &= (~CAP_UNIX);
/* pSesInfo->sequence_number = 0;*/ /* pSesInfo->sequence_number = 0;*/
cFYI(1, ("Security Mode: 0x%x Capabilities: 0x%x TimeAdjust: %d", cFYI(1, ("Security Mode: 0x%x Capabilities: 0x%x TimeAdjust: %d",
pSesInfo->server->secMode, server->secMode, server->capabilities, server->timeAdj));
pSesInfo->server->capabilities,
pSesInfo->server->timeAdj));
if (experimEnabled < 2) if (experimEnabled < 2)
rc = CIFS_SessSetup(xid, pSesInfo, first_time, nls_info); rc = CIFS_SessSetup(xid, pSesInfo, first_time, nls_info);
else if (extended_security else if (extended_security
&& (pSesInfo->capabilities & CAP_EXTENDED_SECURITY) && (pSesInfo->capabilities & CAP_EXTENDED_SECURITY)
&& (pSesInfo->server->secType == NTLMSSP)) { && (server->secType == NTLMSSP)) {
rc = -EOPNOTSUPP; rc = -EOPNOTSUPP;
} else if (extended_security } else if (extended_security
&& (pSesInfo->capabilities & CAP_EXTENDED_SECURITY) && (pSesInfo->capabilities & CAP_EXTENDED_SECURITY)
&& (pSesInfo->server->secType == RawNTLMSSP)) { && (server->secType == RawNTLMSSP)) {
cFYI(1, ("NTLMSSP sesssetup")); cFYI(1, ("NTLMSSP sesssetup"));
rc = CIFSNTLMSSPNegotiateSessSetup(xid, pSesInfo, &ntlmv2_flag, rc = CIFSNTLMSSPNegotiateSessSetup(xid, pSesInfo, &ntlmv2_flag,
nls_info); nls_info);
...@@ -3668,12 +3669,12 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, ...@@ -3668,12 +3669,12 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo,
} else { } else {
SMBNTencrypt(pSesInfo->password, SMBNTencrypt(pSesInfo->password,
pSesInfo->server->cryptKey, server->cryptKey,
ntlm_session_key); ntlm_session_key);
if (first_time) if (first_time)
cifs_calculate_mac_key( cifs_calculate_mac_key(
&pSesInfo->server->mac_signing_key, &server->mac_signing_key,
ntlm_session_key, ntlm_session_key,
pSesInfo->password); pSesInfo->password);
} }
...@@ -3686,13 +3687,13 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, ...@@ -3686,13 +3687,13 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo,
nls_info); nls_info);
} }
} else { /* old style NTLM 0.12 session setup */ } else { /* old style NTLM 0.12 session setup */
SMBNTencrypt(pSesInfo->password, pSesInfo->server->cryptKey, SMBNTencrypt(pSesInfo->password, server->cryptKey,
ntlm_session_key); ntlm_session_key);
if (first_time) if (first_time)
cifs_calculate_mac_key( cifs_calculate_mac_key(&server->mac_signing_key,
&pSesInfo->server->mac_signing_key, ntlm_session_key,
ntlm_session_key, pSesInfo->password); pSesInfo->password);
rc = CIFSSessSetup(xid, pSesInfo, ntlm_session_key, nls_info); rc = CIFSSessSetup(xid, pSesInfo, ntlm_session_key, nls_info);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment