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 void cifs_dump_detail(void *buf
, struct TCP_Server_Info
*server
)
47 #ifdef CONFIG_CIFS_DEBUG2
48 struct smb_hdr
*smb
= (struct smb_hdr
*)buf
;
50 cifs_dbg(VFS
, "Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d\n",
51 smb
->Command
, smb
->Status
.CifsError
,
52 smb
->Flags
, smb
->Flags2
, smb
->Mid
, smb
->Pid
);
53 cifs_dbg(VFS
, "smb buf %p len %u\n", smb
,
54 server
->ops
->calc_smb_size(smb
, server
));
55 #endif /* CONFIG_CIFS_DEBUG2 */
58 void cifs_dump_mids(struct TCP_Server_Info
*server
)
60 #ifdef CONFIG_CIFS_DEBUG2
61 struct list_head
*tmp
;
62 struct mid_q_entry
*mid_entry
;
67 cifs_dbg(VFS
, "Dump pending requests:\n");
68 spin_lock(&GlobalMid_Lock
);
69 list_for_each(tmp
, &server
->pending_mid_q
) {
70 mid_entry
= list_entry(tmp
, struct mid_q_entry
, qhead
);
71 cifs_dbg(VFS
, "State: %d Cmd: %d Pid: %d Cbdata: %p Mid %llu\n",
73 le16_to_cpu(mid_entry
->command
),
75 mid_entry
->callback_data
,
77 #ifdef CONFIG_CIFS_STATS2
78 cifs_dbg(VFS
, "IsLarge: %d buf: %p time rcv: %ld now: %ld\n",
81 mid_entry
->when_received
,
84 cifs_dbg(VFS
, "IsMult: %d IsEnd: %d\n",
85 mid_entry
->multiRsp
, mid_entry
->multiEnd
);
86 if (mid_entry
->resp_buf
) {
87 cifs_dump_detail(mid_entry
->resp_buf
, server
);
88 cifs_dump_mem("existing buf: ",
89 mid_entry
->resp_buf
, 62);
92 spin_unlock(&GlobalMid_Lock
);
93 #endif /* CONFIG_CIFS_DEBUG2 */
97 static void cifs_debug_tcon(struct seq_file
*m
, struct cifs_tcon
*tcon
)
99 __u32 dev_type
= le32_to_cpu(tcon
->fsDevInfo
.DeviceType
);
101 seq_printf(m
, "%s Mounts: %d ", tcon
->treeName
, tcon
->tc_count
);
102 if (tcon
->nativeFileSystem
)
103 seq_printf(m
, "Type: %s ", tcon
->nativeFileSystem
);
104 seq_printf(m
, "DevInfo: 0x%x Attributes: 0x%x\n\tPathComponentMax: %d Status: %d",
105 le32_to_cpu(tcon
->fsDevInfo
.DeviceCharacteristics
),
106 le32_to_cpu(tcon
->fsAttrInfo
.Attributes
),
107 le32_to_cpu(tcon
->fsAttrInfo
.MaxPathNameComponentLength
),
109 if (dev_type
== FILE_DEVICE_DISK
)
110 seq_puts(m
, " type: DISK ");
111 else if (dev_type
== FILE_DEVICE_CD_ROM
)
112 seq_puts(m
, " type: CDROM ");
114 seq_printf(m
, " type: %d ", dev_type
);
116 seq_printf(m
, " Encrypted");
118 seq_printf(m
, " nocase");
120 seq_printf(m
, " POSIX Extensions");
121 if (tcon
->ses
->server
->ops
->dump_share_caps
)
122 tcon
->ses
->server
->ops
->dump_share_caps(m
, tcon
);
124 if (tcon
->need_reconnect
)
125 seq_puts(m
, "\tDISCONNECTED ");
130 cifs_dump_iface(struct seq_file
*m
, struct cifs_server_iface
*iface
)
132 struct sockaddr_in
*ipv4
= (struct sockaddr_in
*)&iface
->sockaddr
;
133 struct sockaddr_in6
*ipv6
= (struct sockaddr_in6
*)&iface
->sockaddr
;
135 seq_printf(m
, "\t\tSpeed: %zu bps\n", iface
->speed
);
136 seq_puts(m
, "\t\tCapabilities: ");
137 if (iface
->rdma_capable
)
138 seq_puts(m
, "rdma ");
139 if (iface
->rss_capable
)
142 if (iface
->sockaddr
.ss_family
== AF_INET
)
143 seq_printf(m
, "\t\tIPv4: %pI4\n", &ipv4
->sin_addr
);
144 else if (iface
->sockaddr
.ss_family
== AF_INET6
)
145 seq_printf(m
, "\t\tIPv6: %pI6\n", &ipv6
->sin6_addr
);
148 static int cifs_debug_data_proc_show(struct seq_file
*m
, void *v
)
150 struct list_head
*tmp1
, *tmp2
, *tmp3
;
151 struct mid_q_entry
*mid_entry
;
152 struct TCP_Server_Info
*server
;
153 struct cifs_ses
*ses
;
154 struct cifs_tcon
*tcon
;
158 "Display Internal CIFS Data Structures for Debugging\n"
159 "---------------------------------------------------\n");
160 seq_printf(m
, "CIFS Version %s\n", CIFS_VERSION
);
161 seq_printf(m
, "Features:");
162 #ifdef CONFIG_CIFS_DFS_UPCALL
163 seq_printf(m
, " dfs");
165 #ifdef CONFIG_CIFS_FSCACHE
166 seq_printf(m
, " fscache");
168 #ifdef CONFIG_CIFS_WEAK_PW_HASH
169 seq_printf(m
, " lanman");
171 #ifdef CONFIG_CIFS_POSIX
172 seq_printf(m
, " posix");
174 #ifdef CONFIG_CIFS_UPCALL
175 seq_printf(m
, " spnego");
177 #ifdef CONFIG_CIFS_XATTR
178 seq_printf(m
, " xattr");
180 #ifdef CONFIG_CIFS_ACL
181 seq_printf(m
, " acl");
184 seq_printf(m
, "Active VFS Requests: %d\n", GlobalTotalActiveXid
);
185 seq_printf(m
, "Servers:");
188 spin_lock(&cifs_tcp_ses_lock
);
189 list_for_each(tmp1
, &cifs_tcp_ses_list
) {
190 server
= list_entry(tmp1
, struct TCP_Server_Info
,
193 #ifdef CONFIG_CIFS_SMB_DIRECT
197 seq_printf(m
, "\nSMBDirect (in hex) protocol version: %x "
198 "transport status: %x",
199 server
->smbd_conn
->protocol
,
200 server
->smbd_conn
->transport_status
);
201 seq_printf(m
, "\nConn receive_credit_max: %x "
202 "send_credit_target: %x max_send_size: %x",
203 server
->smbd_conn
->receive_credit_max
,
204 server
->smbd_conn
->send_credit_target
,
205 server
->smbd_conn
->max_send_size
);
206 seq_printf(m
, "\nConn max_fragmented_recv_size: %x "
207 "max_fragmented_send_size: %x max_receive_size:%x",
208 server
->smbd_conn
->max_fragmented_recv_size
,
209 server
->smbd_conn
->max_fragmented_send_size
,
210 server
->smbd_conn
->max_receive_size
);
211 seq_printf(m
, "\nConn keep_alive_interval: %x "
212 "max_readwrite_size: %x rdma_readwrite_threshold: %x",
213 server
->smbd_conn
->keep_alive_interval
,
214 server
->smbd_conn
->max_readwrite_size
,
215 server
->smbd_conn
->rdma_readwrite_threshold
);
216 seq_printf(m
, "\nDebug count_get_receive_buffer: %x "
217 "count_put_receive_buffer: %x count_send_empty: %x",
218 server
->smbd_conn
->count_get_receive_buffer
,
219 server
->smbd_conn
->count_put_receive_buffer
,
220 server
->smbd_conn
->count_send_empty
);
221 seq_printf(m
, "\nRead Queue count_reassembly_queue: %x "
222 "count_enqueue_reassembly_queue: %x "
223 "count_dequeue_reassembly_queue: %x "
224 "fragment_reassembly_remaining: %x "
225 "reassembly_data_length: %x "
226 "reassembly_queue_length: %x",
227 server
->smbd_conn
->count_reassembly_queue
,
228 server
->smbd_conn
->count_enqueue_reassembly_queue
,
229 server
->smbd_conn
->count_dequeue_reassembly_queue
,
230 server
->smbd_conn
->fragment_reassembly_remaining
,
231 server
->smbd_conn
->reassembly_data_length
,
232 server
->smbd_conn
->reassembly_queue_length
);
233 seq_printf(m
, "\nCurrent Credits send_credits: %x "
234 "receive_credits: %x receive_credit_target: %x",
235 atomic_read(&server
->smbd_conn
->send_credits
),
236 atomic_read(&server
->smbd_conn
->receive_credits
),
237 server
->smbd_conn
->receive_credit_target
);
238 seq_printf(m
, "\nPending send_pending: %x send_payload_pending:"
239 " %x smbd_send_pending: %x smbd_recv_pending: %x",
240 atomic_read(&server
->smbd_conn
->send_pending
),
241 atomic_read(&server
->smbd_conn
->send_payload_pending
),
242 server
->smbd_conn
->smbd_send_pending
,
243 server
->smbd_conn
->smbd_recv_pending
);
244 seq_printf(m
, "\nReceive buffers count_receive_queue: %x "
245 "count_empty_packet_queue: %x",
246 server
->smbd_conn
->count_receive_queue
,
247 server
->smbd_conn
->count_empty_packet_queue
);
248 seq_printf(m
, "\nMR responder_resources: %x "
249 "max_frmr_depth: %x mr_type: %x",
250 server
->smbd_conn
->responder_resources
,
251 server
->smbd_conn
->max_frmr_depth
,
252 server
->smbd_conn
->mr_type
);
253 seq_printf(m
, "\nMR mr_ready_count: %x mr_used_count: %x",
254 atomic_read(&server
->smbd_conn
->mr_ready_count
),
255 atomic_read(&server
->smbd_conn
->mr_used_count
));
258 seq_printf(m
, "\nNumber of credits: %d Dialect 0x%x",
259 server
->credits
, server
->dialect
);
261 seq_printf(m
, " signed");
262 #ifdef CONFIG_CIFS_SMB311
263 if (server
->posix_ext_supported
)
264 seq_printf(m
, " posix");
267 list_for_each(tmp2
, &server
->smb_ses_list
) {
268 ses
= list_entry(tmp2
, struct cifs_ses
,
270 if ((ses
->serverDomain
== NULL
) ||
271 (ses
->serverOS
== NULL
) ||
272 (ses
->serverNOS
== NULL
)) {
273 seq_printf(m
, "\n%d) Name: %s Uses: %d Capability: 0x%x\tSession Status: %d\t",
274 i
, ses
->serverName
, ses
->ses_count
,
275 ses
->capabilities
, ses
->status
);
276 if (ses
->session_flags
& SMB2_SESSION_FLAG_IS_GUEST
)
277 seq_printf(m
, "Guest\t");
278 else if (ses
->session_flags
& SMB2_SESSION_FLAG_IS_NULL
)
279 seq_printf(m
, "Anonymous\t");
282 "\n%d) Name: %s Domain: %s Uses: %d OS:"
283 " %s\n\tNOS: %s\tCapability: 0x%x\n\tSMB"
284 " session status: %d\t",
285 i
, ses
->serverName
, ses
->serverDomain
,
286 ses
->ses_count
, ses
->serverOS
, ses
->serverNOS
,
287 ses
->capabilities
, ses
->status
);
290 seq_printf(m
, "RDMA\n\t");
291 seq_printf(m
, "TCP status: %d\n\tLocal Users To "
292 "Server: %d SecMode: 0x%x Req On Wire: %d",
293 server
->tcpStatus
, server
->srv_count
,
294 server
->sec_mode
, in_flight(server
));
296 #ifdef CONFIG_CIFS_STATS2
297 seq_printf(m
, " In Send: %d In MaxReq Wait: %d",
298 atomic_read(&server
->in_send
),
299 atomic_read(&server
->num_waiters
));
302 seq_puts(m
, "\n\tShares:");
305 seq_printf(m
, "\n\t%d) IPC: ", j
);
307 cifs_debug_tcon(m
, ses
->tcon_ipc
);
309 seq_puts(m
, "none\n");
311 list_for_each(tmp3
, &ses
->tcon_list
) {
312 tcon
= list_entry(tmp3
, struct cifs_tcon
,
315 seq_printf(m
, "\n\t%d) ", j
);
316 cifs_debug_tcon(m
, tcon
);
319 seq_puts(m
, "\n\tMIDs:\n");
321 spin_lock(&GlobalMid_Lock
);
322 list_for_each(tmp3
, &server
->pending_mid_q
) {
323 mid_entry
= list_entry(tmp3
, struct mid_q_entry
,
325 seq_printf(m
, "\tState: %d com: %d pid:"
326 " %d cbdata: %p mid %llu\n",
327 mid_entry
->mid_state
,
328 le16_to_cpu(mid_entry
->command
),
330 mid_entry
->callback_data
,
333 spin_unlock(&GlobalMid_Lock
);
335 spin_lock(&ses
->iface_lock
);
336 if (ses
->iface_count
)
337 seq_printf(m
, "\n\tServer interfaces: %zu\n",
339 for (j
= 0; j
< ses
->iface_count
; j
++) {
340 seq_printf(m
, "\t%d)\n", j
);
341 cifs_dump_iface(m
, &ses
->iface_list
[j
]);
343 spin_unlock(&ses
->iface_lock
);
346 spin_unlock(&cifs_tcp_ses_lock
);
349 /* BB add code to dump additional info such as TCP session info now */
353 #ifdef CONFIG_CIFS_STATS
354 static ssize_t
cifs_stats_proc_write(struct file
*file
,
355 const char __user
*buffer
, size_t count
, loff_t
*ppos
)
359 struct list_head
*tmp1
, *tmp2
, *tmp3
;
360 struct TCP_Server_Info
*server
;
361 struct cifs_ses
*ses
;
362 struct cifs_tcon
*tcon
;
364 rc
= kstrtobool_from_user(buffer
, count
, &bv
);
366 #ifdef CONFIG_CIFS_STATS2
367 atomic_set(&totBufAllocCount
, 0);
368 atomic_set(&totSmBufAllocCount
, 0);
369 #endif /* CONFIG_CIFS_STATS2 */
370 spin_lock(&cifs_tcp_ses_lock
);
371 list_for_each(tmp1
, &cifs_tcp_ses_list
) {
372 server
= list_entry(tmp1
, struct TCP_Server_Info
,
374 list_for_each(tmp2
, &server
->smb_ses_list
) {
375 ses
= list_entry(tmp2
, struct cifs_ses
,
377 list_for_each(tmp3
, &ses
->tcon_list
) {
378 tcon
= list_entry(tmp3
,
381 atomic_set(&tcon
->num_smbs_sent
, 0);
382 if (server
->ops
->clear_stats
)
383 server
->ops
->clear_stats(tcon
);
387 spin_unlock(&cifs_tcp_ses_lock
);
395 static int cifs_stats_proc_show(struct seq_file
*m
, void *v
)
398 struct list_head
*tmp1
, *tmp2
, *tmp3
;
399 struct TCP_Server_Info
*server
;
400 struct cifs_ses
*ses
;
401 struct cifs_tcon
*tcon
;
404 "Resources in use\nCIFS Session: %d\n",
405 sesInfoAllocCount
.counter
);
406 seq_printf(m
, "Share (unique mount targets): %d\n",
407 tconInfoAllocCount
.counter
);
408 seq_printf(m
, "SMB Request/Response Buffer: %d Pool size: %d\n",
409 bufAllocCount
.counter
,
410 cifs_min_rcv
+ tcpSesAllocCount
.counter
);
411 seq_printf(m
, "SMB Small Req/Resp Buffer: %d Pool size: %d\n",
412 smBufAllocCount
.counter
, cifs_min_small
);
413 #ifdef CONFIG_CIFS_STATS2
414 seq_printf(m
, "Total Large %d Small %d Allocations\n",
415 atomic_read(&totBufAllocCount
),
416 atomic_read(&totSmBufAllocCount
));
417 #endif /* CONFIG_CIFS_STATS2 */
419 seq_printf(m
, "Operations (MIDs): %d\n", atomic_read(&midCount
));
421 "\n%d session %d share reconnects\n",
422 tcpSesReconnectCount
.counter
, tconInfoReconnectCount
.counter
);
425 "Total vfs operations: %d maximum at one time: %d\n",
426 GlobalCurrentXid
, GlobalMaxActiveXid
);
429 spin_lock(&cifs_tcp_ses_lock
);
430 list_for_each(tmp1
, &cifs_tcp_ses_list
) {
431 server
= list_entry(tmp1
, struct TCP_Server_Info
,
433 list_for_each(tmp2
, &server
->smb_ses_list
) {
434 ses
= list_entry(tmp2
, struct cifs_ses
,
436 list_for_each(tmp3
, &ses
->tcon_list
) {
437 tcon
= list_entry(tmp3
,
441 seq_printf(m
, "\n%d) %s", i
, tcon
->treeName
);
442 if (tcon
->need_reconnect
)
443 seq_puts(m
, "\tDISCONNECTED ");
444 seq_printf(m
, "\nSMBs: %d",
445 atomic_read(&tcon
->num_smbs_sent
));
446 if (server
->ops
->print_stats
)
447 server
->ops
->print_stats(m
, tcon
);
451 spin_unlock(&cifs_tcp_ses_lock
);
457 static int cifs_stats_proc_open(struct inode
*inode
, struct file
*file
)
459 return single_open(file
, cifs_stats_proc_show
, NULL
);
462 static const struct file_operations cifs_stats_proc_fops
= {
463 .open
= cifs_stats_proc_open
,
466 .release
= single_release
,
467 .write
= cifs_stats_proc_write
,
471 #ifdef CONFIG_CIFS_SMB_DIRECT
472 #define PROC_FILE_DEFINE(name) \
473 static ssize_t name##_write(struct file *file, const char __user *buffer, \
474 size_t count, loff_t *ppos) \
477 rc = kstrtoint_from_user(buffer, count, 10, & name); \
482 static int name##_proc_show(struct seq_file *m, void *v) \
484 seq_printf(m, "%d\n", name ); \
487 static int name##_open(struct inode *inode, struct file *file) \
489 return single_open(file, name##_proc_show, NULL); \
492 static const struct file_operations cifs_##name##_proc_fops = { \
493 .open = name##_open, \
495 .llseek = seq_lseek, \
496 .release = single_release, \
497 .write = name##_write, \
500 PROC_FILE_DEFINE(rdma_readwrite_threshold
);
501 PROC_FILE_DEFINE(smbd_max_frmr_depth
);
502 PROC_FILE_DEFINE(smbd_keep_alive_interval
);
503 PROC_FILE_DEFINE(smbd_max_receive_size
);
504 PROC_FILE_DEFINE(smbd_max_fragmented_recv_size
);
505 PROC_FILE_DEFINE(smbd_max_send_size
);
506 PROC_FILE_DEFINE(smbd_send_credit_target
);
507 PROC_FILE_DEFINE(smbd_receive_credit_max
);
510 static struct proc_dir_entry
*proc_fs_cifs
;
511 static const struct file_operations cifsFYI_proc_fops
;
512 static const struct file_operations cifs_lookup_cache_proc_fops
;
513 static const struct file_operations traceSMB_proc_fops
;
514 static const struct file_operations cifs_security_flags_proc_fops
;
515 static const struct file_operations cifs_linux_ext_proc_fops
;
520 proc_fs_cifs
= proc_mkdir("fs/cifs", NULL
);
521 if (proc_fs_cifs
== NULL
)
524 proc_create_single("DebugData", 0, proc_fs_cifs
,
525 cifs_debug_data_proc_show
);
527 #ifdef CONFIG_CIFS_STATS
528 proc_create("Stats", 0644, proc_fs_cifs
, &cifs_stats_proc_fops
);
530 proc_create("cifsFYI", 0644, proc_fs_cifs
, &cifsFYI_proc_fops
);
531 proc_create("traceSMB", 0644, proc_fs_cifs
, &traceSMB_proc_fops
);
532 proc_create("LinuxExtensionsEnabled", 0644, proc_fs_cifs
,
533 &cifs_linux_ext_proc_fops
);
534 proc_create("SecurityFlags", 0644, proc_fs_cifs
,
535 &cifs_security_flags_proc_fops
);
536 proc_create("LookupCacheEnabled", 0644, proc_fs_cifs
,
537 &cifs_lookup_cache_proc_fops
);
538 #ifdef CONFIG_CIFS_SMB_DIRECT
539 proc_create("rdma_readwrite_threshold", 0644, proc_fs_cifs
,
540 &cifs_rdma_readwrite_threshold_proc_fops
);
541 proc_create("smbd_max_frmr_depth", 0644, proc_fs_cifs
,
542 &cifs_smbd_max_frmr_depth_proc_fops
);
543 proc_create("smbd_keep_alive_interval", 0644, proc_fs_cifs
,
544 &cifs_smbd_keep_alive_interval_proc_fops
);
545 proc_create("smbd_max_receive_size", 0644, proc_fs_cifs
,
546 &cifs_smbd_max_receive_size_proc_fops
);
547 proc_create("smbd_max_fragmented_recv_size", 0644, proc_fs_cifs
,
548 &cifs_smbd_max_fragmented_recv_size_proc_fops
);
549 proc_create("smbd_max_send_size", 0644, proc_fs_cifs
,
550 &cifs_smbd_max_send_size_proc_fops
);
551 proc_create("smbd_send_credit_target", 0644, proc_fs_cifs
,
552 &cifs_smbd_send_credit_target_proc_fops
);
553 proc_create("smbd_receive_credit_max", 0644, proc_fs_cifs
,
554 &cifs_smbd_receive_credit_max_proc_fops
);
559 cifs_proc_clean(void)
561 if (proc_fs_cifs
== NULL
)
564 remove_proc_entry("DebugData", proc_fs_cifs
);
565 remove_proc_entry("cifsFYI", proc_fs_cifs
);
566 remove_proc_entry("traceSMB", proc_fs_cifs
);
567 #ifdef CONFIG_CIFS_STATS
568 remove_proc_entry("Stats", proc_fs_cifs
);
570 remove_proc_entry("SecurityFlags", proc_fs_cifs
);
571 remove_proc_entry("LinuxExtensionsEnabled", proc_fs_cifs
);
572 remove_proc_entry("LookupCacheEnabled", proc_fs_cifs
);
573 #ifdef CONFIG_CIFS_SMB_DIRECT
574 remove_proc_entry("rdma_readwrite_threshold", proc_fs_cifs
);
575 remove_proc_entry("smbd_max_frmr_depth", proc_fs_cifs
);
576 remove_proc_entry("smbd_keep_alive_interval", proc_fs_cifs
);
577 remove_proc_entry("smbd_max_receive_size", proc_fs_cifs
);
578 remove_proc_entry("smbd_max_fragmented_recv_size", proc_fs_cifs
);
579 remove_proc_entry("smbd_max_send_size", proc_fs_cifs
);
580 remove_proc_entry("smbd_send_credit_target", proc_fs_cifs
);
581 remove_proc_entry("smbd_receive_credit_max", proc_fs_cifs
);
583 remove_proc_entry("fs/cifs", NULL
);
586 static int cifsFYI_proc_show(struct seq_file
*m
, void *v
)
588 seq_printf(m
, "%d\n", cifsFYI
);
592 static int cifsFYI_proc_open(struct inode
*inode
, struct file
*file
)
594 return single_open(file
, cifsFYI_proc_show
, NULL
);
597 static ssize_t
cifsFYI_proc_write(struct file
*file
, const char __user
*buffer
,
598 size_t count
, loff_t
*ppos
)
600 char c
[2] = { '\0' };
604 rc
= get_user(c
[0], buffer
);
607 if (strtobool(c
, &bv
) == 0)
609 else if ((c
[0] > '1') && (c
[0] <= '9'))
610 cifsFYI
= (int) (c
[0] - '0'); /* see cifs_debug.h for meanings */
617 static const struct file_operations cifsFYI_proc_fops
= {
618 .open
= cifsFYI_proc_open
,
621 .release
= single_release
,
622 .write
= cifsFYI_proc_write
,
625 static int cifs_linux_ext_proc_show(struct seq_file
*m
, void *v
)
627 seq_printf(m
, "%d\n", linuxExtEnabled
);
631 static int cifs_linux_ext_proc_open(struct inode
*inode
, struct file
*file
)
633 return single_open(file
, cifs_linux_ext_proc_show
, NULL
);
636 static ssize_t
cifs_linux_ext_proc_write(struct file
*file
,
637 const char __user
*buffer
, size_t count
, loff_t
*ppos
)
641 rc
= kstrtobool_from_user(buffer
, count
, &linuxExtEnabled
);
648 static const struct file_operations cifs_linux_ext_proc_fops
= {
649 .open
= cifs_linux_ext_proc_open
,
652 .release
= single_release
,
653 .write
= cifs_linux_ext_proc_write
,
656 static int cifs_lookup_cache_proc_show(struct seq_file
*m
, void *v
)
658 seq_printf(m
, "%d\n", lookupCacheEnabled
);
662 static int cifs_lookup_cache_proc_open(struct inode
*inode
, struct file
*file
)
664 return single_open(file
, cifs_lookup_cache_proc_show
, NULL
);
667 static ssize_t
cifs_lookup_cache_proc_write(struct file
*file
,
668 const char __user
*buffer
, size_t count
, loff_t
*ppos
)
672 rc
= kstrtobool_from_user(buffer
, count
, &lookupCacheEnabled
);
679 static const struct file_operations cifs_lookup_cache_proc_fops
= {
680 .open
= cifs_lookup_cache_proc_open
,
683 .release
= single_release
,
684 .write
= cifs_lookup_cache_proc_write
,
687 static int traceSMB_proc_show(struct seq_file
*m
, void *v
)
689 seq_printf(m
, "%d\n", traceSMB
);
693 static int traceSMB_proc_open(struct inode
*inode
, struct file
*file
)
695 return single_open(file
, traceSMB_proc_show
, NULL
);
698 static ssize_t
traceSMB_proc_write(struct file
*file
, const char __user
*buffer
,
699 size_t count
, loff_t
*ppos
)
703 rc
= kstrtobool_from_user(buffer
, count
, &traceSMB
);
710 static const struct file_operations traceSMB_proc_fops
= {
711 .open
= traceSMB_proc_open
,
714 .release
= single_release
,
715 .write
= traceSMB_proc_write
,
718 static int cifs_security_flags_proc_show(struct seq_file
*m
, void *v
)
720 seq_printf(m
, "0x%x\n", global_secflags
);
724 static int cifs_security_flags_proc_open(struct inode
*inode
, struct file
*file
)
726 return single_open(file
, cifs_security_flags_proc_show
, NULL
);
730 * Ensure that if someone sets a MUST flag, that we disable all other MAY
731 * flags except for the ones corresponding to the given MUST flag. If there are
732 * multiple MUST flags, then try to prefer more secure ones.
735 cifs_security_flags_handle_must_flags(unsigned int *flags
)
737 unsigned int signflags
= *flags
& CIFSSEC_MUST_SIGN
;
739 if ((*flags
& CIFSSEC_MUST_KRB5
) == CIFSSEC_MUST_KRB5
)
740 *flags
= CIFSSEC_MUST_KRB5
;
741 else if ((*flags
& CIFSSEC_MUST_NTLMSSP
) == CIFSSEC_MUST_NTLMSSP
)
742 *flags
= CIFSSEC_MUST_NTLMSSP
;
743 else if ((*flags
& CIFSSEC_MUST_NTLMV2
) == CIFSSEC_MUST_NTLMV2
)
744 *flags
= CIFSSEC_MUST_NTLMV2
;
745 else if ((*flags
& CIFSSEC_MUST_NTLM
) == CIFSSEC_MUST_NTLM
)
746 *flags
= CIFSSEC_MUST_NTLM
;
747 else if (CIFSSEC_MUST_LANMAN
&&
748 (*flags
& CIFSSEC_MUST_LANMAN
) == CIFSSEC_MUST_LANMAN
)
749 *flags
= CIFSSEC_MUST_LANMAN
;
750 else if (CIFSSEC_MUST_PLNTXT
&&
751 (*flags
& CIFSSEC_MUST_PLNTXT
) == CIFSSEC_MUST_PLNTXT
)
752 *flags
= CIFSSEC_MUST_PLNTXT
;
757 static ssize_t
cifs_security_flags_proc_write(struct file
*file
,
758 const char __user
*buffer
, size_t count
, loff_t
*ppos
)
762 char flags_string
[12];
765 if ((count
< 1) || (count
> 11))
768 memset(flags_string
, 0, 12);
770 if (copy_from_user(flags_string
, buffer
, count
))
774 /* single char or single char followed by null */
775 if (strtobool(flags_string
, &bv
) == 0) {
776 global_secflags
= bv
? CIFSSEC_MAX
: CIFSSEC_DEF
;
778 } else if (!isdigit(flags_string
[0])) {
779 cifs_dbg(VFS
, "Invalid SecurityFlags: %s\n",
785 /* else we have a number */
786 rc
= kstrtouint(flags_string
, 0, &flags
);
788 cifs_dbg(VFS
, "Invalid SecurityFlags: %s\n",
793 cifs_dbg(FYI
, "sec flags 0x%x\n", flags
);
796 cifs_dbg(VFS
, "Invalid SecurityFlags: %s\n", flags_string
);
800 if (flags
& ~CIFSSEC_MASK
) {
801 cifs_dbg(VFS
, "Unsupported security flags: 0x%x\n",
802 flags
& ~CIFSSEC_MASK
);
806 cifs_security_flags_handle_must_flags(&flags
);
808 /* flags look ok - update the global security flags for cifs module */
809 global_secflags
= flags
;
810 if (global_secflags
& CIFSSEC_MUST_SIGN
) {
811 /* requiring signing implies signing is allowed */
812 global_secflags
|= CIFSSEC_MAY_SIGN
;
813 cifs_dbg(FYI
, "packet signing now required\n");
814 } else if ((global_secflags
& CIFSSEC_MAY_SIGN
) == 0) {
815 cifs_dbg(FYI
, "packet signing disabled\n");
817 /* BB should we turn on MAY flags for other MUST options? */
821 static const struct file_operations cifs_security_flags_proc_fops
= {
822 .open
= cifs_security_flags_proc_open
,
825 .release
= single_release
,
826 .write
= cifs_security_flags_proc_write
,
829 inline void cifs_proc_init(void)
833 inline void cifs_proc_clean(void)