diff options
author | Steve French <sfrench@us.ibm.com> | 2007-07-09 21:16:18 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2007-07-09 21:16:18 -0400 |
commit | fb8c4b14d9259ba467241a7aaeb712caedce7ee8 (patch) | |
tree | 8f94a3b3b5e9e1bbdf9b38156ab2bfe2c055b47d /fs/cifs/connect.c | |
parent | b609f06ac4ac77433035366e9aa4dcd7a0f743a0 (diff) |
[CIFS] whitespace cleanup
More than halfway there
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/connect.c')
-rw-r--r-- | fs/cifs/connect.c | 398 |
1 files changed, 199 insertions, 199 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 9b95d4637fcc..ef10c3717fb5 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -16,7 +16,7 @@ | |||
16 | * | 16 | * |
17 | * You should have received a copy of the GNU Lesser General Public License | 17 | * You should have received a copy of the GNU Lesser General Public License |
18 | * along with this library; if not, write to the Free Software | 18 | * along with this library; if not, write to the Free Software |
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 | */ | 20 | */ |
21 | #include <linux/fs.h> | 21 | #include <linux/fs.h> |
22 | #include <linux/net.h> | 22 | #include <linux/net.h> |
@@ -93,20 +93,20 @@ struct smb_vol { | |||
93 | unsigned int wsize; | 93 | unsigned int wsize; |
94 | unsigned int sockopt; | 94 | unsigned int sockopt; |
95 | unsigned short int port; | 95 | unsigned short int port; |
96 | char * prepath; | 96 | char *prepath; |
97 | }; | 97 | }; |
98 | 98 | ||
99 | static int ipv4_connect(struct sockaddr_in *psin_server, | 99 | static int ipv4_connect(struct sockaddr_in *psin_server, |
100 | struct socket **csocket, | 100 | struct socket **csocket, |
101 | char * netb_name, | 101 | char *netb_name, |
102 | char * server_netb_name); | 102 | char *server_netb_name); |
103 | static int ipv6_connect(struct sockaddr_in6 *psin_server, | 103 | static int ipv6_connect(struct sockaddr_in6 *psin_server, |
104 | struct socket **csocket); | 104 | struct socket **csocket); |
105 | 105 | ||
106 | 106 | ||
107 | /* | 107 | /* |
108 | * cifs tcp session reconnection | 108 | * cifs tcp session reconnection |
109 | * | 109 | * |
110 | * mark tcp session as reconnecting so temporarily locked | 110 | * mark tcp session as reconnecting so temporarily locked |
111 | * mark all smb sessions as reconnecting for tcp session | 111 | * mark all smb sessions as reconnecting for tcp session |
112 | * reconnect tcp session | 112 | * reconnect tcp session |
@@ -120,11 +120,11 @@ cifs_reconnect(struct TCP_Server_Info *server) | |||
120 | struct list_head *tmp; | 120 | struct list_head *tmp; |
121 | struct cifsSesInfo *ses; | 121 | struct cifsSesInfo *ses; |
122 | struct cifsTconInfo *tcon; | 122 | struct cifsTconInfo *tcon; |
123 | struct mid_q_entry * mid_entry; | 123 | struct mid_q_entry *mid_entry; |
124 | 124 | ||
125 | spin_lock(&GlobalMid_Lock); | 125 | spin_lock(&GlobalMid_Lock); |
126 | if( kthread_should_stop() ) { | 126 | if ( kthread_should_stop() ) { |
127 | /* the demux thread will exit normally | 127 | /* the demux thread will exit normally |
128 | next time through the loop */ | 128 | next time through the loop */ |
129 | spin_unlock(&GlobalMid_Lock); | 129 | spin_unlock(&GlobalMid_Lock); |
130 | return rc; | 130 | return rc; |
@@ -150,18 +150,18 @@ cifs_reconnect(struct TCP_Server_Info *server) | |||
150 | } | 150 | } |
151 | list_for_each(tmp, &GlobalTreeConnectionList) { | 151 | list_for_each(tmp, &GlobalTreeConnectionList) { |
152 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); | 152 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); |
153 | if((tcon) && (tcon->ses) && (tcon->ses->server == server)) { | 153 | if ((tcon) && (tcon->ses) && (tcon->ses->server == server)) { |
154 | tcon->tidStatus = CifsNeedReconnect; | 154 | tcon->tidStatus = CifsNeedReconnect; |
155 | } | 155 | } |
156 | } | 156 | } |
157 | read_unlock(&GlobalSMBSeslock); | 157 | read_unlock(&GlobalSMBSeslock); |
158 | /* do not want to be sending data on a socket we are freeing */ | 158 | /* do not want to be sending data on a socket we are freeing */ |
159 | down(&server->tcpSem); | 159 | down(&server->tcpSem); |
160 | if(server->ssocket) { | 160 | if (server->ssocket) { |
161 | cFYI(1, ("State: 0x%x Flags: 0x%lx", server->ssocket->state, | 161 | cFYI(1, ("State: 0x%x Flags: 0x%lx", server->ssocket->state, |
162 | server->ssocket->flags)); | 162 | server->ssocket->flags)); |
163 | server->ssocket->ops->shutdown(server->ssocket,SEND_SHUTDOWN); | 163 | server->ssocket->ops->shutdown(server->ssocket, SEND_SHUTDOWN); |
164 | cFYI(1, ("Post shutdown state: 0x%x Flags: 0x%lx", | 164 | cFYI(1, ("Post shutdown state: 0x%x Flags: 0x%lx", |
165 | server->ssocket->state, | 165 | server->ssocket->state, |
166 | server->ssocket->flags)); | 166 | server->ssocket->flags)); |
167 | sock_release(server->ssocket); | 167 | sock_release(server->ssocket); |
@@ -173,8 +173,8 @@ cifs_reconnect(struct TCP_Server_Info *server) | |||
173 | mid_entry = list_entry(tmp, struct | 173 | mid_entry = list_entry(tmp, struct |
174 | mid_q_entry, | 174 | mid_q_entry, |
175 | qhead); | 175 | qhead); |
176 | if(mid_entry) { | 176 | if (mid_entry) { |
177 | if(mid_entry->midState == MID_REQUEST_SUBMITTED) { | 177 | if (mid_entry->midState == MID_REQUEST_SUBMITTED) { |
178 | /* Mark other intransit requests as needing | 178 | /* Mark other intransit requests as needing |
179 | retry so we do not immediately mark the | 179 | retry so we do not immediately mark the |
180 | session bad again (ie after we reconnect | 180 | session bad again (ie after we reconnect |
@@ -184,29 +184,29 @@ cifs_reconnect(struct TCP_Server_Info *server) | |||
184 | } | 184 | } |
185 | } | 185 | } |
186 | spin_unlock(&GlobalMid_Lock); | 186 | spin_unlock(&GlobalMid_Lock); |
187 | up(&server->tcpSem); | 187 | up(&server->tcpSem); |
188 | 188 | ||
189 | while ( (!kthread_should_stop()) && (server->tcpStatus != CifsGood)) | 189 | while ( (!kthread_should_stop()) && (server->tcpStatus != CifsGood)) { |
190 | { | ||
191 | try_to_freeze(); | 190 | try_to_freeze(); |
192 | if(server->protocolType == IPV6) { | 191 | if (server->protocolType == IPV6) { |
193 | rc = ipv6_connect(&server->addr.sockAddr6,&server->ssocket); | 192 | rc = ipv6_connect(&server->addr.sockAddr6, |
193 | &server->ssocket); | ||
194 | } else { | 194 | } else { |
195 | rc = ipv4_connect(&server->addr.sockAddr, | 195 | rc = ipv4_connect(&server->addr.sockAddr, |
196 | &server->ssocket, | 196 | &server->ssocket, |
197 | server->workstation_RFC1001_name, | 197 | server->workstation_RFC1001_name, |
198 | server->server_RFC1001_name); | 198 | server->server_RFC1001_name); |
199 | } | 199 | } |
200 | if(rc) { | 200 | if (rc) { |
201 | cFYI(1, ("reconnect error %d",rc)); | 201 | cFYI(1, ("reconnect error %d", rc)); |
202 | msleep(3000); | 202 | msleep(3000); |
203 | } else { | 203 | } else { |
204 | atomic_inc(&tcpSesReconnectCount); | 204 | atomic_inc(&tcpSesReconnectCount); |
205 | spin_lock(&GlobalMid_Lock); | 205 | spin_lock(&GlobalMid_Lock); |
206 | if( !kthread_should_stop() ) | 206 | if ( !kthread_should_stop() ) |
207 | server->tcpStatus = CifsGood; | 207 | server->tcpStatus = CifsGood; |
208 | server->sequence_number = 0; | 208 | server->sequence_number = 0; |
209 | spin_unlock(&GlobalMid_Lock); | 209 | spin_unlock(&GlobalMid_Lock); |
210 | /* atomic_set(&server->inFlight,0);*/ | 210 | /* atomic_set(&server->inFlight,0);*/ |
211 | wake_up(&server->response_q); | 211 | wake_up(&server->response_q); |
212 | } | 212 | } |
@@ -214,26 +214,26 @@ cifs_reconnect(struct TCP_Server_Info *server) | |||
214 | return rc; | 214 | return rc; |
215 | } | 215 | } |
216 | 216 | ||
217 | /* | 217 | /* |
218 | return codes: | 218 | return codes: |
219 | 0 not a transact2, or all data present | 219 | 0 not a transact2, or all data present |
220 | >0 transact2 with that much data missing | 220 | >0 transact2 with that much data missing |
221 | -EINVAL = invalid transact2 | 221 | -EINVAL = invalid transact2 |
222 | 222 | ||
223 | */ | 223 | */ |
224 | static int check2ndT2(struct smb_hdr * pSMB, unsigned int maxBufSize) | 224 | static int check2ndT2(struct smb_hdr *pSMB, unsigned int maxBufSize) |
225 | { | 225 | { |
226 | struct smb_t2_rsp * pSMBt; | 226 | struct smb_t2_rsp *pSMBt; |
227 | int total_data_size; | 227 | int total_data_size; |
228 | int data_in_this_rsp; | 228 | int data_in_this_rsp; |
229 | int remaining; | 229 | int remaining; |
230 | 230 | ||
231 | if(pSMB->Command != SMB_COM_TRANSACTION2) | 231 | if (pSMB->Command != SMB_COM_TRANSACTION2) |
232 | return 0; | 232 | return 0; |
233 | 233 | ||
234 | /* check for plausible wct, bcc and t2 data and parm sizes */ | 234 | /* check for plausible wct, bcc and t2 data and parm sizes */ |
235 | /* check for parm and data offset going beyond end of smb */ | 235 | /* check for parm and data offset going beyond end of smb */ |
236 | if(pSMB->WordCount != 10) { /* coalesce_t2 depends on this */ | 236 | if (pSMB->WordCount != 10) { /* coalesce_t2 depends on this */ |
237 | cFYI(1, ("invalid transact2 word count")); | 237 | cFYI(1, ("invalid transact2 word count")); |
238 | return -EINVAL; | 238 | return -EINVAL; |
239 | } | 239 | } |
@@ -245,25 +245,25 @@ static int check2ndT2(struct smb_hdr * pSMB, unsigned int maxBufSize) | |||
245 | 245 | ||
246 | remaining = total_data_size - data_in_this_rsp; | 246 | remaining = total_data_size - data_in_this_rsp; |
247 | 247 | ||
248 | if(remaining == 0) | 248 | if (remaining == 0) |
249 | return 0; | 249 | return 0; |
250 | else if(remaining < 0) { | 250 | else if (remaining < 0) { |
251 | cFYI(1, ("total data %d smaller than data in frame %d", | 251 | cFYI(1, ("total data %d smaller than data in frame %d", |
252 | total_data_size, data_in_this_rsp)); | 252 | total_data_size, data_in_this_rsp)); |
253 | return -EINVAL; | 253 | return -EINVAL; |
254 | } else { | 254 | } else { |
255 | cFYI(1, ("missing %d bytes from transact2, check next response", | 255 | cFYI(1, ("missing %d bytes from transact2, check next response", |
256 | remaining)); | 256 | remaining)); |
257 | if(total_data_size > maxBufSize) { | 257 | if (total_data_size > maxBufSize) { |
258 | cERROR(1,("TotalDataSize %d is over maximum buffer %d", | 258 | cERROR(1, ("TotalDataSize %d is over maximum buffer %d", |
259 | total_data_size,maxBufSize)); | 259 | total_data_size, maxBufSize)); |
260 | return -EINVAL; | 260 | return -EINVAL; |
261 | } | 261 | } |
262 | return remaining; | 262 | return remaining; |
263 | } | 263 | } |
264 | } | 264 | } |
265 | 265 | ||
266 | static int coalesce_t2(struct smb_hdr * psecond, struct smb_hdr *pTargetSMB) | 266 | static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB) |
267 | { | 267 | { |
268 | struct smb_t2_rsp *pSMB2 = (struct smb_t2_rsp *)psecond; | 268 | struct smb_t2_rsp *pSMB2 = (struct smb_t2_rsp *)psecond; |
269 | struct smb_t2_rsp *pSMBt = (struct smb_t2_rsp *)pTargetSMB; | 269 | struct smb_t2_rsp *pSMBt = (struct smb_t2_rsp *)pTargetSMB; |
@@ -271,43 +271,43 @@ static int coalesce_t2(struct smb_hdr * psecond, struct smb_hdr *pTargetSMB) | |||
271 | int total_in_buf; | 271 | int total_in_buf; |
272 | int remaining; | 272 | int remaining; |
273 | int total_in_buf2; | 273 | int total_in_buf2; |
274 | char * data_area_of_target; | 274 | char *data_area_of_target; |
275 | char * data_area_of_buf2; | 275 | char *data_area_of_buf2; |
276 | __u16 byte_count; | 276 | __u16 byte_count; |
277 | 277 | ||
278 | total_data_size = le16_to_cpu(pSMBt->t2_rsp.TotalDataCount); | 278 | total_data_size = le16_to_cpu(pSMBt->t2_rsp.TotalDataCount); |
279 | 279 | ||
280 | if(total_data_size != le16_to_cpu(pSMB2->t2_rsp.TotalDataCount)) { | 280 | if (total_data_size != le16_to_cpu(pSMB2->t2_rsp.TotalDataCount)) { |
281 | cFYI(1,("total data sizes of primary and secondary t2 differ")); | 281 | cFYI(1, ("total data sizes of primary and secondary t2 differ")); |
282 | } | 282 | } |
283 | 283 | ||
284 | total_in_buf = le16_to_cpu(pSMBt->t2_rsp.DataCount); | 284 | total_in_buf = le16_to_cpu(pSMBt->t2_rsp.DataCount); |
285 | 285 | ||
286 | remaining = total_data_size - total_in_buf; | 286 | remaining = total_data_size - total_in_buf; |
287 | 287 | ||
288 | if(remaining < 0) | 288 | if (remaining < 0) |
289 | return -EINVAL; | 289 | return -EINVAL; |
290 | 290 | ||
291 | if(remaining == 0) /* nothing to do, ignore */ | 291 | if (remaining == 0) /* nothing to do, ignore */ |
292 | return 0; | 292 | return 0; |
293 | 293 | ||
294 | total_in_buf2 = le16_to_cpu(pSMB2->t2_rsp.DataCount); | 294 | total_in_buf2 = le16_to_cpu(pSMB2->t2_rsp.DataCount); |
295 | if(remaining < total_in_buf2) { | 295 | if (remaining < total_in_buf2) { |
296 | cFYI(1, ("transact2 2nd response contains too much data")); | 296 | cFYI(1, ("transact2 2nd response contains too much data")); |
297 | } | 297 | } |
298 | 298 | ||
299 | /* find end of first SMB data area */ | 299 | /* find end of first SMB data area */ |
300 | data_area_of_target = (char *)&pSMBt->hdr.Protocol + | 300 | data_area_of_target = (char *)&pSMBt->hdr.Protocol + |
301 | le16_to_cpu(pSMBt->t2_rsp.DataOffset); | 301 | le16_to_cpu(pSMBt->t2_rsp.DataOffset); |
302 | /* validate target area */ | 302 | /* validate target area */ |
303 | 303 | ||
304 | data_area_of_buf2 = (char *) &pSMB2->hdr.Protocol + | 304 | data_area_of_buf2 = (char *) &pSMB2->hdr.Protocol + |
305 | le16_to_cpu(pSMB2->t2_rsp.DataOffset); | 305 | le16_to_cpu(pSMB2->t2_rsp.DataOffset); |
306 | 306 | ||
307 | data_area_of_target += total_in_buf; | 307 | data_area_of_target += total_in_buf; |
308 | 308 | ||
309 | /* copy second buffer into end of first buffer */ | 309 | /* copy second buffer into end of first buffer */ |
310 | memcpy(data_area_of_target,data_area_of_buf2,total_in_buf2); | 310 | memcpy(data_area_of_target, data_area_of_buf2, total_in_buf2); |
311 | total_in_buf += total_in_buf2; | 311 | total_in_buf += total_in_buf2; |
312 | pSMBt->t2_rsp.DataCount = cpu_to_le16(total_in_buf); | 312 | pSMBt->t2_rsp.DataCount = cpu_to_le16(total_in_buf); |
313 | byte_count = le16_to_cpu(BCC_LE(pTargetSMB)); | 313 | byte_count = le16_to_cpu(BCC_LE(pTargetSMB)); |
@@ -321,7 +321,7 @@ static int coalesce_t2(struct smb_hdr * psecond, struct smb_hdr *pTargetSMB) | |||
321 | 321 | ||
322 | pTargetSMB->smb_buf_length = byte_count; | 322 | pTargetSMB->smb_buf_length = byte_count; |
323 | 323 | ||
324 | if(remaining == total_in_buf2) { | 324 | if (remaining == total_in_buf2) { |
325 | cFYI(1, ("found the last secondary response")); | 325 | cFYI(1, ("found the last secondary response")); |
326 | return 0; /* we are done */ | 326 | return 0; /* we are done */ |
327 | } else /* more responses to go */ | 327 | } else /* more responses to go */ |
@@ -352,12 +352,12 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
352 | current->flags |= PF_MEMALLOC; | 352 | current->flags |= PF_MEMALLOC; |
353 | server->tsk = current; /* save process info to wake at shutdown */ | 353 | server->tsk = current; /* save process info to wake at shutdown */ |
354 | cFYI(1, ("Demultiplex PID: %d", current->pid)); | 354 | cFYI(1, ("Demultiplex PID: %d", current->pid)); |
355 | write_lock(&GlobalSMBSeslock); | 355 | write_lock(&GlobalSMBSeslock); |
356 | atomic_inc(&tcpSesAllocCount); | 356 | atomic_inc(&tcpSesAllocCount); |
357 | length = tcpSesAllocCount.counter; | 357 | length = tcpSesAllocCount.counter; |
358 | write_unlock(&GlobalSMBSeslock); | 358 | write_unlock(&GlobalSMBSeslock); |
359 | complete(&cifsd_complete); | 359 | complete(&cifsd_complete); |
360 | if(length > 1) { | 360 | if (length > 1) { |
361 | mempool_resize(cifs_req_poolp, | 361 | mempool_resize(cifs_req_poolp, |
362 | length + cifs_min_rcv, | 362 | length + cifs_min_rcv, |
363 | GFP_KERNEL); | 363 | GFP_KERNEL); |
@@ -452,7 +452,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
452 | with the most common, zero, as regular data */ | 452 | with the most common, zero, as regular data */ |
453 | temp = *((char *) smb_buffer); | 453 | temp = *((char *) smb_buffer); |
454 | 454 | ||
455 | /* Note that FC 1001 length is big endian on the wire, | 455 | /* Note that FC 1001 length is big endian on the wire, |
456 | but we convert it here so it is always manipulated | 456 | but we convert it here so it is always manipulated |
457 | as host byte order */ | 457 | as host byte order */ |
458 | pdu_length = ntohl(smb_buffer->smb_buf_length); | 458 | pdu_length = ntohl(smb_buffer->smb_buf_length); |
@@ -461,17 +461,17 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
461 | cFYI(1, ("rfc1002 length 0x%x", pdu_length+4)); | 461 | cFYI(1, ("rfc1002 length 0x%x", pdu_length+4)); |
462 | 462 | ||
463 | if (temp == (char) RFC1002_SESSION_KEEP_ALIVE) { | 463 | if (temp == (char) RFC1002_SESSION_KEEP_ALIVE) { |
464 | continue; | 464 | continue; |
465 | } else if (temp == (char)RFC1002_POSITIVE_SESSION_RESPONSE) { | 465 | } else if (temp == (char)RFC1002_POSITIVE_SESSION_RESPONSE) { |
466 | cFYI(1, ("Good RFC 1002 session rsp")); | 466 | cFYI(1, ("Good RFC 1002 session rsp")); |
467 | continue; | 467 | continue; |
468 | } else if (temp == (char)RFC1002_NEGATIVE_SESSION_RESPONSE) { | 468 | } else if (temp == (char)RFC1002_NEGATIVE_SESSION_RESPONSE) { |
469 | /* we get this from Windows 98 instead of | 469 | /* we get this from Windows 98 instead of |
470 | an error on SMB negprot response */ | 470 | an error on SMB negprot response */ |
471 | cFYI(1,("Negative RFC1002 Session Response Error 0x%x)", | 471 | cFYI(1, ("Negative RFC1002 Session Response Error 0x%x)", |
472 | pdu_length)); | 472 | pdu_length)); |
473 | if(server->tcpStatus == CifsNew) { | 473 | if (server->tcpStatus == CifsNew) { |
474 | /* if nack on negprot (rather than | 474 | /* if nack on negprot (rather than |
475 | ret of smb negprot error) reconnecting | 475 | ret of smb negprot error) reconnecting |
476 | not going to help, ret error to mount */ | 476 | not going to help, ret error to mount */ |
477 | break; | 477 | break; |
@@ -481,10 +481,10 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
481 | msleep(1000); | 481 | msleep(1000); |
482 | /* always try 445 first on reconnect | 482 | /* always try 445 first on reconnect |
483 | since we get NACK on some if we ever | 483 | since we get NACK on some if we ever |
484 | connected to port 139 (the NACK is | 484 | connected to port 139 (the NACK is |
485 | since we do not begin with RFC1001 | 485 | since we do not begin with RFC1001 |
486 | session initialize frame) */ | 486 | session initialize frame) */ |
487 | server->addr.sockAddr.sin_port = | 487 | server->addr.sockAddr.sin_port = |
488 | htons(CIFS_PORT); | 488 | htons(CIFS_PORT); |
489 | cifs_reconnect(server); | 489 | cifs_reconnect(server); |
490 | csocket = server->ssocket; | 490 | csocket = server->ssocket; |
@@ -492,7 +492,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
492 | continue; | 492 | continue; |
493 | } | 493 | } |
494 | } else if (temp != (char) 0) { | 494 | } else if (temp != (char) 0) { |
495 | cERROR(1,("Unknown RFC 1002 frame")); | 495 | cERROR(1, ("Unknown RFC 1002 frame")); |
496 | cifs_dump_mem(" Received Data: ", (char *)smb_buffer, | 496 | cifs_dump_mem(" Received Data: ", (char *)smb_buffer, |
497 | length); | 497 | length); |
498 | cifs_reconnect(server); | 498 | cifs_reconnect(server); |
@@ -501,7 +501,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
501 | } | 501 | } |
502 | 502 | ||
503 | /* else we have an SMB response */ | 503 | /* else we have an SMB response */ |
504 | if((pdu_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) || | 504 | if ((pdu_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) || |
505 | (pdu_length < sizeof (struct smb_hdr) - 1 - 4)) { | 505 | (pdu_length < sizeof (struct smb_hdr) - 1 - 4)) { |
506 | cERROR(1, ("Invalid size SMB length %d pdu_length %d", | 506 | cERROR(1, ("Invalid size SMB length %d pdu_length %d", |
507 | length, pdu_length+4)); | 507 | length, pdu_length+4)); |
@@ -509,12 +509,12 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
509 | csocket = server->ssocket; | 509 | csocket = server->ssocket; |
510 | wake_up(&server->response_q); | 510 | wake_up(&server->response_q); |
511 | continue; | 511 | continue; |
512 | } | 512 | } |
513 | 513 | ||
514 | /* else length ok */ | 514 | /* else length ok */ |
515 | reconnect = 0; | 515 | reconnect = 0; |
516 | 516 | ||
517 | if(pdu_length > MAX_CIFS_SMALL_BUFFER_SIZE - 4) { | 517 | if (pdu_length > MAX_CIFS_SMALL_BUFFER_SIZE - 4) { |
518 | isLargeBuf = TRUE; | 518 | isLargeBuf = TRUE; |
519 | memcpy(bigbuf, smallbuf, 4); | 519 | memcpy(bigbuf, smallbuf, 4); |
520 | smb_buffer = bigbuf; | 520 | smb_buffer = bigbuf; |
@@ -522,11 +522,11 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
522 | length = 0; | 522 | length = 0; |
523 | iov.iov_base = 4 + (char *)smb_buffer; | 523 | iov.iov_base = 4 + (char *)smb_buffer; |
524 | iov.iov_len = pdu_length; | 524 | iov.iov_len = pdu_length; |
525 | for (total_read = 0; total_read < pdu_length; | 525 | for (total_read = 0; total_read < pdu_length; |
526 | total_read += length) { | 526 | total_read += length) { |
527 | length = kernel_recvmsg(csocket, &smb_msg, &iov, 1, | 527 | length = kernel_recvmsg(csocket, &smb_msg, &iov, 1, |
528 | pdu_length - total_read, 0); | 528 | pdu_length - total_read, 0); |
529 | if( kthread_should_stop() || | 529 | if ( kthread_should_stop() || |
530 | (length == -EINTR)) { | 530 | (length == -EINTR)) { |
531 | /* then will exit */ | 531 | /* then will exit */ |
532 | reconnect = 2; | 532 | reconnect = 2; |
@@ -534,19 +534,19 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
534 | } else if (server->tcpStatus == CifsNeedReconnect) { | 534 | } else if (server->tcpStatus == CifsNeedReconnect) { |
535 | cifs_reconnect(server); | 535 | cifs_reconnect(server); |
536 | csocket = server->ssocket; | 536 | csocket = server->ssocket; |
537 | /* Reconnect wakes up rspns q */ | 537 | /* Reconnect wakes up rspns q */ |
538 | /* Now we will reread sock */ | 538 | /* Now we will reread sock */ |
539 | reconnect = 1; | 539 | reconnect = 1; |
540 | break; | 540 | break; |
541 | } else if ((length == -ERESTARTSYS) || | 541 | } else if ((length == -ERESTARTSYS) || |
542 | (length == -EAGAIN)) { | 542 | (length == -EAGAIN)) { |
543 | msleep(1); /* minimum sleep to prevent looping, | 543 | msleep(1); /* minimum sleep to prevent looping, |
544 | allowing socket to clear and app | 544 | allowing socket to clear and app |
545 | threads to set tcpStatus | 545 | threads to set tcpStatus |
546 | CifsNeedReconnect if server hung*/ | 546 | CifsNeedReconnect if server hung*/ |
547 | continue; | 547 | continue; |
548 | } else if (length <= 0) { | 548 | } else if (length <= 0) { |
549 | cERROR(1,("Received no data, expecting %d", | 549 | cERROR(1, ("Received no data, expecting %d", |
550 | pdu_length - total_read)); | 550 | pdu_length - total_read)); |
551 | cifs_reconnect(server); | 551 | cifs_reconnect(server); |
552 | csocket = server->ssocket; | 552 | csocket = server->ssocket; |
@@ -554,9 +554,9 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
554 | break; | 554 | break; |
555 | } | 555 | } |
556 | } | 556 | } |
557 | if(reconnect == 2) | 557 | if (reconnect == 2) |
558 | break; | 558 | break; |
559 | else if(reconnect == 1) | 559 | else if (reconnect == 1) |
560 | continue; | 560 | continue; |
561 | 561 | ||
562 | length += 4; /* account for rfc1002 hdr */ | 562 | length += 4; /* account for rfc1002 hdr */ |
@@ -577,12 +577,12 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
577 | if ((mid_entry->mid == smb_buffer->Mid) && | 577 | if ((mid_entry->mid == smb_buffer->Mid) && |
578 | (mid_entry->midState == MID_REQUEST_SUBMITTED) && | 578 | (mid_entry->midState == MID_REQUEST_SUBMITTED) && |
579 | (mid_entry->command == smb_buffer->Command)) { | 579 | (mid_entry->command == smb_buffer->Command)) { |
580 | if(check2ndT2(smb_buffer,server->maxBuf) > 0) { | 580 | if (check2ndT2(smb_buffer,server->maxBuf) > 0) { |
581 | /* We have a multipart transact2 resp */ | 581 | /* We have a multipart transact2 resp */ |
582 | isMultiRsp = TRUE; | 582 | isMultiRsp = TRUE; |
583 | if(mid_entry->resp_buf) { | 583 | if (mid_entry->resp_buf) { |
584 | /* merge response - fix up 1st*/ | 584 | /* merge response - fix up 1st*/ |
585 | if(coalesce_t2(smb_buffer, | 585 | if (coalesce_t2(smb_buffer, |
586 | mid_entry->resp_buf)) { | 586 | mid_entry->resp_buf)) { |
587 | mid_entry->multiRsp = 1; | 587 | mid_entry->multiRsp = 1; |
588 | break; | 588 | break; |
@@ -592,7 +592,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
592 | goto multi_t2_fnd; | 592 | goto multi_t2_fnd; |
593 | } | 593 | } |
594 | } else { | 594 | } else { |
595 | if(!isLargeBuf) { | 595 | if (!isLargeBuf) { |
596 | cERROR(1,("1st trans2 resp needs bigbuf")); | 596 | cERROR(1,("1st trans2 resp needs bigbuf")); |
597 | /* BB maybe we can fix this up, switch | 597 | /* BB maybe we can fix this up, switch |
598 | to already allocated large buffer? */ | 598 | to already allocated large buffer? */ |
@@ -607,7 +607,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
607 | break; | 607 | break; |
608 | } | 608 | } |
609 | mid_entry->resp_buf = smb_buffer; | 609 | mid_entry->resp_buf = smb_buffer; |
610 | if(isLargeBuf) | 610 | if (isLargeBuf) |
611 | mid_entry->largeBuf = 1; | 611 | mid_entry->largeBuf = 1; |
612 | else | 612 | else |
613 | mid_entry->largeBuf = 0; | 613 | mid_entry->largeBuf = 0; |
@@ -627,9 +627,9 @@ multi_t2_fnd: | |||
627 | spin_unlock(&GlobalMid_Lock); | 627 | spin_unlock(&GlobalMid_Lock); |
628 | if (task_to_wake) { | 628 | if (task_to_wake) { |
629 | /* Was previous buf put in mpx struct for multi-rsp? */ | 629 | /* Was previous buf put in mpx struct for multi-rsp? */ |
630 | if(!isMultiRsp) { | 630 | if (!isMultiRsp) { |
631 | /* smb buffer will be freed by user thread */ | 631 | /* smb buffer will be freed by user thread */ |
632 | if(isLargeBuf) { | 632 | if (isLargeBuf) { |
633 | bigbuf = NULL; | 633 | bigbuf = NULL; |
634 | } else | 634 | } else |
635 | smallbuf = NULL; | 635 | smallbuf = NULL; |
@@ -654,7 +654,7 @@ multi_t2_fnd: | |||
654 | /* check if we have blocked requests that need to free */ | 654 | /* check if we have blocked requests that need to free */ |
655 | /* Note that cifs_max_pending is normally 50, but | 655 | /* Note that cifs_max_pending is normally 50, but |
656 | can be set at module install time to as little as two */ | 656 | can be set at module install time to as little as two */ |
657 | if(atomic_read(&server->inFlight) >= cifs_max_pending) | 657 | if (atomic_read(&server->inFlight) >= cifs_max_pending) |
658 | atomic_set(&server->inFlight, cifs_max_pending - 1); | 658 | atomic_set(&server->inFlight, cifs_max_pending - 1); |
659 | /* We do not want to set the max_pending too low or we | 659 | /* We do not want to set the max_pending too low or we |
660 | could end up with the counter going negative */ | 660 | could end up with the counter going negative */ |
@@ -668,7 +668,7 @@ multi_t2_fnd: | |||
668 | /* give those requests time to exit */ | 668 | /* give those requests time to exit */ |
669 | msleep(125); | 669 | msleep(125); |
670 | 670 | ||
671 | if(server->ssocket) { | 671 | if (server->ssocket) { |
672 | sock_release(csocket); | 672 | sock_release(csocket); |
673 | server->ssocket = NULL; | 673 | server->ssocket = NULL; |
674 | } | 674 | } |
@@ -711,7 +711,7 @@ multi_t2_fnd: | |||
711 | cFYI(1, | 711 | cFYI(1, |
712 | ("Clearing Mid 0x%x - waking up ",mid_entry->mid)); | 712 | ("Clearing Mid 0x%x - waking up ",mid_entry->mid)); |
713 | task_to_wake = mid_entry->tsk; | 713 | task_to_wake = mid_entry->tsk; |
714 | if(task_to_wake) { | 714 | if (task_to_wake) { |
715 | wake_up_process(task_to_wake); | 715 | wake_up_process(task_to_wake); |
716 | } | 716 | } |
717 | } | 717 | } |
@@ -753,7 +753,7 @@ multi_t2_fnd: | |||
753 | write_unlock(&GlobalSMBSeslock); | 753 | write_unlock(&GlobalSMBSeslock); |
754 | 754 | ||
755 | kfree(server); | 755 | kfree(server); |
756 | if(length > 0) { | 756 | if (length > 0) { |
757 | mempool_resize(cifs_req_poolp, | 757 | mempool_resize(cifs_req_poolp, |
758 | length + cifs_min_rcv, | 758 | length + cifs_min_rcv, |
759 | GFP_KERNEL); | 759 | GFP_KERNEL); |
@@ -804,8 +804,8 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
804 | if (!options) | 804 | if (!options) |
805 | return 1; | 805 | return 1; |
806 | 806 | ||
807 | if(strncmp(options,"sep=",4) == 0) { | 807 | if (strncmp(options,"sep=",4) == 0) { |
808 | if(options[4] != 0) { | 808 | if (options[4] != 0) { |
809 | separator[0] = options[4]; | 809 | separator[0] = options[4]; |
810 | options += 5; | 810 | options += 5; |
811 | } else { | 811 | } else { |
@@ -828,7 +828,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
828 | printk(KERN_WARNING | 828 | printk(KERN_WARNING |
829 | "CIFS: invalid or missing username\n"); | 829 | "CIFS: invalid or missing username\n"); |
830 | return 1; /* needs_arg; */ | 830 | return 1; /* needs_arg; */ |
831 | } else if(!*value) { | 831 | } else if (!*value) { |
832 | /* null user, ie anonymous, authentication */ | 832 | /* null user, ie anonymous, authentication */ |
833 | vol->nullauth = 1; | 833 | vol->nullauth = 1; |
834 | } | 834 | } |
@@ -842,12 +842,12 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
842 | if (!value) { | 842 | if (!value) { |
843 | vol->password = NULL; | 843 | vol->password = NULL; |
844 | continue; | 844 | continue; |
845 | } else if(value[0] == 0) { | 845 | } else if (value[0] == 0) { |
846 | /* check if string begins with double comma | 846 | /* check if string begins with double comma |
847 | since that would mean the password really | 847 | since that would mean the password really |
848 | does start with a comma, and would not | 848 | does start with a comma, and would not |
849 | indicate an empty string */ | 849 | indicate an empty string */ |
850 | if(value[1] != separator[0]) { | 850 | if (value[1] != separator[0]) { |
851 | vol->password = NULL; | 851 | vol->password = NULL; |
852 | continue; | 852 | continue; |
853 | } | 853 | } |
@@ -885,7 +885,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
885 | } | 885 | } |
886 | temp_len++; | 886 | temp_len++; |
887 | } | 887 | } |
888 | if(value[temp_len] == 0) { | 888 | if (value[temp_len] == 0) { |
889 | options = NULL; | 889 | options = NULL; |
890 | } else { | 890 | } else { |
891 | value[temp_len] = 0; | 891 | value[temp_len] = 0; |
@@ -896,13 +896,13 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
896 | double commas to singles. Note that this ends up | 896 | double commas to singles. Note that this ends up |
897 | allocating a few bytes too many, which is ok */ | 897 | allocating a few bytes too many, which is ok */ |
898 | vol->password = kzalloc(temp_len, GFP_KERNEL); | 898 | vol->password = kzalloc(temp_len, GFP_KERNEL); |
899 | if(vol->password == NULL) { | 899 | if (vol->password == NULL) { |
900 | printk("CIFS: no memory for pass\n"); | 900 | printk("CIFS: no memory for pass\n"); |
901 | return 1; | 901 | return 1; |
902 | } | 902 | } |
903 | for(i=0,j=0;i<temp_len;i++,j++) { | 903 | for(i=0,j=0;i<temp_len;i++,j++) { |
904 | vol->password[j] = value[i]; | 904 | vol->password[j] = value[i]; |
905 | if(value[i] == separator[0] | 905 | if (value[i] == separator[0] |
906 | && value[i+1] == separator[0]) { | 906 | && value[i+1] == separator[0]) { |
907 | /* skip second comma */ | 907 | /* skip second comma */ |
908 | i++; | 908 | i++; |
@@ -911,7 +911,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
911 | vol->password[j] = 0; | 911 | vol->password[j] = 0; |
912 | } else { | 912 | } else { |
913 | vol->password = kzalloc(temp_len+1, GFP_KERNEL); | 913 | vol->password = kzalloc(temp_len+1, GFP_KERNEL); |
914 | if(vol->password == NULL) { | 914 | if (vol->password == NULL) { |
915 | printk("CIFS: no memory for pass\n"); | 915 | printk("CIFS: no memory for pass\n"); |
916 | return 1; | 916 | return 1; |
917 | } | 917 | } |
@@ -1089,7 +1089,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
1089 | } | 1089 | } |
1090 | } else if (strnicmp(data, "netbiosname", 4) == 0) { | 1090 | } else if (strnicmp(data, "netbiosname", 4) == 0) { |
1091 | if (!value || !*value || (*value == ' ')) { | 1091 | if (!value || !*value || (*value == ' ')) { |
1092 | cFYI(1,("invalid (empty) netbiosname specified")); | 1092 | cFYI(1, ("invalid (empty) netbiosname specified")); |
1093 | } else { | 1093 | } else { |
1094 | memset(vol->source_rfc1001_name,0x20,15); | 1094 | memset(vol->source_rfc1001_name,0x20,15); |
1095 | for(i=0;i<15;i++) { | 1095 | for(i=0;i<15;i++) { |
@@ -1187,7 +1187,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
1187 | /* turn off mandatory locking in mode | 1187 | /* turn off mandatory locking in mode |
1188 | if remote locking is turned off since the | 1188 | if remote locking is turned off since the |
1189 | local vfs will do advisory */ | 1189 | local vfs will do advisory */ |
1190 | if(vol->file_mode == (S_IALLUGO & ~(S_ISUID | S_IXGRP))) | 1190 | if (vol->file_mode == (S_IALLUGO & ~(S_ISUID | S_IXGRP))) |
1191 | vol->file_mode = S_IALLUGO; | 1191 | vol->file_mode = S_IALLUGO; |
1192 | } else if (strnicmp(data, "setuids", 7) == 0) { | 1192 | } else if (strnicmp(data, "setuids", 7) == 0) { |
1193 | vol->setuids = 1; | 1193 | vol->setuids = 1; |
@@ -1257,7 +1257,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
1257 | return 1; | 1257 | return 1; |
1258 | } | 1258 | } |
1259 | } | 1259 | } |
1260 | if(vol->UNCip == NULL) | 1260 | if (vol->UNCip == NULL) |
1261 | vol->UNCip = &vol->UNC[2]; | 1261 | vol->UNCip = &vol->UNC[2]; |
1262 | 1262 | ||
1263 | return 0; | 1263 | return 0; |
@@ -1276,7 +1276,7 @@ cifs_find_tcp_session(struct in_addr * target_ip_addr, | |||
1276 | list_for_each(tmp, &GlobalSMBSessionList) { | 1276 | list_for_each(tmp, &GlobalSMBSessionList) { |
1277 | ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); | 1277 | ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); |
1278 | if (ses->server) { | 1278 | if (ses->server) { |
1279 | if((target_ip_addr && | 1279 | if ((target_ip_addr && |
1280 | (ses->server->addr.sockAddr.sin_addr.s_addr | 1280 | (ses->server->addr.sockAddr.sin_addr.s_addr |
1281 | == target_ip_addr->s_addr)) || (target_ip6_addr | 1281 | == target_ip_addr->s_addr)) || (target_ip6_addr |
1282 | && memcmp(&ses->server->addr.sockAddr6.sin6_addr, | 1282 | && memcmp(&ses->server->addr.sockAddr6.sin6_addr, |
@@ -1319,7 +1319,7 @@ find_unc(__be32 new_target_ip_addr, char *uncName, char *userName) | |||
1319 | /* BB lock tcon, server and tcp session and increment use count here? */ | 1319 | /* BB lock tcon, server and tcp session and increment use count here? */ |
1320 | /* found a match on the TCP session */ | 1320 | /* found a match on the TCP session */ |
1321 | /* BB check if reconnection needed */ | 1321 | /* BB check if reconnection needed */ |
1322 | cFYI(1,("IP match, old UNC: %s new: %s", | 1322 | cFYI(1, ("IP match, old UNC: %s new: %s", |
1323 | tcon->treeName, uncName)); | 1323 | tcon->treeName, uncName)); |
1324 | if (strncmp | 1324 | if (strncmp |
1325 | (tcon->treeName, uncName, | 1325 | (tcon->treeName, uncName, |
@@ -1423,7 +1423,7 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, | |||
1423 | int connected = 0; | 1423 | int connected = 0; |
1424 | __be16 orig_port = 0; | 1424 | __be16 orig_port = 0; |
1425 | 1425 | ||
1426 | if(*csocket == NULL) { | 1426 | if (*csocket == NULL) { |
1427 | rc = sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, csocket); | 1427 | rc = sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, csocket); |
1428 | if (rc < 0) { | 1428 | if (rc < 0) { |
1429 | cERROR(1, ("Error %d creating socket",rc)); | 1429 | cERROR(1, ("Error %d creating socket",rc)); |
@@ -1437,7 +1437,7 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, | |||
1437 | } | 1437 | } |
1438 | 1438 | ||
1439 | psin_server->sin_family = AF_INET; | 1439 | psin_server->sin_family = AF_INET; |
1440 | if(psin_server->sin_port) { /* user overrode default port */ | 1440 | if (psin_server->sin_port) { /* user overrode default port */ |
1441 | rc = (*csocket)->ops->connect(*csocket, | 1441 | rc = (*csocket)->ops->connect(*csocket, |
1442 | (struct sockaddr *) psin_server, | 1442 | (struct sockaddr *) psin_server, |
1443 | sizeof (struct sockaddr_in),0); | 1443 | sizeof (struct sockaddr_in),0); |
@@ -1445,13 +1445,13 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, | |||
1445 | connected = 1; | 1445 | connected = 1; |
1446 | } | 1446 | } |
1447 | 1447 | ||
1448 | if(!connected) { | 1448 | if (!connected) { |
1449 | /* save original port so we can retry user specified port | 1449 | /* save original port so we can retry user specified port |
1450 | later if fall back ports fail this time */ | 1450 | later if fall back ports fail this time */ |
1451 | orig_port = psin_server->sin_port; | 1451 | orig_port = psin_server->sin_port; |
1452 | 1452 | ||
1453 | /* do not retry on the same port we just failed on */ | 1453 | /* do not retry on the same port we just failed on */ |
1454 | if(psin_server->sin_port != htons(CIFS_PORT)) { | 1454 | if (psin_server->sin_port != htons(CIFS_PORT)) { |
1455 | psin_server->sin_port = htons(CIFS_PORT); | 1455 | psin_server->sin_port = htons(CIFS_PORT); |
1456 | 1456 | ||
1457 | rc = (*csocket)->ops->connect(*csocket, | 1457 | rc = (*csocket)->ops->connect(*csocket, |
@@ -1472,9 +1472,9 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, | |||
1472 | /* give up here - unless we want to retry on different | 1472 | /* give up here - unless we want to retry on different |
1473 | protocol families some day */ | 1473 | protocol families some day */ |
1474 | if (!connected) { | 1474 | if (!connected) { |
1475 | if(orig_port) | 1475 | if (orig_port) |
1476 | psin_server->sin_port = orig_port; | 1476 | psin_server->sin_port = orig_port; |
1477 | cFYI(1,("Error %d connecting to server via ipv4",rc)); | 1477 | cFYI(1, ("Error %d connecting to server via ipv4",rc)); |
1478 | sock_release(*csocket); | 1478 | sock_release(*csocket); |
1479 | *csocket = NULL; | 1479 | *csocket = NULL; |
1480 | return rc; | 1480 | return rc; |
@@ -1482,26 +1482,26 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, | |||
1482 | /* Eventually check for other socket options to change from | 1482 | /* Eventually check for other socket options to change from |
1483 | the default. sock_setsockopt not used because it expects | 1483 | the default. sock_setsockopt not used because it expects |
1484 | user space buffer */ | 1484 | user space buffer */ |
1485 | cFYI(1,("sndbuf %d rcvbuf %d rcvtimeo 0x%lx",(*csocket)->sk->sk_sndbuf, | 1485 | cFYI(1, ("sndbuf %d rcvbuf %d rcvtimeo 0x%lx",(*csocket)->sk->sk_sndbuf, |
1486 | (*csocket)->sk->sk_rcvbuf, (*csocket)->sk->sk_rcvtimeo)); | 1486 | (*csocket)->sk->sk_rcvbuf, (*csocket)->sk->sk_rcvtimeo)); |
1487 | (*csocket)->sk->sk_rcvtimeo = 7 * HZ; | 1487 | (*csocket)->sk->sk_rcvtimeo = 7 * HZ; |
1488 | /* make the bufsizes depend on wsize/rsize and max requests */ | 1488 | /* make the bufsizes depend on wsize/rsize and max requests */ |
1489 | if((*csocket)->sk->sk_sndbuf < (200 * 1024)) | 1489 | if ((*csocket)->sk->sk_sndbuf < (200 * 1024)) |
1490 | (*csocket)->sk->sk_sndbuf = 200 * 1024; | 1490 | (*csocket)->sk->sk_sndbuf = 200 * 1024; |
1491 | if((*csocket)->sk->sk_rcvbuf < (140 * 1024)) | 1491 | if ((*csocket)->sk->sk_rcvbuf < (140 * 1024)) |
1492 | (*csocket)->sk->sk_rcvbuf = 140 * 1024; | 1492 | (*csocket)->sk->sk_rcvbuf = 140 * 1024; |
1493 | 1493 | ||
1494 | /* send RFC1001 sessinit */ | 1494 | /* send RFC1001 sessinit */ |
1495 | if(psin_server->sin_port == htons(RFC1001_PORT)) { | 1495 | if (psin_server->sin_port == htons(RFC1001_PORT)) { |
1496 | /* some servers require RFC1001 sessinit before sending | 1496 | /* some servers require RFC1001 sessinit before sending |
1497 | negprot - BB check reconnection in case where second | 1497 | negprot - BB check reconnection in case where second |
1498 | sessinit is sent but no second negprot */ | 1498 | sessinit is sent but no second negprot */ |
1499 | struct rfc1002_session_packet * ses_init_buf; | 1499 | struct rfc1002_session_packet * ses_init_buf; |
1500 | struct smb_hdr * smb_buf; | 1500 | struct smb_hdr * smb_buf; |
1501 | ses_init_buf = kzalloc(sizeof(struct rfc1002_session_packet), GFP_KERNEL); | 1501 | ses_init_buf = kzalloc(sizeof(struct rfc1002_session_packet), GFP_KERNEL); |
1502 | if(ses_init_buf) { | 1502 | if (ses_init_buf) { |
1503 | ses_init_buf->trailer.session_req.called_len = 32; | 1503 | ses_init_buf->trailer.session_req.called_len = 32; |
1504 | if(target_name && (target_name[0] != 0)) { | 1504 | if (target_name && (target_name[0] != 0)) { |
1505 | rfc1002mangle(ses_init_buf->trailer.session_req.called_name, | 1505 | rfc1002mangle(ses_init_buf->trailer.session_req.called_name, |
1506 | target_name, 16); | 1506 | target_name, 16); |
1507 | } else { | 1507 | } else { |
@@ -1512,7 +1512,7 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, | |||
1512 | ses_init_buf->trailer.session_req.calling_len = 32; | 1512 | ses_init_buf->trailer.session_req.calling_len = 32; |
1513 | /* calling name ends in null (byte 16) from old smb | 1513 | /* calling name ends in null (byte 16) from old smb |
1514 | convention. */ | 1514 | convention. */ |
1515 | if(netbios_name && (netbios_name[0] !=0)) { | 1515 | if (netbios_name && (netbios_name[0] !=0)) { |
1516 | rfc1002mangle(ses_init_buf->trailer.session_req.calling_name, | 1516 | rfc1002mangle(ses_init_buf->trailer.session_req.calling_name, |
1517 | netbios_name,16); | 1517 | netbios_name,16); |
1518 | } else { | 1518 | } else { |
@@ -1551,7 +1551,7 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket) | |||
1551 | int connected = 0; | 1551 | int connected = 0; |
1552 | __be16 orig_port = 0; | 1552 | __be16 orig_port = 0; |
1553 | 1553 | ||
1554 | if(*csocket == NULL) { | 1554 | if (*csocket == NULL) { |
1555 | rc = sock_create_kern(PF_INET6, SOCK_STREAM, IPPROTO_TCP, csocket); | 1555 | rc = sock_create_kern(PF_INET6, SOCK_STREAM, IPPROTO_TCP, csocket); |
1556 | if (rc < 0) { | 1556 | if (rc < 0) { |
1557 | cERROR(1, ("Error %d creating ipv6 socket",rc)); | 1557 | cERROR(1, ("Error %d creating ipv6 socket",rc)); |
@@ -1559,14 +1559,14 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket) | |||
1559 | return rc; | 1559 | return rc; |
1560 | } else { | 1560 | } else { |
1561 | /* BB other socket options to set KEEPALIVE, NODELAY? */ | 1561 | /* BB other socket options to set KEEPALIVE, NODELAY? */ |
1562 | cFYI(1,("ipv6 Socket created")); | 1562 | cFYI(1, ("ipv6 Socket created")); |
1563 | (*csocket)->sk->sk_allocation = GFP_NOFS; | 1563 | (*csocket)->sk->sk_allocation = GFP_NOFS; |
1564 | } | 1564 | } |
1565 | } | 1565 | } |
1566 | 1566 | ||
1567 | psin_server->sin6_family = AF_INET6; | 1567 | psin_server->sin6_family = AF_INET6; |
1568 | 1568 | ||
1569 | if(psin_server->sin6_port) { /* user overrode default port */ | 1569 | if (psin_server->sin6_port) { /* user overrode default port */ |
1570 | rc = (*csocket)->ops->connect(*csocket, | 1570 | rc = (*csocket)->ops->connect(*csocket, |
1571 | (struct sockaddr *) psin_server, | 1571 | (struct sockaddr *) psin_server, |
1572 | sizeof (struct sockaddr_in6),0); | 1572 | sizeof (struct sockaddr_in6),0); |
@@ -1574,13 +1574,13 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket) | |||
1574 | connected = 1; | 1574 | connected = 1; |
1575 | } | 1575 | } |
1576 | 1576 | ||
1577 | if(!connected) { | 1577 | if (!connected) { |
1578 | /* save original port so we can retry user specified port | 1578 | /* save original port so we can retry user specified port |
1579 | later if fall back ports fail this time */ | 1579 | later if fall back ports fail this time */ |
1580 | 1580 | ||
1581 | orig_port = psin_server->sin6_port; | 1581 | orig_port = psin_server->sin6_port; |
1582 | /* do not retry on the same port we just failed on */ | 1582 | /* do not retry on the same port we just failed on */ |
1583 | if(psin_server->sin6_port != htons(CIFS_PORT)) { | 1583 | if (psin_server->sin6_port != htons(CIFS_PORT)) { |
1584 | psin_server->sin6_port = htons(CIFS_PORT); | 1584 | psin_server->sin6_port = htons(CIFS_PORT); |
1585 | 1585 | ||
1586 | rc = (*csocket)->ops->connect(*csocket, | 1586 | rc = (*csocket)->ops->connect(*csocket, |
@@ -1601,9 +1601,9 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket) | |||
1601 | /* give up here - unless we want to retry on different | 1601 | /* give up here - unless we want to retry on different |
1602 | protocol families some day */ | 1602 | protocol families some day */ |
1603 | if (!connected) { | 1603 | if (!connected) { |
1604 | if(orig_port) | 1604 | if (orig_port) |
1605 | psin_server->sin6_port = orig_port; | 1605 | psin_server->sin6_port = orig_port; |
1606 | cFYI(1,("Error %d connecting to server via ipv6",rc)); | 1606 | cFYI(1, ("Error %d connecting to server via ipv6",rc)); |
1607 | sock_release(*csocket); | 1607 | sock_release(*csocket); |
1608 | *csocket = NULL; | 1608 | *csocket = NULL; |
1609 | return rc; | 1609 | return rc; |
@@ -1631,12 +1631,12 @@ void reset_cifs_unix_caps(int xid, struct cifsTconInfo * tcon, | |||
1631 | __u64 saved_cap = le64_to_cpu(tcon->fsUnixInfo.Capability); | 1631 | __u64 saved_cap = le64_to_cpu(tcon->fsUnixInfo.Capability); |
1632 | 1632 | ||
1633 | 1633 | ||
1634 | if(!CIFSSMBQFSUnixInfo(xid, tcon)) { | 1634 | if (!CIFSSMBQFSUnixInfo(xid, tcon)) { |
1635 | __u64 cap = le64_to_cpu(tcon->fsUnixInfo.Capability); | 1635 | __u64 cap = le64_to_cpu(tcon->fsUnixInfo.Capability); |
1636 | 1636 | ||
1637 | /* check for reconnect case in which we do not | 1637 | /* check for reconnect case in which we do not |
1638 | want to change the mount behavior if we can avoid it */ | 1638 | want to change the mount behavior if we can avoid it */ |
1639 | if(vol_info == NULL) { | 1639 | if (vol_info == NULL) { |
1640 | /* turn off POSIX ACL and PATHNAMES if not set | 1640 | /* turn off POSIX ACL and PATHNAMES if not set |
1641 | originally at mount time */ | 1641 | originally at mount time */ |
1642 | if ((saved_cap & CIFS_UNIX_POSIX_ACL_CAP) == 0) | 1642 | if ((saved_cap & CIFS_UNIX_POSIX_ACL_CAP) == 0) |
@@ -1653,15 +1653,15 @@ void reset_cifs_unix_caps(int xid, struct cifsTconInfo * tcon, | |||
1653 | if (vol_info && vol_info->no_psx_acl) | 1653 | if (vol_info && vol_info->no_psx_acl) |
1654 | cap &= ~CIFS_UNIX_POSIX_ACL_CAP; | 1654 | cap &= ~CIFS_UNIX_POSIX_ACL_CAP; |
1655 | else if (CIFS_UNIX_POSIX_ACL_CAP & cap) { | 1655 | else if (CIFS_UNIX_POSIX_ACL_CAP & cap) { |
1656 | cFYI(1,("negotiated posix acl support")); | 1656 | cFYI(1, ("negotiated posix acl support")); |
1657 | if(sb) | 1657 | if (sb) |
1658 | sb->s_flags |= MS_POSIXACL; | 1658 | sb->s_flags |= MS_POSIXACL; |
1659 | } | 1659 | } |
1660 | 1660 | ||
1661 | if (vol_info && vol_info->posix_paths == 0) | 1661 | if (vol_info && vol_info->posix_paths == 0) |
1662 | cap &= ~CIFS_UNIX_POSIX_PATHNAMES_CAP; | 1662 | cap &= ~CIFS_UNIX_POSIX_PATHNAMES_CAP; |
1663 | else if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) { | 1663 | else if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) { |
1664 | cFYI(1,("negotiate posix pathnames")); | 1664 | cFYI(1, ("negotiate posix pathnames")); |
1665 | if (sb) | 1665 | if (sb) |
1666 | CIFS_SB(sb)->mnt_cifs_flags |= | 1666 | CIFS_SB(sb)->mnt_cifs_flags |= |
1667 | CIFS_MOUNT_POSIX_PATHS; | 1667 | CIFS_MOUNT_POSIX_PATHS; |
@@ -1677,31 +1677,31 @@ void reset_cifs_unix_caps(int xid, struct cifsTconInfo * tcon, | |||
1677 | if ((cap & CIFS_UNIX_LARGE_READ_CAP) == 0) { | 1677 | if ((cap & CIFS_UNIX_LARGE_READ_CAP) == 0) { |
1678 | CIFS_SB(sb)->rsize = 127 * 1024; | 1678 | CIFS_SB(sb)->rsize = 127 * 1024; |
1679 | #ifdef CONFIG_CIFS_DEBUG2 | 1679 | #ifdef CONFIG_CIFS_DEBUG2 |
1680 | cFYI(1,("larger reads not supported by srv")); | 1680 | cFYI(1, ("larger reads not supported by srv")); |
1681 | #endif | 1681 | #endif |
1682 | } | 1682 | } |
1683 | } | 1683 | } |
1684 | 1684 | ||
1685 | 1685 | ||
1686 | cFYI(1,("Negotiate caps 0x%x",(int)cap)); | 1686 | cFYI(1, ("Negotiate caps 0x%x",(int)cap)); |
1687 | #ifdef CONFIG_CIFS_DEBUG2 | 1687 | #ifdef CONFIG_CIFS_DEBUG2 |
1688 | if (cap & CIFS_UNIX_FCNTL_CAP) | 1688 | if (cap & CIFS_UNIX_FCNTL_CAP) |
1689 | cFYI(1,("FCNTL cap")); | 1689 | cFYI(1, ("FCNTL cap")); |
1690 | if (cap & CIFS_UNIX_EXTATTR_CAP) | 1690 | if (cap & CIFS_UNIX_EXTATTR_CAP) |
1691 | cFYI(1,("EXTATTR cap")); | 1691 | cFYI(1, ("EXTATTR cap")); |
1692 | if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) | 1692 | if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) |
1693 | cFYI(1,("POSIX path cap")); | 1693 | cFYI(1, ("POSIX path cap")); |
1694 | if (cap & CIFS_UNIX_XATTR_CAP) | 1694 | if (cap & CIFS_UNIX_XATTR_CAP) |
1695 | cFYI(1,("XATTR cap")); | 1695 | cFYI(1, ("XATTR cap")); |
1696 | if (cap & CIFS_UNIX_POSIX_ACL_CAP) | 1696 | if (cap & CIFS_UNIX_POSIX_ACL_CAP) |
1697 | cFYI(1,("POSIX ACL cap")); | 1697 | cFYI(1, ("POSIX ACL cap")); |
1698 | if (cap & CIFS_UNIX_LARGE_READ_CAP) | 1698 | if (cap & CIFS_UNIX_LARGE_READ_CAP) |
1699 | cFYI(1,("very large read cap")); | 1699 | cFYI(1, ("very large read cap")); |
1700 | if (cap & CIFS_UNIX_LARGE_WRITE_CAP) | 1700 | if (cap & CIFS_UNIX_LARGE_WRITE_CAP) |
1701 | cFYI(1,("very large write cap")); | 1701 | cFYI(1, ("very large write cap")); |
1702 | #endif /* CIFS_DEBUG2 */ | 1702 | #endif /* CIFS_DEBUG2 */ |
1703 | if (CIFSSMBSetFSUnixInfo(xid, tcon, cap)) { | 1703 | if (CIFSSMBSetFSUnixInfo(xid, tcon, cap)) { |
1704 | cFYI(1,("setting capabilities failed")); | 1704 | cFYI(1, ("setting capabilities failed")); |
1705 | } | 1705 | } |
1706 | } | 1706 | } |
1707 | } | 1707 | } |
@@ -1736,7 +1736,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1736 | } | 1736 | } |
1737 | 1737 | ||
1738 | if (volume_info.nullauth) { | 1738 | if (volume_info.nullauth) { |
1739 | cFYI(1,("null user")); | 1739 | cFYI(1, ("null user")); |
1740 | volume_info.username = NULL; | 1740 | volume_info.username = NULL; |
1741 | } else if (volume_info.username) { | 1741 | } else if (volume_info.username) { |
1742 | /* BB fixme parse for domain name here */ | 1742 | /* BB fixme parse for domain name here */ |
@@ -1755,16 +1755,16 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1755 | if (volume_info.UNCip && volume_info.UNC) { | 1755 | if (volume_info.UNCip && volume_info.UNC) { |
1756 | rc = cifs_inet_pton(AF_INET, volume_info.UNCip,&sin_server.sin_addr.s_addr); | 1756 | rc = cifs_inet_pton(AF_INET, volume_info.UNCip,&sin_server.sin_addr.s_addr); |
1757 | 1757 | ||
1758 | if(rc <= 0) { | 1758 | if (rc <= 0) { |
1759 | /* not ipv4 address, try ipv6 */ | 1759 | /* not ipv4 address, try ipv6 */ |
1760 | rc = cifs_inet_pton(AF_INET6,volume_info.UNCip,&sin_server6.sin6_addr.in6_u); | 1760 | rc = cifs_inet_pton(AF_INET6,volume_info.UNCip,&sin_server6.sin6_addr.in6_u); |
1761 | if(rc > 0) | 1761 | if (rc > 0) |
1762 | address_type = AF_INET6; | 1762 | address_type = AF_INET6; |
1763 | } else { | 1763 | } else { |
1764 | address_type = AF_INET; | 1764 | address_type = AF_INET; |
1765 | } | 1765 | } |
1766 | 1766 | ||
1767 | if(rc <= 0) { | 1767 | if (rc <= 0) { |
1768 | /* we failed translating address */ | 1768 | /* we failed translating address */ |
1769 | kfree(volume_info.UNC); | 1769 | kfree(volume_info.UNC); |
1770 | kfree(volume_info.password); | 1770 | kfree(volume_info.password); |
@@ -1795,12 +1795,12 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1795 | } | 1795 | } |
1796 | 1796 | ||
1797 | /* this is needed for ASCII cp to Unicode converts */ | 1797 | /* this is needed for ASCII cp to Unicode converts */ |
1798 | if(volume_info.iocharset == NULL) { | 1798 | if (volume_info.iocharset == NULL) { |
1799 | cifs_sb->local_nls = load_nls_default(); | 1799 | cifs_sb->local_nls = load_nls_default(); |
1800 | /* load_nls_default can not return null */ | 1800 | /* load_nls_default can not return null */ |
1801 | } else { | 1801 | } else { |
1802 | cifs_sb->local_nls = load_nls(volume_info.iocharset); | 1802 | cifs_sb->local_nls = load_nls(volume_info.iocharset); |
1803 | if(cifs_sb->local_nls == NULL) { | 1803 | if (cifs_sb->local_nls == NULL) { |
1804 | cERROR(1,("CIFS mount error: iocharset %s not found",volume_info.iocharset)); | 1804 | cERROR(1,("CIFS mount error: iocharset %s not found",volume_info.iocharset)); |
1805 | kfree(volume_info.UNC); | 1805 | kfree(volume_info.UNC); |
1806 | kfree(volume_info.password); | 1806 | kfree(volume_info.password); |
@@ -1810,12 +1810,12 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1810 | } | 1810 | } |
1811 | } | 1811 | } |
1812 | 1812 | ||
1813 | if(address_type == AF_INET) | 1813 | if (address_type == AF_INET) |
1814 | existingCifsSes = cifs_find_tcp_session(&sin_server.sin_addr, | 1814 | existingCifsSes = cifs_find_tcp_session(&sin_server.sin_addr, |
1815 | NULL /* no ipv6 addr */, | 1815 | NULL /* no ipv6 addr */, |
1816 | volume_info.username, &srvTcp); | 1816 | volume_info.username, &srvTcp); |
1817 | else if(address_type == AF_INET6) { | 1817 | else if (address_type == AF_INET6) { |
1818 | cFYI(1,("looking for ipv6 address")); | 1818 | cFYI(1, ("looking for ipv6 address")); |
1819 | existingCifsSes = cifs_find_tcp_session(NULL /* no ipv4 addr */, | 1819 | existingCifsSes = cifs_find_tcp_session(NULL /* no ipv4 addr */, |
1820 | &sin_server6.sin6_addr, | 1820 | &sin_server6.sin6_addr, |
1821 | volume_info.username, &srvTcp); | 1821 | volume_info.username, &srvTcp); |
@@ -1836,7 +1836,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1836 | else | 1836 | else |
1837 | sin_server.sin_port = 0; | 1837 | sin_server.sin_port = 0; |
1838 | if (address_type == AF_INET6) { | 1838 | if (address_type == AF_INET6) { |
1839 | cFYI(1,("attempting ipv6 connect")); | 1839 | cFYI(1, ("attempting ipv6 connect")); |
1840 | /* BB should we allow ipv6 on port 139? */ | 1840 | /* BB should we allow ipv6 on port 139? */ |
1841 | /* other OS never observed in Wild doing 139 with v6 */ | 1841 | /* other OS never observed in Wild doing 139 with v6 */ |
1842 | rc = ipv6_connect(&sin_server6,&csocket); | 1842 | rc = ipv6_connect(&sin_server6,&csocket); |
@@ -2091,7 +2091,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
2091 | send_sig call */ | 2091 | send_sig call */ |
2092 | force_sig(SIGKILL,srvTcp->tsk); | 2092 | force_sig(SIGKILL,srvTcp->tsk); |
2093 | tsk = srvTcp->tsk; | 2093 | tsk = srvTcp->tsk; |
2094 | if(tsk) | 2094 | if (tsk) |
2095 | kthread_stop(tsk); | 2095 | kthread_stop(tsk); |
2096 | } | 2096 | } |
2097 | } | 2097 | } |
@@ -2133,7 +2133,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
2133 | /* tell server which Unix caps we support */ | 2133 | /* tell server which Unix caps we support */ |
2134 | if (tcon->ses->capabilities & CAP_UNIX) | 2134 | if (tcon->ses->capabilities & CAP_UNIX) |
2135 | reset_cifs_unix_caps(xid, tcon, sb, &volume_info); | 2135 | reset_cifs_unix_caps(xid, tcon, sb, &volume_info); |
2136 | else if(cifs_sb->rsize > (1024 * 127)) { | 2136 | else if (cifs_sb->rsize > (1024 * 127)) { |
2137 | cifs_sb->rsize = 1024 * 127; | 2137 | cifs_sb->rsize = 1024 * 127; |
2138 | #ifdef CONFIG_CIFS_DEBUG2 | 2138 | #ifdef CONFIG_CIFS_DEBUG2 |
2139 | cFYI(1, ("no very large read support, rsize 127K")); | 2139 | cFYI(1, ("no very large read support, rsize 127K")); |
@@ -2200,7 +2200,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2200 | pSMB->req_no_secext.MaxBufferSize = cpu_to_le16(ses->server->maxBuf); | 2200 | pSMB->req_no_secext.MaxBufferSize = cpu_to_le16(ses->server->maxBuf); |
2201 | pSMB->req_no_secext.MaxMpxCount = cpu_to_le16(ses->server->maxReq); | 2201 | pSMB->req_no_secext.MaxMpxCount = cpu_to_le16(ses->server->maxReq); |
2202 | 2202 | ||
2203 | if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) | 2203 | if (ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) |
2204 | smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; | 2204 | smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; |
2205 | 2205 | ||
2206 | capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | | 2206 | capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | |
@@ -2330,10 +2330,10 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2330 | /* We look for obvious messed up bcc or strings in response so we do not go off | 2330 | /* We look for obvious messed up bcc or strings in response so we do not go off |
2331 | the end since (at least) WIN2K and Windows XP have a major bug in not null | 2331 | the end since (at least) WIN2K and Windows XP have a major bug in not null |
2332 | terminating last Unicode string in response */ | 2332 | terminating last Unicode string in response */ |
2333 | if(ses->serverOS) | 2333 | if (ses->serverOS) |
2334 | kfree(ses->serverOS); | 2334 | kfree(ses->serverOS); |
2335 | ses->serverOS = kzalloc(2 * (len + 1), GFP_KERNEL); | 2335 | ses->serverOS = kzalloc(2 * (len + 1), GFP_KERNEL); |
2336 | if(ses->serverOS == NULL) | 2336 | if (ses->serverOS == NULL) |
2337 | goto sesssetup_nomem; | 2337 | goto sesssetup_nomem; |
2338 | cifs_strfromUCS_le(ses->serverOS, | 2338 | cifs_strfromUCS_le(ses->serverOS, |
2339 | (__le16 *)bcc_ptr, len,nls_codepage); | 2339 | (__le16 *)bcc_ptr, len,nls_codepage); |
@@ -2346,14 +2346,14 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2346 | remaining_words-1); | 2346 | remaining_words-1); |
2347 | kfree(ses->serverNOS); | 2347 | kfree(ses->serverNOS); |
2348 | ses->serverNOS = kzalloc(2 * (len + 1),GFP_KERNEL); | 2348 | ses->serverNOS = kzalloc(2 * (len + 1),GFP_KERNEL); |
2349 | if(ses->serverNOS == NULL) | 2349 | if (ses->serverNOS == NULL) |
2350 | goto sesssetup_nomem; | 2350 | goto sesssetup_nomem; |
2351 | cifs_strfromUCS_le(ses->serverNOS, | 2351 | cifs_strfromUCS_le(ses->serverNOS, |
2352 | (__le16 *)bcc_ptr,len,nls_codepage); | 2352 | (__le16 *)bcc_ptr,len,nls_codepage); |
2353 | bcc_ptr += 2 * (len + 1); | 2353 | bcc_ptr += 2 * (len + 1); |
2354 | ses->serverNOS[2 * len] = 0; | 2354 | ses->serverNOS[2 * len] = 0; |
2355 | ses->serverNOS[1 + (2 * len)] = 0; | 2355 | ses->serverNOS[1 + (2 * len)] = 0; |
2356 | if(strncmp(ses->serverNOS, | 2356 | if (strncmp(ses->serverNOS, |
2357 | "NT LAN Manager 4",16) == 0) { | 2357 | "NT LAN Manager 4",16) == 0) { |
2358 | cFYI(1, ("NT4 server")); | 2358 | cFYI(1, ("NT4 server")); |
2359 | ses->flags |= CIFS_SES_NT4; | 2359 | ses->flags |= CIFS_SES_NT4; |
@@ -2362,11 +2362,11 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2362 | if (remaining_words > 0) { | 2362 | if (remaining_words > 0) { |
2363 | len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); | 2363 | len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); |
2364 | /* last string is not always null terminated (for e.g. for Windows XP & 2000) */ | 2364 | /* last string is not always null terminated (for e.g. for Windows XP & 2000) */ |
2365 | if(ses->serverDomain) | 2365 | if (ses->serverDomain) |
2366 | kfree(ses->serverDomain); | 2366 | kfree(ses->serverDomain); |
2367 | ses->serverDomain = | 2367 | ses->serverDomain = |
2368 | kzalloc(2*(len+1),GFP_KERNEL); | 2368 | kzalloc(2*(len+1),GFP_KERNEL); |
2369 | if(ses->serverDomain == NULL) | 2369 | if (ses->serverDomain == NULL) |
2370 | goto sesssetup_nomem; | 2370 | goto sesssetup_nomem; |
2371 | cifs_strfromUCS_le(ses->serverDomain, | 2371 | cifs_strfromUCS_le(ses->serverDomain, |
2372 | (__le16 *)bcc_ptr,len,nls_codepage); | 2372 | (__le16 *)bcc_ptr,len,nls_codepage); |
@@ -2375,7 +2375,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2375 | ses->serverDomain[1+(2*len)] = 0; | 2375 | ses->serverDomain[1+(2*len)] = 0; |
2376 | } /* else no more room so create dummy domain string */ | 2376 | } /* else no more room so create dummy domain string */ |
2377 | else { | 2377 | else { |
2378 | if(ses->serverDomain) | 2378 | if (ses->serverDomain) |
2379 | kfree(ses->serverDomain); | 2379 | kfree(ses->serverDomain); |
2380 | ses->serverDomain = | 2380 | ses->serverDomain = |
2381 | kzalloc(2, GFP_KERNEL); | 2381 | kzalloc(2, GFP_KERNEL); |
@@ -2398,7 +2398,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2398 | <= BCC(smb_buffer_response)) { | 2398 | <= BCC(smb_buffer_response)) { |
2399 | kfree(ses->serverOS); | 2399 | kfree(ses->serverOS); |
2400 | ses->serverOS = kzalloc(len + 1,GFP_KERNEL); | 2400 | ses->serverOS = kzalloc(len + 1,GFP_KERNEL); |
2401 | if(ses->serverOS == NULL) | 2401 | if (ses->serverOS == NULL) |
2402 | goto sesssetup_nomem; | 2402 | goto sesssetup_nomem; |
2403 | strncpy(ses->serverOS,bcc_ptr, len); | 2403 | strncpy(ses->serverOS,bcc_ptr, len); |
2404 | 2404 | ||
@@ -2409,7 +2409,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2409 | len = strnlen(bcc_ptr, 1024); | 2409 | len = strnlen(bcc_ptr, 1024); |
2410 | kfree(ses->serverNOS); | 2410 | kfree(ses->serverNOS); |
2411 | ses->serverNOS = kzalloc(len + 1,GFP_KERNEL); | 2411 | ses->serverNOS = kzalloc(len + 1,GFP_KERNEL); |
2412 | if(ses->serverNOS == NULL) | 2412 | if (ses->serverNOS == NULL) |
2413 | goto sesssetup_nomem; | 2413 | goto sesssetup_nomem; |
2414 | strncpy(ses->serverNOS, bcc_ptr, len); | 2414 | strncpy(ses->serverNOS, bcc_ptr, len); |
2415 | bcc_ptr += len; | 2415 | bcc_ptr += len; |
@@ -2417,10 +2417,10 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2417 | bcc_ptr++; | 2417 | bcc_ptr++; |
2418 | 2418 | ||
2419 | len = strnlen(bcc_ptr, 1024); | 2419 | len = strnlen(bcc_ptr, 1024); |
2420 | if(ses->serverDomain) | 2420 | if (ses->serverDomain) |
2421 | kfree(ses->serverDomain); | 2421 | kfree(ses->serverDomain); |
2422 | ses->serverDomain = kzalloc(len + 1,GFP_KERNEL); | 2422 | ses->serverDomain = kzalloc(len + 1,GFP_KERNEL); |
2423 | if(ses->serverDomain == NULL) | 2423 | if (ses->serverDomain == NULL) |
2424 | goto sesssetup_nomem; | 2424 | goto sesssetup_nomem; |
2425 | strncpy(ses->serverDomain, bcc_ptr, len); | 2425 | strncpy(ses->serverDomain, bcc_ptr, len); |
2426 | bcc_ptr += len; | 2426 | bcc_ptr += len; |
@@ -2472,7 +2472,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2472 | __u16 count; | 2472 | __u16 count; |
2473 | 2473 | ||
2474 | cFYI(1, ("In NTLMSSP sesssetup (negotiate)")); | 2474 | cFYI(1, ("In NTLMSSP sesssetup (negotiate)")); |
2475 | if(ses == NULL) | 2475 | if (ses == NULL) |
2476 | return -EINVAL; | 2476 | return -EINVAL; |
2477 | domain = ses->domainName; | 2477 | domain = ses->domainName; |
2478 | *pNTLMv2_flag = FALSE; | 2478 | *pNTLMv2_flag = FALSE; |
@@ -2496,7 +2496,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2496 | pSMB->req.MaxBufferSize = cpu_to_le16(ses->server->maxBuf); | 2496 | pSMB->req.MaxBufferSize = cpu_to_le16(ses->server->maxBuf); |
2497 | pSMB->req.MaxMpxCount = cpu_to_le16(ses->server->maxReq); | 2497 | pSMB->req.MaxMpxCount = cpu_to_le16(ses->server->maxReq); |
2498 | 2498 | ||
2499 | if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) | 2499 | if (ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) |
2500 | smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; | 2500 | smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; |
2501 | 2501 | ||
2502 | capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | | 2502 | capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | |
@@ -2524,9 +2524,9 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2524 | NTLMSSP_REQUEST_TARGET | NTLMSSP_NEGOTIATE_NTLM | | 2524 | NTLMSSP_REQUEST_TARGET | NTLMSSP_NEGOTIATE_NTLM | |
2525 | NTLMSSP_NEGOTIATE_56 | | 2525 | NTLMSSP_NEGOTIATE_56 | |
2526 | /* NTLMSSP_NEGOTIATE_ALWAYS_SIGN | */ NTLMSSP_NEGOTIATE_128; | 2526 | /* NTLMSSP_NEGOTIATE_ALWAYS_SIGN | */ NTLMSSP_NEGOTIATE_128; |
2527 | if(sign_CIFS_PDUs) | 2527 | if (sign_CIFS_PDUs) |
2528 | negotiate_flags |= NTLMSSP_NEGOTIATE_SIGN; | 2528 | negotiate_flags |= NTLMSSP_NEGOTIATE_SIGN; |
2529 | /* if(ntlmv2_support) | 2529 | /* if (ntlmv2_support) |
2530 | negotiate_flags |= NTLMSSP_NEGOTIATE_NTLMV2;*/ | 2530 | negotiate_flags |= NTLMSSP_NEGOTIATE_NTLMV2;*/ |
2531 | /* setup pointers to domain name and workstation name */ | 2531 | /* setup pointers to domain name and workstation name */ |
2532 | bcc_ptr += SecurityBlobLength; | 2532 | bcc_ptr += SecurityBlobLength; |
@@ -2626,11 +2626,11 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2626 | memcpy(ses->server->cryptKey, | 2626 | memcpy(ses->server->cryptKey, |
2627 | SecurityBlob2->Challenge, | 2627 | SecurityBlob2->Challenge, |
2628 | CIFS_CRYPTO_KEY_SIZE); | 2628 | CIFS_CRYPTO_KEY_SIZE); |
2629 | if(SecurityBlob2->NegotiateFlags & | 2629 | if (SecurityBlob2->NegotiateFlags & |
2630 | cpu_to_le32(NTLMSSP_NEGOTIATE_NTLMV2)) | 2630 | cpu_to_le32(NTLMSSP_NEGOTIATE_NTLMV2)) |
2631 | *pNTLMv2_flag = TRUE; | 2631 | *pNTLMv2_flag = TRUE; |
2632 | 2632 | ||
2633 | if((SecurityBlob2->NegotiateFlags & | 2633 | if ((SecurityBlob2->NegotiateFlags & |
2634 | cpu_to_le32(NTLMSSP_NEGOTIATE_ALWAYS_SIGN)) | 2634 | cpu_to_le32(NTLMSSP_NEGOTIATE_ALWAYS_SIGN)) |
2635 | || (sign_CIFS_PDUs > 1)) | 2635 | || (sign_CIFS_PDUs > 1)) |
2636 | ses->server->secMode |= | 2636 | ses->server->secMode |= |
@@ -2657,7 +2657,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2657 | /* We look for obvious messed up bcc or strings in response so we do not go off | 2657 | /* We look for obvious messed up bcc or strings in response so we do not go off |
2658 | the end since (at least) WIN2K and Windows XP have a major bug in not null | 2658 | the end since (at least) WIN2K and Windows XP have a major bug in not null |
2659 | terminating last Unicode string in response */ | 2659 | terminating last Unicode string in response */ |
2660 | if(ses->serverOS) | 2660 | if (ses->serverOS) |
2661 | kfree(ses->serverOS); | 2661 | kfree(ses->serverOS); |
2662 | ses->serverOS = | 2662 | ses->serverOS = |
2663 | kzalloc(2 * (len + 1), GFP_KERNEL); | 2663 | kzalloc(2 * (len + 1), GFP_KERNEL); |
@@ -2729,7 +2729,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2729 | if (((long) bcc_ptr + len) - (long) | 2729 | if (((long) bcc_ptr + len) - (long) |
2730 | pByteArea(smb_buffer_response) | 2730 | pByteArea(smb_buffer_response) |
2731 | <= BCC(smb_buffer_response)) { | 2731 | <= BCC(smb_buffer_response)) { |
2732 | if(ses->serverOS) | 2732 | if (ses->serverOS) |
2733 | kfree(ses->serverOS); | 2733 | kfree(ses->serverOS); |
2734 | ses->serverOS = | 2734 | ses->serverOS = |
2735 | kzalloc(len + 1, | 2735 | kzalloc(len + 1, |
@@ -2806,7 +2806,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2806 | __u16 count; | 2806 | __u16 count; |
2807 | 2807 | ||
2808 | cFYI(1, ("In NTLMSSPSessSetup (Authenticate)")); | 2808 | cFYI(1, ("In NTLMSSPSessSetup (Authenticate)")); |
2809 | if(ses == NULL) | 2809 | if (ses == NULL) |
2810 | return -EINVAL; | 2810 | return -EINVAL; |
2811 | user = ses->userName; | 2811 | user = ses->userName; |
2812 | domain = ses->domainName; | 2812 | domain = ses->domainName; |
@@ -2831,7 +2831,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2831 | 2831 | ||
2832 | pSMB->req.hdr.Uid = ses->Suid; | 2832 | pSMB->req.hdr.Uid = ses->Suid; |
2833 | 2833 | ||
2834 | if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) | 2834 | if (ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) |
2835 | smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; | 2835 | smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; |
2836 | 2836 | ||
2837 | capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | | 2837 | capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | |
@@ -2859,9 +2859,9 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2859 | NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_REQUEST_TARGET | | 2859 | NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_REQUEST_TARGET | |
2860 | NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_TARGET_INFO | | 2860 | NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_TARGET_INFO | |
2861 | 0x80000000 | NTLMSSP_NEGOTIATE_128; | 2861 | 0x80000000 | NTLMSSP_NEGOTIATE_128; |
2862 | if(sign_CIFS_PDUs) | 2862 | if (sign_CIFS_PDUs) |
2863 | negotiate_flags |= /* NTLMSSP_NEGOTIATE_ALWAYS_SIGN |*/ NTLMSSP_NEGOTIATE_SIGN; | 2863 | negotiate_flags |= /* NTLMSSP_NEGOTIATE_ALWAYS_SIGN |*/ NTLMSSP_NEGOTIATE_SIGN; |
2864 | if(ntlmv2_flag) | 2864 | if (ntlmv2_flag) |
2865 | negotiate_flags |= NTLMSSP_NEGOTIATE_NTLMV2; | 2865 | negotiate_flags |= NTLMSSP_NEGOTIATE_NTLMV2; |
2866 | 2866 | ||
2867 | /* setup pointers to domain name and workstation name */ | 2867 | /* setup pointers to domain name and workstation name */ |
@@ -3018,7 +3018,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
3018 | le16_to_cpu(pSMBr->resp.SecurityBlobLength); | 3018 | le16_to_cpu(pSMBr->resp.SecurityBlobLength); |
3019 | if (action & GUEST_LOGIN) | 3019 | if (action & GUEST_LOGIN) |
3020 | cFYI(1, (" Guest login")); /* BB do we want to set anything in SesInfo struct ? */ | 3020 | cFYI(1, (" Guest login")); /* BB do we want to set anything in SesInfo struct ? */ |
3021 | /* if(SecurityBlob2->MessageType != NtLm??){ | 3021 | /* if (SecurityBlob2->MessageType != NtLm??){ |
3022 | cFYI("Unexpected message type on auth response is %d ")); | 3022 | cFYI("Unexpected message type on auth response is %d ")); |
3023 | } */ | 3023 | } */ |
3024 | if (ses) { | 3024 | if (ses) { |
@@ -3057,7 +3057,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
3057 | /* We look for obvious messed up bcc or strings in response so we do not go off | 3057 | /* We look for obvious messed up bcc or strings in response so we do not go off |
3058 | the end since (at least) WIN2K and Windows XP have a major bug in not null | 3058 | the end since (at least) WIN2K and Windows XP have a major bug in not null |
3059 | terminating last Unicode string in response */ | 3059 | terminating last Unicode string in response */ |
3060 | if(ses->serverOS) | 3060 | if (ses->serverOS) |
3061 | kfree(ses->serverOS); | 3061 | kfree(ses->serverOS); |
3062 | ses->serverOS = | 3062 | ses->serverOS = |
3063 | kzalloc(2 * (len + 1), GFP_KERNEL); | 3063 | kzalloc(2 * (len + 1), GFP_KERNEL); |
@@ -3091,7 +3091,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
3091 | if (remaining_words > 0) { | 3091 | if (remaining_words > 0) { |
3092 | len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); | 3092 | len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); |
3093 | /* last string not always null terminated (e.g. for Windows XP & 2000) */ | 3093 | /* last string not always null terminated (e.g. for Windows XP & 2000) */ |
3094 | if(ses->serverDomain) | 3094 | if (ses->serverDomain) |
3095 | kfree(ses->serverDomain); | 3095 | kfree(ses->serverDomain); |
3096 | ses->serverDomain = | 3096 | ses->serverDomain = |
3097 | kzalloc(2 * | 3097 | kzalloc(2 * |
@@ -3119,12 +3119,12 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
3119 | = 0; | 3119 | = 0; |
3120 | } /* else no more room so create dummy domain string */ | 3120 | } /* else no more room so create dummy domain string */ |
3121 | else { | 3121 | else { |
3122 | if(ses->serverDomain) | 3122 | if (ses->serverDomain) |
3123 | kfree(ses->serverDomain); | 3123 | kfree(ses->serverDomain); |
3124 | ses->serverDomain = kzalloc(2,GFP_KERNEL); | 3124 | ses->serverDomain = kzalloc(2,GFP_KERNEL); |
3125 | } | 3125 | } |
3126 | } else { /* no room so create dummy domain and NOS string */ | 3126 | } else { /* no room so create dummy domain and NOS string */ |
3127 | if(ses->serverDomain) | 3127 | if (ses->serverDomain) |
3128 | kfree(ses->serverDomain); | 3128 | kfree(ses->serverDomain); |
3129 | ses->serverDomain = kzalloc(2, GFP_KERNEL); | 3129 | ses->serverDomain = kzalloc(2, GFP_KERNEL); |
3130 | kfree(ses->serverNOS); | 3130 | kfree(ses->serverNOS); |
@@ -3135,7 +3135,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
3135 | if (((long) bcc_ptr + len) - | 3135 | if (((long) bcc_ptr + len) - |
3136 | (long) pByteArea(smb_buffer_response) | 3136 | (long) pByteArea(smb_buffer_response) |
3137 | <= BCC(smb_buffer_response)) { | 3137 | <= BCC(smb_buffer_response)) { |
3138 | if(ses->serverOS) | 3138 | if (ses->serverOS) |
3139 | kfree(ses->serverOS); | 3139 | kfree(ses->serverOS); |
3140 | ses->serverOS = kzalloc(len + 1,GFP_KERNEL); | 3140 | ses->serverOS = kzalloc(len + 1,GFP_KERNEL); |
3141 | strncpy(ses->serverOS,bcc_ptr, len); | 3141 | strncpy(ses->serverOS,bcc_ptr, len); |
@@ -3153,7 +3153,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
3153 | bcc_ptr++; | 3153 | bcc_ptr++; |
3154 | 3154 | ||
3155 | len = strnlen(bcc_ptr, 1024); | 3155 | len = strnlen(bcc_ptr, 1024); |
3156 | if(ses->serverDomain) | 3156 | if (ses->serverDomain) |
3157 | kfree(ses->serverDomain); | 3157 | kfree(ses->serverDomain); |
3158 | ses->serverDomain = kzalloc(len+1,GFP_KERNEL); | 3158 | ses->serverDomain = kzalloc(len+1,GFP_KERNEL); |
3159 | strncpy(ses->serverDomain, bcc_ptr, len); | 3159 | strncpy(ses->serverDomain, bcc_ptr, len); |
@@ -3219,7 +3219,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3219 | pSMB->AndXCommand = 0xFF; | 3219 | pSMB->AndXCommand = 0xFF; |
3220 | pSMB->Flags = cpu_to_le16(TCON_EXTENDED_SECINFO); | 3220 | pSMB->Flags = cpu_to_le16(TCON_EXTENDED_SECINFO); |
3221 | bcc_ptr = &pSMB->Password[0]; | 3221 | bcc_ptr = &pSMB->Password[0]; |
3222 | if((ses->server->secMode) & SECMODE_USER) { | 3222 | if ((ses->server->secMode) & SECMODE_USER) { |
3223 | pSMB->PasswordLength = cpu_to_le16(1); /* minimum */ | 3223 | pSMB->PasswordLength = cpu_to_le16(1); /* minimum */ |
3224 | *bcc_ptr = 0; /* password is null byte */ | 3224 | *bcc_ptr = 0; /* password is null byte */ |
3225 | bcc_ptr++; /* skip password */ | 3225 | bcc_ptr++; /* skip password */ |
@@ -3233,7 +3233,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3233 | by Samba (not sure whether other servers allow | 3233 | by Samba (not sure whether other servers allow |
3234 | NTLMv2 password here) */ | 3234 | NTLMv2 password here) */ |
3235 | #ifdef CONFIG_CIFS_WEAK_PW_HASH | 3235 | #ifdef CONFIG_CIFS_WEAK_PW_HASH |
3236 | if((extended_security & CIFSSEC_MAY_LANMAN) && | 3236 | if ((extended_security & CIFSSEC_MAY_LANMAN) && |
3237 | (ses->server->secType == LANMAN)) | 3237 | (ses->server->secType == LANMAN)) |
3238 | calc_lanman_hash(ses, bcc_ptr); | 3238 | calc_lanman_hash(ses, bcc_ptr); |
3239 | else | 3239 | else |
@@ -3243,14 +3243,14 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3243 | bcc_ptr); | 3243 | bcc_ptr); |
3244 | 3244 | ||
3245 | bcc_ptr += CIFS_SESS_KEY_SIZE; | 3245 | bcc_ptr += CIFS_SESS_KEY_SIZE; |
3246 | if(ses->capabilities & CAP_UNICODE) { | 3246 | if (ses->capabilities & CAP_UNICODE) { |
3247 | /* must align unicode strings */ | 3247 | /* must align unicode strings */ |
3248 | *bcc_ptr = 0; /* null byte password */ | 3248 | *bcc_ptr = 0; /* null byte password */ |
3249 | bcc_ptr++; | 3249 | bcc_ptr++; |
3250 | } | 3250 | } |
3251 | } | 3251 | } |
3252 | 3252 | ||
3253 | if(ses->server->secMode & | 3253 | if (ses->server->secMode & |
3254 | (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) | 3254 | (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) |
3255 | smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; | 3255 | smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; |
3256 | 3256 | ||
@@ -3321,7 +3321,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3321 | } | 3321 | } |
3322 | /* else do not bother copying these informational fields */ | 3322 | /* else do not bother copying these informational fields */ |
3323 | } | 3323 | } |
3324 | if((smb_buffer_response->WordCount == 3) || | 3324 | if ((smb_buffer_response->WordCount == 3) || |
3325 | (smb_buffer_response->WordCount == 7)) | 3325 | (smb_buffer_response->WordCount == 7)) |
3326 | /* field is in same location */ | 3326 | /* field is in same location */ |
3327 | tcon->Flags = le16_to_cpu(pSMBr->OptionalSupport); | 3327 | tcon->Flags = le16_to_cpu(pSMBr->OptionalSupport); |
@@ -3401,16 +3401,16 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | |||
3401 | int first_time = 0; | 3401 | int first_time = 0; |
3402 | 3402 | ||
3403 | /* what if server changes its buffer size after dropping the session? */ | 3403 | /* what if server changes its buffer size after dropping the session? */ |
3404 | if(pSesInfo->server->maxBuf == 0) /* no need to send on reconnect */ { | 3404 | if (pSesInfo->server->maxBuf == 0) /* no need to send on reconnect */ { |
3405 | rc = CIFSSMBNegotiate(xid, pSesInfo); | 3405 | rc = CIFSSMBNegotiate(xid, pSesInfo); |
3406 | if(rc == -EAGAIN) /* retry only once on 1st time connection */ { | 3406 | if (rc == -EAGAIN) /* retry only once on 1st time connection */ { |
3407 | rc = CIFSSMBNegotiate(xid, pSesInfo); | 3407 | rc = CIFSSMBNegotiate(xid, pSesInfo); |
3408 | if(rc == -EAGAIN) | 3408 | if (rc == -EAGAIN) |
3409 | rc = -EHOSTDOWN; | 3409 | rc = -EHOSTDOWN; |
3410 | } | 3410 | } |
3411 | if(rc == 0) { | 3411 | if (rc == 0) { |
3412 | spin_lock(&GlobalMid_Lock); | 3412 | spin_lock(&GlobalMid_Lock); |
3413 | if(pSesInfo->server->tcpStatus != CifsExiting) | 3413 | if (pSesInfo->server->tcpStatus != CifsExiting) |
3414 | pSesInfo->server->tcpStatus = CifsGood; | 3414 | pSesInfo->server->tcpStatus = CifsGood; |
3415 | else | 3415 | else |
3416 | rc = -EHOSTDOWN; | 3416 | rc = -EHOSTDOWN; |
@@ -3422,14 +3422,14 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | |||
3422 | if (!rc) { | 3422 | if (!rc) { |
3423 | pSesInfo->flags = 0; | 3423 | pSesInfo->flags = 0; |
3424 | pSesInfo->capabilities = pSesInfo->server->capabilities; | 3424 | pSesInfo->capabilities = pSesInfo->server->capabilities; |
3425 | if(linuxExtEnabled == 0) | 3425 | if (linuxExtEnabled == 0) |
3426 | pSesInfo->capabilities &= (~CAP_UNIX); | 3426 | pSesInfo->capabilities &= (~CAP_UNIX); |
3427 | /* pSesInfo->sequence_number = 0;*/ | 3427 | /* pSesInfo->sequence_number = 0;*/ |
3428 | cFYI(1,("Security Mode: 0x%x Capabilities: 0x%x TimeAdjust: %d", | 3428 | cFYI(1, ("Security Mode: 0x%x Capabilities: 0x%x TimeAdjust: %d", |
3429 | pSesInfo->server->secMode, | 3429 | pSesInfo->server->secMode, |
3430 | pSesInfo->server->capabilities, | 3430 | pSesInfo->server->capabilities, |
3431 | pSesInfo->server->timeAdj)); | 3431 | pSesInfo->server->timeAdj)); |
3432 | if(experimEnabled < 2) | 3432 | if (experimEnabled < 2) |
3433 | rc = CIFS_SessSetup(xid, pSesInfo, | 3433 | rc = CIFS_SessSetup(xid, pSesInfo, |
3434 | first_time, nls_info); | 3434 | first_time, nls_info); |
3435 | else if (extended_security | 3435 | else if (extended_security |
@@ -3446,18 +3446,18 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | |||
3446 | &ntlmv2_flag, | 3446 | &ntlmv2_flag, |
3447 | nls_info); | 3447 | nls_info); |
3448 | if (!rc) { | 3448 | if (!rc) { |
3449 | if(ntlmv2_flag) { | 3449 | if (ntlmv2_flag) { |
3450 | char * v2_response; | 3450 | char * v2_response; |
3451 | cFYI(1, ("more secure NTLM ver2 hash")); | 3451 | cFYI(1, ("more secure NTLM ver2 hash")); |
3452 | if(CalcNTLMv2_partial_mac_key(pSesInfo, | 3452 | if (CalcNTLMv2_partial_mac_key(pSesInfo, |
3453 | nls_info)) { | 3453 | nls_info)) { |
3454 | rc = -ENOMEM; | 3454 | rc = -ENOMEM; |
3455 | goto ss_err_exit; | 3455 | goto ss_err_exit; |
3456 | } else | 3456 | } else |
3457 | v2_response = kmalloc(16 + 64 /* blob */, GFP_KERNEL); | 3457 | v2_response = kmalloc(16 + 64 /* blob */, GFP_KERNEL); |
3458 | if(v2_response) { | 3458 | if (v2_response) { |
3459 | CalcNTLMv2_response(pSesInfo,v2_response); | 3459 | CalcNTLMv2_response(pSesInfo,v2_response); |
3460 | /* if(first_time) | 3460 | /* if (first_time) |
3461 | cifs_calculate_ntlmv2_mac_key( | 3461 | cifs_calculate_ntlmv2_mac_key( |
3462 | pSesInfo->server->mac_signing_key, | 3462 | pSesInfo->server->mac_signing_key, |
3463 | response, ntlm_session_key, */ | 3463 | response, ntlm_session_key, */ |
@@ -3473,7 +3473,7 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | |||
3473 | pSesInfo->server->cryptKey, | 3473 | pSesInfo->server->cryptKey, |
3474 | ntlm_session_key); | 3474 | ntlm_session_key); |
3475 | 3475 | ||
3476 | if(first_time) | 3476 | if (first_time) |
3477 | cifs_calculate_mac_key( | 3477 | cifs_calculate_mac_key( |
3478 | &pSesInfo->server->mac_signing_key, | 3478 | &pSesInfo->server->mac_signing_key, |
3479 | ntlm_session_key, | 3479 | ntlm_session_key, |
@@ -3493,7 +3493,7 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | |||
3493 | pSesInfo->server->cryptKey, | 3493 | pSesInfo->server->cryptKey, |
3494 | ntlm_session_key); | 3494 | ntlm_session_key); |
3495 | 3495 | ||
3496 | if(first_time) | 3496 | if (first_time) |
3497 | cifs_calculate_mac_key( | 3497 | cifs_calculate_mac_key( |
3498 | &pSesInfo->server->mac_signing_key, | 3498 | &pSesInfo->server->mac_signing_key, |
3499 | ntlm_session_key, pSesInfo->password); | 3499 | ntlm_session_key, pSesInfo->password); |
@@ -3502,7 +3502,7 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | |||
3502 | ntlm_session_key, nls_info); | 3502 | ntlm_session_key, nls_info); |
3503 | } | 3503 | } |
3504 | if (rc) { | 3504 | if (rc) { |
3505 | cERROR(1,("Send error in SessSetup = %d",rc)); | 3505 | cERROR(1, ("Send error in SessSetup = %d", rc)); |
3506 | } else { | 3506 | } else { |
3507 | cFYI(1, ("CIFS Session Established successfully")); | 3507 | cFYI(1, ("CIFS Session Established successfully")); |
3508 | pSesInfo->status = CifsGood; | 3508 | pSesInfo->status = CifsGood; |