From: Enzo Matsumiya <ematsumiya@suse.de>
To: linux-cifs@vger.kernel.org
Cc: smfrench@gmail.com, pc@cjr.nz, ronniesahlberg@gmail.com,
nspmangalore@gmail.com, Enzo Matsumiya <ematsumiya@suse.de>
Subject: [PATCH 1/2] cifs: create procfs for dns_interval setting
Date: Wed, 8 Jun 2022 18:54:43 -0300 [thread overview]
Message-ID: <20220608215444.1216-2-ematsumiya@suse.de> (raw)
In-Reply-To: <20220608215444.1216-1-ematsumiya@suse.de>
This patch introduces the /proc/fs/cifs/dns_interval setting, used to
configure the interval that DNS resolutions must be done.
Enforces the minimum value SMB_DNS_RESOLVE_INTERVAL_MIN (currently 120),
but allows it to be lower (10, arbitrarily chosen) when debugging (i.e.
cifsFYI > 0).
Signed-off-by: Enzo Matsumiya <ematsumiya@suse.de>
---
fs/cifs/cifs_debug.c | 63 ++++++++++++++++++++++++++++++++++++++++++++
fs/cifs/cifs_debug.h | 2 ++
fs/cifs/cifsfs.c | 1 +
3 files changed, 66 insertions(+)
diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
index 1dd995efd5b8..96ff549a103e 100644
--- a/fs/cifs/cifs_debug.c
+++ b/fs/cifs/cifs_debug.c
@@ -695,6 +695,7 @@ PROC_FILE_DEFINE(smbd_receive_credit_max);
static struct proc_dir_entry *proc_fs_cifs;
static const struct proc_ops cifsFYI_proc_ops;
+static const struct proc_ops cifs_dns_interval_proc_ops;
static const struct proc_ops cifs_lookup_cache_proc_ops;
static const struct proc_ops traceSMB_proc_ops;
static const struct proc_ops cifs_security_flags_proc_ops;
@@ -716,6 +717,7 @@ cifs_proc_init(void)
proc_create("Stats", 0644, proc_fs_cifs, &cifs_stats_proc_ops);
proc_create("cifsFYI", 0644, proc_fs_cifs, &cifsFYI_proc_ops);
+ proc_create("dns_interval", 0644, proc_fs_cifs, &cifs_dns_interval_proc_ops);
proc_create("traceSMB", 0644, proc_fs_cifs, &traceSMB_proc_ops);
proc_create("LinuxExtensionsEnabled", 0644, proc_fs_cifs,
&cifs_linux_ext_proc_ops);
@@ -759,6 +761,7 @@ cifs_proc_clean(void)
remove_proc_entry("DebugData", proc_fs_cifs);
remove_proc_entry("open_files", proc_fs_cifs);
remove_proc_entry("cifsFYI", proc_fs_cifs);
+ remove_proc_entry("dns_interval", proc_fs_cifs);
remove_proc_entry("traceSMB", proc_fs_cifs);
remove_proc_entry("Stats", proc_fs_cifs);
remove_proc_entry("SecurityFlags", proc_fs_cifs);
@@ -821,6 +824,66 @@ static const struct proc_ops cifsFYI_proc_ops = {
.proc_write = cifsFYI_proc_write,
};
+static int cifs_dns_interval_show(struct seq_file *m, void *v)
+{
+ seq_printf(m, "%u\n", dns_interval);
+ return 0;
+}
+
+static int cifs_dns_interval_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, cifs_dns_interval_show, NULL);
+}
+
+static ssize_t cifs_dns_interval_write(struct file *file, const char __user *buffer,
+ size_t count, loff_t *ppos)
+{
+ int rc;
+ unsigned int interval;
+ char buf[12] = { 0 };
+ /* allow the minimum interval to be 10 (arbritrary) when debugging */
+ unsigned int min_interval = cifsFYI ? 10 : SMB_DNS_RESOLVE_INTERVAL_MIN;
+
+ if ((count < 1) || (count > 11))
+ return -EINVAL;
+
+ if (copy_from_user(buf, buffer, count))
+ return -EFAULT;
+
+ if (count < 3) {
+ if (!isdigit(buf[0])) {
+ cifs_dbg(VFS, "Invalid value for dns_interval: %s\n",
+ buf);
+ return -EINVAL;
+ }
+ }
+
+ rc = kstrtouint(buf, 0, &interval);
+ if (rc) {
+ cifs_dbg(VFS, "Invalid value for dns_interval: %s\n",
+ buf);
+ return rc;
+ }
+
+ if (interval < min_interval) {
+ cifs_dbg(VFS, "minimum value for dns_interval is %u, default value is %u\n",
+ SMB_DNS_RESOLVE_INTERVAL_MIN,
+ SMB_DNS_RESOLVE_INTERVAL_DEFAULT);
+ return -EINVAL;
+ }
+
+ dns_interval = interval;
+ return count;
+}
+
+static const struct proc_ops cifs_dns_interval_proc_ops = {
+ .proc_open = cifs_dns_interval_open,
+ .proc_read = seq_read,
+ .proc_lseek = seq_lseek,
+ .proc_release = single_release,
+ .proc_write = cifs_dns_interval_write,
+};
+
static int cifs_linux_ext_proc_show(struct seq_file *m, void *v)
{
seq_printf(m, "%d\n", linuxExtEnabled);
diff --git a/fs/cifs/cifs_debug.h b/fs/cifs/cifs_debug.h
index ee4ea2b60c0f..40ef322450a3 100644
--- a/fs/cifs/cifs_debug.h
+++ b/fs/cifs/cifs_debug.h
@@ -33,6 +33,8 @@ extern int cifsFYI;
#endif
#define ONCE 8
+extern unsigned int dns_interval;
+
/*
* debug ON
* --------
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 325423180fd2..284645da8cd3 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -66,6 +66,7 @@ bool enable_gcm_256 = true;
bool require_gcm_256; /* false by default */
bool enable_negotiate_signing; /* false by default */
unsigned int global_secflags = CIFSSEC_DEF;
+unsigned int dns_interval = SMB_DNS_RESOLVE_INTERVAL_DEFAULT;
/* unsigned int ntlmv2_support = 0; */
unsigned int sign_CIFS_PDUs = 1;
static const struct super_operations cifs_super_ops;
--
2.36.1
next prev parent reply other threads:[~2022-06-08 21:55 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-08 21:54 [PATCH 0/2] Introduce dns_interval procfs setting Enzo Matsumiya
2022-06-08 21:54 ` Enzo Matsumiya [this message]
2022-06-08 21:54 ` [PATCH 2/2] cifs: reschedule DNS resolve worker based on dns_interval Enzo Matsumiya
2022-06-09 0:39 ` [PATCH 0/2] Introduce dns_interval procfs setting ronnie sahlberg
2022-06-09 14:17 ` Tom Talpey
2022-06-09 15:03 ` Enzo Matsumiya
2022-06-09 15:24 ` Tom Talpey
2022-06-09 16:17 ` Enzo Matsumiya
2022-06-09 14:53 ` Paulo Alcantara
2022-06-09 15:14 ` Enzo Matsumiya
2022-06-09 15:21 ` Paulo Alcantara
2022-06-09 15:30 ` Enzo Matsumiya
2022-06-09 15:49 ` Paulo Alcantara
2022-06-09 16:16 ` Enzo Matsumiya
2022-06-09 16:42 ` Paulo Alcantara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220608215444.1216-2-ematsumiya@suse.de \
--to=ematsumiya@suse.de \
--cc=linux-cifs@vger.kernel.org \
--cc=nspmangalore@gmail.com \
--cc=pc@cjr.nz \
--cc=ronniesahlberg@gmail.com \
--cc=smfrench@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox