diff options
author | Ronnie Sahlberg <lsahlber@redhat.com> | 2019-08-28 03:15:35 -0400 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2019-09-16 12:43:37 -0400 |
commit | afe6f65353b644f55875d42d812ffe87f1887d68 (patch) | |
tree | 98c7bdf6bacc724c70e44b4f64f07630a30ac607 /fs/cifs | |
parent | dc9300a670aebb22e9b04b3664da6b218b29ab60 (diff) |
cifs: add new debugging macro cifs_server_dbg
which can be used from contexts where we have a TCP_Server_Info *server.
This new macro will prepend the debugging string with "Server:<servername> "
which will help when debugging issues on hosts with many cifs connections
to several different servers.
Convert a bunch of cifs_dbg(VFS) calls to cifs_server_dbg(VFS)
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/cifs')
-rw-r--r-- | fs/cifs/cifs_debug.h | 31 | ||||
-rw-r--r-- | fs/cifs/connect.c | 47 | ||||
-rw-r--r-- | fs/cifs/smb2pdu.c | 113 | ||||
-rw-r--r-- | fs/cifs/smb2transport.c | 61 | ||||
-rw-r--r-- | fs/cifs/transport.c | 115 |
5 files changed, 204 insertions, 163 deletions
diff --git a/fs/cifs/cifs_debug.h b/fs/cifs/cifs_debug.h index 3d392620a2f4..567af916f103 100644 --- a/fs/cifs/cifs_debug.h +++ b/fs/cifs/cifs_debug.h | |||
@@ -80,6 +80,30 @@ do { \ | |||
80 | type, fmt, ##__VA_ARGS__); \ | 80 | type, fmt, ##__VA_ARGS__); \ |
81 | } while (0) | 81 | } while (0) |
82 | 82 | ||
83 | #define cifs_server_dbg_func(ratefunc, type, fmt, ...) \ | ||
84 | do { \ | ||
85 | if ((type) & FYI && cifsFYI & CIFS_INFO) { \ | ||
86 | pr_debug_ ## ratefunc("%s: Server:%s " fmt, \ | ||
87 | __FILE__, server->hostname, ##__VA_ARGS__);\ | ||
88 | } else if ((type) & VFS) { \ | ||
89 | pr_err_ ## ratefunc("CIFS VFS: Server:%s " fmt, \ | ||
90 | server->hostname, ##__VA_ARGS__); \ | ||
91 | } else if ((type) & NOISY && (NOISY != 0)) { \ | ||
92 | pr_debug_ ## ratefunc("Server:%s " fmt, \ | ||
93 | server->hostname, ##__VA_ARGS__); \ | ||
94 | } \ | ||
95 | } while (0) | ||
96 | |||
97 | #define cifs_server_dbg(type, fmt, ...) \ | ||
98 | do { \ | ||
99 | if ((type) & ONCE) \ | ||
100 | cifs_server_dbg_func(once, \ | ||
101 | type, fmt, ##__VA_ARGS__); \ | ||
102 | else \ | ||
103 | cifs_server_dbg_func(ratelimited, \ | ||
104 | type, fmt, ##__VA_ARGS__); \ | ||
105 | } while (0) | ||
106 | |||
83 | /* | 107 | /* |
84 | * debug OFF | 108 | * debug OFF |
85 | * --------- | 109 | * --------- |
@@ -91,6 +115,13 @@ do { \ | |||
91 | pr_debug(fmt, ##__VA_ARGS__); \ | 115 | pr_debug(fmt, ##__VA_ARGS__); \ |
92 | } while (0) | 116 | } while (0) |
93 | 117 | ||
118 | #define cifs_server_dbg(type, fmt, ...) \ | ||
119 | do { \ | ||
120 | if (0) \ | ||
121 | pr_debug("Server:%s " fmt, \ | ||
122 | server->hostname, ##__VA_ARGS__); \ | ||
123 | } while (0) | ||
124 | |||
94 | #define cifs_info(fmt, ...) \ | 125 | #define cifs_info(fmt, ...) \ |
95 | do { \ | 126 | do { \ |
96 | pr_info("CIFS: "fmt, ##__VA_ARGS__); \ | 127 | pr_info("CIFS: "fmt, ##__VA_ARGS__); \ |
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 4fe559821aff..1efbbfffddba 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -489,7 +489,7 @@ cifs_reconnect(struct TCP_Server_Info *server) | |||
489 | } else { | 489 | } else { |
490 | rc = reconn_setup_dfs_targets(cifs_sb, &tgt_list, &tgt_it); | 490 | rc = reconn_setup_dfs_targets(cifs_sb, &tgt_list, &tgt_it); |
491 | if (rc && (rc != -EOPNOTSUPP)) { | 491 | if (rc && (rc != -EOPNOTSUPP)) { |
492 | cifs_dbg(VFS, "%s: no target servers for DFS failover\n", | 492 | cifs_server_dbg(VFS, "%s: no target servers for DFS failover\n", |
493 | __func__); | 493 | __func__); |
494 | } else { | 494 | } else { |
495 | server->nr_targets = dfs_cache_get_nr_tgts(&tgt_list); | 495 | server->nr_targets = dfs_cache_get_nr_tgts(&tgt_list); |
@@ -617,12 +617,12 @@ cifs_reconnect(struct TCP_Server_Info *server) | |||
617 | rc = dfs_cache_noreq_update_tgthint(cifs_sb->origin_fullpath + 1, | 617 | rc = dfs_cache_noreq_update_tgthint(cifs_sb->origin_fullpath + 1, |
618 | tgt_it); | 618 | tgt_it); |
619 | if (rc) { | 619 | if (rc) { |
620 | cifs_dbg(VFS, "%s: failed to update DFS target hint: rc = %d\n", | 620 | cifs_server_dbg(VFS, "%s: failed to update DFS target hint: rc = %d\n", |
621 | __func__, rc); | 621 | __func__, rc); |
622 | } | 622 | } |
623 | rc = dfs_cache_update_vol(cifs_sb->origin_fullpath, server); | 623 | rc = dfs_cache_update_vol(cifs_sb->origin_fullpath, server); |
624 | if (rc) { | 624 | if (rc) { |
625 | cifs_dbg(VFS, "%s: failed to update vol info in DFS cache: rc = %d\n", | 625 | cifs_server_dbg(VFS, "%s: failed to update vol info in DFS cache: rc = %d\n", |
626 | __func__, rc); | 626 | __func__, rc); |
627 | } | 627 | } |
628 | dfs_cache_free_tgts(&tgt_list); | 628 | dfs_cache_free_tgts(&tgt_list); |
@@ -678,7 +678,7 @@ allocate_buffers(struct TCP_Server_Info *server) | |||
678 | if (!server->bigbuf) { | 678 | if (!server->bigbuf) { |
679 | server->bigbuf = (char *)cifs_buf_get(); | 679 | server->bigbuf = (char *)cifs_buf_get(); |
680 | if (!server->bigbuf) { | 680 | if (!server->bigbuf) { |
681 | cifs_dbg(VFS, "No memory for large SMB response\n"); | 681 | cifs_server_dbg(VFS, "No memory for large SMB response\n"); |
682 | msleep(3000); | 682 | msleep(3000); |
683 | /* retry will check if exiting */ | 683 | /* retry will check if exiting */ |
684 | return false; | 684 | return false; |
@@ -691,7 +691,7 @@ allocate_buffers(struct TCP_Server_Info *server) | |||
691 | if (!server->smallbuf) { | 691 | if (!server->smallbuf) { |
692 | server->smallbuf = (char *)cifs_small_buf_get(); | 692 | server->smallbuf = (char *)cifs_small_buf_get(); |
693 | if (!server->smallbuf) { | 693 | if (!server->smallbuf) { |
694 | cifs_dbg(VFS, "No memory for SMB response\n"); | 694 | cifs_server_dbg(VFS, "No memory for SMB response\n"); |
695 | msleep(1000); | 695 | msleep(1000); |
696 | /* retry will check if exiting */ | 696 | /* retry will check if exiting */ |
697 | return false; | 697 | return false; |
@@ -722,8 +722,8 @@ server_unresponsive(struct TCP_Server_Info *server) | |||
722 | if ((server->tcpStatus == CifsGood || | 722 | if ((server->tcpStatus == CifsGood || |
723 | server->tcpStatus == CifsNeedNegotiate) && | 723 | server->tcpStatus == CifsNeedNegotiate) && |
724 | time_after(jiffies, server->lstrp + 3 * server->echo_interval)) { | 724 | time_after(jiffies, server->lstrp + 3 * server->echo_interval)) { |
725 | cifs_dbg(VFS, "Server %s has not responded in %lu seconds. Reconnecting...\n", | 725 | cifs_server_dbg(VFS, "has not responded in %lu seconds. Reconnecting...\n", |
726 | server->hostname, (3 * server->echo_interval) / HZ); | 726 | (3 * server->echo_interval) / HZ); |
727 | cifs_reconnect(server); | 727 | cifs_reconnect(server); |
728 | wake_up(&server->response_q); | 728 | wake_up(&server->response_q); |
729 | return true; | 729 | return true; |
@@ -861,7 +861,7 @@ is_smb_response(struct TCP_Server_Info *server, unsigned char type) | |||
861 | wake_up(&server->response_q); | 861 | wake_up(&server->response_q); |
862 | break; | 862 | break; |
863 | default: | 863 | default: |
864 | cifs_dbg(VFS, "RFC 1002 unknown response type 0x%x\n", type); | 864 | cifs_server_dbg(VFS, "RFC 1002 unknown response type 0x%x\n", type); |
865 | cifs_reconnect(server); | 865 | cifs_reconnect(server); |
866 | } | 866 | } |
867 | 867 | ||
@@ -1008,7 +1008,7 @@ standard_receive3(struct TCP_Server_Info *server, struct mid_q_entry *mid) | |||
1008 | /* make sure this will fit in a large buffer */ | 1008 | /* make sure this will fit in a large buffer */ |
1009 | if (pdu_length > CIFSMaxBufSize + MAX_HEADER_SIZE(server) - | 1009 | if (pdu_length > CIFSMaxBufSize + MAX_HEADER_SIZE(server) - |
1010 | server->vals->header_preamble_size) { | 1010 | server->vals->header_preamble_size) { |
1011 | cifs_dbg(VFS, "SMB response too long (%u bytes)\n", pdu_length); | 1011 | cifs_server_dbg(VFS, "SMB response too long (%u bytes)\n", pdu_length); |
1012 | cifs_reconnect(server); | 1012 | cifs_reconnect(server); |
1013 | wake_up(&server->response_q); | 1013 | wake_up(&server->response_q); |
1014 | return -ECONNABORTED; | 1014 | return -ECONNABORTED; |
@@ -1149,7 +1149,7 @@ next_pdu: | |||
1149 | /* make sure we have enough to get to the MID */ | 1149 | /* make sure we have enough to get to the MID */ |
1150 | if (server->pdu_size < HEADER_SIZE(server) - 1 - | 1150 | if (server->pdu_size < HEADER_SIZE(server) - 1 - |
1151 | server->vals->header_preamble_size) { | 1151 | server->vals->header_preamble_size) { |
1152 | cifs_dbg(VFS, "SMB response too short (%u bytes)\n", | 1152 | cifs_server_dbg(VFS, "SMB response too short (%u bytes)\n", |
1153 | server->pdu_size); | 1153 | server->pdu_size); |
1154 | cifs_reconnect(server); | 1154 | cifs_reconnect(server); |
1155 | wake_up(&server->response_q); | 1155 | wake_up(&server->response_q); |
@@ -1222,7 +1222,7 @@ next_pdu: | |||
1222 | smb2_add_credits_from_hdr(bufs[i], server); | 1222 | smb2_add_credits_from_hdr(bufs[i], server); |
1223 | cifs_dbg(FYI, "Received oplock break\n"); | 1223 | cifs_dbg(FYI, "Received oplock break\n"); |
1224 | } else { | 1224 | } else { |
1225 | cifs_dbg(VFS, "No task to wake, unknown frame " | 1225 | cifs_server_dbg(VFS, "No task to wake, unknown frame " |
1226 | "received! NumMids %d\n", | 1226 | "received! NumMids %d\n", |
1227 | atomic_read(&midCount)); | 1227 | atomic_read(&midCount)); |
1228 | cifs_dump_mem("Received Data is: ", bufs[i], | 1228 | cifs_dump_mem("Received Data is: ", bufs[i], |
@@ -2840,16 +2840,17 @@ cifs_setup_ipc(struct cifs_ses *ses, struct smb_vol *volume_info) | |||
2840 | struct nls_table *nls_codepage; | 2840 | struct nls_table *nls_codepage; |
2841 | char unc[SERVER_NAME_LENGTH + sizeof("//x/IPC$")] = {0}; | 2841 | char unc[SERVER_NAME_LENGTH + sizeof("//x/IPC$")] = {0}; |
2842 | bool seal = false; | 2842 | bool seal = false; |
2843 | struct TCP_Server_Info *server = ses->server; | ||
2843 | 2844 | ||
2844 | /* | 2845 | /* |
2845 | * If the mount request that resulted in the creation of the | 2846 | * If the mount request that resulted in the creation of the |
2846 | * session requires encryption, force IPC to be encrypted too. | 2847 | * session requires encryption, force IPC to be encrypted too. |
2847 | */ | 2848 | */ |
2848 | if (volume_info->seal) { | 2849 | if (volume_info->seal) { |
2849 | if (ses->server->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION) | 2850 | if (server->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION) |
2850 | seal = true; | 2851 | seal = true; |
2851 | else { | 2852 | else { |
2852 | cifs_dbg(VFS, | 2853 | cifs_server_dbg(VFS, |
2853 | "IPC: server doesn't support encryption\n"); | 2854 | "IPC: server doesn't support encryption\n"); |
2854 | return -EOPNOTSUPP; | 2855 | return -EOPNOTSUPP; |
2855 | } | 2856 | } |
@@ -2859,7 +2860,7 @@ cifs_setup_ipc(struct cifs_ses *ses, struct smb_vol *volume_info) | |||
2859 | if (tcon == NULL) | 2860 | if (tcon == NULL) |
2860 | return -ENOMEM; | 2861 | return -ENOMEM; |
2861 | 2862 | ||
2862 | scnprintf(unc, sizeof(unc), "\\\\%s\\IPC$", ses->server->hostname); | 2863 | scnprintf(unc, sizeof(unc), "\\\\%s\\IPC$", server->hostname); |
2863 | 2864 | ||
2864 | /* cannot fail */ | 2865 | /* cannot fail */ |
2865 | nls_codepage = load_nls_default(); | 2866 | nls_codepage = load_nls_default(); |
@@ -2868,11 +2869,11 @@ cifs_setup_ipc(struct cifs_ses *ses, struct smb_vol *volume_info) | |||
2868 | tcon->ses = ses; | 2869 | tcon->ses = ses; |
2869 | tcon->ipc = true; | 2870 | tcon->ipc = true; |
2870 | tcon->seal = seal; | 2871 | tcon->seal = seal; |
2871 | rc = ses->server->ops->tree_connect(xid, ses, unc, tcon, nls_codepage); | 2872 | rc = server->ops->tree_connect(xid, ses, unc, tcon, nls_codepage); |
2872 | free_xid(xid); | 2873 | free_xid(xid); |
2873 | 2874 | ||
2874 | if (rc) { | 2875 | if (rc) { |
2875 | cifs_dbg(VFS, "failed to connect to IPC (rc=%d)\n", rc); | 2876 | cifs_server_dbg(VFS, "failed to connect to IPC (rc=%d)\n", rc); |
2876 | tconInfoFree(tcon); | 2877 | tconInfoFree(tcon); |
2877 | goto out; | 2878 | goto out; |
2878 | } | 2879 | } |
@@ -2958,7 +2959,7 @@ void cifs_put_smb_ses(struct cifs_ses *ses) | |||
2958 | xid = get_xid(); | 2959 | xid = get_xid(); |
2959 | rc = server->ops->logoff(xid, ses); | 2960 | rc = server->ops->logoff(xid, ses); |
2960 | if (rc) | 2961 | if (rc) |
2961 | cifs_dbg(VFS, "%s: Session Logoff failure rc=%d\n", | 2962 | cifs_server_dbg(VFS, "%s: Session Logoff failure rc=%d\n", |
2962 | __func__, rc); | 2963 | __func__, rc); |
2963 | _free_xid(xid); | 2964 | _free_xid(xid); |
2964 | } | 2965 | } |
@@ -3659,10 +3660,10 @@ bind_socket(struct TCP_Server_Info *server) | |||
3659 | saddr4 = (struct sockaddr_in *)&server->srcaddr; | 3660 | saddr4 = (struct sockaddr_in *)&server->srcaddr; |
3660 | saddr6 = (struct sockaddr_in6 *)&server->srcaddr; | 3661 | saddr6 = (struct sockaddr_in6 *)&server->srcaddr; |
3661 | if (saddr6->sin6_family == AF_INET6) | 3662 | if (saddr6->sin6_family == AF_INET6) |
3662 | cifs_dbg(VFS, "Failed to bind to: %pI6c, error: %d\n", | 3663 | cifs_server_dbg(VFS, "Failed to bind to: %pI6c, error: %d\n", |
3663 | &saddr6->sin6_addr, rc); | 3664 | &saddr6->sin6_addr, rc); |
3664 | else | 3665 | else |
3665 | cifs_dbg(VFS, "Failed to bind to: %pI4, error: %d\n", | 3666 | cifs_server_dbg(VFS, "Failed to bind to: %pI4, error: %d\n", |
3666 | &saddr4->sin_addr.s_addr, rc); | 3667 | &saddr4->sin_addr.s_addr, rc); |
3667 | } | 3668 | } |
3668 | } | 3669 | } |
@@ -3766,7 +3767,7 @@ generic_ip_connect(struct TCP_Server_Info *server) | |||
3766 | rc = __sock_create(cifs_net_ns(server), sfamily, SOCK_STREAM, | 3767 | rc = __sock_create(cifs_net_ns(server), sfamily, SOCK_STREAM, |
3767 | IPPROTO_TCP, &socket, 1); | 3768 | IPPROTO_TCP, &socket, 1); |
3768 | if (rc < 0) { | 3769 | if (rc < 0) { |
3769 | cifs_dbg(VFS, "Error %d creating socket\n", rc); | 3770 | cifs_server_dbg(VFS, "Error %d creating socket\n", rc); |
3770 | server->ssocket = NULL; | 3771 | server->ssocket = NULL; |
3771 | return rc; | 3772 | return rc; |
3772 | } | 3773 | } |
@@ -4150,7 +4151,7 @@ static int mount_get_conns(struct smb_vol *vol, struct cifs_sb_info *cifs_sb, | |||
4150 | 4151 | ||
4151 | if ((vol->persistent == true) && (!(ses->server->capabilities & | 4152 | if ((vol->persistent == true) && (!(ses->server->capabilities & |
4152 | SMB2_GLOBAL_CAP_PERSISTENT_HANDLES))) { | 4153 | SMB2_GLOBAL_CAP_PERSISTENT_HANDLES))) { |
4153 | cifs_dbg(VFS, "persistent handles not supported by server\n"); | 4154 | cifs_server_dbg(VFS, "persistent handles not supported by server\n"); |
4154 | return -EOPNOTSUPP; | 4155 | return -EOPNOTSUPP; |
4155 | } | 4156 | } |
4156 | 4157 | ||
@@ -4588,7 +4589,7 @@ static int is_path_remote(struct cifs_sb_info *cifs_sb, struct smb_vol *vol, | |||
4588 | rc = cifs_are_all_path_components_accessible(server, xid, tcon, | 4589 | rc = cifs_are_all_path_components_accessible(server, xid, tcon, |
4589 | cifs_sb, full_path, tcon->Flags & SMB_SHARE_IS_IN_DFS); | 4590 | cifs_sb, full_path, tcon->Flags & SMB_SHARE_IS_IN_DFS); |
4590 | if (rc != 0) { | 4591 | if (rc != 0) { |
4591 | cifs_dbg(VFS, "cannot query dirs between root and final path, " | 4592 | cifs_server_dbg(VFS, "cannot query dirs between root and final path, " |
4592 | "enabling CIFS_MOUNT_USE_PREFIX_PATH\n"); | 4593 | "enabling CIFS_MOUNT_USE_PREFIX_PATH\n"); |
4593 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_USE_PREFIX_PATH; | 4594 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_USE_PREFIX_PATH; |
4594 | rc = 0; | 4595 | rc = 0; |
@@ -5090,7 +5091,7 @@ cifs_setup_session(const unsigned int xid, struct cifs_ses *ses, | |||
5090 | rc = server->ops->sess_setup(xid, ses, nls_info); | 5091 | rc = server->ops->sess_setup(xid, ses, nls_info); |
5091 | 5092 | ||
5092 | if (rc) | 5093 | if (rc) |
5093 | cifs_dbg(VFS, "Send error in SessSetup = %d\n", rc); | 5094 | cifs_server_dbg(VFS, "Send error in SessSetup = %d\n", rc); |
5094 | 5095 | ||
5095 | return rc; | 5096 | return rc; |
5096 | } | 5097 | } |
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index a33cb91b4963..dbc6ef50dd45 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c | |||
@@ -542,7 +542,7 @@ assemble_neg_contexts(struct smb2_negotiate_req *req, | |||
542 | 542 | ||
543 | if (*total_len > 200) { | 543 | if (*total_len > 200) { |
544 | /* In case length corrupted don't want to overrun smb buffer */ | 544 | /* In case length corrupted don't want to overrun smb buffer */ |
545 | cifs_dbg(VFS, "Bad frame length assembling neg contexts\n"); | 545 | cifs_server_dbg(VFS, "Bad frame length assembling neg contexts\n"); |
546 | return; | 546 | return; |
547 | } | 547 | } |
548 | 548 | ||
@@ -660,7 +660,7 @@ static int smb311_decode_neg_context(struct smb2_negotiate_rsp *rsp, | |||
660 | 660 | ||
661 | cifs_dbg(FYI, "decoding %d negotiate contexts\n", ctxt_cnt); | 661 | cifs_dbg(FYI, "decoding %d negotiate contexts\n", ctxt_cnt); |
662 | if (len_of_smb <= offset) { | 662 | if (len_of_smb <= offset) { |
663 | cifs_dbg(VFS, "Invalid response: negotiate context offset\n"); | 663 | cifs_server_dbg(VFS, "Invalid response: negotiate context offset\n"); |
664 | return -EINVAL; | 664 | return -EINVAL; |
665 | } | 665 | } |
666 | 666 | ||
@@ -692,7 +692,7 @@ static int smb311_decode_neg_context(struct smb2_negotiate_rsp *rsp, | |||
692 | else if (pctx->ContextType == SMB2_POSIX_EXTENSIONS_AVAILABLE) | 692 | else if (pctx->ContextType == SMB2_POSIX_EXTENSIONS_AVAILABLE) |
693 | server->posix_ext_supported = true; | 693 | server->posix_ext_supported = true; |
694 | else | 694 | else |
695 | cifs_dbg(VFS, "unknown negcontext of type %d ignored\n", | 695 | cifs_server_dbg(VFS, "unknown negcontext of type %d ignored\n", |
696 | le16_to_cpu(pctx->ContextType)); | 696 | le16_to_cpu(pctx->ContextType)); |
697 | 697 | ||
698 | if (rc) | 698 | if (rc) |
@@ -817,7 +817,7 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) | |||
817 | req->Dialects[1] = cpu_to_le16(SMB302_PROT_ID); | 817 | req->Dialects[1] = cpu_to_le16(SMB302_PROT_ID); |
818 | req->DialectCount = cpu_to_le16(2); | 818 | req->DialectCount = cpu_to_le16(2); |
819 | total_len += 4; | 819 | total_len += 4; |
820 | } else if (strcmp(ses->server->vals->version_string, | 820 | } else if (strcmp(server->vals->version_string, |
821 | SMBDEFAULT_VERSION_STRING) == 0) { | 821 | SMBDEFAULT_VERSION_STRING) == 0) { |
822 | req->Dialects[0] = cpu_to_le16(SMB21_PROT_ID); | 822 | req->Dialects[0] = cpu_to_le16(SMB21_PROT_ID); |
823 | req->Dialects[1] = cpu_to_le16(SMB30_PROT_ID); | 823 | req->Dialects[1] = cpu_to_le16(SMB30_PROT_ID); |
@@ -840,16 +840,16 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) | |||
840 | else | 840 | else |
841 | req->SecurityMode = 0; | 841 | req->SecurityMode = 0; |
842 | 842 | ||
843 | req->Capabilities = cpu_to_le32(ses->server->vals->req_capabilities); | 843 | req->Capabilities = cpu_to_le32(server->vals->req_capabilities); |
844 | 844 | ||
845 | /* ClientGUID must be zero for SMB2.02 dialect */ | 845 | /* ClientGUID must be zero for SMB2.02 dialect */ |
846 | if (ses->server->vals->protocol_id == SMB20_PROT_ID) | 846 | if (server->vals->protocol_id == SMB20_PROT_ID) |
847 | memset(req->ClientGUID, 0, SMB2_CLIENT_GUID_SIZE); | 847 | memset(req->ClientGUID, 0, SMB2_CLIENT_GUID_SIZE); |
848 | else { | 848 | else { |
849 | memcpy(req->ClientGUID, server->client_guid, | 849 | memcpy(req->ClientGUID, server->client_guid, |
850 | SMB2_CLIENT_GUID_SIZE); | 850 | SMB2_CLIENT_GUID_SIZE); |
851 | if ((ses->server->vals->protocol_id == SMB311_PROT_ID) || | 851 | if ((server->vals->protocol_id == SMB311_PROT_ID) || |
852 | (strcmp(ses->server->vals->version_string, | 852 | (strcmp(server->vals->version_string, |
853 | SMBDEFAULT_VERSION_STRING) == 0)) | 853 | SMBDEFAULT_VERSION_STRING) == 0)) |
854 | assemble_neg_contexts(req, server, &total_len); | 854 | assemble_neg_contexts(req, server, &total_len); |
855 | } | 855 | } |
@@ -868,42 +868,42 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) | |||
868 | * cifs_stats_inc(&tcon->stats.smb2_stats.smb2_com_fail[SMB2...]); | 868 | * cifs_stats_inc(&tcon->stats.smb2_stats.smb2_com_fail[SMB2...]); |
869 | */ | 869 | */ |
870 | if (rc == -EOPNOTSUPP) { | 870 | if (rc == -EOPNOTSUPP) { |
871 | cifs_dbg(VFS, "Dialect not supported by server. Consider " | 871 | cifs_server_dbg(VFS, "Dialect not supported by server. Consider " |
872 | "specifying vers=1.0 or vers=2.0 on mount for accessing" | 872 | "specifying vers=1.0 or vers=2.0 on mount for accessing" |
873 | " older servers\n"); | 873 | " older servers\n"); |
874 | goto neg_exit; | 874 | goto neg_exit; |
875 | } else if (rc != 0) | 875 | } else if (rc != 0) |
876 | goto neg_exit; | 876 | goto neg_exit; |
877 | 877 | ||
878 | if (strcmp(ses->server->vals->version_string, | 878 | if (strcmp(server->vals->version_string, |
879 | SMB3ANY_VERSION_STRING) == 0) { | 879 | SMB3ANY_VERSION_STRING) == 0) { |
880 | if (rsp->DialectRevision == cpu_to_le16(SMB20_PROT_ID)) { | 880 | if (rsp->DialectRevision == cpu_to_le16(SMB20_PROT_ID)) { |
881 | cifs_dbg(VFS, | 881 | cifs_server_dbg(VFS, |
882 | "SMB2 dialect returned but not requested\n"); | 882 | "SMB2 dialect returned but not requested\n"); |
883 | return -EIO; | 883 | return -EIO; |
884 | } else if (rsp->DialectRevision == cpu_to_le16(SMB21_PROT_ID)) { | 884 | } else if (rsp->DialectRevision == cpu_to_le16(SMB21_PROT_ID)) { |
885 | cifs_dbg(VFS, | 885 | cifs_server_dbg(VFS, |
886 | "SMB2.1 dialect returned but not requested\n"); | 886 | "SMB2.1 dialect returned but not requested\n"); |
887 | return -EIO; | 887 | return -EIO; |
888 | } | 888 | } |
889 | } else if (strcmp(ses->server->vals->version_string, | 889 | } else if (strcmp(server->vals->version_string, |
890 | SMBDEFAULT_VERSION_STRING) == 0) { | 890 | SMBDEFAULT_VERSION_STRING) == 0) { |
891 | if (rsp->DialectRevision == cpu_to_le16(SMB20_PROT_ID)) { | 891 | if (rsp->DialectRevision == cpu_to_le16(SMB20_PROT_ID)) { |
892 | cifs_dbg(VFS, | 892 | cifs_server_dbg(VFS, |
893 | "SMB2 dialect returned but not requested\n"); | 893 | "SMB2 dialect returned but not requested\n"); |
894 | return -EIO; | 894 | return -EIO; |
895 | } else if (rsp->DialectRevision == cpu_to_le16(SMB21_PROT_ID)) { | 895 | } else if (rsp->DialectRevision == cpu_to_le16(SMB21_PROT_ID)) { |
896 | /* ops set to 3.0 by default for default so update */ | 896 | /* ops set to 3.0 by default for default so update */ |
897 | ses->server->ops = &smb21_operations; | 897 | server->ops = &smb21_operations; |
898 | ses->server->vals = &smb21_values; | 898 | server->vals = &smb21_values; |
899 | } else if (rsp->DialectRevision == cpu_to_le16(SMB311_PROT_ID)) { | 899 | } else if (rsp->DialectRevision == cpu_to_le16(SMB311_PROT_ID)) { |
900 | ses->server->ops = &smb311_operations; | 900 | server->ops = &smb311_operations; |
901 | ses->server->vals = &smb311_values; | 901 | server->vals = &smb311_values; |
902 | } | 902 | } |
903 | } else if (le16_to_cpu(rsp->DialectRevision) != | 903 | } else if (le16_to_cpu(rsp->DialectRevision) != |
904 | ses->server->vals->protocol_id) { | 904 | server->vals->protocol_id) { |
905 | /* if requested single dialect ensure returned dialect matched */ | 905 | /* if requested single dialect ensure returned dialect matched */ |
906 | cifs_dbg(VFS, "Illegal 0x%x dialect returned: not requested\n", | 906 | cifs_server_dbg(VFS, "Illegal 0x%x dialect returned: not requested\n", |
907 | le16_to_cpu(rsp->DialectRevision)); | 907 | le16_to_cpu(rsp->DialectRevision)); |
908 | return -EIO; | 908 | return -EIO; |
909 | } | 909 | } |
@@ -921,7 +921,7 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) | |||
921 | else if (rsp->DialectRevision == cpu_to_le16(SMB311_PROT_ID)) | 921 | else if (rsp->DialectRevision == cpu_to_le16(SMB311_PROT_ID)) |
922 | cifs_dbg(FYI, "negotiated smb3.1.1 dialect\n"); | 922 | cifs_dbg(FYI, "negotiated smb3.1.1 dialect\n"); |
923 | else { | 923 | else { |
924 | cifs_dbg(VFS, "Illegal dialect returned by server 0x%x\n", | 924 | cifs_server_dbg(VFS, "Illegal dialect returned by server 0x%x\n", |
925 | le16_to_cpu(rsp->DialectRevision)); | 925 | le16_to_cpu(rsp->DialectRevision)); |
926 | rc = -EIO; | 926 | rc = -EIO; |
927 | goto neg_exit; | 927 | goto neg_exit; |
@@ -981,7 +981,7 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) | |||
981 | rc = smb311_decode_neg_context(rsp, server, | 981 | rc = smb311_decode_neg_context(rsp, server, |
982 | rsp_iov.iov_len); | 982 | rsp_iov.iov_len); |
983 | else | 983 | else |
984 | cifs_dbg(VFS, "Missing expected negotiate contexts\n"); | 984 | cifs_server_dbg(VFS, "Missing expected negotiate contexts\n"); |
985 | } | 985 | } |
986 | neg_exit: | 986 | neg_exit: |
987 | free_rsp_buf(resp_buftype, rsp); | 987 | free_rsp_buf(resp_buftype, rsp); |
@@ -995,11 +995,12 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon) | |||
995 | struct validate_negotiate_info_rsp *pneg_rsp = NULL; | 995 | struct validate_negotiate_info_rsp *pneg_rsp = NULL; |
996 | u32 rsplen; | 996 | u32 rsplen; |
997 | u32 inbuflen; /* max of 4 dialects */ | 997 | u32 inbuflen; /* max of 4 dialects */ |
998 | struct TCP_Server_Info *server = tcon->ses->server; | ||
998 | 999 | ||
999 | cifs_dbg(FYI, "validate negotiate\n"); | 1000 | cifs_dbg(FYI, "validate negotiate\n"); |
1000 | 1001 | ||
1001 | /* In SMB3.11 preauth integrity supersedes validate negotiate */ | 1002 | /* In SMB3.11 preauth integrity supersedes validate negotiate */ |
1002 | if (tcon->ses->server->dialect == SMB311_PROT_ID) | 1003 | if (server->dialect == SMB311_PROT_ID) |
1003 | return 0; | 1004 | return 0; |
1004 | 1005 | ||
1005 | /* | 1006 | /* |
@@ -1018,15 +1019,15 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon) | |||
1018 | } | 1019 | } |
1019 | 1020 | ||
1020 | if (tcon->ses->session_flags & SMB2_SESSION_FLAG_IS_NULL) | 1021 | if (tcon->ses->session_flags & SMB2_SESSION_FLAG_IS_NULL) |
1021 | cifs_dbg(VFS, "Unexpected null user (anonymous) auth flag sent by server\n"); | 1022 | cifs_server_dbg(VFS, "Unexpected null user (anonymous) auth flag sent by server\n"); |
1022 | 1023 | ||
1023 | pneg_inbuf = kmalloc(sizeof(*pneg_inbuf), GFP_NOFS); | 1024 | pneg_inbuf = kmalloc(sizeof(*pneg_inbuf), GFP_NOFS); |
1024 | if (!pneg_inbuf) | 1025 | if (!pneg_inbuf) |
1025 | return -ENOMEM; | 1026 | return -ENOMEM; |
1026 | 1027 | ||
1027 | pneg_inbuf->Capabilities = | 1028 | pneg_inbuf->Capabilities = |
1028 | cpu_to_le32(tcon->ses->server->vals->req_capabilities); | 1029 | cpu_to_le32(server->vals->req_capabilities); |
1029 | memcpy(pneg_inbuf->Guid, tcon->ses->server->client_guid, | 1030 | memcpy(pneg_inbuf->Guid, server->client_guid, |
1030 | SMB2_CLIENT_GUID_SIZE); | 1031 | SMB2_CLIENT_GUID_SIZE); |
1031 | 1032 | ||
1032 | if (tcon->ses->sign) | 1033 | if (tcon->ses->sign) |
@@ -1039,7 +1040,7 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon) | |||
1039 | pneg_inbuf->SecurityMode = 0; | 1040 | pneg_inbuf->SecurityMode = 0; |
1040 | 1041 | ||
1041 | 1042 | ||
1042 | if (strcmp(tcon->ses->server->vals->version_string, | 1043 | if (strcmp(server->vals->version_string, |
1043 | SMB3ANY_VERSION_STRING) == 0) { | 1044 | SMB3ANY_VERSION_STRING) == 0) { |
1044 | pneg_inbuf->Dialects[0] = cpu_to_le16(SMB30_PROT_ID); | 1045 | pneg_inbuf->Dialects[0] = cpu_to_le16(SMB30_PROT_ID); |
1045 | pneg_inbuf->Dialects[1] = cpu_to_le16(SMB302_PROT_ID); | 1046 | pneg_inbuf->Dialects[1] = cpu_to_le16(SMB302_PROT_ID); |
@@ -1047,7 +1048,7 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon) | |||
1047 | /* structure is big enough for 3 dialects, sending only 2 */ | 1048 | /* structure is big enough for 3 dialects, sending only 2 */ |
1048 | inbuflen = sizeof(*pneg_inbuf) - | 1049 | inbuflen = sizeof(*pneg_inbuf) - |
1049 | (2 * sizeof(pneg_inbuf->Dialects[0])); | 1050 | (2 * sizeof(pneg_inbuf->Dialects[0])); |
1050 | } else if (strcmp(tcon->ses->server->vals->version_string, | 1051 | } else if (strcmp(server->vals->version_string, |
1051 | SMBDEFAULT_VERSION_STRING) == 0) { | 1052 | SMBDEFAULT_VERSION_STRING) == 0) { |
1052 | pneg_inbuf->Dialects[0] = cpu_to_le16(SMB21_PROT_ID); | 1053 | pneg_inbuf->Dialects[0] = cpu_to_le16(SMB21_PROT_ID); |
1053 | pneg_inbuf->Dialects[1] = cpu_to_le16(SMB30_PROT_ID); | 1054 | pneg_inbuf->Dialects[1] = cpu_to_le16(SMB30_PROT_ID); |
@@ -1059,7 +1060,7 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon) | |||
1059 | } else { | 1060 | } else { |
1060 | /* otherwise specific dialect was requested */ | 1061 | /* otherwise specific dialect was requested */ |
1061 | pneg_inbuf->Dialects[0] = | 1062 | pneg_inbuf->Dialects[0] = |
1062 | cpu_to_le16(tcon->ses->server->vals->protocol_id); | 1063 | cpu_to_le16(server->vals->protocol_id); |
1063 | pneg_inbuf->DialectCount = cpu_to_le16(1); | 1064 | pneg_inbuf->DialectCount = cpu_to_le16(1); |
1064 | /* structure is big enough for 3 dialects, sending only 1 */ | 1065 | /* structure is big enough for 3 dialects, sending only 1 */ |
1065 | inbuflen = sizeof(*pneg_inbuf) - | 1066 | inbuflen = sizeof(*pneg_inbuf) - |
@@ -1075,18 +1076,18 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon) | |||
1075 | * Old Windows versions or Netapp SMB server can return | 1076 | * Old Windows versions or Netapp SMB server can return |
1076 | * not supported error. Client should accept it. | 1077 | * not supported error. Client should accept it. |
1077 | */ | 1078 | */ |
1078 | cifs_dbg(VFS, "Server does not support validate negotiate\n"); | 1079 | cifs_server_dbg(VFS, "Server does not support validate negotiate\n"); |
1079 | rc = 0; | 1080 | rc = 0; |
1080 | goto out_free_inbuf; | 1081 | goto out_free_inbuf; |
1081 | } else if (rc != 0) { | 1082 | } else if (rc != 0) { |
1082 | cifs_dbg(VFS, "validate protocol negotiate failed: %d\n", rc); | 1083 | cifs_server_dbg(VFS, "validate protocol negotiate failed: %d\n", rc); |
1083 | rc = -EIO; | 1084 | rc = -EIO; |
1084 | goto out_free_inbuf; | 1085 | goto out_free_inbuf; |
1085 | } | 1086 | } |
1086 | 1087 | ||
1087 | rc = -EIO; | 1088 | rc = -EIO; |
1088 | if (rsplen != sizeof(*pneg_rsp)) { | 1089 | if (rsplen != sizeof(*pneg_rsp)) { |
1089 | cifs_dbg(VFS, "invalid protocol negotiate response size: %d\n", | 1090 | cifs_server_dbg(VFS, "invalid protocol negotiate response size: %d\n", |
1090 | rsplen); | 1091 | rsplen); |
1091 | 1092 | ||
1092 | /* relax check since Mac returns max bufsize allowed on ioctl */ | 1093 | /* relax check since Mac returns max bufsize allowed on ioctl */ |
@@ -1095,16 +1096,16 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon) | |||
1095 | } | 1096 | } |
1096 | 1097 | ||
1097 | /* check validate negotiate info response matches what we got earlier */ | 1098 | /* check validate negotiate info response matches what we got earlier */ |
1098 | if (pneg_rsp->Dialect != cpu_to_le16(tcon->ses->server->dialect)) | 1099 | if (pneg_rsp->Dialect != cpu_to_le16(server->dialect)) |
1099 | goto vneg_out; | 1100 | goto vneg_out; |
1100 | 1101 | ||
1101 | if (pneg_rsp->SecurityMode != cpu_to_le16(tcon->ses->server->sec_mode)) | 1102 | if (pneg_rsp->SecurityMode != cpu_to_le16(server->sec_mode)) |
1102 | goto vneg_out; | 1103 | goto vneg_out; |
1103 | 1104 | ||
1104 | /* do not validate server guid because not saved at negprot time yet */ | 1105 | /* do not validate server guid because not saved at negprot time yet */ |
1105 | 1106 | ||
1106 | if ((le32_to_cpu(pneg_rsp->Capabilities) | SMB2_NT_FIND | | 1107 | if ((le32_to_cpu(pneg_rsp->Capabilities) | SMB2_NT_FIND | |
1107 | SMB2_LARGE_FILES) != tcon->ses->server->capabilities) | 1108 | SMB2_LARGE_FILES) != server->capabilities) |
1108 | goto vneg_out; | 1109 | goto vneg_out; |
1109 | 1110 | ||
1110 | /* validate negotiate successful */ | 1111 | /* validate negotiate successful */ |
@@ -1113,7 +1114,7 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon) | |||
1113 | goto out_free_rsp; | 1114 | goto out_free_rsp; |
1114 | 1115 | ||
1115 | vneg_out: | 1116 | vneg_out: |
1116 | cifs_dbg(VFS, "protocol revalidation - security settings mismatch\n"); | 1117 | cifs_server_dbg(VFS, "protocol revalidation - security settings mismatch\n"); |
1117 | out_free_rsp: | 1118 | out_free_rsp: |
1118 | kfree(pneg_rsp); | 1119 | kfree(pneg_rsp); |
1119 | out_free_inbuf: | 1120 | out_free_inbuf: |
@@ -1567,7 +1568,7 @@ SMB2_sess_setup(const unsigned int xid, struct cifs_ses *ses, | |||
1567 | sess_data->func(sess_data); | 1568 | sess_data->func(sess_data); |
1568 | 1569 | ||
1569 | if ((ses->session_flags & SMB2_SESSION_FLAG_IS_GUEST) && (ses->sign)) | 1570 | if ((ses->session_flags & SMB2_SESSION_FLAG_IS_GUEST) && (ses->sign)) |
1570 | cifs_dbg(VFS, "signing requested but authenticated as guest\n"); | 1571 | cifs_server_dbg(VFS, "signing requested but authenticated as guest\n"); |
1571 | rc = sess_data->result; | 1572 | rc = sess_data->result; |
1572 | out: | 1573 | out: |
1573 | kfree(sess_data); | 1574 | kfree(sess_data); |
@@ -1660,10 +1661,11 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree, | |||
1660 | __le16 *unc_path = NULL; | 1661 | __le16 *unc_path = NULL; |
1661 | int flags = 0; | 1662 | int flags = 0; |
1662 | unsigned int total_len; | 1663 | unsigned int total_len; |
1664 | struct TCP_Server_Info *server = ses->server; | ||
1663 | 1665 | ||
1664 | cifs_dbg(FYI, "TCON\n"); | 1666 | cifs_dbg(FYI, "TCON\n"); |
1665 | 1667 | ||
1666 | if (!(ses->server) || !tree) | 1668 | if (!server || !tree) |
1667 | return -EIO; | 1669 | return -EIO; |
1668 | 1670 | ||
1669 | unc_path = kmalloc(MAX_SHARENAME_LENGTH * 2, GFP_KERNEL); | 1671 | unc_path = kmalloc(MAX_SHARENAME_LENGTH * 2, GFP_KERNEL); |
@@ -1706,7 +1708,7 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree, | |||
1706 | * unless it is guest or anonymous user. See MS-SMB2 3.2.5.3.1 | 1708 | * unless it is guest or anonymous user. See MS-SMB2 3.2.5.3.1 |
1707 | * (Samba servers don't always set the flag so also check if null user) | 1709 | * (Samba servers don't always set the flag so also check if null user) |
1708 | */ | 1710 | */ |
1709 | if ((ses->server->dialect == SMB311_PROT_ID) && | 1711 | if ((server->dialect == SMB311_PROT_ID) && |
1710 | !smb3_encryption_required(tcon) && | 1712 | !smb3_encryption_required(tcon) && |
1711 | !(ses->session_flags & | 1713 | !(ses->session_flags & |
1712 | (SMB2_SESSION_FLAG_IS_GUEST|SMB2_SESSION_FLAG_IS_NULL)) && | 1714 | (SMB2_SESSION_FLAG_IS_GUEST|SMB2_SESSION_FLAG_IS_NULL)) && |
@@ -1745,7 +1747,7 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree, | |||
1745 | cifs_dbg(FYI, "connection to printer\n"); | 1747 | cifs_dbg(FYI, "connection to printer\n"); |
1746 | break; | 1748 | break; |
1747 | default: | 1749 | default: |
1748 | cifs_dbg(VFS, "unknown share type %d\n", rsp->ShareType); | 1750 | cifs_server_dbg(VFS, "unknown share type %d\n", rsp->ShareType); |
1749 | rc = -EOPNOTSUPP; | 1751 | rc = -EOPNOTSUPP; |
1750 | goto tcon_error_exit; | 1752 | goto tcon_error_exit; |
1751 | } | 1753 | } |
@@ -1760,15 +1762,15 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree, | |||
1760 | 1762 | ||
1761 | if ((rsp->Capabilities & SMB2_SHARE_CAP_DFS) && | 1763 | if ((rsp->Capabilities & SMB2_SHARE_CAP_DFS) && |
1762 | ((tcon->share_flags & SHI1005_FLAGS_DFS) == 0)) | 1764 | ((tcon->share_flags & SHI1005_FLAGS_DFS) == 0)) |
1763 | cifs_dbg(VFS, "DFS capability contradicts DFS flag\n"); | 1765 | cifs_server_dbg(VFS, "DFS capability contradicts DFS flag\n"); |
1764 | 1766 | ||
1765 | if (tcon->seal && | 1767 | if (tcon->seal && |
1766 | !(tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION)) | 1768 | !(server->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION)) |
1767 | cifs_dbg(VFS, "Encryption is requested but not supported\n"); | 1769 | cifs_server_dbg(VFS, "Encryption is requested but not supported\n"); |
1768 | 1770 | ||
1769 | init_copy_chunk_defaults(tcon); | 1771 | init_copy_chunk_defaults(tcon); |
1770 | if (tcon->ses->server->ops->validate_negotiate) | 1772 | if (server->ops->validate_negotiate) |
1771 | rc = tcon->ses->server->ops->validate_negotiate(xid, tcon); | 1773 | rc = server->ops->validate_negotiate(xid, tcon); |
1772 | tcon_exit: | 1774 | tcon_exit: |
1773 | 1775 | ||
1774 | free_rsp_buf(resp_buftype, rsp); | 1776 | free_rsp_buf(resp_buftype, rsp); |
@@ -1777,7 +1779,7 @@ tcon_exit: | |||
1777 | 1779 | ||
1778 | tcon_error_exit: | 1780 | tcon_error_exit: |
1779 | if (rsp && rsp->sync_hdr.Status == STATUS_BAD_NETWORK_NAME) { | 1781 | if (rsp && rsp->sync_hdr.Status == STATUS_BAD_NETWORK_NAME) { |
1780 | cifs_dbg(VFS, "BAD_NETWORK_NAME: %s\n", tree); | 1782 | cifs_server_dbg(VFS, "BAD_NETWORK_NAME: %s\n", tree); |
1781 | } | 1783 | } |
1782 | goto tcon_exit; | 1784 | goto tcon_exit; |
1783 | } | 1785 | } |
@@ -2741,6 +2743,7 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, | |||
2741 | int resp_buftype = CIFS_NO_BUFFER; | 2743 | int resp_buftype = CIFS_NO_BUFFER; |
2742 | int rc = 0; | 2744 | int rc = 0; |
2743 | int flags = 0; | 2745 | int flags = 0; |
2746 | struct TCP_Server_Info *server; | ||
2744 | 2747 | ||
2745 | cifs_dbg(FYI, "SMB2 IOCTL\n"); | 2748 | cifs_dbg(FYI, "SMB2 IOCTL\n"); |
2746 | 2749 | ||
@@ -2756,7 +2759,8 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, | |||
2756 | else | 2759 | else |
2757 | return -EIO; | 2760 | return -EIO; |
2758 | 2761 | ||
2759 | if (!ses || !(ses->server)) | 2762 | server = ses->server; |
2763 | if (!ses || !(server)) | ||
2760 | return -EIO; | 2764 | return -EIO; |
2761 | 2765 | ||
2762 | if (smb3_encryption_required(tcon)) | 2766 | if (smb3_encryption_required(tcon)) |
@@ -2806,14 +2810,14 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, | |||
2806 | if (*plen == 0) | 2810 | if (*plen == 0) |
2807 | goto ioctl_exit; /* server returned no data */ | 2811 | goto ioctl_exit; /* server returned no data */ |
2808 | else if (*plen > rsp_iov.iov_len || *plen > 0xFF00) { | 2812 | else if (*plen > rsp_iov.iov_len || *plen > 0xFF00) { |
2809 | cifs_dbg(VFS, "srv returned invalid ioctl length: %d\n", *plen); | 2813 | cifs_server_dbg(VFS, "srv returned invalid ioctl length: %d\n", *plen); |
2810 | *plen = 0; | 2814 | *plen = 0; |
2811 | rc = -EIO; | 2815 | rc = -EIO; |
2812 | goto ioctl_exit; | 2816 | goto ioctl_exit; |
2813 | } | 2817 | } |
2814 | 2818 | ||
2815 | if (rsp_iov.iov_len - *plen < le32_to_cpu(rsp->OutputOffset)) { | 2819 | if (rsp_iov.iov_len - *plen < le32_to_cpu(rsp->OutputOffset)) { |
2816 | cifs_dbg(VFS, "Malformed ioctl resp: len %d offset %d\n", *plen, | 2820 | cifs_server_dbg(VFS, "Malformed ioctl resp: len %d offset %d\n", *plen, |
2817 | le32_to_cpu(rsp->OutputOffset)); | 2821 | le32_to_cpu(rsp->OutputOffset)); |
2818 | *plen = 0; | 2822 | *plen = 0; |
2819 | rc = -EIO; | 2823 | rc = -EIO; |
@@ -3054,12 +3058,13 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon, | |||
3054 | int rc = 0; | 3058 | int rc = 0; |
3055 | int resp_buftype = CIFS_NO_BUFFER; | 3059 | int resp_buftype = CIFS_NO_BUFFER; |
3056 | struct cifs_ses *ses = tcon->ses; | 3060 | struct cifs_ses *ses = tcon->ses; |
3061 | struct TCP_Server_Info *server = ses->server; | ||
3057 | int flags = 0; | 3062 | int flags = 0; |
3058 | bool allocated = false; | 3063 | bool allocated = false; |
3059 | 3064 | ||
3060 | cifs_dbg(FYI, "Query Info\n"); | 3065 | cifs_dbg(FYI, "Query Info\n"); |
3061 | 3066 | ||
3062 | if (!ses || !(ses->server)) | 3067 | if (!ses || !(server)) |
3063 | return -EIO; | 3068 | return -EIO; |
3064 | 3069 | ||
3065 | if (smb3_encryption_required(tcon)) | 3070 | if (smb3_encryption_required(tcon)) |
@@ -3097,7 +3102,7 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon, | |||
3097 | if (!*data) { | 3102 | if (!*data) { |
3098 | *data = kmalloc(*dlen, GFP_KERNEL); | 3103 | *data = kmalloc(*dlen, GFP_KERNEL); |
3099 | if (!*data) { | 3104 | if (!*data) { |
3100 | cifs_dbg(VFS, | 3105 | cifs_server_dbg(VFS, |
3101 | "Error %d allocating memory for acl\n", | 3106 | "Error %d allocating memory for acl\n", |
3102 | rc); | 3107 | rc); |
3103 | *dlen = 0; | 3108 | *dlen = 0; |
@@ -3489,7 +3494,7 @@ smb2_readv_callback(struct mid_q_entry *mid) | |||
3489 | 3494 | ||
3490 | rc = smb2_verify_signature(&rqst, server); | 3495 | rc = smb2_verify_signature(&rqst, server); |
3491 | if (rc) | 3496 | if (rc) |
3492 | cifs_dbg(VFS, "SMB signature verification returned error = %d\n", | 3497 | cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n", |
3493 | rc); | 3498 | rc); |
3494 | } | 3499 | } |
3495 | /* FIXME: should this be counted toward the initiating task? */ | 3500 | /* FIXME: should this be counted toward the initiating task? */ |
@@ -4079,7 +4084,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon, | |||
4079 | info_buf_size = sizeof(SEARCH_ID_FULL_DIR_INFO) - 1; | 4084 | info_buf_size = sizeof(SEARCH_ID_FULL_DIR_INFO) - 1; |
4080 | break; | 4085 | break; |
4081 | default: | 4086 | default: |
4082 | cifs_dbg(VFS, "info level %u isn't supported\n", | 4087 | cifs_server_dbg(VFS, "info level %u isn't supported\n", |
4083 | srch_inf->info_level); | 4088 | srch_inf->info_level); |
4084 | rc = -EINVAL; | 4089 | rc = -EINVAL; |
4085 | goto qdir_exit; | 4090 | goto qdir_exit; |
@@ -4170,7 +4175,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon, | |||
4170 | else if (resp_buftype == CIFS_SMALL_BUFFER) | 4175 | else if (resp_buftype == CIFS_SMALL_BUFFER) |
4171 | srch_inf->smallBuf = true; | 4176 | srch_inf->smallBuf = true; |
4172 | else | 4177 | else |
4173 | cifs_dbg(VFS, "illegal search buffer type\n"); | 4178 | cifs_server_dbg(VFS, "illegal search buffer type\n"); |
4174 | 4179 | ||
4175 | trace_smb3_query_dir_done(xid, persistent_fid, tcon->tid, | 4180 | trace_smb3_query_dir_done(xid, persistent_fid, tcon->tid, |
4176 | tcon->ses->Suid, index, srch_inf->entries_in_buffer); | 4181 | tcon->ses->Suid, index, srch_inf->entries_in_buffer); |
diff --git a/fs/cifs/smb2transport.c b/fs/cifs/smb2transport.c index 1ccbcf9c2c3b..b02242eacb55 100644 --- a/fs/cifs/smb2transport.c +++ b/fs/cifs/smb2transport.c | |||
@@ -176,7 +176,7 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) | |||
176 | 176 | ||
177 | ses = smb2_find_smb_ses(server, shdr->SessionId); | 177 | ses = smb2_find_smb_ses(server, shdr->SessionId); |
178 | if (!ses) { | 178 | if (!ses) { |
179 | cifs_dbg(VFS, "%s: Could not find session\n", __func__); | 179 | cifs_server_dbg(VFS, "%s: Could not find session\n", __func__); |
180 | return 0; | 180 | return 0; |
181 | } | 181 | } |
182 | 182 | ||
@@ -185,21 +185,21 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) | |||
185 | 185 | ||
186 | rc = smb2_crypto_shash_allocate(server); | 186 | rc = smb2_crypto_shash_allocate(server); |
187 | if (rc) { | 187 | if (rc) { |
188 | cifs_dbg(VFS, "%s: sha256 alloc failed\n", __func__); | 188 | cifs_server_dbg(VFS, "%s: sha256 alloc failed\n", __func__); |
189 | return rc; | 189 | return rc; |
190 | } | 190 | } |
191 | 191 | ||
192 | rc = crypto_shash_setkey(server->secmech.hmacsha256, | 192 | rc = crypto_shash_setkey(server->secmech.hmacsha256, |
193 | ses->auth_key.response, SMB2_NTLMV2_SESSKEY_SIZE); | 193 | ses->auth_key.response, SMB2_NTLMV2_SESSKEY_SIZE); |
194 | if (rc) { | 194 | if (rc) { |
195 | cifs_dbg(VFS, "%s: Could not update with response\n", __func__); | 195 | cifs_server_dbg(VFS, "%s: Could not update with response\n", __func__); |
196 | return rc; | 196 | return rc; |
197 | } | 197 | } |
198 | 198 | ||
199 | shash = &server->secmech.sdeschmacsha256->shash; | 199 | shash = &server->secmech.sdeschmacsha256->shash; |
200 | rc = crypto_shash_init(shash); | 200 | rc = crypto_shash_init(shash); |
201 | if (rc) { | 201 | if (rc) { |
202 | cifs_dbg(VFS, "%s: Could not init sha256", __func__); | 202 | cifs_server_dbg(VFS, "%s: Could not init sha256", __func__); |
203 | return rc; | 203 | return rc; |
204 | } | 204 | } |
205 | 205 | ||
@@ -215,7 +215,7 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) | |||
215 | rc = crypto_shash_update(shash, iov[0].iov_base, | 215 | rc = crypto_shash_update(shash, iov[0].iov_base, |
216 | iov[0].iov_len); | 216 | iov[0].iov_len); |
217 | if (rc) { | 217 | if (rc) { |
218 | cifs_dbg(VFS, "%s: Could not update with payload\n", | 218 | cifs_server_dbg(VFS, "%s: Could not update with payload\n", |
219 | __func__); | 219 | __func__); |
220 | return rc; | 220 | return rc; |
221 | } | 221 | } |
@@ -239,68 +239,69 @@ static int generate_key(struct cifs_ses *ses, struct kvec label, | |||
239 | int rc = 0; | 239 | int rc = 0; |
240 | unsigned char prfhash[SMB2_HMACSHA256_SIZE]; | 240 | unsigned char prfhash[SMB2_HMACSHA256_SIZE]; |
241 | unsigned char *hashptr = prfhash; | 241 | unsigned char *hashptr = prfhash; |
242 | struct TCP_Server_Info *server = ses->server; | ||
242 | 243 | ||
243 | memset(prfhash, 0x0, SMB2_HMACSHA256_SIZE); | 244 | memset(prfhash, 0x0, SMB2_HMACSHA256_SIZE); |
244 | memset(key, 0x0, key_size); | 245 | memset(key, 0x0, key_size); |
245 | 246 | ||
246 | rc = smb3_crypto_shash_allocate(ses->server); | 247 | rc = smb3_crypto_shash_allocate(server); |
247 | if (rc) { | 248 | if (rc) { |
248 | cifs_dbg(VFS, "%s: crypto alloc failed\n", __func__); | 249 | cifs_server_dbg(VFS, "%s: crypto alloc failed\n", __func__); |
249 | goto smb3signkey_ret; | 250 | goto smb3signkey_ret; |
250 | } | 251 | } |
251 | 252 | ||
252 | rc = crypto_shash_setkey(ses->server->secmech.hmacsha256, | 253 | rc = crypto_shash_setkey(server->secmech.hmacsha256, |
253 | ses->auth_key.response, SMB2_NTLMV2_SESSKEY_SIZE); | 254 | ses->auth_key.response, SMB2_NTLMV2_SESSKEY_SIZE); |
254 | if (rc) { | 255 | if (rc) { |
255 | cifs_dbg(VFS, "%s: Could not set with session key\n", __func__); | 256 | cifs_server_dbg(VFS, "%s: Could not set with session key\n", __func__); |
256 | goto smb3signkey_ret; | 257 | goto smb3signkey_ret; |
257 | } | 258 | } |
258 | 259 | ||
259 | rc = crypto_shash_init(&ses->server->secmech.sdeschmacsha256->shash); | 260 | rc = crypto_shash_init(&server->secmech.sdeschmacsha256->shash); |
260 | if (rc) { | 261 | if (rc) { |
261 | cifs_dbg(VFS, "%s: Could not init sign hmac\n", __func__); | 262 | cifs_server_dbg(VFS, "%s: Could not init sign hmac\n", __func__); |
262 | goto smb3signkey_ret; | 263 | goto smb3signkey_ret; |
263 | } | 264 | } |
264 | 265 | ||
265 | rc = crypto_shash_update(&ses->server->secmech.sdeschmacsha256->shash, | 266 | rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash, |
266 | i, 4); | 267 | i, 4); |
267 | if (rc) { | 268 | if (rc) { |
268 | cifs_dbg(VFS, "%s: Could not update with n\n", __func__); | 269 | cifs_server_dbg(VFS, "%s: Could not update with n\n", __func__); |
269 | goto smb3signkey_ret; | 270 | goto smb3signkey_ret; |
270 | } | 271 | } |
271 | 272 | ||
272 | rc = crypto_shash_update(&ses->server->secmech.sdeschmacsha256->shash, | 273 | rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash, |
273 | label.iov_base, label.iov_len); | 274 | label.iov_base, label.iov_len); |
274 | if (rc) { | 275 | if (rc) { |
275 | cifs_dbg(VFS, "%s: Could not update with label\n", __func__); | 276 | cifs_server_dbg(VFS, "%s: Could not update with label\n", __func__); |
276 | goto smb3signkey_ret; | 277 | goto smb3signkey_ret; |
277 | } | 278 | } |
278 | 279 | ||
279 | rc = crypto_shash_update(&ses->server->secmech.sdeschmacsha256->shash, | 280 | rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash, |
280 | &zero, 1); | 281 | &zero, 1); |
281 | if (rc) { | 282 | if (rc) { |
282 | cifs_dbg(VFS, "%s: Could not update with zero\n", __func__); | 283 | cifs_server_dbg(VFS, "%s: Could not update with zero\n", __func__); |
283 | goto smb3signkey_ret; | 284 | goto smb3signkey_ret; |
284 | } | 285 | } |
285 | 286 | ||
286 | rc = crypto_shash_update(&ses->server->secmech.sdeschmacsha256->shash, | 287 | rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash, |
287 | context.iov_base, context.iov_len); | 288 | context.iov_base, context.iov_len); |
288 | if (rc) { | 289 | if (rc) { |
289 | cifs_dbg(VFS, "%s: Could not update with context\n", __func__); | 290 | cifs_server_dbg(VFS, "%s: Could not update with context\n", __func__); |
290 | goto smb3signkey_ret; | 291 | goto smb3signkey_ret; |
291 | } | 292 | } |
292 | 293 | ||
293 | rc = crypto_shash_update(&ses->server->secmech.sdeschmacsha256->shash, | 294 | rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash, |
294 | L, 4); | 295 | L, 4); |
295 | if (rc) { | 296 | if (rc) { |
296 | cifs_dbg(VFS, "%s: Could not update with L\n", __func__); | 297 | cifs_server_dbg(VFS, "%s: Could not update with L\n", __func__); |
297 | goto smb3signkey_ret; | 298 | goto smb3signkey_ret; |
298 | } | 299 | } |
299 | 300 | ||
300 | rc = crypto_shash_final(&ses->server->secmech.sdeschmacsha256->shash, | 301 | rc = crypto_shash_final(&server->secmech.sdeschmacsha256->shash, |
301 | hashptr); | 302 | hashptr); |
302 | if (rc) { | 303 | if (rc) { |
303 | cifs_dbg(VFS, "%s: Could not generate sha256 hash\n", __func__); | 304 | cifs_server_dbg(VFS, "%s: Could not generate sha256 hash\n", __func__); |
304 | goto smb3signkey_ret; | 305 | goto smb3signkey_ret; |
305 | } | 306 | } |
306 | 307 | ||
@@ -436,7 +437,7 @@ smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) | |||
436 | 437 | ||
437 | ses = smb2_find_smb_ses(server, shdr->SessionId); | 438 | ses = smb2_find_smb_ses(server, shdr->SessionId); |
438 | if (!ses) { | 439 | if (!ses) { |
439 | cifs_dbg(VFS, "%s: Could not find session\n", __func__); | 440 | cifs_server_dbg(VFS, "%s: Could not find session\n", __func__); |
440 | return 0; | 441 | return 0; |
441 | } | 442 | } |
442 | 443 | ||
@@ -446,7 +447,7 @@ smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) | |||
446 | rc = crypto_shash_setkey(server->secmech.cmacaes, | 447 | rc = crypto_shash_setkey(server->secmech.cmacaes, |
447 | ses->smb3signingkey, SMB2_CMACAES_SIZE); | 448 | ses->smb3signingkey, SMB2_CMACAES_SIZE); |
448 | if (rc) { | 449 | if (rc) { |
449 | cifs_dbg(VFS, "%s: Could not set key for cmac aes\n", __func__); | 450 | cifs_server_dbg(VFS, "%s: Could not set key for cmac aes\n", __func__); |
450 | return rc; | 451 | return rc; |
451 | } | 452 | } |
452 | 453 | ||
@@ -457,7 +458,7 @@ smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) | |||
457 | */ | 458 | */ |
458 | rc = crypto_shash_init(shash); | 459 | rc = crypto_shash_init(shash); |
459 | if (rc) { | 460 | if (rc) { |
460 | cifs_dbg(VFS, "%s: Could not init cmac aes\n", __func__); | 461 | cifs_server_dbg(VFS, "%s: Could not init cmac aes\n", __func__); |
461 | return rc; | 462 | return rc; |
462 | } | 463 | } |
463 | 464 | ||
@@ -473,7 +474,7 @@ smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) | |||
473 | rc = crypto_shash_update(shash, iov[0].iov_base, | 474 | rc = crypto_shash_update(shash, iov[0].iov_base, |
474 | iov[0].iov_len); | 475 | iov[0].iov_len); |
475 | if (rc) { | 476 | if (rc) { |
476 | cifs_dbg(VFS, "%s: Could not update with payload\n", | 477 | cifs_server_dbg(VFS, "%s: Could not update with payload\n", |
477 | __func__); | 478 | __func__); |
478 | return rc; | 479 | return rc; |
479 | } | 480 | } |
@@ -665,7 +666,7 @@ smb2_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server, | |||
665 | 666 | ||
666 | rc = smb2_verify_signature(&rqst, server); | 667 | rc = smb2_verify_signature(&rqst, server); |
667 | if (rc) | 668 | if (rc) |
668 | cifs_dbg(VFS, "SMB signature verification returned error = %d\n", | 669 | cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n", |
669 | rc); | 670 | rc); |
670 | } | 671 | } |
671 | 672 | ||
@@ -739,7 +740,7 @@ smb3_crypto_aead_allocate(struct TCP_Server_Info *server) | |||
739 | else | 740 | else |
740 | tfm = crypto_alloc_aead("ccm(aes)", 0, 0); | 741 | tfm = crypto_alloc_aead("ccm(aes)", 0, 0); |
741 | if (IS_ERR(tfm)) { | 742 | if (IS_ERR(tfm)) { |
742 | cifs_dbg(VFS, "%s: Failed to alloc encrypt aead\n", | 743 | cifs_server_dbg(VFS, "%s: Failed to alloc encrypt aead\n", |
743 | __func__); | 744 | __func__); |
744 | return PTR_ERR(tfm); | 745 | return PTR_ERR(tfm); |
745 | } | 746 | } |
@@ -754,7 +755,7 @@ smb3_crypto_aead_allocate(struct TCP_Server_Info *server) | |||
754 | if (IS_ERR(tfm)) { | 755 | if (IS_ERR(tfm)) { |
755 | crypto_free_aead(server->secmech.ccmaesencrypt); | 756 | crypto_free_aead(server->secmech.ccmaesencrypt); |
756 | server->secmech.ccmaesencrypt = NULL; | 757 | server->secmech.ccmaesencrypt = NULL; |
757 | cifs_dbg(VFS, "%s: Failed to alloc decrypt aead\n", | 758 | cifs_server_dbg(VFS, "%s: Failed to alloc decrypt aead\n", |
758 | __func__); | 759 | __func__); |
759 | return PTR_ERR(tfm); | 760 | return PTR_ERR(tfm); |
760 | } | 761 | } |
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index 5d6d44bfe10a..0d60bd2f4dca 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c | |||
@@ -118,7 +118,7 @@ DeleteMidQEntry(struct mid_q_entry *midEntry) | |||
118 | #ifdef CONFIG_CIFS_STATS2 | 118 | #ifdef CONFIG_CIFS_STATS2 |
119 | now = jiffies; | 119 | now = jiffies; |
120 | if (now < midEntry->when_alloc) | 120 | if (now < midEntry->when_alloc) |
121 | cifs_dbg(VFS, "invalid mid allocation time\n"); | 121 | cifs_server_dbg(VFS, "invalid mid allocation time\n"); |
122 | roundtrip_time = now - midEntry->when_alloc; | 122 | roundtrip_time = now - midEntry->when_alloc; |
123 | 123 | ||
124 | if (smb_cmd < NUMBER_OF_SMB2_COMMANDS) { | 124 | if (smb_cmd < NUMBER_OF_SMB2_COMMANDS) { |
@@ -232,7 +232,7 @@ smb_send_kvec(struct TCP_Server_Info *server, struct msghdr *smb_msg, | |||
232 | retries++; | 232 | retries++; |
233 | if (retries >= 14 || | 233 | if (retries >= 14 || |
234 | (!server->noblocksnd && (retries > 2))) { | 234 | (!server->noblocksnd && (retries > 2))) { |
235 | cifs_dbg(VFS, "sends on sock %p stuck for 15 seconds\n", | 235 | cifs_server_dbg(VFS, "sends on sock %p stuck for 15 seconds\n", |
236 | ssocket); | 236 | ssocket); |
237 | return -EAGAIN; | 237 | return -EAGAIN; |
238 | } | 238 | } |
@@ -246,7 +246,7 @@ smb_send_kvec(struct TCP_Server_Info *server, struct msghdr *smb_msg, | |||
246 | if (rc == 0) { | 246 | if (rc == 0) { |
247 | /* should never happen, letting socket clear before | 247 | /* should never happen, letting socket clear before |
248 | retrying is our only obvious option here */ | 248 | retrying is our only obvious option here */ |
249 | cifs_dbg(VFS, "tcp sent no data\n"); | 249 | cifs_server_dbg(VFS, "tcp sent no data\n"); |
250 | msleep(500); | 250 | msleep(500); |
251 | continue; | 251 | continue; |
252 | } | 252 | } |
@@ -440,7 +440,7 @@ unmask: | |||
440 | } | 440 | } |
441 | smbd_done: | 441 | smbd_done: |
442 | if (rc < 0 && rc != -EINTR) | 442 | if (rc < 0 && rc != -EINTR) |
443 | cifs_dbg(VFS, "Error %d sending data on socket to server\n", | 443 | cifs_server_dbg(VFS, "Error %d sending data on socket to server\n", |
444 | rc); | 444 | rc); |
445 | else if (rc > 0) | 445 | else if (rc > 0) |
446 | rc = 0; | 446 | rc = 0; |
@@ -473,8 +473,8 @@ smb_send_rqst(struct TCP_Server_Info *server, int num_rqst, | |||
473 | cur_rqst[0].rq_nvec = 1; | 473 | cur_rqst[0].rq_nvec = 1; |
474 | 474 | ||
475 | if (!server->ops->init_transform_rq) { | 475 | if (!server->ops->init_transform_rq) { |
476 | cifs_dbg(VFS, "Encryption requested but transform callback " | 476 | cifs_server_dbg(VFS, "Encryption requested but transform " |
477 | "is missing\n"); | 477 | "callback is missing\n"); |
478 | return -EIO; | 478 | return -EIO; |
479 | } | 479 | } |
480 | 480 | ||
@@ -548,7 +548,7 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int num_credits, | |||
548 | if (!rc) { | 548 | if (!rc) { |
549 | trace_smb3_credit_timeout(server->CurrentMid, | 549 | trace_smb3_credit_timeout(server->CurrentMid, |
550 | server->hostname, num_credits); | 550 | server->hostname, num_credits); |
551 | cifs_dbg(VFS, "wait timed out after %d ms\n", | 551 | cifs_server_dbg(VFS, "wait timed out after %d ms\n", |
552 | timeout); | 552 | timeout); |
553 | return -ENOTSUPP; | 553 | return -ENOTSUPP; |
554 | } | 554 | } |
@@ -589,7 +589,7 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int num_credits, | |||
589 | trace_smb3_credit_timeout( | 589 | trace_smb3_credit_timeout( |
590 | server->CurrentMid, | 590 | server->CurrentMid, |
591 | server->hostname, num_credits); | 591 | server->hostname, num_credits); |
592 | cifs_dbg(VFS, "wait timed out after %d ms\n", | 592 | cifs_server_dbg(VFS, "wait timed out after %d ms\n", |
593 | timeout); | 593 | timeout); |
594 | return -ENOTSUPP; | 594 | return -ENOTSUPP; |
595 | } | 595 | } |
@@ -869,7 +869,7 @@ cifs_sync_mid_result(struct mid_q_entry *mid, struct TCP_Server_Info *server) | |||
869 | break; | 869 | break; |
870 | default: | 870 | default: |
871 | list_del_init(&mid->qhead); | 871 | list_del_init(&mid->qhead); |
872 | cifs_dbg(VFS, "%s: invalid mid state mid=%llu state=%d\n", | 872 | cifs_server_dbg(VFS, "%s: invalid mid state mid=%llu state=%d\n", |
873 | __func__, mid->mid, mid->mid_state); | 873 | __func__, mid->mid, mid->mid_state); |
874 | rc = -EIO; | 874 | rc = -EIO; |
875 | } | 875 | } |
@@ -910,7 +910,7 @@ cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server, | |||
910 | rc = cifs_verify_signature(&rqst, server, | 910 | rc = cifs_verify_signature(&rqst, server, |
911 | mid->sequence_number); | 911 | mid->sequence_number); |
912 | if (rc) | 912 | if (rc) |
913 | cifs_dbg(VFS, "SMB signature verification returned error = %d\n", | 913 | cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n", |
914 | rc); | 914 | rc); |
915 | } | 915 | } |
916 | 916 | ||
@@ -1107,7 +1107,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, | |||
1107 | } | 1107 | } |
1108 | if (rc != 0) { | 1108 | if (rc != 0) { |
1109 | for (; i < num_rqst; i++) { | 1109 | for (; i < num_rqst; i++) { |
1110 | cifs_dbg(VFS, "Cancelling wait for mid %llu cmd: %d\n", | 1110 | cifs_server_dbg(VFS, "Cancelling wait for mid %llu cmd: %d\n", |
1111 | midQ[i]->mid, le16_to_cpu(midQ[i]->command)); | 1111 | midQ[i]->mid, le16_to_cpu(midQ[i]->command)); |
1112 | send_cancel(server, &rqst[i], midQ[i]); | 1112 | send_cancel(server, &rqst[i], midQ[i]); |
1113 | spin_lock(&GlobalMid_Lock); | 1113 | spin_lock(&GlobalMid_Lock); |
@@ -1242,17 +1242,18 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses, | |||
1242 | struct kvec iov = { .iov_base = in_buf, .iov_len = len }; | 1242 | struct kvec iov = { .iov_base = in_buf, .iov_len = len }; |
1243 | struct smb_rqst rqst = { .rq_iov = &iov, .rq_nvec = 1 }; | 1243 | struct smb_rqst rqst = { .rq_iov = &iov, .rq_nvec = 1 }; |
1244 | struct cifs_credits credits = { .value = 1, .instance = 0 }; | 1244 | struct cifs_credits credits = { .value = 1, .instance = 0 }; |
1245 | struct TCP_Server_Info *server = ses->server; | ||
1245 | 1246 | ||
1246 | if (ses == NULL) { | 1247 | if (ses == NULL) { |
1247 | cifs_dbg(VFS, "Null smb session\n"); | 1248 | cifs_dbg(VFS, "Null smb session\n"); |
1248 | return -EIO; | 1249 | return -EIO; |
1249 | } | 1250 | } |
1250 | if (ses->server == NULL) { | 1251 | if (server == NULL) { |
1251 | cifs_dbg(VFS, "Null tcp session\n"); | 1252 | cifs_dbg(VFS, "Null tcp session\n"); |
1252 | return -EIO; | 1253 | return -EIO; |
1253 | } | 1254 | } |
1254 | 1255 | ||
1255 | if (ses->server->tcpStatus == CifsExiting) | 1256 | if (server->tcpStatus == CifsExiting) |
1256 | return -ENOENT; | 1257 | return -ENOENT; |
1257 | 1258 | ||
1258 | /* Ensure that we do not send more than 50 overlapping requests | 1259 | /* Ensure that we do not send more than 50 overlapping requests |
@@ -1260,12 +1261,12 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses, | |||
1260 | use ses->maxReq */ | 1261 | use ses->maxReq */ |
1261 | 1262 | ||
1262 | if (len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) { | 1263 | if (len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) { |
1263 | cifs_dbg(VFS, "Illegal length, greater than maximum frame, %d\n", | 1264 | cifs_server_dbg(VFS, "Illegal length, greater than maximum frame, %d\n", |
1264 | len); | 1265 | len); |
1265 | return -EIO; | 1266 | return -EIO; |
1266 | } | 1267 | } |
1267 | 1268 | ||
1268 | rc = wait_for_free_request(ses->server, flags, &credits.instance); | 1269 | rc = wait_for_free_request(server, flags, &credits.instance); |
1269 | if (rc) | 1270 | if (rc) |
1270 | return rc; | 1271 | return rc; |
1271 | 1272 | ||
@@ -1273,70 +1274,70 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses, | |||
1273 | and avoid races inside tcp sendmsg code that could cause corruption | 1274 | and avoid races inside tcp sendmsg code that could cause corruption |
1274 | of smb data */ | 1275 | of smb data */ |
1275 | 1276 | ||
1276 | mutex_lock(&ses->server->srv_mutex); | 1277 | mutex_lock(&server->srv_mutex); |
1277 | 1278 | ||
1278 | rc = allocate_mid(ses, in_buf, &midQ); | 1279 | rc = allocate_mid(ses, in_buf, &midQ); |
1279 | if (rc) { | 1280 | if (rc) { |
1280 | mutex_unlock(&ses->server->srv_mutex); | 1281 | mutex_unlock(&ses->server->srv_mutex); |
1281 | /* Update # of requests on wire to server */ | 1282 | /* Update # of requests on wire to server */ |
1282 | add_credits(ses->server, &credits, 0); | 1283 | add_credits(server, &credits, 0); |
1283 | return rc; | 1284 | return rc; |
1284 | } | 1285 | } |
1285 | 1286 | ||
1286 | rc = cifs_sign_smb(in_buf, ses->server, &midQ->sequence_number); | 1287 | rc = cifs_sign_smb(in_buf, server, &midQ->sequence_number); |
1287 | if (rc) { | 1288 | if (rc) { |
1288 | mutex_unlock(&ses->server->srv_mutex); | 1289 | mutex_unlock(&server->srv_mutex); |
1289 | goto out; | 1290 | goto out; |
1290 | } | 1291 | } |
1291 | 1292 | ||
1292 | midQ->mid_state = MID_REQUEST_SUBMITTED; | 1293 | midQ->mid_state = MID_REQUEST_SUBMITTED; |
1293 | 1294 | ||
1294 | cifs_in_send_inc(ses->server); | 1295 | cifs_in_send_inc(server); |
1295 | rc = smb_send(ses->server, in_buf, len); | 1296 | rc = smb_send(server, in_buf, len); |
1296 | cifs_in_send_dec(ses->server); | 1297 | cifs_in_send_dec(server); |
1297 | cifs_save_when_sent(midQ); | 1298 | cifs_save_when_sent(midQ); |
1298 | 1299 | ||
1299 | if (rc < 0) | 1300 | if (rc < 0) |
1300 | ses->server->sequence_number -= 2; | 1301 | server->sequence_number -= 2; |
1301 | 1302 | ||
1302 | mutex_unlock(&ses->server->srv_mutex); | 1303 | mutex_unlock(&server->srv_mutex); |
1303 | 1304 | ||
1304 | if (rc < 0) | 1305 | if (rc < 0) |
1305 | goto out; | 1306 | goto out; |
1306 | 1307 | ||
1307 | rc = wait_for_response(ses->server, midQ); | 1308 | rc = wait_for_response(server, midQ); |
1308 | if (rc != 0) { | 1309 | if (rc != 0) { |
1309 | send_cancel(ses->server, &rqst, midQ); | 1310 | send_cancel(server, &rqst, midQ); |
1310 | spin_lock(&GlobalMid_Lock); | 1311 | spin_lock(&GlobalMid_Lock); |
1311 | if (midQ->mid_state == MID_REQUEST_SUBMITTED) { | 1312 | if (midQ->mid_state == MID_REQUEST_SUBMITTED) { |
1312 | /* no longer considered to be "in-flight" */ | 1313 | /* no longer considered to be "in-flight" */ |
1313 | midQ->callback = DeleteMidQEntry; | 1314 | midQ->callback = DeleteMidQEntry; |
1314 | spin_unlock(&GlobalMid_Lock); | 1315 | spin_unlock(&GlobalMid_Lock); |
1315 | add_credits(ses->server, &credits, 0); | 1316 | add_credits(server, &credits, 0); |
1316 | return rc; | 1317 | return rc; |
1317 | } | 1318 | } |
1318 | spin_unlock(&GlobalMid_Lock); | 1319 | spin_unlock(&GlobalMid_Lock); |
1319 | } | 1320 | } |
1320 | 1321 | ||
1321 | rc = cifs_sync_mid_result(midQ, ses->server); | 1322 | rc = cifs_sync_mid_result(midQ, server); |
1322 | if (rc != 0) { | 1323 | if (rc != 0) { |
1323 | add_credits(ses->server, &credits, 0); | 1324 | add_credits(server, &credits, 0); |
1324 | return rc; | 1325 | return rc; |
1325 | } | 1326 | } |
1326 | 1327 | ||
1327 | if (!midQ->resp_buf || !out_buf || | 1328 | if (!midQ->resp_buf || !out_buf || |
1328 | midQ->mid_state != MID_RESPONSE_RECEIVED) { | 1329 | midQ->mid_state != MID_RESPONSE_RECEIVED) { |
1329 | rc = -EIO; | 1330 | rc = -EIO; |
1330 | cifs_dbg(VFS, "Bad MID state?\n"); | 1331 | cifs_server_dbg(VFS, "Bad MID state?\n"); |
1331 | goto out; | 1332 | goto out; |
1332 | } | 1333 | } |
1333 | 1334 | ||
1334 | *pbytes_returned = get_rfc1002_length(midQ->resp_buf); | 1335 | *pbytes_returned = get_rfc1002_length(midQ->resp_buf); |
1335 | memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4); | 1336 | memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4); |
1336 | rc = cifs_check_receive(midQ, ses->server, 0); | 1337 | rc = cifs_check_receive(midQ, server, 0); |
1337 | out: | 1338 | out: |
1338 | cifs_delete_mid(midQ); | 1339 | cifs_delete_mid(midQ); |
1339 | add_credits(ses->server, &credits, 0); | 1340 | add_credits(server, &credits, 0); |
1340 | 1341 | ||
1341 | return rc; | 1342 | return rc; |
1342 | } | 1343 | } |
@@ -1379,19 +1380,21 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, | |||
1379 | struct kvec iov = { .iov_base = in_buf, .iov_len = len }; | 1380 | struct kvec iov = { .iov_base = in_buf, .iov_len = len }; |
1380 | struct smb_rqst rqst = { .rq_iov = &iov, .rq_nvec = 1 }; | 1381 | struct smb_rqst rqst = { .rq_iov = &iov, .rq_nvec = 1 }; |
1381 | unsigned int instance; | 1382 | unsigned int instance; |
1383 | struct TCP_Server_Info *server; | ||
1382 | 1384 | ||
1383 | if (tcon == NULL || tcon->ses == NULL) { | 1385 | if (tcon == NULL || tcon->ses == NULL) { |
1384 | cifs_dbg(VFS, "Null smb session\n"); | 1386 | cifs_dbg(VFS, "Null smb session\n"); |
1385 | return -EIO; | 1387 | return -EIO; |
1386 | } | 1388 | } |
1387 | ses = tcon->ses; | 1389 | ses = tcon->ses; |
1390 | server = ses->server; | ||
1388 | 1391 | ||
1389 | if (ses->server == NULL) { | 1392 | if (server == NULL) { |
1390 | cifs_dbg(VFS, "Null tcp session\n"); | 1393 | cifs_dbg(VFS, "Null tcp session\n"); |
1391 | return -EIO; | 1394 | return -EIO; |
1392 | } | 1395 | } |
1393 | 1396 | ||
1394 | if (ses->server->tcpStatus == CifsExiting) | 1397 | if (server->tcpStatus == CifsExiting) |
1395 | return -ENOENT; | 1398 | return -ENOENT; |
1396 | 1399 | ||
1397 | /* Ensure that we do not send more than 50 overlapping requests | 1400 | /* Ensure that we do not send more than 50 overlapping requests |
@@ -1399,12 +1402,12 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, | |||
1399 | use ses->maxReq */ | 1402 | use ses->maxReq */ |
1400 | 1403 | ||
1401 | if (len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) { | 1404 | if (len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) { |
1402 | cifs_dbg(VFS, "Illegal length, greater than maximum frame, %d\n", | 1405 | cifs_server_dbg(VFS, "Illegal length, greater than maximum frame, %d\n", |
1403 | len); | 1406 | len); |
1404 | return -EIO; | 1407 | return -EIO; |
1405 | } | 1408 | } |
1406 | 1409 | ||
1407 | rc = wait_for_free_request(ses->server, CIFS_BLOCKING_OP, &instance); | 1410 | rc = wait_for_free_request(server, CIFS_BLOCKING_OP, &instance); |
1408 | if (rc) | 1411 | if (rc) |
1409 | return rc; | 1412 | return rc; |
1410 | 1413 | ||
@@ -1412,31 +1415,31 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, | |||
1412 | and avoid races inside tcp sendmsg code that could cause corruption | 1415 | and avoid races inside tcp sendmsg code that could cause corruption |
1413 | of smb data */ | 1416 | of smb data */ |
1414 | 1417 | ||
1415 | mutex_lock(&ses->server->srv_mutex); | 1418 | mutex_lock(&server->srv_mutex); |
1416 | 1419 | ||
1417 | rc = allocate_mid(ses, in_buf, &midQ); | 1420 | rc = allocate_mid(ses, in_buf, &midQ); |
1418 | if (rc) { | 1421 | if (rc) { |
1419 | mutex_unlock(&ses->server->srv_mutex); | 1422 | mutex_unlock(&server->srv_mutex); |
1420 | return rc; | 1423 | return rc; |
1421 | } | 1424 | } |
1422 | 1425 | ||
1423 | rc = cifs_sign_smb(in_buf, ses->server, &midQ->sequence_number); | 1426 | rc = cifs_sign_smb(in_buf, server, &midQ->sequence_number); |
1424 | if (rc) { | 1427 | if (rc) { |
1425 | cifs_delete_mid(midQ); | 1428 | cifs_delete_mid(midQ); |
1426 | mutex_unlock(&ses->server->srv_mutex); | 1429 | mutex_unlock(&server->srv_mutex); |
1427 | return rc; | 1430 | return rc; |
1428 | } | 1431 | } |
1429 | 1432 | ||
1430 | midQ->mid_state = MID_REQUEST_SUBMITTED; | 1433 | midQ->mid_state = MID_REQUEST_SUBMITTED; |
1431 | cifs_in_send_inc(ses->server); | 1434 | cifs_in_send_inc(server); |
1432 | rc = smb_send(ses->server, in_buf, len); | 1435 | rc = smb_send(server, in_buf, len); |
1433 | cifs_in_send_dec(ses->server); | 1436 | cifs_in_send_dec(server); |
1434 | cifs_save_when_sent(midQ); | 1437 | cifs_save_when_sent(midQ); |
1435 | 1438 | ||
1436 | if (rc < 0) | 1439 | if (rc < 0) |
1437 | ses->server->sequence_number -= 2; | 1440 | server->sequence_number -= 2; |
1438 | 1441 | ||
1439 | mutex_unlock(&ses->server->srv_mutex); | 1442 | mutex_unlock(&server->srv_mutex); |
1440 | 1443 | ||
1441 | if (rc < 0) { | 1444 | if (rc < 0) { |
1442 | cifs_delete_mid(midQ); | 1445 | cifs_delete_mid(midQ); |
@@ -1444,21 +1447,21 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, | |||
1444 | } | 1447 | } |
1445 | 1448 | ||
1446 | /* Wait for a reply - allow signals to interrupt. */ | 1449 | /* Wait for a reply - allow signals to interrupt. */ |
1447 | rc = wait_event_interruptible(ses->server->response_q, | 1450 | rc = wait_event_interruptible(server->response_q, |
1448 | (!(midQ->mid_state == MID_REQUEST_SUBMITTED)) || | 1451 | (!(midQ->mid_state == MID_REQUEST_SUBMITTED)) || |
1449 | ((ses->server->tcpStatus != CifsGood) && | 1452 | ((server->tcpStatus != CifsGood) && |
1450 | (ses->server->tcpStatus != CifsNew))); | 1453 | (server->tcpStatus != CifsNew))); |
1451 | 1454 | ||
1452 | /* Were we interrupted by a signal ? */ | 1455 | /* Were we interrupted by a signal ? */ |
1453 | if ((rc == -ERESTARTSYS) && | 1456 | if ((rc == -ERESTARTSYS) && |
1454 | (midQ->mid_state == MID_REQUEST_SUBMITTED) && | 1457 | (midQ->mid_state == MID_REQUEST_SUBMITTED) && |
1455 | ((ses->server->tcpStatus == CifsGood) || | 1458 | ((server->tcpStatus == CifsGood) || |
1456 | (ses->server->tcpStatus == CifsNew))) { | 1459 | (server->tcpStatus == CifsNew))) { |
1457 | 1460 | ||
1458 | if (in_buf->Command == SMB_COM_TRANSACTION2) { | 1461 | if (in_buf->Command == SMB_COM_TRANSACTION2) { |
1459 | /* POSIX lock. We send a NT_CANCEL SMB to cause the | 1462 | /* POSIX lock. We send a NT_CANCEL SMB to cause the |
1460 | blocking lock to return. */ | 1463 | blocking lock to return. */ |
1461 | rc = send_cancel(ses->server, &rqst, midQ); | 1464 | rc = send_cancel(server, &rqst, midQ); |
1462 | if (rc) { | 1465 | if (rc) { |
1463 | cifs_delete_mid(midQ); | 1466 | cifs_delete_mid(midQ); |
1464 | return rc; | 1467 | return rc; |
@@ -1477,9 +1480,9 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, | |||
1477 | } | 1480 | } |
1478 | } | 1481 | } |
1479 | 1482 | ||
1480 | rc = wait_for_response(ses->server, midQ); | 1483 | rc = wait_for_response(server, midQ); |
1481 | if (rc) { | 1484 | if (rc) { |
1482 | send_cancel(ses->server, &rqst, midQ); | 1485 | send_cancel(server, &rqst, midQ); |
1483 | spin_lock(&GlobalMid_Lock); | 1486 | spin_lock(&GlobalMid_Lock); |
1484 | if (midQ->mid_state == MID_REQUEST_SUBMITTED) { | 1487 | if (midQ->mid_state == MID_REQUEST_SUBMITTED) { |
1485 | /* no longer considered to be "in-flight" */ | 1488 | /* no longer considered to be "in-flight" */ |
@@ -1494,20 +1497,20 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, | |||
1494 | rstart = 1; | 1497 | rstart = 1; |
1495 | } | 1498 | } |
1496 | 1499 | ||
1497 | rc = cifs_sync_mid_result(midQ, ses->server); | 1500 | rc = cifs_sync_mid_result(midQ, server); |
1498 | if (rc != 0) | 1501 | if (rc != 0) |
1499 | return rc; | 1502 | return rc; |
1500 | 1503 | ||
1501 | /* rcvd frame is ok */ | 1504 | /* rcvd frame is ok */ |
1502 | if (out_buf == NULL || midQ->mid_state != MID_RESPONSE_RECEIVED) { | 1505 | if (out_buf == NULL || midQ->mid_state != MID_RESPONSE_RECEIVED) { |
1503 | rc = -EIO; | 1506 | rc = -EIO; |
1504 | cifs_dbg(VFS, "Bad MID state?\n"); | 1507 | cifs_server_dbg(VFS, "Bad MID state?\n"); |
1505 | goto out; | 1508 | goto out; |
1506 | } | 1509 | } |
1507 | 1510 | ||
1508 | *pbytes_returned = get_rfc1002_length(midQ->resp_buf); | 1511 | *pbytes_returned = get_rfc1002_length(midQ->resp_buf); |
1509 | memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4); | 1512 | memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4); |
1510 | rc = cifs_check_receive(midQ, ses->server, 0); | 1513 | rc = cifs_check_receive(midQ, server, 0); |
1511 | out: | 1514 | out: |
1512 | cifs_delete_mid(midQ); | 1515 | cifs_delete_mid(midQ); |
1513 | if (rstart && rc == -EACCES) | 1516 | if (rstart && rc == -EACCES) |