aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/cifs/cifs_debug.c6
-rw-r--r--fs/cifs/cifs_debug.h4
-rw-r--r--fs/cifs/cifsglob.h6
-rw-r--r--fs/cifs/connect.c27
-rw-r--r--fs/cifs/smb1ops.c23
5 files changed, 39 insertions, 27 deletions
diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
index 8aae8e28038c..e8140528ca5c 100644
--- a/fs/cifs/cifs_debug.c
+++ b/fs/cifs/cifs_debug.c
@@ -57,19 +57,21 @@ cifs_dump_mem(char *label, void *data, int length)
57 } 57 }
58} 58}
59 59
60#ifdef CONFIG_CIFS_DEBUG2
61void cifs_dump_detail(void *buf) 60void cifs_dump_detail(void *buf)
62{ 61{
62#ifdef CONFIG_CIFS_DEBUG2
63 struct smb_hdr *smb = (struct smb_hdr *)buf; 63 struct smb_hdr *smb = (struct smb_hdr *)buf;
64 64
65 cERROR(1, "Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d", 65 cERROR(1, "Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d",
66 smb->Command, smb->Status.CifsError, 66 smb->Command, smb->Status.CifsError,
67 smb->Flags, smb->Flags2, smb->Mid, smb->Pid); 67 smb->Flags, smb->Flags2, smb->Mid, smb->Pid);
68 cERROR(1, "smb buf %p len %d", smb, smbCalcSize(smb)); 68 cERROR(1, "smb buf %p len %d", smb, smbCalcSize(smb));
69#endif /* CONFIG_CIFS_DEBUG2 */
69} 70}
70 71
71void cifs_dump_mids(struct TCP_Server_Info *server) 72void cifs_dump_mids(struct TCP_Server_Info *server)
72{ 73{
74#ifdef CONFIG_CIFS_DEBUG2
73 struct list_head *tmp; 75 struct list_head *tmp;
74 struct mid_q_entry *mid_entry; 76 struct mid_q_entry *mid_entry;
75 77
@@ -102,8 +104,8 @@ void cifs_dump_mids(struct TCP_Server_Info *server)
102 } 104 }
103 } 105 }
104 spin_unlock(&GlobalMid_Lock); 106 spin_unlock(&GlobalMid_Lock);
105}
106#endif /* CONFIG_CIFS_DEBUG2 */ 107#endif /* CONFIG_CIFS_DEBUG2 */
108}
107 109
108#ifdef CONFIG_PROC_FS 110#ifdef CONFIG_PROC_FS
109static int cifs_debug_data_proc_show(struct seq_file *m, void *v) 111static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
diff --git a/fs/cifs/cifs_debug.h b/fs/cifs/cifs_debug.h
index 566e0ae8dc2c..c0c68bb492d7 100644
--- a/fs/cifs/cifs_debug.h
+++ b/fs/cifs/cifs_debug.h
@@ -24,10 +24,10 @@
24#define _H_CIFS_DEBUG 24#define _H_CIFS_DEBUG
25 25
26void cifs_dump_mem(char *label, void *data, int length); 26void cifs_dump_mem(char *label, void *data, int length);
27#ifdef CONFIG_CIFS_DEBUG2
28#define DBG2 2
29void cifs_dump_detail(void *); 27void cifs_dump_detail(void *);
30void cifs_dump_mids(struct TCP_Server_Info *); 28void cifs_dump_mids(struct TCP_Server_Info *);
29#ifdef CONFIG_CIFS_DEBUG2
30#define DBG2 2
31#else 31#else
32#define DBG2 0 32#define DBG2 0
33#endif 33#endif
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 825140170b1e..1001924f594a 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -175,6 +175,12 @@ struct smb_version_operations {
175 unsigned int (*read_data_length)(char *); 175 unsigned int (*read_data_length)(char *);
176 /* map smb to linux error */ 176 /* map smb to linux error */
177 int (*map_error)(char *, bool); 177 int (*map_error)(char *, bool);
178 /* find mid corresponding to the response message */
179 struct mid_q_entry * (*find_mid)(struct TCP_Server_Info *, char *);
180 void (*dump_detail)(void *);
181 /* verify the message */
182 int (*check_message)(char *, unsigned int);
183 bool (*is_oplock_break)(char *, struct TCP_Server_Info *);
178}; 184};
179 185
180struct smb_version_values { 186struct smb_version_values {
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 65ec6ef0995e..ce033d74f315 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -783,25 +783,6 @@ is_smb_response(struct TCP_Server_Info *server, unsigned char type)
783 return false; 783 return false;
784} 784}
785 785
786static struct mid_q_entry *
787find_mid(struct TCP_Server_Info *server, char *buffer)
788{
789 struct smb_hdr *buf = (struct smb_hdr *)buffer;
790 struct mid_q_entry *mid;
791
792 spin_lock(&GlobalMid_Lock);
793 list_for_each_entry(mid, &server->pending_mid_q, qhead) {
794 if (mid->mid == buf->Mid &&
795 mid->mid_state == MID_REQUEST_SUBMITTED &&
796 le16_to_cpu(mid->command) == buf->Command) {
797 spin_unlock(&GlobalMid_Lock);
798 return mid;
799 }
800 }
801 spin_unlock(&GlobalMid_Lock);
802 return NULL;
803}
804
805void 786void
806dequeue_mid(struct mid_q_entry *mid, bool malformed) 787dequeue_mid(struct mid_q_entry *mid, bool malformed)
807{ 788{
@@ -986,7 +967,7 @@ standard_receive3(struct TCP_Server_Info *server, struct mid_q_entry *mid)
986 * 48 bytes is enough to display the header and a little bit 967 * 48 bytes is enough to display the header and a little bit
987 * into the payload for debugging purposes. 968 * into the payload for debugging purposes.
988 */ 969 */
989 length = checkSMB(buf, server->total_read); 970 length = server->ops->check_message(buf, server->total_read);
990 if (length != 0) 971 if (length != 0)
991 cifs_dump_mem("Bad SMB: ", buf, 972 cifs_dump_mem("Bad SMB: ", buf,
992 min_t(unsigned int, server->total_read, 48)); 973 min_t(unsigned int, server->total_read, 48));
@@ -1059,7 +1040,7 @@ cifs_demultiplex_thread(void *p)
1059 continue; 1040 continue;
1060 server->total_read += length; 1041 server->total_read += length;
1061 1042
1062 mid_entry = find_mid(server, buf); 1043 mid_entry = server->ops->find_mid(server, buf);
1063 1044
1064 if (!mid_entry || !mid_entry->receive) 1045 if (!mid_entry || !mid_entry->receive)
1065 length = standard_receive3(server, mid_entry); 1046 length = standard_receive3(server, mid_entry);
@@ -1076,13 +1057,13 @@ cifs_demultiplex_thread(void *p)
1076 if (mid_entry != NULL) { 1057 if (mid_entry != NULL) {
1077 if (!mid_entry->multiRsp || mid_entry->multiEnd) 1058 if (!mid_entry->multiRsp || mid_entry->multiEnd)
1078 mid_entry->callback(mid_entry); 1059 mid_entry->callback(mid_entry);
1079 } else if (!is_valid_oplock_break(buf, server)) { 1060 } else if (!server->ops->is_oplock_break(buf, server)) {
1080 cERROR(1, "No task to wake, unknown frame received! " 1061 cERROR(1, "No task to wake, unknown frame received! "
1081 "NumMids %d", atomic_read(&midCount)); 1062 "NumMids %d", atomic_read(&midCount));
1082 cifs_dump_mem("Received Data is: ", buf, 1063 cifs_dump_mem("Received Data is: ", buf,
1083 HEADER_SIZE(server)); 1064 HEADER_SIZE(server));
1084#ifdef CONFIG_CIFS_DEBUG2 1065#ifdef CONFIG_CIFS_DEBUG2
1085 cifs_dump_detail(buf); 1066 server->ops->dump_detail(buf);
1086 cifs_dump_mids(server); 1067 cifs_dump_mids(server);
1087#endif /* CIFS_DEBUG2 */ 1068#endif /* CIFS_DEBUG2 */
1088 1069
diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
index daa2edec391e..ddc8ca6c3090 100644
--- a/fs/cifs/smb1ops.c
+++ b/fs/cifs/smb1ops.c
@@ -81,6 +81,25 @@ cifs_read_data_length(char *buf)
81 le16_to_cpu(rsp->DataLength); 81 le16_to_cpu(rsp->DataLength);
82} 82}
83 83
84static struct mid_q_entry *
85cifs_find_mid(struct TCP_Server_Info *server, char *buffer)
86{
87 struct smb_hdr *buf = (struct smb_hdr *)buffer;
88 struct mid_q_entry *mid;
89
90 spin_lock(&GlobalMid_Lock);
91 list_for_each_entry(mid, &server->pending_mid_q, qhead) {
92 if (mid->mid == buf->Mid &&
93 mid->mid_state == MID_REQUEST_SUBMITTED &&
94 le16_to_cpu(mid->command) == buf->Command) {
95 spin_unlock(&GlobalMid_Lock);
96 return mid;
97 }
98 }
99 spin_unlock(&GlobalMid_Lock);
100 return NULL;
101}
102
84struct smb_version_operations smb1_operations = { 103struct smb_version_operations smb1_operations = {
85 .send_cancel = send_nt_cancel, 104 .send_cancel = send_nt_cancel,
86 .compare_fids = cifs_compare_fids, 105 .compare_fids = cifs_compare_fids,
@@ -89,6 +108,10 @@ struct smb_version_operations smb1_operations = {
89 .read_data_offset = cifs_read_data_offset, 108 .read_data_offset = cifs_read_data_offset,
90 .read_data_length = cifs_read_data_length, 109 .read_data_length = cifs_read_data_length,
91 .map_error = map_smb_to_linux_error, 110 .map_error = map_smb_to_linux_error,
111 .find_mid = cifs_find_mid,
112 .check_message = checkSMB,
113 .dump_detail = cifs_dump_detail,
114 .is_oplock_break = is_valid_oplock_break,
92}; 115};
93 116
94struct smb_version_values smb1_values = { 117struct smb_version_values smb1_values = {