aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/connect.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cifs/connect.c')
-rw-r--r--fs/cifs/connect.c211
1 files changed, 109 insertions, 102 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 9f59887badd..47d8ff62368 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -52,8 +52,8 @@
52#define CIFS_PORT 445 52#define CIFS_PORT 445
53#define RFC1001_PORT 139 53#define RFC1001_PORT 139
54 54
55extern void SMBNTencrypt(unsigned char *passwd, unsigned char *c8, 55/* SMB echo "timeout" -- FIXME: tunable? */
56 unsigned char *p24); 56#define SMB_ECHO_INTERVAL (60 * HZ)
57 57
58extern mempool_t *cifs_req_poolp; 58extern mempool_t *cifs_req_poolp;
59 59
@@ -84,6 +84,7 @@ struct smb_vol {
84 bool no_xattr:1; /* set if xattr (EA) support should be disabled*/ 84 bool no_xattr:1; /* set if xattr (EA) support should be disabled*/
85 bool server_ino:1; /* use inode numbers from server ie UniqueId */ 85 bool server_ino:1; /* use inode numbers from server ie UniqueId */
86 bool direct_io:1; 86 bool direct_io:1;
87 bool strict_io:1; /* strict cache behavior */
87 bool remap:1; /* set to remap seven reserved chars in filenames */ 88 bool remap:1; /* set to remap seven reserved chars in filenames */
88 bool posix_paths:1; /* unset to not ask for posix pathnames. */ 89 bool posix_paths:1; /* unset to not ask for posix pathnames. */
89 bool no_linux_ext:1; 90 bool no_linux_ext:1;
@@ -152,6 +153,7 @@ cifs_reconnect(struct TCP_Server_Info *server)
152 153
153 /* before reconnecting the tcp session, mark the smb session (uid) 154 /* before reconnecting the tcp session, mark the smb session (uid)
154 and the tid bad so they are not used until reconnected */ 155 and the tid bad so they are not used until reconnected */
156 cFYI(1, "%s: marking sessions and tcons for reconnect", __func__);
155 spin_lock(&cifs_tcp_ses_lock); 157 spin_lock(&cifs_tcp_ses_lock);
156 list_for_each(tmp, &server->smb_ses_list) { 158 list_for_each(tmp, &server->smb_ses_list) {
157 ses = list_entry(tmp, struct cifsSesInfo, smb_ses_list); 159 ses = list_entry(tmp, struct cifsSesInfo, smb_ses_list);
@@ -163,7 +165,9 @@ cifs_reconnect(struct TCP_Server_Info *server)
163 } 165 }
164 } 166 }
165 spin_unlock(&cifs_tcp_ses_lock); 167 spin_unlock(&cifs_tcp_ses_lock);
168
166 /* do not want to be sending data on a socket we are freeing */ 169 /* do not want to be sending data on a socket we are freeing */
170 cFYI(1, "%s: tearing down socket", __func__);
167 mutex_lock(&server->srv_mutex); 171 mutex_lock(&server->srv_mutex);
168 if (server->ssocket) { 172 if (server->ssocket) {
169 cFYI(1, "State: 0x%x Flags: 0x%lx", server->ssocket->state, 173 cFYI(1, "State: 0x%x Flags: 0x%lx", server->ssocket->state,
@@ -180,22 +184,20 @@ cifs_reconnect(struct TCP_Server_Info *server)
180 kfree(server->session_key.response); 184 kfree(server->session_key.response);
181 server->session_key.response = NULL; 185 server->session_key.response = NULL;
182 server->session_key.len = 0; 186 server->session_key.len = 0;
187 server->lstrp = jiffies;
188 mutex_unlock(&server->srv_mutex);
183 189
190 /* mark submitted MIDs for retry and issue callback */
191 cFYI(1, "%s: issuing mid callbacks", __func__);
184 spin_lock(&GlobalMid_Lock); 192 spin_lock(&GlobalMid_Lock);
185 list_for_each(tmp, &server->pending_mid_q) { 193 list_for_each_safe(tmp, tmp2, &server->pending_mid_q) {
186 mid_entry = list_entry(tmp, struct 194 mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
187 mid_q_entry, 195 if (mid_entry->midState == MID_REQUEST_SUBMITTED)
188 qhead);
189 if (mid_entry->midState == MID_REQUEST_SUBMITTED) {
190 /* Mark other intransit requests as needing
191 retry so we do not immediately mark the
192 session bad again (ie after we reconnect
193 below) as they timeout too */
194 mid_entry->midState = MID_RETRY_NEEDED; 196 mid_entry->midState = MID_RETRY_NEEDED;
195 } 197 list_del_init(&mid_entry->qhead);
198 mid_entry->callback(mid_entry);
196 } 199 }
197 spin_unlock(&GlobalMid_Lock); 200 spin_unlock(&GlobalMid_Lock);
198 mutex_unlock(&server->srv_mutex);
199 201
200 while ((server->tcpStatus != CifsExiting) && 202 while ((server->tcpStatus != CifsExiting) &&
201 (server->tcpStatus != CifsGood)) { 203 (server->tcpStatus != CifsGood)) {
@@ -212,10 +214,9 @@ cifs_reconnect(struct TCP_Server_Info *server)
212 if (server->tcpStatus != CifsExiting) 214 if (server->tcpStatus != CifsExiting)
213 server->tcpStatus = CifsGood; 215 server->tcpStatus = CifsGood;
214 spin_unlock(&GlobalMid_Lock); 216 spin_unlock(&GlobalMid_Lock);
215 /* atomic_set(&server->inFlight,0);*/
216 wake_up(&server->response_q);
217 } 217 }
218 } 218 }
219
219 return rc; 220 return rc;
220} 221}
221 222
@@ -229,9 +230,8 @@ cifs_reconnect(struct TCP_Server_Info *server)
229static int check2ndT2(struct smb_hdr *pSMB, unsigned int maxBufSize) 230static int check2ndT2(struct smb_hdr *pSMB, unsigned int maxBufSize)
230{ 231{
231 struct smb_t2_rsp *pSMBt; 232 struct smb_t2_rsp *pSMBt;
232 int total_data_size;
233 int data_in_this_rsp;
234 int remaining; 233 int remaining;
234 __u16 total_data_size, data_in_this_rsp;
235 235
236 if (pSMB->Command != SMB_COM_TRANSACTION2) 236 if (pSMB->Command != SMB_COM_TRANSACTION2)
237 return 0; 237 return 0;
@@ -245,8 +245,8 @@ static int check2ndT2(struct smb_hdr *pSMB, unsigned int maxBufSize)
245 245
246 pSMBt = (struct smb_t2_rsp *)pSMB; 246 pSMBt = (struct smb_t2_rsp *)pSMB;
247 247
248 total_data_size = le16_to_cpu(pSMBt->t2_rsp.TotalDataCount); 248 total_data_size = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount);
249 data_in_this_rsp = le16_to_cpu(pSMBt->t2_rsp.DataCount); 249 data_in_this_rsp = get_unaligned_le16(&pSMBt->t2_rsp.DataCount);
250 250
251 remaining = total_data_size - data_in_this_rsp; 251 remaining = total_data_size - data_in_this_rsp;
252 252
@@ -272,21 +272,18 @@ static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB)
272{ 272{
273 struct smb_t2_rsp *pSMB2 = (struct smb_t2_rsp *)psecond; 273 struct smb_t2_rsp *pSMB2 = (struct smb_t2_rsp *)psecond;
274 struct smb_t2_rsp *pSMBt = (struct smb_t2_rsp *)pTargetSMB; 274 struct smb_t2_rsp *pSMBt = (struct smb_t2_rsp *)pTargetSMB;
275 int total_data_size;
276 int total_in_buf;
277 int remaining;
278 int total_in_buf2;
279 char *data_area_of_target; 275 char *data_area_of_target;
280 char *data_area_of_buf2; 276 char *data_area_of_buf2;
281 __u16 byte_count; 277 int remaining;
278 __u16 byte_count, total_data_size, total_in_buf, total_in_buf2;
282 279
283 total_data_size = le16_to_cpu(pSMBt->t2_rsp.TotalDataCount); 280 total_data_size = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount);
284 281
285 if (total_data_size != le16_to_cpu(pSMB2->t2_rsp.TotalDataCount)) { 282 if (total_data_size !=
283 get_unaligned_le16(&pSMB2->t2_rsp.TotalDataCount))
286 cFYI(1, "total data size of primary and secondary t2 differ"); 284 cFYI(1, "total data size of primary and secondary t2 differ");
287 }
288 285
289 total_in_buf = le16_to_cpu(pSMBt->t2_rsp.DataCount); 286 total_in_buf = get_unaligned_le16(&pSMBt->t2_rsp.DataCount);
290 287
291 remaining = total_data_size - total_in_buf; 288 remaining = total_data_size - total_in_buf;
292 289
@@ -296,28 +293,28 @@ static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB)
296 if (remaining == 0) /* nothing to do, ignore */ 293 if (remaining == 0) /* nothing to do, ignore */
297 return 0; 294 return 0;
298 295
299 total_in_buf2 = le16_to_cpu(pSMB2->t2_rsp.DataCount); 296 total_in_buf2 = get_unaligned_le16(&pSMB2->t2_rsp.DataCount);
300 if (remaining < total_in_buf2) { 297 if (remaining < total_in_buf2) {
301 cFYI(1, "transact2 2nd response contains too much data"); 298 cFYI(1, "transact2 2nd response contains too much data");
302 } 299 }
303 300
304 /* find end of first SMB data area */ 301 /* find end of first SMB data area */
305 data_area_of_target = (char *)&pSMBt->hdr.Protocol + 302 data_area_of_target = (char *)&pSMBt->hdr.Protocol +
306 le16_to_cpu(pSMBt->t2_rsp.DataOffset); 303 get_unaligned_le16(&pSMBt->t2_rsp.DataOffset);
307 /* validate target area */ 304 /* validate target area */
308 305
309 data_area_of_buf2 = (char *) &pSMB2->hdr.Protocol + 306 data_area_of_buf2 = (char *)&pSMB2->hdr.Protocol +
310 le16_to_cpu(pSMB2->t2_rsp.DataOffset); 307 get_unaligned_le16(&pSMB2->t2_rsp.DataOffset);
311 308
312 data_area_of_target += total_in_buf; 309 data_area_of_target += total_in_buf;
313 310
314 /* copy second buffer into end of first buffer */ 311 /* copy second buffer into end of first buffer */
315 memcpy(data_area_of_target, data_area_of_buf2, total_in_buf2); 312 memcpy(data_area_of_target, data_area_of_buf2, total_in_buf2);
316 total_in_buf += total_in_buf2; 313 total_in_buf += total_in_buf2;
317 pSMBt->t2_rsp.DataCount = cpu_to_le16(total_in_buf); 314 put_unaligned_le16(total_in_buf, &pSMBt->t2_rsp.DataCount);
318 byte_count = le16_to_cpu(BCC_LE(pTargetSMB)); 315 byte_count = get_bcc_le(pTargetSMB);
319 byte_count += total_in_buf2; 316 byte_count += total_in_buf2;
320 BCC_LE(pTargetSMB) = cpu_to_le16(byte_count); 317 put_bcc_le(byte_count, pTargetSMB);
321 318
322 byte_count = pTargetSMB->smb_buf_length; 319 byte_count = pTargetSMB->smb_buf_length;
323 byte_count += total_in_buf2; 320 byte_count += total_in_buf2;
@@ -331,7 +328,26 @@ static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB)
331 return 0; /* we are done */ 328 return 0; /* we are done */
332 } else /* more responses to go */ 329 } else /* more responses to go */
333 return 1; 330 return 1;
331}
332
333static void
334cifs_echo_request(struct work_struct *work)
335{
336 int rc;
337 struct TCP_Server_Info *server = container_of(work,
338 struct TCP_Server_Info, echo.work);
339
340 /* no need to ping if we got a response recently */
341 if (time_before(jiffies, server->lstrp + SMB_ECHO_INTERVAL - HZ))
342 goto requeue_echo;
343
344 rc = CIFSSMBEcho(server);
345 if (rc)
346 cFYI(1, "Unable to send echo request to server: %s",
347 server->hostname);
334 348
349requeue_echo:
350 queue_delayed_work(system_nrt_wq, &server->echo, SMB_ECHO_INTERVAL);
335} 351}
336 352
337static int 353static int
@@ -345,8 +361,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
345 struct msghdr smb_msg; 361 struct msghdr smb_msg;
346 struct kvec iov; 362 struct kvec iov;
347 struct socket *csocket = server->ssocket; 363 struct socket *csocket = server->ssocket;
348 struct list_head *tmp; 364 struct list_head *tmp, *tmp2;
349 struct cifsSesInfo *ses;
350 struct task_struct *task_to_wake = NULL; 365 struct task_struct *task_to_wake = NULL;
351 struct mid_q_entry *mid_entry; 366 struct mid_q_entry *mid_entry;
352 char temp; 367 char temp;
@@ -399,7 +414,20 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
399 smb_msg.msg_control = NULL; 414 smb_msg.msg_control = NULL;
400 smb_msg.msg_controllen = 0; 415 smb_msg.msg_controllen = 0;
401 pdu_length = 4; /* enough to get RFC1001 header */ 416 pdu_length = 4; /* enough to get RFC1001 header */
417
402incomplete_rcv: 418incomplete_rcv:
419 if (echo_retries > 0 &&
420 time_after(jiffies, server->lstrp +
421 (echo_retries * SMB_ECHO_INTERVAL))) {
422 cERROR(1, "Server %s has not responded in %d seconds. "
423 "Reconnecting...", server->hostname,
424 (echo_retries * SMB_ECHO_INTERVAL / HZ));
425 cifs_reconnect(server);
426 csocket = server->ssocket;
427 wake_up(&server->response_q);
428 continue;
429 }
430
403 length = 431 length =
404 kernel_recvmsg(csocket, &smb_msg, 432 kernel_recvmsg(csocket, &smb_msg,
405 &iov, 1, pdu_length, 0 /* BB other flags? */); 433 &iov, 1, pdu_length, 0 /* BB other flags? */);
@@ -559,10 +587,11 @@ incomplete_rcv:
559 continue; 587 continue;
560 } 588 }
561 589
590 mid_entry = NULL;
591 server->lstrp = jiffies;
562 592
563 task_to_wake = NULL;
564 spin_lock(&GlobalMid_Lock); 593 spin_lock(&GlobalMid_Lock);
565 list_for_each(tmp, &server->pending_mid_q) { 594 list_for_each_safe(tmp, tmp2, &server->pending_mid_q) {
566 mid_entry = list_entry(tmp, struct mid_q_entry, qhead); 595 mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
567 596
568 if ((mid_entry->mid == smb_buffer->Mid) && 597 if ((mid_entry->mid == smb_buffer->Mid) &&
@@ -603,20 +632,19 @@ incomplete_rcv:
603 mid_entry->resp_buf = smb_buffer; 632 mid_entry->resp_buf = smb_buffer;
604 mid_entry->largeBuf = isLargeBuf; 633 mid_entry->largeBuf = isLargeBuf;
605multi_t2_fnd: 634multi_t2_fnd:
606 task_to_wake = mid_entry->tsk;
607 mid_entry->midState = MID_RESPONSE_RECEIVED; 635 mid_entry->midState = MID_RESPONSE_RECEIVED;
636 list_del_init(&mid_entry->qhead);
637 mid_entry->callback(mid_entry);
608#ifdef CONFIG_CIFS_STATS2 638#ifdef CONFIG_CIFS_STATS2
609 mid_entry->when_received = jiffies; 639 mid_entry->when_received = jiffies;
610#endif 640#endif
611 /* so we do not time out requests to server
612 which is still responding (since server could
613 be busy but not dead) */
614 server->lstrp = jiffies;
615 break; 641 break;
616 } 642 }
643 mid_entry = NULL;
617 } 644 }
618 spin_unlock(&GlobalMid_Lock); 645 spin_unlock(&GlobalMid_Lock);
619 if (task_to_wake) { 646
647 if (mid_entry != NULL) {
620 /* Was previous buf put in mpx struct for multi-rsp? */ 648 /* Was previous buf put in mpx struct for multi-rsp? */
621 if (!isMultiRsp) { 649 if (!isMultiRsp) {
622 /* smb buffer will be freed by user thread */ 650 /* smb buffer will be freed by user thread */
@@ -625,11 +653,10 @@ multi_t2_fnd:
625 else 653 else
626 smallbuf = NULL; 654 smallbuf = NULL;
627 } 655 }
628 wake_up_process(task_to_wake);
629 } else if (!is_valid_oplock_break(smb_buffer, server) && 656 } else if (!is_valid_oplock_break(smb_buffer, server) &&
630 !isMultiRsp) { 657 !isMultiRsp) {
631 cERROR(1, "No task to wake, unknown frame received! " 658 cERROR(1, "No task to wake, unknown frame received! "
632 "NumMids %d", midCount.counter); 659 "NumMids %d", atomic_read(&midCount));
633 cifs_dump_mem("Received Data is: ", (char *)smb_buffer, 660 cifs_dump_mem("Received Data is: ", (char *)smb_buffer,
634 sizeof(struct smb_hdr)); 661 sizeof(struct smb_hdr));
635#ifdef CONFIG_CIFS_DEBUG2 662#ifdef CONFIG_CIFS_DEBUG2
@@ -677,44 +704,16 @@ multi_t2_fnd:
677 if (smallbuf) /* no sense logging a debug message if NULL */ 704 if (smallbuf) /* no sense logging a debug message if NULL */
678 cifs_small_buf_release(smallbuf); 705 cifs_small_buf_release(smallbuf);
679 706
680 /* 707 if (!list_empty(&server->pending_mid_q)) {
681 * BB: we shouldn't have to do any of this. It shouldn't be
682 * possible to exit from the thread with active SMB sessions
683 */
684 spin_lock(&cifs_tcp_ses_lock);
685 if (list_empty(&server->pending_mid_q)) {
686 /* loop through server session structures attached to this and
687 mark them dead */
688 list_for_each(tmp, &server->smb_ses_list) {
689 ses = list_entry(tmp, struct cifsSesInfo,
690 smb_ses_list);
691 ses->status = CifsExiting;
692 ses->server = NULL;
693 }
694 spin_unlock(&cifs_tcp_ses_lock);
695 } else {
696 /* although we can not zero the server struct pointer yet,
697 since there are active requests which may depnd on them,
698 mark the corresponding SMB sessions as exiting too */
699 list_for_each(tmp, &server->smb_ses_list) {
700 ses = list_entry(tmp, struct cifsSesInfo,
701 smb_ses_list);
702 ses->status = CifsExiting;
703 }
704
705 spin_lock(&GlobalMid_Lock); 708 spin_lock(&GlobalMid_Lock);
706 list_for_each(tmp, &server->pending_mid_q) { 709 list_for_each_safe(tmp, tmp2, &server->pending_mid_q) {
707 mid_entry = list_entry(tmp, struct mid_q_entry, qhead); 710 mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
708 if (mid_entry->midState == MID_REQUEST_SUBMITTED) { 711 cFYI(1, "Clearing Mid 0x%x - issuing callback",
709 cFYI(1, "Clearing Mid 0x%x - waking up ",
710 mid_entry->mid); 712 mid_entry->mid);
711 task_to_wake = mid_entry->tsk; 713 list_del_init(&mid_entry->qhead);
712 if (task_to_wake) 714 mid_entry->callback(mid_entry);
713 wake_up_process(task_to_wake);
714 }
715 } 715 }
716 spin_unlock(&GlobalMid_Lock); 716 spin_unlock(&GlobalMid_Lock);
717 spin_unlock(&cifs_tcp_ses_lock);
718 /* 1/8th of sec is more than enough time for them to exit */ 717 /* 1/8th of sec is more than enough time for them to exit */
719 msleep(125); 718 msleep(125);
720 } 719 }
@@ -732,18 +731,6 @@ multi_t2_fnd:
732 coming home not much else we can do but free the memory */ 731 coming home not much else we can do but free the memory */
733 } 732 }
734 733
735 /* last chance to mark ses pointers invalid
736 if there are any pointing to this (e.g
737 if a crazy root user tried to kill cifsd
738 kernel thread explicitly this might happen) */
739 /* BB: This shouldn't be necessary, see above */
740 spin_lock(&cifs_tcp_ses_lock);
741 list_for_each(tmp, &server->smb_ses_list) {
742 ses = list_entry(tmp, struct cifsSesInfo, smb_ses_list);
743 ses->server = NULL;
744 }
745 spin_unlock(&cifs_tcp_ses_lock);
746
747 kfree(server->hostname); 734 kfree(server->hostname);
748 task_to_wake = xchg(&server->tsk, NULL); 735 task_to_wake = xchg(&server->tsk, NULL);
749 kfree(server); 736 kfree(server);
@@ -1355,6 +1342,8 @@ cifs_parse_mount_options(char *options, const char *devname,
1355 vol->direct_io = 1; 1342 vol->direct_io = 1;
1356 } else if (strnicmp(data, "forcedirectio", 13) == 0) { 1343 } else if (strnicmp(data, "forcedirectio", 13) == 0) {
1357 vol->direct_io = 1; 1344 vol->direct_io = 1;
1345 } else if (strnicmp(data, "strictcache", 11) == 0) {
1346 vol->strict_io = 1;
1358 } else if (strnicmp(data, "noac", 4) == 0) { 1347 } else if (strnicmp(data, "noac", 4) == 0) {
1359 printk(KERN_WARNING "CIFS: Mount option noac not " 1348 printk(KERN_WARNING "CIFS: Mount option noac not "
1360 "supported. Instead set " 1349 "supported. Instead set "
@@ -1579,6 +1568,9 @@ cifs_find_tcp_session(struct sockaddr *addr, struct smb_vol *vol)
1579 1568
1580 spin_lock(&cifs_tcp_ses_lock); 1569 spin_lock(&cifs_tcp_ses_lock);
1581 list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) { 1570 list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) {
1571 if (!net_eq(cifs_net_ns(server), current->nsproxy->net_ns))
1572 continue;
1573
1582 if (!match_address(server, addr, 1574 if (!match_address(server, addr,
1583 (struct sockaddr *)&vol->srcaddr)) 1575 (struct sockaddr *)&vol->srcaddr))
1584 continue; 1576 continue;
@@ -1609,9 +1601,13 @@ cifs_put_tcp_session(struct TCP_Server_Info *server)
1609 return; 1601 return;
1610 } 1602 }
1611 1603
1604 put_net(cifs_net_ns(server));
1605
1612 list_del_init(&server->tcp_ses_list); 1606 list_del_init(&server->tcp_ses_list);
1613 spin_unlock(&cifs_tcp_ses_lock); 1607 spin_unlock(&cifs_tcp_ses_lock);
1614 1608
1609 cancel_delayed_work_sync(&server->echo);
1610
1615 spin_lock(&GlobalMid_Lock); 1611 spin_lock(&GlobalMid_Lock);
1616 server->tcpStatus = CifsExiting; 1612 server->tcpStatus = CifsExiting;
1617 spin_unlock(&GlobalMid_Lock); 1613 spin_unlock(&GlobalMid_Lock);
@@ -1681,6 +1677,7 @@ cifs_get_tcp_session(struct smb_vol *volume_info)
1681 goto out_err; 1677 goto out_err;
1682 } 1678 }
1683 1679
1680 cifs_set_net_ns(tcp_ses, get_net(current->nsproxy->net_ns));
1684 tcp_ses->hostname = extract_hostname(volume_info->UNC); 1681 tcp_ses->hostname = extract_hostname(volume_info->UNC);
1685 if (IS_ERR(tcp_ses->hostname)) { 1682 if (IS_ERR(tcp_ses->hostname)) {
1686 rc = PTR_ERR(tcp_ses->hostname); 1683 rc = PTR_ERR(tcp_ses->hostname);
@@ -1701,8 +1698,10 @@ cifs_get_tcp_session(struct smb_vol *volume_info)
1701 volume_info->target_rfc1001_name, RFC1001_NAME_LEN_WITH_NULL); 1698 volume_info->target_rfc1001_name, RFC1001_NAME_LEN_WITH_NULL);
1702 tcp_ses->session_estab = false; 1699 tcp_ses->session_estab = false;
1703 tcp_ses->sequence_number = 0; 1700 tcp_ses->sequence_number = 0;
1701 tcp_ses->lstrp = jiffies;
1704 INIT_LIST_HEAD(&tcp_ses->tcp_ses_list); 1702 INIT_LIST_HEAD(&tcp_ses->tcp_ses_list);
1705 INIT_LIST_HEAD(&tcp_ses->smb_ses_list); 1703 INIT_LIST_HEAD(&tcp_ses->smb_ses_list);
1704 INIT_DELAYED_WORK(&tcp_ses->echo, cifs_echo_request);
1706 1705
1707 /* 1706 /*
1708 * at this point we are the only ones with the pointer 1707 * at this point we are the only ones with the pointer
@@ -1751,11 +1750,16 @@ cifs_get_tcp_session(struct smb_vol *volume_info)
1751 1750
1752 cifs_fscache_get_client_cookie(tcp_ses); 1751 cifs_fscache_get_client_cookie(tcp_ses);
1753 1752
1753 /* queue echo request delayed work */
1754 queue_delayed_work(system_nrt_wq, &tcp_ses->echo, SMB_ECHO_INTERVAL);
1755
1754 return tcp_ses; 1756 return tcp_ses;
1755 1757
1756out_err_crypto_release: 1758out_err_crypto_release:
1757 cifs_crypto_shash_release(tcp_ses); 1759 cifs_crypto_shash_release(tcp_ses);
1758 1760
1761 put_net(cifs_net_ns(tcp_ses));
1762
1759out_err: 1763out_err:
1760 if (tcp_ses) { 1764 if (tcp_ses) {
1761 if (!IS_ERR(tcp_ses->hostname)) 1765 if (!IS_ERR(tcp_ses->hostname))
@@ -2267,8 +2271,8 @@ generic_ip_connect(struct TCP_Server_Info *server)
2267 } 2271 }
2268 2272
2269 if (socket == NULL) { 2273 if (socket == NULL) {
2270 rc = sock_create_kern(sfamily, SOCK_STREAM, 2274 rc = __sock_create(cifs_net_ns(server), sfamily, SOCK_STREAM,
2271 IPPROTO_TCP, &socket); 2275 IPPROTO_TCP, &socket, 1);
2272 if (rc < 0) { 2276 if (rc < 0) {
2273 cERROR(1, "Error %d creating socket", rc); 2277 cERROR(1, "Error %d creating socket", rc);
2274 server->ssocket = NULL; 2278 server->ssocket = NULL;
@@ -2580,6 +2584,8 @@ static void setup_cifs_sb(struct smb_vol *pvolume_info,
2580 if (pvolume_info->multiuser) 2584 if (pvolume_info->multiuser)
2581 cifs_sb->mnt_cifs_flags |= (CIFS_MOUNT_MULTIUSER | 2585 cifs_sb->mnt_cifs_flags |= (CIFS_MOUNT_MULTIUSER |
2582 CIFS_MOUNT_NO_PERM); 2586 CIFS_MOUNT_NO_PERM);
2587 if (pvolume_info->strict_io)
2588 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_STRICT_IO;
2583 if (pvolume_info->direct_io) { 2589 if (pvolume_info->direct_io) {
2584 cFYI(1, "mounting share using direct i/o"); 2590 cFYI(1, "mounting share using direct i/o");
2585 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DIRECT_IO; 2591 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DIRECT_IO;
@@ -2936,8 +2942,8 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
2936 TCONX_RSP *pSMBr; 2942 TCONX_RSP *pSMBr;
2937 unsigned char *bcc_ptr; 2943 unsigned char *bcc_ptr;
2938 int rc = 0; 2944 int rc = 0;
2939 int length, bytes_left; 2945 int length;
2940 __u16 count; 2946 __u16 bytes_left, count;
2941 2947
2942 if (ses == NULL) 2948 if (ses == NULL)
2943 return -EIO; 2949 return -EIO;
@@ -2965,7 +2971,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
2965 bcc_ptr++; /* skip password */ 2971 bcc_ptr++; /* skip password */
2966 /* already aligned so no need to do it below */ 2972 /* already aligned so no need to do it below */
2967 } else { 2973 } else {
2968 pSMB->PasswordLength = cpu_to_le16(CIFS_SESS_KEY_SIZE); 2974 pSMB->PasswordLength = cpu_to_le16(CIFS_AUTH_RESP_SIZE);
2969 /* BB FIXME add code to fail this if NTLMv2 or Kerberos 2975 /* BB FIXME add code to fail this if NTLMv2 or Kerberos
2970 specified as required (when that support is added to 2976 specified as required (when that support is added to
2971 the vfs in the future) as only NTLM or the much 2977 the vfs in the future) as only NTLM or the much
@@ -2981,9 +2987,10 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
2981 bcc_ptr); 2987 bcc_ptr);
2982 else 2988 else
2983#endif /* CIFS_WEAK_PW_HASH */ 2989#endif /* CIFS_WEAK_PW_HASH */
2984 SMBNTencrypt(tcon->password, ses->server->cryptkey, bcc_ptr); 2990 rc = SMBNTencrypt(tcon->password, ses->server->cryptkey,
2991 bcc_ptr);
2985 2992
2986 bcc_ptr += CIFS_SESS_KEY_SIZE; 2993 bcc_ptr += CIFS_AUTH_RESP_SIZE;
2987 if (ses->capabilities & CAP_UNICODE) { 2994 if (ses->capabilities & CAP_UNICODE) {
2988 /* must align unicode strings */ 2995 /* must align unicode strings */
2989 *bcc_ptr = 0; /* null byte password */ 2996 *bcc_ptr = 0; /* null byte password */
@@ -3021,7 +3028,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
3021 pSMB->ByteCount = cpu_to_le16(count); 3028 pSMB->ByteCount = cpu_to_le16(count);
3022 3029
3023 rc = SendReceive(xid, ses, smb_buffer, smb_buffer_response, &length, 3030 rc = SendReceive(xid, ses, smb_buffer, smb_buffer_response, &length,
3024 CIFS_STD_OP); 3031 0);
3025 3032
3026 /* above now done in SendReceive */ 3033 /* above now done in SendReceive */
3027 if ((rc == 0) && (tcon != NULL)) { 3034 if ((rc == 0) && (tcon != NULL)) {
@@ -3031,7 +3038,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
3031 tcon->need_reconnect = false; 3038 tcon->need_reconnect = false;
3032 tcon->tid = smb_buffer_response->Tid; 3039 tcon->tid = smb_buffer_response->Tid;
3033 bcc_ptr = pByteArea(smb_buffer_response); 3040 bcc_ptr = pByteArea(smb_buffer_response);
3034 bytes_left = BCC(smb_buffer_response); 3041 bytes_left = get_bcc(smb_buffer_response);
3035 length = strnlen(bcc_ptr, bytes_left - 2); 3042 length = strnlen(bcc_ptr, bytes_left - 2);
3036 if (smb_buffer->Flags2 & SMBFLG2_UNICODE) 3043 if (smb_buffer->Flags2 & SMBFLG2_UNICODE)
3037 is_unicode = true; 3044 is_unicode = true;