aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cifs/smb2transport.c')
-rw-r--r--fs/cifs/smb2transport.c58
1 files changed, 52 insertions, 6 deletions
diff --git a/fs/cifs/smb2transport.c b/fs/cifs/smb2transport.c
index d4c5b6f109a7..69e3b322bbfe 100644
--- a/fs/cifs/smb2transport.c
+++ b/fs/cifs/smb2transport.c
@@ -115,22 +115,68 @@ smb3_crypto_shash_allocate(struct TCP_Server_Info *server)
115} 115}
116 116
117static struct cifs_ses * 117static struct cifs_ses *
118smb2_find_smb_ses(struct smb2_hdr *smb2hdr, struct TCP_Server_Info *server) 118smb2_find_smb_ses_unlocked(struct TCP_Server_Info *server, __u64 ses_id)
119{ 119{
120 struct cifs_ses *ses; 120 struct cifs_ses *ses;
121 121
122 spin_lock(&cifs_tcp_ses_lock);
123 list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) { 122 list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) {
124 if (ses->Suid != smb2hdr->SessionId) 123 if (ses->Suid != ses_id)
125 continue; 124 continue;
126 spin_unlock(&cifs_tcp_ses_lock);
127 return ses; 125 return ses;
128 } 126 }
127
128 return NULL;
129}
130
131struct cifs_ses *
132smb2_find_smb_ses(struct TCP_Server_Info *server, __u64 ses_id)
133{
134 struct cifs_ses *ses;
135
136 spin_lock(&cifs_tcp_ses_lock);
137 ses = smb2_find_smb_ses_unlocked(server, ses_id);
129 spin_unlock(&cifs_tcp_ses_lock); 138 spin_unlock(&cifs_tcp_ses_lock);
130 139
140 return ses;
141}
142
143static struct cifs_tcon *
144smb2_find_smb_sess_tcon_unlocked(struct cifs_ses *ses, __u32 tid)
145{
146 struct cifs_tcon *tcon;
147
148 list_for_each_entry(tcon, &ses->tcon_list, tcon_list) {
149 if (tcon->tid != tid)
150 continue;
151 ++tcon->tc_count;
152 return tcon;
153 }
154
131 return NULL; 155 return NULL;
132} 156}
133 157
158/*
159 * Obtain tcon corresponding to the tid in the given
160 * cifs_ses
161 */
162
163struct cifs_tcon *
164smb2_find_smb_tcon(struct TCP_Server_Info *server, __u64 ses_id, __u32 tid)
165{
166 struct cifs_ses *ses;
167 struct cifs_tcon *tcon;
168
169 spin_lock(&cifs_tcp_ses_lock);
170 ses = smb2_find_smb_ses_unlocked(server, ses_id);
171 if (!ses) {
172 spin_unlock(&cifs_tcp_ses_lock);
173 return NULL;
174 }
175 tcon = smb2_find_smb_sess_tcon_unlocked(ses, tid);
176 spin_unlock(&cifs_tcp_ses_lock);
177
178 return tcon;
179}
134 180
135int 181int
136smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) 182smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
@@ -143,7 +189,7 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
143 struct smb2_hdr *smb2_pdu = (struct smb2_hdr *)iov[0].iov_base; 189 struct smb2_hdr *smb2_pdu = (struct smb2_hdr *)iov[0].iov_base;
144 struct cifs_ses *ses; 190 struct cifs_ses *ses;
145 191
146 ses = smb2_find_smb_ses(smb2_pdu, server); 192 ses = smb2_find_smb_ses(server, smb2_pdu->SessionId);
147 if (!ses) { 193 if (!ses) {
148 cifs_dbg(VFS, "%s: Could not find session\n", __func__); 194 cifs_dbg(VFS, "%s: Could not find session\n", __func__);
149 return 0; 195 return 0;
@@ -314,7 +360,7 @@ smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
314 struct smb2_hdr *smb2_pdu = (struct smb2_hdr *)iov[0].iov_base; 360 struct smb2_hdr *smb2_pdu = (struct smb2_hdr *)iov[0].iov_base;
315 struct cifs_ses *ses; 361 struct cifs_ses *ses;
316 362
317 ses = smb2_find_smb_ses(smb2_pdu, server); 363 ses = smb2_find_smb_ses(server, smb2_pdu->SessionId);
318 if (!ses) { 364 if (!ses) {
319 cifs_dbg(VFS, "%s: Could not find session\n", __func__); 365 cifs_dbg(VFS, "%s: Could not find session\n", __func__);
320 return 0; 366 return 0;