4 * Copyright (C) International Business Machines Corp., 2000,2005
6 * Modified by Steve French (sfrench@us.ibm.com)
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
16 * the GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <linux/string.h>
24 #include <linux/ctype.h>
25 #include <linux/module.h>
26 #include <linux/proc_fs.h>
27 #include <linux/uaccess.h>
30 #include "cifsproto.h"
31 #include "cifs_debug.h"
33 #ifdef CONFIG_CIFS_SMB_DIRECT
34 #include "smbdirect.h"
38 cifs_dump_mem(char *label
, void *data
, int length
)
40 pr_debug("%s: dump of %d bytes of data at 0x%p\n", label
, length
, data
);
41 print_hex_dump(KERN_DEBUG
, "", DUMP_PREFIX_OFFSET
, 16, 4,
45 #ifdef CONFIG_CIFS_DEBUG
46 void cifs_vfs_err(const char *fmt
, ...)
56 pr_err_ratelimited("CIFS VFS: %pV", &vaf
);
62 void cifs_dump_detail(void *buf
)
64 #ifdef CONFIG_CIFS_DEBUG2
65 struct smb_hdr
*smb
= (struct smb_hdr
*)buf
;
67 cifs_dbg(VFS
, "Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d\n",
68 smb
->Command
, smb
->Status
.CifsError
,
69 smb
->Flags
, smb
->Flags2
, smb
->Mid
, smb
->Pid
);
70 cifs_dbg(VFS
, "smb buf %p len %u\n", smb
, smbCalcSize(smb
));
71 #endif /* CONFIG_CIFS_DEBUG2 */
74 void cifs_dump_mids(struct TCP_Server_Info
*server
)
76 #ifdef CONFIG_CIFS_DEBUG2
77 struct list_head
*tmp
;
78 struct mid_q_entry
*mid_entry
;
83 cifs_dbg(VFS
, "Dump pending requests:\n");
84 spin_lock(&GlobalMid_Lock
);
85 list_for_each(tmp
, &server
->pending_mid_q
) {
86 mid_entry
= list_entry(tmp
, struct mid_q_entry
, qhead
);
87 cifs_dbg(VFS
, "State: %d Cmd: %d Pid: %d Cbdata: %p Mid %llu\n",
89 le16_to_cpu(mid_entry
->command
),
91 mid_entry
->callback_data
,
93 #ifdef CONFIG_CIFS_STATS2
94 cifs_dbg(VFS
, "IsLarge: %d buf: %p time rcv: %ld now: %ld\n",
97 mid_entry
->when_received
,
100 cifs_dbg(VFS
, "IsMult: %d IsEnd: %d\n",
101 mid_entry
->multiRsp
, mid_entry
->multiEnd
);
102 if (mid_entry
->resp_buf
) {
103 cifs_dump_detail(mid_entry
->resp_buf
);
104 cifs_dump_mem("existing buf: ",
105 mid_entry
->resp_buf
, 62);
108 spin_unlock(&GlobalMid_Lock
);
109 #endif /* CONFIG_CIFS_DEBUG2 */
112 #ifdef CONFIG_PROC_FS
113 static void cifs_debug_tcon(struct seq_file
*m
, struct cifs_tcon
*tcon
)
115 __u32 dev_type
= le32_to_cpu(tcon
->fsDevInfo
.DeviceType
);
117 seq_printf(m
, "%s Mounts: %d ", tcon
->treeName
, tcon
->tc_count
);
118 if (tcon
->nativeFileSystem
)
119 seq_printf(m
, "Type: %s ", tcon
->nativeFileSystem
);
120 seq_printf(m
, "DevInfo: 0x%x Attributes: 0x%x\n\tPathComponentMax: %d Status: %d",
121 le32_to_cpu(tcon
->fsDevInfo
.DeviceCharacteristics
),
122 le32_to_cpu(tcon
->fsAttrInfo
.Attributes
),
123 le32_to_cpu(tcon
->fsAttrInfo
.MaxPathNameComponentLength
),
125 if (dev_type
== FILE_DEVICE_DISK
)
126 seq_puts(m
, " type: DISK ");
127 else if (dev_type
== FILE_DEVICE_CD_ROM
)
128 seq_puts(m
, " type: CDROM ");
130 seq_printf(m
, " type: %d ", dev_type
);
132 seq_printf(m
, " Encrypted");
134 seq_printf(m
, " POSIX Extensions");
135 if (tcon
->ses
->server
->ops
->dump_share_caps
)
136 tcon
->ses
->server
->ops
->dump_share_caps(m
, tcon
);
138 if (tcon
->need_reconnect
)
139 seq_puts(m
, "\tDISCONNECTED ");
143 static int cifs_debug_data_proc_show(struct seq_file
*m
, void *v
)
145 struct list_head
*tmp1
, *tmp2
, *tmp3
;
146 struct mid_q_entry
*mid_entry
;
147 struct TCP_Server_Info
*server
;
148 struct cifs_ses
*ses
;
149 struct cifs_tcon
*tcon
;
153 "Display Internal CIFS Data Structures for Debugging\n"
154 "---------------------------------------------------\n");
155 seq_printf(m
, "CIFS Version %s\n", CIFS_VERSION
);
156 seq_printf(m
, "Features:");
157 #ifdef CONFIG_CIFS_DFS_UPCALL
158 seq_printf(m
, " dfs");
160 #ifdef CONFIG_CIFS_FSCACHE
161 seq_printf(m
, " fscache");
163 #ifdef CONFIG_CIFS_WEAK_PW_HASH
164 seq_printf(m
, " lanman");
166 #ifdef CONFIG_CIFS_POSIX
167 seq_printf(m
, " posix");
169 #ifdef CONFIG_CIFS_UPCALL
170 seq_printf(m
, " spnego");
172 #ifdef CONFIG_CIFS_XATTR
173 seq_printf(m
, " xattr");
175 #ifdef CONFIG_CIFS_ACL
176 seq_printf(m
, " acl");
179 seq_printf(m
, "Active VFS Requests: %d\n", GlobalTotalActiveXid
);
180 seq_printf(m
, "Servers:");
183 spin_lock(&cifs_tcp_ses_lock
);
184 list_for_each(tmp1
, &cifs_tcp_ses_list
) {
185 server
= list_entry(tmp1
, struct TCP_Server_Info
,
188 #ifdef CONFIG_CIFS_SMB_DIRECT
192 seq_printf(m
, "\nSMBDirect (in hex) protocol version: %x "
193 "transport status: %x",
194 server
->smbd_conn
->protocol
,
195 server
->smbd_conn
->transport_status
);
196 seq_printf(m
, "\nConn receive_credit_max: %x "
197 "send_credit_target: %x max_send_size: %x",
198 server
->smbd_conn
->receive_credit_max
,
199 server
->smbd_conn
->send_credit_target
,
200 server
->smbd_conn
->max_send_size
);
201 seq_printf(m
, "\nConn max_fragmented_recv_size: %x "
202 "max_fragmented_send_size: %x max_receive_size:%x",
203 server
->smbd_conn
->max_fragmented_recv_size
,
204 server
->smbd_conn
->max_fragmented_send_size
,
205 server
->smbd_conn
->max_receive_size
);
206 seq_printf(m
, "\nConn keep_alive_interval: %x "
207 "max_readwrite_size: %x rdma_readwrite_threshold: %x",
208 server
->smbd_conn
->keep_alive_interval
,
209 server
->smbd_conn
->max_readwrite_size
,
210 server
->smbd_conn
->rdma_readwrite_threshold
);
211 seq_printf(m
, "\nDebug count_get_receive_buffer: %x "
212 "count_put_receive_buffer: %x count_send_empty: %x",
213 server
->smbd_conn
->count_get_receive_buffer
,
214 server
->smbd_conn
->count_put_receive_buffer
,
215 server
->smbd_conn
->count_send_empty
);
216 seq_printf(m
, "\nRead Queue count_reassembly_queue: %x "
217 "count_enqueue_reassembly_queue: %x "
218 "count_dequeue_reassembly_queue: %x "
219 "fragment_reassembly_remaining: %x "
220 "reassembly_data_length: %x "
221 "reassembly_queue_length: %x",
222 server
->smbd_conn
->count_reassembly_queue
,
223 server
->smbd_conn
->count_enqueue_reassembly_queue
,
224 server
->smbd_conn
->count_dequeue_reassembly_queue
,
225 server
->smbd_conn
->fragment_reassembly_remaining
,
226 server
->smbd_conn
->reassembly_data_length
,
227 server
->smbd_conn
->reassembly_queue_length
);
228 seq_printf(m
, "\nCurrent Credits send_credits: %x "
229 "receive_credits: %x receive_credit_target: %x",
230 atomic_read(&server
->smbd_conn
->send_credits
),
231 atomic_read(&server
->smbd_conn
->receive_credits
),
232 server
->smbd_conn
->receive_credit_target
);
233 seq_printf(m
, "\nPending send_pending: %x send_payload_pending:"
234 " %x smbd_send_pending: %x smbd_recv_pending: %x",
235 atomic_read(&server
->smbd_conn
->send_pending
),
236 atomic_read(&server
->smbd_conn
->send_payload_pending
),
237 server
->smbd_conn
->smbd_send_pending
,
238 server
->smbd_conn
->smbd_recv_pending
);
239 seq_printf(m
, "\nReceive buffers count_receive_queue: %x "
240 "count_empty_packet_queue: %x",
241 server
->smbd_conn
->count_receive_queue
,
242 server
->smbd_conn
->count_empty_packet_queue
);
243 seq_printf(m
, "\nMR responder_resources: %x "
244 "max_frmr_depth: %x mr_type: %x",
245 server
->smbd_conn
->responder_resources
,
246 server
->smbd_conn
->max_frmr_depth
,
247 server
->smbd_conn
->mr_type
);
248 seq_printf(m
, "\nMR mr_ready_count: %x mr_used_count: %x",
249 atomic_read(&server
->smbd_conn
->mr_ready_count
),
250 atomic_read(&server
->smbd_conn
->mr_used_count
));
253 seq_printf(m
, "\nNumber of credits: %d Dialect 0x%x",
254 server
->credits
, server
->dialect
);
256 seq_printf(m
, " signed");
258 list_for_each(tmp2
, &server
->smb_ses_list
) {
259 ses
= list_entry(tmp2
, struct cifs_ses
,
261 if ((ses
->serverDomain
== NULL
) ||
262 (ses
->serverOS
== NULL
) ||
263 (ses
->serverNOS
== NULL
)) {
264 seq_printf(m
, "\n%d) Name: %s Uses: %d Capability: 0x%x\tSession Status: %d\t",
265 i
, ses
->serverName
, ses
->ses_count
,
266 ses
->capabilities
, ses
->status
);
267 if (ses
->session_flags
& SMB2_SESSION_FLAG_IS_GUEST
)
268 seq_printf(m
, "Guest\t");
269 else if (ses
->session_flags
& SMB2_SESSION_FLAG_IS_NULL
)
270 seq_printf(m
, "Anonymous\t");
273 "\n%d) Name: %s Domain: %s Uses: %d OS:"
274 " %s\n\tNOS: %s\tCapability: 0x%x\n\tSMB"
275 " session status: %d\t",
276 i
, ses
->serverName
, ses
->serverDomain
,
277 ses
->ses_count
, ses
->serverOS
, ses
->serverNOS
,
278 ses
->capabilities
, ses
->status
);
281 seq_printf(m
, "RDMA\n\t");
282 seq_printf(m
, "TCP status: %d\n\tLocal Users To "
283 "Server: %d SecMode: 0x%x Req On Wire: %d",
284 server
->tcpStatus
, server
->srv_count
,
285 server
->sec_mode
, in_flight(server
));
287 #ifdef CONFIG_CIFS_STATS2
288 seq_printf(m
, " In Send: %d In MaxReq Wait: %d",
289 atomic_read(&server
->in_send
),
290 atomic_read(&server
->num_waiters
));
293 seq_puts(m
, "\n\tShares:");
296 seq_printf(m
, "\n\t%d) IPC: ", j
);
298 cifs_debug_tcon(m
, ses
->tcon_ipc
);
300 seq_puts(m
, "none\n");
302 list_for_each(tmp3
, &ses
->tcon_list
) {
303 tcon
= list_entry(tmp3
, struct cifs_tcon
,
306 seq_printf(m
, "\n\t%d) ", j
);
307 cifs_debug_tcon(m
, tcon
);
310 seq_puts(m
, "\n\tMIDs:\n");
312 spin_lock(&GlobalMid_Lock
);
313 list_for_each(tmp3
, &server
->pending_mid_q
) {
314 mid_entry
= list_entry(tmp3
, struct mid_q_entry
,
316 seq_printf(m
, "\tState: %d com: %d pid:"
317 " %d cbdata: %p mid %llu\n",
318 mid_entry
->mid_state
,
319 le16_to_cpu(mid_entry
->command
),
321 mid_entry
->callback_data
,
324 spin_unlock(&GlobalMid_Lock
);
327 spin_unlock(&cifs_tcp_ses_lock
);
330 /* BB add code to dump additional info such as TCP session info now */
334 static int cifs_debug_data_proc_open(struct inode
*inode
, struct file
*file
)
336 return single_open(file
, cifs_debug_data_proc_show
, NULL
);
339 static const struct file_operations cifs_debug_data_proc_fops
= {
340 .open
= cifs_debug_data_proc_open
,
343 .release
= single_release
,
346 #ifdef CONFIG_CIFS_STATS
347 static ssize_t
cifs_stats_proc_write(struct file
*file
,
348 const char __user
*buffer
, size_t count
, loff_t
*ppos
)
352 struct list_head
*tmp1
, *tmp2
, *tmp3
;
353 struct TCP_Server_Info
*server
;
354 struct cifs_ses
*ses
;
355 struct cifs_tcon
*tcon
;
357 rc
= kstrtobool_from_user(buffer
, count
, &bv
);
359 #ifdef CONFIG_CIFS_STATS2
360 atomic_set(&totBufAllocCount
, 0);
361 atomic_set(&totSmBufAllocCount
, 0);
362 #endif /* CONFIG_CIFS_STATS2 */
363 spin_lock(&cifs_tcp_ses_lock
);
364 list_for_each(tmp1
, &cifs_tcp_ses_list
) {
365 server
= list_entry(tmp1
, struct TCP_Server_Info
,
367 list_for_each(tmp2
, &server
->smb_ses_list
) {
368 ses
= list_entry(tmp2
, struct cifs_ses
,
370 list_for_each(tmp3
, &ses
->tcon_list
) {
371 tcon
= list_entry(tmp3
,
374 atomic_set(&tcon
->num_smbs_sent
, 0);
375 if (server
->ops
->clear_stats
)
376 server
->ops
->clear_stats(tcon
);
380 spin_unlock(&cifs_tcp_ses_lock
);
388 static int cifs_stats_proc_show(struct seq_file
*m
, void *v
)
391 struct list_head
*tmp1
, *tmp2
, *tmp3
;
392 struct TCP_Server_Info
*server
;
393 struct cifs_ses
*ses
;
394 struct cifs_tcon
*tcon
;
397 "Resources in use\nCIFS Session: %d\n",
398 sesInfoAllocCount
.counter
);
399 seq_printf(m
, "Share (unique mount targets): %d\n",
400 tconInfoAllocCount
.counter
);
401 seq_printf(m
, "SMB Request/Response Buffer: %d Pool size: %d\n",
402 bufAllocCount
.counter
,
403 cifs_min_rcv
+ tcpSesAllocCount
.counter
);
404 seq_printf(m
, "SMB Small Req/Resp Buffer: %d Pool size: %d\n",
405 smBufAllocCount
.counter
, cifs_min_small
);
406 #ifdef CONFIG_CIFS_STATS2
407 seq_printf(m
, "Total Large %d Small %d Allocations\n",
408 atomic_read(&totBufAllocCount
),
409 atomic_read(&totSmBufAllocCount
));
410 #endif /* CONFIG_CIFS_STATS2 */
412 seq_printf(m
, "Operations (MIDs): %d\n", atomic_read(&midCount
));
414 "\n%d session %d share reconnects\n",
415 tcpSesReconnectCount
.counter
, tconInfoReconnectCount
.counter
);
418 "Total vfs operations: %d maximum at one time: %d\n",
419 GlobalCurrentXid
, GlobalMaxActiveXid
);
422 spin_lock(&cifs_tcp_ses_lock
);
423 list_for_each(tmp1
, &cifs_tcp_ses_list
) {
424 server
= list_entry(tmp1
, struct TCP_Server_Info
,
426 list_for_each(tmp2
, &server
->smb_ses_list
) {
427 ses
= list_entry(tmp2
, struct cifs_ses
,
429 list_for_each(tmp3
, &ses
->tcon_list
) {
430 tcon
= list_entry(tmp3
,
434 seq_printf(m
, "\n%d) %s", i
, tcon
->treeName
);
435 if (tcon
->need_reconnect
)
436 seq_puts(m
, "\tDISCONNECTED ");
437 seq_printf(m
, "\nSMBs: %d",
438 atomic_read(&tcon
->num_smbs_sent
));
439 if (server
->ops
->print_stats
)
440 server
->ops
->print_stats(m
, tcon
);
444 spin_unlock(&cifs_tcp_ses_lock
);
450 static int cifs_stats_proc_open(struct inode
*inode
, struct file
*file
)
452 return single_open(file
, cifs_stats_proc_show
, NULL
);
455 static const struct file_operations cifs_stats_proc_fops
= {
456 .open
= cifs_stats_proc_open
,
459 .release
= single_release
,
460 .write
= cifs_stats_proc_write
,
464 #ifdef CONFIG_CIFS_SMB_DIRECT
465 #define PROC_FILE_DEFINE(name) \
466 static ssize_t name##_write(struct file *file, const char __user *buffer, \
467 size_t count, loff_t *ppos) \
470 rc = kstrtoint_from_user(buffer, count, 10, & name); \
475 static int name##_proc_show(struct seq_file *m, void *v) \
477 seq_printf(m, "%d\n", name ); \
480 static int name##_open(struct inode *inode, struct file *file) \
482 return single_open(file, name##_proc_show, NULL); \
485 static const struct file_operations cifs_##name##_proc_fops = { \
486 .open = name##_open, \
488 .llseek = seq_lseek, \
489 .release = single_release, \
490 .write = name##_write, \
493 PROC_FILE_DEFINE(rdma_readwrite_threshold
);
494 PROC_FILE_DEFINE(smbd_max_frmr_depth
);
495 PROC_FILE_DEFINE(smbd_keep_alive_interval
);
496 PROC_FILE_DEFINE(smbd_max_receive_size
);
497 PROC_FILE_DEFINE(smbd_max_fragmented_recv_size
);
498 PROC_FILE_DEFINE(smbd_max_send_size
);
499 PROC_FILE_DEFINE(smbd_send_credit_target
);
500 PROC_FILE_DEFINE(smbd_receive_credit_max
);
503 static struct proc_dir_entry
*proc_fs_cifs
;
504 static const struct file_operations cifsFYI_proc_fops
;
505 static const struct file_operations cifs_lookup_cache_proc_fops
;
506 static const struct file_operations traceSMB_proc_fops
;
507 static const struct file_operations cifs_security_flags_proc_fops
;
508 static const struct file_operations cifs_linux_ext_proc_fops
;
513 proc_fs_cifs
= proc_mkdir("fs/cifs", NULL
);
514 if (proc_fs_cifs
== NULL
)
517 proc_create("DebugData", 0, proc_fs_cifs
, &cifs_debug_data_proc_fops
);
519 #ifdef CONFIG_CIFS_STATS
520 proc_create("Stats", 0, proc_fs_cifs
, &cifs_stats_proc_fops
);
522 proc_create("cifsFYI", 0, proc_fs_cifs
, &cifsFYI_proc_fops
);
523 proc_create("traceSMB", 0, proc_fs_cifs
, &traceSMB_proc_fops
);
524 proc_create("LinuxExtensionsEnabled", 0, proc_fs_cifs
,
525 &cifs_linux_ext_proc_fops
);
526 proc_create("SecurityFlags", 0, proc_fs_cifs
,
527 &cifs_security_flags_proc_fops
);
528 proc_create("LookupCacheEnabled", 0, proc_fs_cifs
,
529 &cifs_lookup_cache_proc_fops
);
530 #ifdef CONFIG_CIFS_SMB_DIRECT
531 proc_create("rdma_readwrite_threshold", 0, proc_fs_cifs
,
532 &cifs_rdma_readwrite_threshold_proc_fops
);
533 proc_create("smbd_max_frmr_depth", 0, proc_fs_cifs
,
534 &cifs_smbd_max_frmr_depth_proc_fops
);
535 proc_create("smbd_keep_alive_interval", 0, proc_fs_cifs
,
536 &cifs_smbd_keep_alive_interval_proc_fops
);
537 proc_create("smbd_max_receive_size", 0, proc_fs_cifs
,
538 &cifs_smbd_max_receive_size_proc_fops
);
539 proc_create("smbd_max_fragmented_recv_size", 0, proc_fs_cifs
,
540 &cifs_smbd_max_fragmented_recv_size_proc_fops
);
541 proc_create("smbd_max_send_size", 0, proc_fs_cifs
,
542 &cifs_smbd_max_send_size_proc_fops
);
543 proc_create("smbd_send_credit_target", 0, proc_fs_cifs
,
544 &cifs_smbd_send_credit_target_proc_fops
);
545 proc_create("smbd_receive_credit_max", 0, proc_fs_cifs
,
546 &cifs_smbd_receive_credit_max_proc_fops
);
551 cifs_proc_clean(void)
553 if (proc_fs_cifs
== NULL
)
556 remove_proc_entry("DebugData", proc_fs_cifs
);
557 remove_proc_entry("cifsFYI", proc_fs_cifs
);
558 remove_proc_entry("traceSMB", proc_fs_cifs
);
559 #ifdef CONFIG_CIFS_STATS
560 remove_proc_entry("Stats", proc_fs_cifs
);
562 remove_proc_entry("SecurityFlags", proc_fs_cifs
);
563 remove_proc_entry("LinuxExtensionsEnabled", proc_fs_cifs
);
564 remove_proc_entry("LookupCacheEnabled", proc_fs_cifs
);
565 #ifdef CONFIG_CIFS_SMB_DIRECT
566 remove_proc_entry("rdma_readwrite_threshold", proc_fs_cifs
);
567 remove_proc_entry("smbd_max_frmr_depth", proc_fs_cifs
);
568 remove_proc_entry("smbd_keep_alive_interval", proc_fs_cifs
);
569 remove_proc_entry("smbd_max_receive_size", proc_fs_cifs
);
570 remove_proc_entry("smbd_max_fragmented_recv_size", proc_fs_cifs
);
571 remove_proc_entry("smbd_max_send_size", proc_fs_cifs
);
572 remove_proc_entry("smbd_send_credit_target", proc_fs_cifs
);
573 remove_proc_entry("smbd_receive_credit_max", proc_fs_cifs
);
575 remove_proc_entry("fs/cifs", NULL
);
578 static int cifsFYI_proc_show(struct seq_file
*m
, void *v
)
580 seq_printf(m
, "%d\n", cifsFYI
);
584 static int cifsFYI_proc_open(struct inode
*inode
, struct file
*file
)
586 return single_open(file
, cifsFYI_proc_show
, NULL
);
589 static ssize_t
cifsFYI_proc_write(struct file
*file
, const char __user
*buffer
,
590 size_t count
, loff_t
*ppos
)
592 char c
[2] = { '\0' };
596 rc
= get_user(c
[0], buffer
);
599 if (strtobool(c
, &bv
) == 0)
601 else if ((c
[0] > '1') && (c
[0] <= '9'))
602 cifsFYI
= (int) (c
[0] - '0'); /* see cifs_debug.h for meanings */
607 static const struct file_operations cifsFYI_proc_fops
= {
608 .open
= cifsFYI_proc_open
,
611 .release
= single_release
,
612 .write
= cifsFYI_proc_write
,
615 static int cifs_linux_ext_proc_show(struct seq_file
*m
, void *v
)
617 seq_printf(m
, "%d\n", linuxExtEnabled
);
621 static int cifs_linux_ext_proc_open(struct inode
*inode
, struct file
*file
)
623 return single_open(file
, cifs_linux_ext_proc_show
, NULL
);
626 static ssize_t
cifs_linux_ext_proc_write(struct file
*file
,
627 const char __user
*buffer
, size_t count
, loff_t
*ppos
)
631 rc
= kstrtobool_from_user(buffer
, count
, &linuxExtEnabled
);
638 static const struct file_operations cifs_linux_ext_proc_fops
= {
639 .open
= cifs_linux_ext_proc_open
,
642 .release
= single_release
,
643 .write
= cifs_linux_ext_proc_write
,
646 static int cifs_lookup_cache_proc_show(struct seq_file
*m
, void *v
)
648 seq_printf(m
, "%d\n", lookupCacheEnabled
);
652 static int cifs_lookup_cache_proc_open(struct inode
*inode
, struct file
*file
)
654 return single_open(file
, cifs_lookup_cache_proc_show
, NULL
);
657 static ssize_t
cifs_lookup_cache_proc_write(struct file
*file
,
658 const char __user
*buffer
, size_t count
, loff_t
*ppos
)
662 rc
= kstrtobool_from_user(buffer
, count
, &lookupCacheEnabled
);
669 static const struct file_operations cifs_lookup_cache_proc_fops
= {
670 .open
= cifs_lookup_cache_proc_open
,
673 .release
= single_release
,
674 .write
= cifs_lookup_cache_proc_write
,
677 static int traceSMB_proc_show(struct seq_file
*m
, void *v
)
679 seq_printf(m
, "%d\n", traceSMB
);
683 static int traceSMB_proc_open(struct inode
*inode
, struct file
*file
)
685 return single_open(file
, traceSMB_proc_show
, NULL
);
688 static ssize_t
traceSMB_proc_write(struct file
*file
, const char __user
*buffer
,
689 size_t count
, loff_t
*ppos
)
693 rc
= kstrtobool_from_user(buffer
, count
, &traceSMB
);
700 static const struct file_operations traceSMB_proc_fops
= {
701 .open
= traceSMB_proc_open
,
704 .release
= single_release
,
705 .write
= traceSMB_proc_write
,
708 static int cifs_security_flags_proc_show(struct seq_file
*m
, void *v
)
710 seq_printf(m
, "0x%x\n", global_secflags
);
714 static int cifs_security_flags_proc_open(struct inode
*inode
, struct file
*file
)
716 return single_open(file
, cifs_security_flags_proc_show
, NULL
);
720 * Ensure that if someone sets a MUST flag, that we disable all other MAY
721 * flags except for the ones corresponding to the given MUST flag. If there are
722 * multiple MUST flags, then try to prefer more secure ones.
725 cifs_security_flags_handle_must_flags(unsigned int *flags
)
727 unsigned int signflags
= *flags
& CIFSSEC_MUST_SIGN
;
729 if ((*flags
& CIFSSEC_MUST_KRB5
) == CIFSSEC_MUST_KRB5
)
730 *flags
= CIFSSEC_MUST_KRB5
;
731 else if ((*flags
& CIFSSEC_MUST_NTLMSSP
) == CIFSSEC_MUST_NTLMSSP
)
732 *flags
= CIFSSEC_MUST_NTLMSSP
;
733 else if ((*flags
& CIFSSEC_MUST_NTLMV2
) == CIFSSEC_MUST_NTLMV2
)
734 *flags
= CIFSSEC_MUST_NTLMV2
;
735 else if ((*flags
& CIFSSEC_MUST_NTLM
) == CIFSSEC_MUST_NTLM
)
736 *flags
= CIFSSEC_MUST_NTLM
;
737 else if (CIFSSEC_MUST_LANMAN
&&
738 (*flags
& CIFSSEC_MUST_LANMAN
) == CIFSSEC_MUST_LANMAN
)
739 *flags
= CIFSSEC_MUST_LANMAN
;
740 else if (CIFSSEC_MUST_PLNTXT
&&
741 (*flags
& CIFSSEC_MUST_PLNTXT
) == CIFSSEC_MUST_PLNTXT
)
742 *flags
= CIFSSEC_MUST_PLNTXT
;
747 static ssize_t
cifs_security_flags_proc_write(struct file
*file
,
748 const char __user
*buffer
, size_t count
, loff_t
*ppos
)
752 char flags_string
[12];
755 if ((count
< 1) || (count
> 11))
758 memset(flags_string
, 0, 12);
760 if (copy_from_user(flags_string
, buffer
, count
))
764 /* single char or single char followed by null */
765 if (strtobool(flags_string
, &bv
) == 0) {
766 global_secflags
= bv
? CIFSSEC_MAX
: CIFSSEC_DEF
;
768 } else if (!isdigit(flags_string
[0])) {
769 cifs_dbg(VFS
, "Invalid SecurityFlags: %s\n",
775 /* else we have a number */
776 rc
= kstrtouint(flags_string
, 0, &flags
);
778 cifs_dbg(VFS
, "Invalid SecurityFlags: %s\n",
783 cifs_dbg(FYI
, "sec flags 0x%x\n", flags
);
786 cifs_dbg(VFS
, "Invalid SecurityFlags: %s\n", flags_string
);
790 if (flags
& ~CIFSSEC_MASK
) {
791 cifs_dbg(VFS
, "Unsupported security flags: 0x%x\n",
792 flags
& ~CIFSSEC_MASK
);
796 cifs_security_flags_handle_must_flags(&flags
);
798 /* flags look ok - update the global security flags for cifs module */
799 global_secflags
= flags
;
800 if (global_secflags
& CIFSSEC_MUST_SIGN
) {
801 /* requiring signing implies signing is allowed */
802 global_secflags
|= CIFSSEC_MAY_SIGN
;
803 cifs_dbg(FYI
, "packet signing now required\n");
804 } else if ((global_secflags
& CIFSSEC_MAY_SIGN
) == 0) {
805 cifs_dbg(FYI
, "packet signing disabled\n");
807 /* BB should we turn on MAY flags for other MUST options? */
811 static const struct file_operations cifs_security_flags_proc_fops
= {
812 .open
= cifs_security_flags_proc_open
,
815 .release
= single_release
,
816 .write
= cifs_security_flags_proc_write
,
819 inline void cifs_proc_init(void)
823 inline void cifs_proc_clean(void)