Lines Matching full:server
62 /* Drop the connection to not overload the server */
65 static int ip_connect(struct TCP_Server_Info *server);
66 static int generic_ip_connect(struct TCP_Server_Info *server);
74 * This should be called with server->srv_mutex held.
76 static int reconn_set_ipaddr_from_hostname(struct TCP_Server_Info *server) in reconn_set_ipaddr_from_hostname() argument
83 if (!server->hostname) in reconn_set_ipaddr_from_hostname()
86 /* if server hostname isn't populated, there's nothing to do here */ in reconn_set_ipaddr_from_hostname()
87 if (server->hostname[0] == '\0') in reconn_set_ipaddr_from_hostname()
90 len = strlen(server->hostname) + 3; in reconn_set_ipaddr_from_hostname()
97 scnprintf(unc, len, "\\\\%s", server->hostname); in reconn_set_ipaddr_from_hostname()
99 spin_lock(&server->srv_lock); in reconn_set_ipaddr_from_hostname()
100 ss = server->dstaddr; in reconn_set_ipaddr_from_hostname()
101 spin_unlock(&server->srv_lock); in reconn_set_ipaddr_from_hostname()
107 cifs_dbg(FYI, "%s: failed to resolve server part of %s to IP: %d\n", in reconn_set_ipaddr_from_hostname()
108 __func__, server->hostname, rc); in reconn_set_ipaddr_from_hostname()
110 spin_lock(&server->srv_lock); in reconn_set_ipaddr_from_hostname()
111 memcpy(&server->dstaddr, &ss, sizeof(server->dstaddr)); in reconn_set_ipaddr_from_hostname()
112 spin_unlock(&server->srv_lock); in reconn_set_ipaddr_from_hostname()
127 * query server network interfaces, in case they change in smb2_query_server_interfaces()
131 cifs_dbg(FYI, "%s: failed to query server interfaces: %d\n", in smb2_query_server_interfaces()
140 * Update the tcpStatus for the server.
145 * @server: the tcp ses for which reconnect is needed
149 cifs_signal_cifsd_for_reconnect(struct TCP_Server_Info *server, in cifs_signal_cifsd_for_reconnect() argument
156 /* If server is a channel, select the primary channel */ in cifs_signal_cifsd_for_reconnect()
157 pserver = SERVER_IS_CHAN(server) ? server->primary_server : server; in cifs_signal_cifsd_for_reconnect()
171 spin_lock(&ses->chans[i].server->srv_lock); in cifs_signal_cifsd_for_reconnect()
172 ses->chans[i].server->tcpStatus = CifsNeedReconnect; in cifs_signal_cifsd_for_reconnect()
173 spin_unlock(&ses->chans[i].server->srv_lock); in cifs_signal_cifsd_for_reconnect()
186 * @server: the tcp ses for which reconnect is needed
187 * @server needs to be previously set to CifsNeedReconnect.
191 cifs_mark_tcp_ses_conns_for_reconnect(struct TCP_Server_Info *server, in cifs_mark_tcp_ses_conns_for_reconnect() argument
204 /* If server is a channel, select the primary channel */ in cifs_mark_tcp_ses_conns_for_reconnect()
205 pserver = SERVER_IS_CHAN(server) ? server->primary_server : server; in cifs_mark_tcp_ses_conns_for_reconnect()
211 if (!cifs_chan_is_iface_active(ses, server)) in cifs_mark_tcp_ses_conns_for_reconnect()
212 cifs_chan_update_iface(ses, server); in cifs_mark_tcp_ses_conns_for_reconnect()
215 if (!mark_smb_session && cifs_chan_needs_reconnect(ses, server)) { in cifs_mark_tcp_ses_conns_for_reconnect()
223 cifs_chan_set_need_reconnect(ses, server); in cifs_mark_tcp_ses_conns_for_reconnect()
256 cifs_abort_connection(struct TCP_Server_Info *server) in cifs_abort_connection() argument
261 server->maxBuf = 0; in cifs_abort_connection()
262 server->max_read = 0; in cifs_abort_connection()
266 cifs_server_lock(server); in cifs_abort_connection()
267 if (server->ssocket) { in cifs_abort_connection()
268 cifs_dbg(FYI, "State: 0x%x Flags: 0x%lx\n", server->ssocket->state, in cifs_abort_connection()
269 server->ssocket->flags); in cifs_abort_connection()
270 kernel_sock_shutdown(server->ssocket, SHUT_WR); in cifs_abort_connection()
271 cifs_dbg(FYI, "Post shutdown state: 0x%x Flags: 0x%lx\n", server->ssocket->state, in cifs_abort_connection()
272 server->ssocket->flags); in cifs_abort_connection()
273 sock_release(server->ssocket); in cifs_abort_connection()
274 server->ssocket = NULL; in cifs_abort_connection()
276 server->sequence_number = 0; in cifs_abort_connection()
277 server->session_estab = false; in cifs_abort_connection()
278 kfree_sensitive(server->session_key.response); in cifs_abort_connection()
279 server->session_key.response = NULL; in cifs_abort_connection()
280 server->session_key.len = 0; in cifs_abort_connection()
281 server->lstrp = jiffies; in cifs_abort_connection()
286 spin_lock(&server->mid_lock); in cifs_abort_connection()
287 list_for_each_entry_safe(mid, nmid, &server->pending_mid_q, qhead) { in cifs_abort_connection()
294 spin_unlock(&server->mid_lock); in cifs_abort_connection()
295 cifs_server_unlock(server); in cifs_abort_connection()
304 if (cifs_rdma_enabled(server)) { in cifs_abort_connection()
305 cifs_server_lock(server); in cifs_abort_connection()
306 smbd_destroy(server); in cifs_abort_connection()
307 cifs_server_unlock(server); in cifs_abort_connection()
311 static bool cifs_tcp_ses_needs_reconnect(struct TCP_Server_Info *server, int num_targets) in cifs_tcp_ses_needs_reconnect() argument
313 spin_lock(&server->srv_lock); in cifs_tcp_ses_needs_reconnect()
314 server->nr_targets = num_targets; in cifs_tcp_ses_needs_reconnect()
315 if (server->tcpStatus == CifsExiting) { in cifs_tcp_ses_needs_reconnect()
317 spin_unlock(&server->srv_lock); in cifs_tcp_ses_needs_reconnect()
318 wake_up(&server->response_q); in cifs_tcp_ses_needs_reconnect()
323 trace_smb3_reconnect(server->CurrentMid, server->conn_id, in cifs_tcp_ses_needs_reconnect()
324 server->hostname); in cifs_tcp_ses_needs_reconnect()
325 server->tcpStatus = CifsNeedReconnect; in cifs_tcp_ses_needs_reconnect()
327 spin_unlock(&server->srv_lock); in cifs_tcp_ses_needs_reconnect()
344 static int __cifs_reconnect(struct TCP_Server_Info *server, in __cifs_reconnect() argument
349 if (!cifs_tcp_ses_needs_reconnect(server, 1)) in __cifs_reconnect()
352 cifs_mark_tcp_ses_conns_for_reconnect(server, mark_smb_session); in __cifs_reconnect()
354 cifs_abort_connection(server); in __cifs_reconnect()
358 cifs_server_lock(server); in __cifs_reconnect()
360 if (!cifs_swn_set_server_dstaddr(server)) { in __cifs_reconnect()
362 rc = reconn_set_ipaddr_from_hostname(server); in __cifs_reconnect()
366 if (cifs_rdma_enabled(server)) in __cifs_reconnect()
367 rc = smbd_reconnect(server); in __cifs_reconnect()
369 rc = generic_ip_connect(server); in __cifs_reconnect()
371 cifs_server_unlock(server); in __cifs_reconnect()
376 set_credits(server, 1); in __cifs_reconnect()
377 spin_lock(&server->srv_lock); in __cifs_reconnect()
378 if (server->tcpStatus != CifsExiting) in __cifs_reconnect()
379 server->tcpStatus = CifsNeedNegotiate; in __cifs_reconnect()
380 spin_unlock(&server->srv_lock); in __cifs_reconnect()
381 cifs_swn_reset_server_dstaddr(server); in __cifs_reconnect()
382 cifs_server_unlock(server); in __cifs_reconnect()
383 mod_delayed_work(cifsiod_wq, &server->reconnect, 0); in __cifs_reconnect()
385 } while (server->tcpStatus == CifsNeedReconnect); in __cifs_reconnect()
387 spin_lock(&server->srv_lock); in __cifs_reconnect()
388 if (server->tcpStatus == CifsNeedNegotiate) in __cifs_reconnect()
389 mod_delayed_work(cifsiod_wq, &server->echo, 0); in __cifs_reconnect()
390 spin_unlock(&server->srv_lock); in __cifs_reconnect()
392 wake_up(&server->response_q); in __cifs_reconnect()
397 static int __reconnect_target_unlocked(struct TCP_Server_Info *server, const char *target) in __reconnect_target_unlocked() argument
402 if (!cifs_swn_set_server_dstaddr(server)) { in __reconnect_target_unlocked()
403 if (server->hostname != target) { in __reconnect_target_unlocked()
406 spin_lock(&server->srv_lock); in __reconnect_target_unlocked()
407 kfree(server->hostname); in __reconnect_target_unlocked()
408 server->hostname = hostname; in __reconnect_target_unlocked()
409 spin_unlock(&server->srv_lock); in __reconnect_target_unlocked()
413 cifs_dbg(FYI, "%s: default to last target server: %s\n", __func__, in __reconnect_target_unlocked()
414 server->hostname); in __reconnect_target_unlocked()
418 rc = reconn_set_ipaddr_from_hostname(server); in __reconnect_target_unlocked()
422 if (cifs_rdma_enabled(server)) in __reconnect_target_unlocked()
423 rc = smbd_reconnect(server); in __reconnect_target_unlocked()
425 rc = generic_ip_connect(server); in __reconnect_target_unlocked()
430 static int reconnect_target_unlocked(struct TCP_Server_Info *server, struct dfs_cache_tgt_list *tl, in reconnect_target_unlocked() argument
438 /* If dfs target list is empty, then reconnect to last server */ in reconnect_target_unlocked()
441 return __reconnect_target_unlocked(server, server->hostname); in reconnect_target_unlocked()
445 rc = __reconnect_target_unlocked(server, dfs_cache_get_tgt_name(tit)); in reconnect_target_unlocked()
454 static int reconnect_dfs_server(struct TCP_Server_Info *server) in reconnect_dfs_server() argument
465 * targets (server->nr_targets). It's also possible that the cached referral was cleared in reconnect_dfs_server()
466 * through /proc/fs/cifs/dfscache or the target list is empty due to server settings after in reconnect_dfs_server()
469 mutex_lock(&server->refpath_lock); in reconnect_dfs_server()
470 if (!dfs_cache_noreq_find(server->leaf_fullpath + 1, NULL, &tl)) in reconnect_dfs_server()
472 mutex_unlock(&server->refpath_lock); in reconnect_dfs_server()
476 if (!cifs_tcp_ses_needs_reconnect(server, num_targets)) in reconnect_dfs_server()
481 * different server or share during failover. It could be improved by adding some logic to in reconnect_dfs_server()
482 * only do that in case it connects to a different server or share, though. in reconnect_dfs_server()
484 cifs_mark_tcp_ses_conns_for_reconnect(server, true); in reconnect_dfs_server()
486 cifs_abort_connection(server); in reconnect_dfs_server()
490 cifs_server_lock(server); in reconnect_dfs_server()
492 rc = reconnect_target_unlocked(server, &tl, &target_hint); in reconnect_dfs_server()
495 cifs_server_unlock(server); in reconnect_dfs_server()
503 * through the reconnected target server. in reconnect_dfs_server()
506 set_credits(server, 1); in reconnect_dfs_server()
507 spin_lock(&server->srv_lock); in reconnect_dfs_server()
508 if (server->tcpStatus != CifsExiting) in reconnect_dfs_server()
509 server->tcpStatus = CifsNeedNegotiate; in reconnect_dfs_server()
510 spin_unlock(&server->srv_lock); in reconnect_dfs_server()
511 cifs_swn_reset_server_dstaddr(server); in reconnect_dfs_server()
512 cifs_server_unlock(server); in reconnect_dfs_server()
513 mod_delayed_work(cifsiod_wq, &server->reconnect, 0); in reconnect_dfs_server()
514 } while (server->tcpStatus == CifsNeedReconnect); in reconnect_dfs_server()
516 mutex_lock(&server->refpath_lock); in reconnect_dfs_server()
517 dfs_cache_noreq_update_tgthint(server->leaf_fullpath + 1, target_hint); in reconnect_dfs_server()
518 mutex_unlock(&server->refpath_lock); in reconnect_dfs_server()
522 spin_lock(&server->srv_lock); in reconnect_dfs_server()
523 if (server->tcpStatus == CifsNeedNegotiate) in reconnect_dfs_server()
524 mod_delayed_work(cifsiod_wq, &server->echo, 0); in reconnect_dfs_server()
525 spin_unlock(&server->srv_lock); in reconnect_dfs_server()
527 wake_up(&server->response_q); in reconnect_dfs_server()
531 int cifs_reconnect(struct TCP_Server_Info *server, bool mark_smb_session) in cifs_reconnect() argument
533 mutex_lock(&server->refpath_lock); in cifs_reconnect()
534 if (!server->leaf_fullpath) { in cifs_reconnect()
535 mutex_unlock(&server->refpath_lock); in cifs_reconnect()
536 return __cifs_reconnect(server, mark_smb_session); in cifs_reconnect()
538 mutex_unlock(&server->refpath_lock); in cifs_reconnect()
540 return reconnect_dfs_server(server); in cifs_reconnect()
543 int cifs_reconnect(struct TCP_Server_Info *server, bool mark_smb_session) in cifs_reconnect() argument
545 return __cifs_reconnect(server, mark_smb_session); in cifs_reconnect()
553 struct TCP_Server_Info *server = container_of(work, in cifs_echo_request() local
561 if (server->tcpStatus == CifsNeedReconnect || in cifs_echo_request()
562 server->tcpStatus == CifsExiting || in cifs_echo_request()
563 server->tcpStatus == CifsNew || in cifs_echo_request()
564 (server->ops->can_echo && !server->ops->can_echo(server)) || in cifs_echo_request()
565 time_before(jiffies, server->lstrp + server->echo_interval - HZ)) in cifs_echo_request()
568 rc = server->ops->echo ? server->ops->echo(server) : -ENOSYS; in cifs_echo_request()
575 queue_delayed_work(cifsiod_wq, &server->echo, server->echo_interval); in cifs_echo_request()
579 allocate_buffers(struct TCP_Server_Info *server) in allocate_buffers() argument
581 if (!server->bigbuf) { in allocate_buffers()
582 server->bigbuf = (char *)cifs_buf_get(); in allocate_buffers()
583 if (!server->bigbuf) { in allocate_buffers()
589 } else if (server->large_buf) { in allocate_buffers()
591 memset(server->bigbuf, 0, HEADER_SIZE(server)); in allocate_buffers()
594 if (!server->smallbuf) { in allocate_buffers()
595 server->smallbuf = (char *)cifs_small_buf_get(); in allocate_buffers()
596 if (!server->smallbuf) { in allocate_buffers()
605 memset(server->smallbuf, 0, HEADER_SIZE(server)); in allocate_buffers()
612 server_unresponsive(struct TCP_Server_Info *server) in server_unresponsive() argument
625 spin_lock(&server->srv_lock); in server_unresponsive()
626 if ((server->tcpStatus == CifsGood || in server_unresponsive()
627 server->tcpStatus == CifsNeedNegotiate) && in server_unresponsive()
628 (!server->ops->can_echo || server->ops->can_echo(server)) && in server_unresponsive()
629 time_after(jiffies, server->lstrp + 3 * server->echo_interval)) { in server_unresponsive()
630 spin_unlock(&server->srv_lock); in server_unresponsive()
632 (3 * server->echo_interval) / HZ); in server_unresponsive()
633 cifs_reconnect(server, false); in server_unresponsive()
636 spin_unlock(&server->srv_lock); in server_unresponsive()
642 zero_credits(struct TCP_Server_Info *server) in zero_credits() argument
646 spin_lock(&server->req_lock); in zero_credits()
647 val = server->credits + server->echo_credits + server->oplock_credits; in zero_credits()
648 if (server->in_flight == 0 && val == 0) { in zero_credits()
649 spin_unlock(&server->req_lock); in zero_credits()
652 spin_unlock(&server->req_lock); in zero_credits()
657 cifs_readv_from_socket(struct TCP_Server_Info *server, struct msghdr *smb_msg) in cifs_readv_from_socket() argument
666 if (zero_credits(server)) { in cifs_readv_from_socket()
667 cifs_reconnect(server, false); in cifs_readv_from_socket()
671 if (server_unresponsive(server)) in cifs_readv_from_socket()
673 if (cifs_rdma_enabled(server) && server->smbd_conn) in cifs_readv_from_socket()
674 length = smbd_recv(server->smbd_conn, smb_msg); in cifs_readv_from_socket()
676 length = sock_recvmsg(server->ssocket, smb_msg, 0); in cifs_readv_from_socket()
678 spin_lock(&server->srv_lock); in cifs_readv_from_socket()
679 if (server->tcpStatus == CifsExiting) { in cifs_readv_from_socket()
680 spin_unlock(&server->srv_lock); in cifs_readv_from_socket()
684 if (server->tcpStatus == CifsNeedReconnect) { in cifs_readv_from_socket()
685 spin_unlock(&server->srv_lock); in cifs_readv_from_socket()
686 cifs_reconnect(server, false); in cifs_readv_from_socket()
689 spin_unlock(&server->srv_lock); in cifs_readv_from_socket()
697 * CifsNeedReconnect if server hung. in cifs_readv_from_socket()
706 cifs_reconnect(server, false); in cifs_readv_from_socket()
714 cifs_read_from_socket(struct TCP_Server_Info *server, char *buf, in cifs_read_from_socket() argument
721 return cifs_readv_from_socket(server, &smb_msg); in cifs_read_from_socket()
725 cifs_discard_from_socket(struct TCP_Server_Info *server, size_t to_read) in cifs_discard_from_socket() argument
736 return cifs_readv_from_socket(server, &smb_msg); in cifs_discard_from_socket()
740 cifs_read_page_from_socket(struct TCP_Server_Info *server, struct page *page, in cifs_read_page_from_socket() argument
748 return cifs_readv_from_socket(server, &smb_msg); in cifs_read_page_from_socket()
752 cifs_read_iter_from_socket(struct TCP_Server_Info *server, struct iov_iter *iter, in cifs_read_iter_from_socket() argument
759 ret = cifs_readv_from_socket(server, &smb_msg); in cifs_read_iter_from_socket()
766 is_smb_response(struct TCP_Server_Info *server, unsigned char type) in is_smb_response() argument
789 /* give server a second to clean up */ in is_smb_response()
797 cifs_set_port((struct sockaddr *)&server->dstaddr, CIFS_PORT); in is_smb_response()
798 cifs_reconnect(server, true); in is_smb_response()
802 cifs_reconnect(server, true); in is_smb_response()
814 spin_lock(&mid->server->mid_lock); in dequeue_mid()
824 spin_unlock(&mid->server->mid_lock); in dequeue_mid()
829 spin_unlock(&mid->server->mid_lock); in dequeue_mid()
834 smb2_get_credits_from_hdr(char *buffer, struct TCP_Server_Info *server) in smb2_get_credits_from_hdr() argument
841 if (is_smb1(server)) in smb2_get_credits_from_hdr()
848 handle_mid(struct mid_q_entry *mid, struct TCP_Server_Info *server, in handle_mid() argument
851 if (server->ops->check_trans2 && in handle_mid()
852 server->ops->check_trans2(mid, server, buf, malformed)) in handle_mid()
854 mid->credits_received = smb2_get_credits_from_hdr(buf, server); in handle_mid()
856 mid->large_buf = server->large_buf; in handle_mid()
860 if (server->large_buf) in handle_mid()
861 server->bigbuf = NULL; in handle_mid()
863 server->smallbuf = NULL; in handle_mid()
869 cifs_enable_signing(struct TCP_Server_Info *server, bool mnt_sign_required) in cifs_enable_signing() argument
871 bool srv_sign_required = server->sec_mode & server->vals->signing_required; in cifs_enable_signing()
872 bool srv_sign_enabled = server->sec_mode & server->vals->signing_enabled; in cifs_enable_signing()
890 /* If server requires signing, does client allow it? */ in cifs_enable_signing()
893 cifs_dbg(VFS, "Server requires signing, but it's disabled in SecurityFlags!\n"); in cifs_enable_signing()
896 server->sign = true; in cifs_enable_signing()
899 /* If client requires signing, does server allow it? */ in cifs_enable_signing()
902 cifs_dbg(VFS, "Server does not support signing!\n"); in cifs_enable_signing()
905 server->sign = true; in cifs_enable_signing()
908 if (cifs_rdma_enabled(server) && server->sign) in cifs_enable_signing()
915 clean_demultiplex_info(struct TCP_Server_Info *server) in clean_demultiplex_info() argument
920 spin_lock(&server->srv_lock); in clean_demultiplex_info()
921 list_del_init(&server->tcp_ses_list); in clean_demultiplex_info()
922 spin_unlock(&server->srv_lock); in clean_demultiplex_info()
924 cancel_delayed_work_sync(&server->echo); in clean_demultiplex_info()
926 spin_lock(&server->srv_lock); in clean_demultiplex_info()
927 server->tcpStatus = CifsExiting; in clean_demultiplex_info()
928 spin_unlock(&server->srv_lock); in clean_demultiplex_info()
929 wake_up_all(&server->response_q); in clean_demultiplex_info()
932 spin_lock(&server->req_lock); in clean_demultiplex_info()
933 if (server->credits <= 0) in clean_demultiplex_info()
934 server->credits = 1; in clean_demultiplex_info()
935 spin_unlock(&server->req_lock); in clean_demultiplex_info()
940 * same server - they now will see the session is in exit state and get in clean_demultiplex_info()
943 wake_up_all(&server->request_q); in clean_demultiplex_info()
946 if (cifs_rdma_enabled(server)) in clean_demultiplex_info()
947 smbd_destroy(server); in clean_demultiplex_info()
948 if (server->ssocket) { in clean_demultiplex_info()
949 sock_release(server->ssocket); in clean_demultiplex_info()
950 server->ssocket = NULL; in clean_demultiplex_info()
953 if (!list_empty(&server->pending_mid_q)) { in clean_demultiplex_info()
959 spin_lock(&server->mid_lock); in clean_demultiplex_info()
960 list_for_each_safe(tmp, tmp2, &server->pending_mid_q) { in clean_demultiplex_info()
968 spin_unlock(&server->mid_lock); in clean_demultiplex_info()
982 if (!list_empty(&server->pending_mid_q)) { in clean_demultiplex_info()
999 kfree(server->leaf_fullpath); in clean_demultiplex_info()
1000 kfree(server); in clean_demultiplex_info()
1008 standard_receive3(struct TCP_Server_Info *server, struct mid_q_entry *mid) in standard_receive3() argument
1011 char *buf = server->smallbuf; in standard_receive3()
1012 unsigned int pdu_length = server->pdu_size; in standard_receive3()
1015 if (pdu_length > CIFSMaxBufSize + MAX_HEADER_SIZE(server) - in standard_receive3()
1016 HEADER_PREAMBLE_SIZE(server)) { in standard_receive3()
1018 cifs_reconnect(server, true); in standard_receive3()
1024 server->large_buf = true; in standard_receive3()
1025 memcpy(server->bigbuf, buf, server->total_read); in standard_receive3()
1026 buf = server->bigbuf; in standard_receive3()
1030 length = cifs_read_from_socket(server, buf + HEADER_SIZE(server) - 1, in standard_receive3()
1031 pdu_length - MID_HEADER_SIZE(server)); in standard_receive3()
1035 server->total_read += length; in standard_receive3()
1037 dump_smb(buf, server->total_read); in standard_receive3()
1039 return cifs_handle_standard(server, mid); in standard_receive3()
1043 cifs_handle_standard(struct TCP_Server_Info *server, struct mid_q_entry *mid) in cifs_handle_standard() argument
1045 char *buf = server->large_buf ? server->bigbuf : server->smallbuf; in cifs_handle_standard()
1056 rc = server->ops->check_message(buf, server->total_read, server); in cifs_handle_standard()
1059 min_t(unsigned int, server->total_read, 48)); in cifs_handle_standard()
1061 if (server->ops->is_session_expired && in cifs_handle_standard()
1062 server->ops->is_session_expired(buf)) { in cifs_handle_standard()
1063 cifs_reconnect(server, true); in cifs_handle_standard()
1067 if (server->ops->is_status_pending && in cifs_handle_standard()
1068 server->ops->is_status_pending(buf, server)) in cifs_handle_standard()
1074 handle_mid(mid, server, buf, rc); in cifs_handle_standard()
1079 smb2_add_credits_from_hdr(char *buffer, struct TCP_Server_Info *server) in smb2_add_credits_from_hdr() argument
1087 if (is_smb1(server)) in smb2_add_credits_from_hdr()
1091 spin_lock(&server->req_lock); in smb2_add_credits_from_hdr()
1092 server->credits += le16_to_cpu(shdr->CreditRequest); in smb2_add_credits_from_hdr()
1093 scredits = server->credits; in smb2_add_credits_from_hdr()
1094 in_flight = server->in_flight; in smb2_add_credits_from_hdr()
1095 spin_unlock(&server->req_lock); in smb2_add_credits_from_hdr()
1096 wake_up(&server->request_q); in smb2_add_credits_from_hdr()
1098 trace_smb3_hdr_credits(server->CurrentMid, in smb2_add_credits_from_hdr()
1099 server->conn_id, server->hostname, scredits, in smb2_add_credits_from_hdr()
1112 struct TCP_Server_Info *server = p; in cifs_demultiplex_thread() local
1131 while (server->tcpStatus != CifsExiting) { in cifs_demultiplex_thread()
1135 if (!allocate_buffers(server)) in cifs_demultiplex_thread()
1138 server->large_buf = false; in cifs_demultiplex_thread()
1139 buf = server->smallbuf; in cifs_demultiplex_thread()
1142 length = cifs_read_from_socket(server, buf, pdu_length); in cifs_demultiplex_thread()
1146 if (is_smb1(server)) in cifs_demultiplex_thread()
1147 server->total_read = length; in cifs_demultiplex_thread()
1149 server->total_read = 0; in cifs_demultiplex_thread()
1158 if (!is_smb_response(server, buf[0])) in cifs_demultiplex_thread()
1163 server->pdu_size = pdu_length; in cifs_demultiplex_thread()
1166 if (server->pdu_size < MID_HEADER_SIZE(server)) { in cifs_demultiplex_thread()
1168 server->pdu_size); in cifs_demultiplex_thread()
1169 cifs_reconnect(server, true); in cifs_demultiplex_thread()
1174 length = cifs_read_from_socket(server, in cifs_demultiplex_thread()
1175 buf + HEADER_PREAMBLE_SIZE(server), in cifs_demultiplex_thread()
1176 MID_HEADER_SIZE(server)); in cifs_demultiplex_thread()
1179 server->total_read += length; in cifs_demultiplex_thread()
1181 if (server->ops->next_header) { in cifs_demultiplex_thread()
1182 next_offset = server->ops->next_header(buf); in cifs_demultiplex_thread()
1184 server->pdu_size = next_offset; in cifs_demultiplex_thread()
1191 if (server->ops->is_transform_hdr && in cifs_demultiplex_thread()
1192 server->ops->receive_transform && in cifs_demultiplex_thread()
1193 server->ops->is_transform_hdr(buf)) { in cifs_demultiplex_thread()
1194 length = server->ops->receive_transform(server, in cifs_demultiplex_thread()
1199 mids[0] = server->ops->find_mid(server, buf); in cifs_demultiplex_thread()
1204 length = standard_receive3(server, mids[0]); in cifs_demultiplex_thread()
1206 length = mids[0]->receive(server, mids[0]); in cifs_demultiplex_thread()
1216 if (server->ops->is_status_io_timeout && in cifs_demultiplex_thread()
1217 server->ops->is_status_io_timeout(buf)) { in cifs_demultiplex_thread()
1229 server->lstrp = jiffies; in cifs_demultiplex_thread()
1233 mids[i]->resp_buf_size = server->pdu_size; in cifs_demultiplex_thread()
1236 if (server->ops->is_network_name_deleted && in cifs_demultiplex_thread()
1237 server->ops->is_network_name_deleted(bufs[i], in cifs_demultiplex_thread()
1238 server)) { in cifs_demultiplex_thread()
1248 } else if (server->ops->is_oplock_break && in cifs_demultiplex_thread()
1249 server->ops->is_oplock_break(bufs[i], in cifs_demultiplex_thread()
1250 server)) { in cifs_demultiplex_thread()
1251 smb2_add_credits_from_hdr(bufs[i], server); in cifs_demultiplex_thread()
1257 HEADER_SIZE(server)); in cifs_demultiplex_thread()
1258 smb2_add_credits_from_hdr(bufs[i], server); in cifs_demultiplex_thread()
1260 if (server->ops->dump_detail) in cifs_demultiplex_thread()
1261 server->ops->dump_detail(bufs[i], in cifs_demultiplex_thread()
1262 server); in cifs_demultiplex_thread()
1263 cifs_dump_mids(server); in cifs_demultiplex_thread()
1268 if (pdu_length > server->pdu_size) { in cifs_demultiplex_thread()
1269 if (!allocate_buffers(server)) in cifs_demultiplex_thread()
1271 pdu_length -= server->pdu_size; in cifs_demultiplex_thread()
1272 server->total_read = 0; in cifs_demultiplex_thread()
1273 server->large_buf = false; in cifs_demultiplex_thread()
1274 buf = server->smallbuf; in cifs_demultiplex_thread()
1280 cifs_reconnect(server, true); in cifs_demultiplex_thread()
1285 cifs_buf_release(server->bigbuf); in cifs_demultiplex_thread()
1286 if (server->smallbuf) /* no sense logging a debug message if NULL */ in cifs_demultiplex_thread()
1287 cifs_small_buf_release(server->smallbuf); in cifs_demultiplex_thread()
1289 task_to_wake = xchg(&server->tsk, NULL); in cifs_demultiplex_thread()
1290 clean_demultiplex_info(server); in cifs_demultiplex_thread()
1292 /* if server->tsk was NULL then wait for a signal before exiting */ in cifs_demultiplex_thread()
1386 * families of server and addr are equal.
1389 match_port(struct TCP_Server_Info *server, struct sockaddr *addr) in match_port() argument
1394 if (server->rdma) in match_port()
1399 sport = &((struct sockaddr_in *) &server->dstaddr)->sin_port; in match_port()
1403 sport = &((struct sockaddr_in6 *) &server->dstaddr)->sin6_port; in match_port()
1422 static bool match_server_address(struct TCP_Server_Info *server, struct sockaddr *addr) in match_server_address() argument
1424 if (!cifs_match_ipaddr(addr, (struct sockaddr *)&server->dstaddr)) in match_server_address()
1431 match_security(struct TCP_Server_Info *server, struct smb3_fs_context *ctx) in match_security() argument
1438 if (server->ops->select_sectype(server, ctx->sectype) in match_security()
1445 * the server->sign had better be too. in match_security()
1447 if (ctx->sign && !server->sign) in match_security()
1454 static int match_server(struct TCP_Server_Info *server, in match_server() argument
1460 lockdep_assert_held(&server->srv_lock); in match_server()
1465 /* this server does not share socket */ in match_server()
1466 if (server->nosharesock) in match_server()
1471 if (server->vals->protocol_id < SMB30_PROT_ID) in match_server()
1475 if (server->vals->protocol_id < SMB21_PROT_ID) in match_server()
1477 } else if ((server->vals != ctx->vals) || (server->ops != ctx->ops)) in match_server()
1480 if (!net_eq(cifs_net_ns(server), current->nsproxy->net_ns)) in match_server()
1484 (struct sockaddr *)&server->srcaddr)) in match_server()
1488 * really match either @server->leaf_fullpath or @server->dstaddr in match_server()
1489 * directly since this @server might belong to a completely different in match_server()
1490 * server -- in case of domain-based DFS referrals or DFS links -- as in match_server()
1493 * Otherwise, match the DFS referral in @server->leaf_fullpath or the in match_server()
1494 * destination address in @server->dstaddr. in match_server()
1501 if (server->leaf_fullpath) { in match_server()
1503 strcasecmp(server->leaf_fullpath, in match_server()
1509 } else if (server->leaf_fullpath) { in match_server()
1518 if (!server->leaf_fullpath && in match_server()
1519 (strcasecmp(server->hostname, ctx->server_hostname) || in match_server()
1520 !match_server_address(server, addr) || in match_server()
1521 !match_port(server, addr))) in match_server()
1524 if (!match_security(server, ctx)) in match_server()
1527 if (server->echo_interval != ctx->echo_interval * HZ) in match_server()
1530 if (server->rdma != ctx->rdma) in match_server()
1533 if (server->ignore_signature != ctx->ignore_signature) in match_server()
1536 if (server->min_offload != ctx->min_offload) in match_server()
1545 struct TCP_Server_Info *server; in cifs_find_tcp_session() local
1548 list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) { in cifs_find_tcp_session()
1549 spin_lock(&server->srv_lock); in cifs_find_tcp_session()
1554 if (SERVER_IS_CHAN(server) || in cifs_find_tcp_session()
1555 !match_server(server, ctx, false)) { in cifs_find_tcp_session()
1556 spin_unlock(&server->srv_lock); in cifs_find_tcp_session()
1559 spin_unlock(&server->srv_lock); in cifs_find_tcp_session()
1561 ++server->srv_count; in cifs_find_tcp_session()
1563 cifs_dbg(FYI, "Existing tcp session with server found\n"); in cifs_find_tcp_session()
1564 return server; in cifs_find_tcp_session()
1571 cifs_put_tcp_session(struct TCP_Server_Info *server, int from_reconnect) in cifs_put_tcp_session() argument
1576 if (--server->srv_count > 0) { in cifs_put_tcp_session()
1582 WARN_ON(server->srv_count < 0); in cifs_put_tcp_session()
1584 put_net(cifs_net_ns(server)); in cifs_put_tcp_session()
1586 list_del_init(&server->tcp_ses_list); in cifs_put_tcp_session()
1589 /* For secondary channels, we pick up ref-count on the primary server */ in cifs_put_tcp_session()
1590 if (SERVER_IS_CHAN(server)) in cifs_put_tcp_session()
1591 cifs_put_tcp_session(server->primary_server, from_reconnect); in cifs_put_tcp_session()
1593 cancel_delayed_work_sync(&server->echo); in cifs_put_tcp_session()
1599 * that reconnect work does nothing with server pointer after in cifs_put_tcp_session()
1602 cancel_delayed_work(&server->reconnect); in cifs_put_tcp_session()
1604 cancel_delayed_work_sync(&server->reconnect); in cifs_put_tcp_session()
1606 spin_lock(&server->srv_lock); in cifs_put_tcp_session()
1607 server->tcpStatus = CifsExiting; in cifs_put_tcp_session()
1608 spin_unlock(&server->srv_lock); in cifs_put_tcp_session()
1610 cifs_crypto_secmech_release(server); in cifs_put_tcp_session()
1612 kfree_sensitive(server->session_key.response); in cifs_put_tcp_session()
1613 server->session_key.response = NULL; in cifs_put_tcp_session()
1614 server->session_key.len = 0; in cifs_put_tcp_session()
1615 kfree(server->hostname); in cifs_put_tcp_session()
1616 server->hostname = NULL; in cifs_put_tcp_session()
1618 task = xchg(&server->tsk, NULL); in cifs_put_tcp_session()
1869 struct TCP_Server_Info *server = ses->server; in cifs_setup_ipc() local
1876 if (server->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION) in cifs_setup_ipc()
1880 "IPC: server doesn't support encryption\n"); in cifs_setup_ipc()
1890 spin_lock(&server->srv_lock); in cifs_setup_ipc()
1891 scnprintf(unc, sizeof(unc), "\\\\%s\\IPC$", server->hostname); in cifs_setup_ipc()
1892 spin_unlock(&server->srv_lock); in cifs_setup_ipc()
1898 rc = server->ops->tree_connect(xid, ses, unc, tcon, ctx->local_nls); in cifs_setup_ipc()
1923 * On session close, the IPC is closed and the server must release all tcons of the session.
1926 * Besides, it will make the server to not close durable and resilient files on session close, as
1943 cifs_find_smb_ses(struct TCP_Server_Info *server, struct smb3_fs_context *ctx) in cifs_find_smb_ses() argument
1948 list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) { in cifs_find_smb_ses()
1974 struct TCP_Server_Info *server = ses->server; in __cifs_put_smb_ses() local
2002 if (ses->ses_status == SES_EXITING && server->ops->logoff) { in __cifs_put_smb_ses()
2006 rc = server->ops->logoff(xid, ses); in __cifs_put_smb_ses()
2031 cifs_put_tcp_session(ses->chans[i].server, 0); in __cifs_put_smb_ses()
2032 ses->chans[i].server = NULL; in __cifs_put_smb_ses()
2037 cifs_put_tcp_session(server, 0); in __cifs_put_smb_ses()
2055 struct TCP_Server_Info *server = ses->server; in cifs_set_cifscreds() local
2065 switch (server->dstaddr.ss_family) { in cifs_set_cifscreds()
2067 sa = (struct sockaddr_in *)&server->dstaddr; in cifs_set_cifscreds()
2071 sa6 = (struct sockaddr_in6 *)&server->dstaddr; in cifs_set_cifscreds()
2076 server->dstaddr.ss_family); in cifs_set_cifscreds()
2194 * cifs_get_smb_ses - get a session matching @ctx data from @server
2195 * @server: server to setup the session to
2199 * already got a server reference (server refcount +1). See
2203 cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb3_fs_context *ctx) in cifs_get_smb_ses() argument
2208 struct sockaddr_in *addr = (struct sockaddr_in *)&server->dstaddr; in cifs_get_smb_ses()
2209 struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)&server->dstaddr; in cifs_get_smb_ses()
2213 ses = cifs_find_smb_ses(server, ctx); in cifs_get_smb_ses()
2219 if (cifs_chan_needs_reconnect(ses, server)) { in cifs_get_smb_ses()
2224 rc = cifs_negotiate_protocol(xid, ses, server); in cifs_get_smb_ses()
2233 rc = cifs_setup_session(xid, ses, server, in cifs_get_smb_ses()
2248 /* existing SMB ses has a server reference already */ in cifs_get_smb_ses()
2249 cifs_put_tcp_session(server, 0); in cifs_get_smb_ses()
2261 /* new SMB session uses our server ref */ in cifs_get_smb_ses()
2262 ses->server = server; in cifs_get_smb_ses()
2263 if (server->dstaddr.ss_family == AF_INET6) in cifs_get_smb_ses()
2297 /* add server as first channel */ in cifs_get_smb_ses()
2299 ses->chans[0].server = server; in cifs_get_smb_ses()
2306 rc = cifs_negotiate_protocol(xid, ses, server); in cifs_get_smb_ses()
2308 rc = cifs_setup_session(xid, ses, server, ctx->local_nls); in cifs_get_smb_ses()
2329 list_add(&ses->smb_ses_list, &server->smb_ses_list); in cifs_get_smb_ses()
2347 struct TCP_Server_Info *server = tcon->ses->server; in match_tcon() local
2357 } else if (!server->leaf_fullpath && in match_tcon()
2443 if (ses->server->ops->tree_disconnect) in cifs_put_tcon()
2444 ses->server->ops->tree_disconnect(xid, tcon); in cifs_put_tcon()
2492 if (!ses->server->ops->tree_connect) { in cifs_get_tcon()
2497 if (ses->server->dialect >= SMB20_PROT_ID && in cifs_get_tcon()
2498 (ses->server->capabilities & SMB2_GLOBAL_CAP_DIRECTORY_LEASING)) in cifs_get_tcon()
2510 if (ses->server->vals->protocol_id == 0) { in cifs_get_tcon()
2520 if (ses->server->vals->protocol_id == 0) { in cifs_get_tcon()
2539 if (ses->server->vals->protocol_id == 0) { in cifs_get_tcon()
2544 } else if (tcon->ses->server->capabilities & in cifs_get_tcon()
2555 if (ses->server->posix_ext_supported) { in cifs_get_tcon()
2558 } else if ((ses->server->vals->protocol_id == SMB311_PROT_ID) || in cifs_get_tcon()
2559 (strcmp(ses->server->vals->version_string, in cifs_get_tcon()
2561 (strcmp(ses->server->vals->version_string, in cifs_get_tcon()
2563 cifs_dbg(VFS, "Server does not support mounting with posix SMB3.11 extensions\n"); in cifs_get_tcon()
2575 rc = ses->server->ops->tree_connect(xid, ses, ctx->UNC, tcon, in cifs_get_tcon()
2585 if (ses->server->vals->protocol_id == 0) { in cifs_get_tcon()
2590 } else if (ses->server->capabilities & in cifs_get_tcon()
2600 && (ses->server->capabilities & SMB2_GLOBAL_CAP_PERSISTENT_HANDLES) in cifs_get_tcon()
2605 if (ses->server->vals->protocol_id == 0) { in cifs_get_tcon()
2616 if (ses->server->vals->protocol_id >= SMB30_PROT_ID) { in cifs_get_tcon()
2651 if (ses->server->vals->protocol_id == 0) { in cifs_get_tcon()
2662 * resources mounted more than once to the same server share the last in cifs_get_tcon()
2676 if (ses->server->dialect >= SMB30_PROT_ID && in cifs_get_tcon()
2677 (ses->server->capabilities & SMB2_GLOBAL_CAP_MULTI_CHANNEL)) { in cifs_get_tcon()
2816 tcp_srv = ses->server; in cifs_match_super()
2892 bind_socket(struct TCP_Server_Info *server) in bind_socket() argument
2895 if (server->srcaddr.ss_family != AF_UNSPEC) { in bind_socket()
2897 struct socket *socket = server->ssocket; in bind_socket()
2899 (struct sockaddr *) &server->srcaddr, in bind_socket()
2900 sizeof(server->srcaddr)); in bind_socket()
2904 saddr4 = (struct sockaddr_in *)&server->srcaddr; in bind_socket()
2905 saddr6 = (struct sockaddr_in6 *)&server->srcaddr; in bind_socket()
2918 ip_rfc1001_connect(struct TCP_Server_Info *server) in ip_rfc1001_connect() argument
2932 if (server->server_RFC1001_name[0] != 0) in ip_rfc1001_connect()
2934 server->server_RFC1001_name, in ip_rfc1001_connect()
2944 if (server->workstation_RFC1001_name[0] != 0) in ip_rfc1001_connect()
2946 server->workstation_RFC1001_name, in ip_rfc1001_connect()
2960 rc = smb_send(server, smb_buf, len); in ip_rfc1001_connect()
2962 * RFC1001 layer in at least one server requires very short break before in ip_rfc1001_connect()
2973 generic_ip_connect(struct TCP_Server_Info *server) in generic_ip_connect() argument
2981 saddr = (struct sockaddr *) &server->dstaddr; in generic_ip_connect()
2983 if (server->dstaddr.ss_family == AF_INET6) { in generic_ip_connect()
2984 struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)&server->dstaddr; in generic_ip_connect()
2992 struct sockaddr_in *ipv4 = (struct sockaddr_in *)&server->dstaddr; in generic_ip_connect()
3001 if (server->ssocket) { in generic_ip_connect()
3002 socket = server->ssocket; in generic_ip_connect()
3004 rc = __sock_create(cifs_net_ns(server), sfamily, SOCK_STREAM, in generic_ip_connect()
3005 IPPROTO_TCP, &server->ssocket, 1); in generic_ip_connect()
3013 socket = server->ssocket; in generic_ip_connect()
3022 rc = bind_socket(server); in generic_ip_connect()
3035 if (server->noautotune) { in generic_ip_connect()
3042 if (server->tcp_nodelay) in generic_ip_connect()
3050 server->noblockcnt ? O_NONBLOCK : 0); in generic_ip_connect()
3056 if (server->noblockcnt && rc == -EINPROGRESS) in generic_ip_connect()
3059 cifs_dbg(FYI, "Error %d connecting to server\n", rc); in generic_ip_connect()
3060 trace_smb3_connect_err(server->hostname, server->conn_id, &server->dstaddr, rc); in generic_ip_connect()
3062 server->ssocket = NULL; in generic_ip_connect()
3065 trace_smb3_connect_done(server->hostname, server->conn_id, &server->dstaddr); in generic_ip_connect()
3067 rc = ip_rfc1001_connect(server); in generic_ip_connect()
3073 ip_connect(struct TCP_Server_Info *server) in ip_connect() argument
3076 struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)&server->dstaddr; in ip_connect()
3077 struct sockaddr_in *addr = (struct sockaddr_in *)&server->dstaddr; in ip_connect()
3079 if (server->dstaddr.ss_family == AF_INET6) in ip_connect()
3090 rc = generic_ip_connect(server); in ip_connect()
3098 return generic_ip_connect(server); in ip_connect()
3113 * What if we wanted to mount the server share twice once with in reset_cifs_unix_caps()
3133 cifs_dbg(FYI, "unix caps which server supports %lld\n", cap); in reset_cifs_unix_caps()
3151 cifs_dbg(VFS, "server disabled POSIX path support\n"); in reset_cifs_unix_caps()
3202 …cifs_dbg(VFS, "Negotiating Unix capabilities with the server failed. Consider mounting with the Un… in reset_cifs_unix_caps()
3270 else if (mnt_ctx->server) in cifs_mount_put_conns()
3271 cifs_put_tcp_session(mnt_ctx->server, 0); in cifs_mount_put_conns()
3278 struct TCP_Server_Info *server = NULL; in cifs_mount_get_session() local
3293 server = cifs_get_tcp_session(ctx, NULL); in cifs_mount_get_session()
3294 if (IS_ERR(server)) { in cifs_mount_get_session()
3295 rc = PTR_ERR(server); in cifs_mount_get_session()
3296 server = NULL; in cifs_mount_get_session()
3301 ses = cifs_get_smb_ses(server, ctx); in cifs_mount_get_session()
3308 if ((ctx->persistent == true) && (!(ses->server->capabilities & in cifs_mount_get_session()
3310 cifs_server_dbg(VFS, "persistent handles not supported by server\n"); in cifs_mount_get_session()
3316 mnt_ctx->server = server; in cifs_mount_get_session()
3325 struct TCP_Server_Info *server; in cifs_mount_get_tcon() local
3331 if (WARN_ON_ONCE(!mnt_ctx || !mnt_ctx->server || !mnt_ctx->ses || !mnt_ctx->fs_ctx || in cifs_mount_get_tcon()
3336 server = mnt_ctx->server; in cifs_mount_get_tcon()
3340 /* search for existing tcon to this server share */ in cifs_mount_get_tcon()
3353 /* tell server which Unix caps we support */ in cifs_mount_get_tcon()
3360 spin_lock(&tcon->ses->server->srv_lock); in cifs_mount_get_tcon()
3361 if ((tcon->ses->server->tcpStatus == CifsNeedReconnect) && in cifs_mount_get_tcon()
3364 spin_unlock(&tcon->ses->server->srv_lock); in cifs_mount_get_tcon()
3368 spin_unlock(&tcon->ses->server->srv_lock); in cifs_mount_get_tcon()
3371 tcon->unix_ext = 0; /* server does not support them */ in cifs_mount_get_tcon()
3374 if (!tcon->pipe && server->ops->qfs_tcon) { in cifs_mount_get_tcon()
3375 server->ops->qfs_tcon(mnt_ctx->xid, tcon, cifs_sb); in cifs_mount_get_tcon()
3388 * Clamp the rsize/wsize mount arguments if they are too big for the server in cifs_mount_get_tcon()
3393 (cifs_sb->ctx->wsize > server->ops->negotiate_wsize(tcon, ctx))) in cifs_mount_get_tcon()
3394 cifs_sb->ctx->wsize = server->ops->negotiate_wsize(tcon, ctx); in cifs_mount_get_tcon()
3396 (cifs_sb->ctx->rsize > server->ops->negotiate_rsize(tcon, ctx))) in cifs_mount_get_tcon()
3397 cifs_sb->ctx->rsize = server->ops->negotiate_rsize(tcon, ctx); in cifs_mount_get_tcon()
3439 cifs_are_all_path_components_accessible(struct TCP_Server_Info *server, in cifs_are_all_path_components_accessible() argument
3454 rc = server->ops->is_path_accessible(xid, tcon, cifs_sb, ""); in cifs_are_all_path_components_accessible()
3478 rc = server->ops->is_path_accessible(xid, tcon, cifs_sb, in cifs_are_all_path_components_accessible()
3494 struct TCP_Server_Info *server = mnt_ctx->server; in cifs_is_path_remote() local
3500 if (!server->ops->is_path_accessible) in cifs_is_path_remote()
3513 rc = server->ops->is_path_accessible(xid, tcon, cifs_sb, in cifs_is_path_remote()
3519 rc = cifs_are_all_path_components_accessible(server, xid, tcon, in cifs_is_path_remote()
3549 * After reconnecting to a different server, unique ids won't match anymore, so we disable in cifs_mount()
3638 smb_buffer->Mid = get_next_mid(ses->server); in CIFSTCon()
3652 if (ses->server->sign) in CIFSTCon()
3666 (/* server len*/ + 256 /* share len */), nls_codepage); in CIFSTCon()
3773 struct TCP_Server_Info *server) in cifs_negotiate_protocol() argument
3777 if (!server->ops->need_neg || !server->ops->negotiate) in cifs_negotiate_protocol()
3781 spin_lock(&server->srv_lock); in cifs_negotiate_protocol()
3782 if (server->tcpStatus != CifsGood && in cifs_negotiate_protocol()
3783 server->tcpStatus != CifsNew && in cifs_negotiate_protocol()
3784 server->tcpStatus != CifsNeedNegotiate) { in cifs_negotiate_protocol()
3785 spin_unlock(&server->srv_lock); in cifs_negotiate_protocol()
3789 if (!server->ops->need_neg(server) && in cifs_negotiate_protocol()
3790 server->tcpStatus == CifsGood) { in cifs_negotiate_protocol()
3791 spin_unlock(&server->srv_lock); in cifs_negotiate_protocol()
3795 server->tcpStatus = CifsInNegotiate; in cifs_negotiate_protocol()
3796 spin_unlock(&server->srv_lock); in cifs_negotiate_protocol()
3798 rc = server->ops->negotiate(xid, ses, server); in cifs_negotiate_protocol()
3800 spin_lock(&server->srv_lock); in cifs_negotiate_protocol()
3801 if (server->tcpStatus == CifsInNegotiate) in cifs_negotiate_protocol()
3802 server->tcpStatus = CifsGood; in cifs_negotiate_protocol()
3805 spin_unlock(&server->srv_lock); in cifs_negotiate_protocol()
3807 spin_lock(&server->srv_lock); in cifs_negotiate_protocol()
3808 if (server->tcpStatus == CifsInNegotiate) in cifs_negotiate_protocol()
3809 server->tcpStatus = CifsNeedNegotiate; in cifs_negotiate_protocol()
3810 spin_unlock(&server->srv_lock); in cifs_negotiate_protocol()
3818 struct TCP_Server_Info *server, in cifs_setup_session() argument
3822 struct TCP_Server_Info *pserver = SERVER_IS_CHAN(server) ? server->primary_server : server; in cifs_setup_session()
3848 cifs_chan_set_in_reconnect(ses, server); in cifs_setup_session()
3857 if (server == pserver) { in cifs_setup_session()
3858 if (server->dstaddr.ss_family == AF_INET6) in cifs_setup_session()
3865 ses->capabilities = server->capabilities; in cifs_setup_session()
3867 ses->capabilities &= (~server->vals->cap_unix); in cifs_setup_session()
3879 server->sec_mode, server->capabilities, server->timeAdj); in cifs_setup_session()
3881 if (server->ops->sess_setup) in cifs_setup_session()
3882 rc = server->ops->sess_setup(xid, ses, server, nls_info); in cifs_setup_session()
3890 cifs_chan_clear_in_reconnect(ses, server); in cifs_setup_session()
3898 cifs_chan_clear_in_reconnect(ses, server); in cifs_setup_session()
3899 cifs_chan_clear_need_reconnect(ses, server); in cifs_setup_session()
3959 ++master_tcon->ses->server->srv_count; in cifs_construct_tcon()
3962 ses = cifs_get_smb_ses(master_tcon->ses->server, ctx); in cifs_construct_tcon()
3965 cifs_put_tcp_session(master_tcon->ses->server, 0); in cifs_construct_tcon()
4175 const struct smb_version_operations *ops = tcon->ses->server->ops; in cifs_tree_connect()