751f52f
Bugzilla: 1037793
751f52f
Upstream-status: submitted for 3.14
751f52f
751f52f
rpc.gssd expects to see an "info" file in each clntXX dir. Since adding
751f52f
the dummy gssd pipe, users that run rpc.gssd see a lot of these messages
751f52f
spamming the logs:
751f52f
751f52f
    rpc.gssd[508]: ERROR: can't open /var/lib/nfs/rpc_pipefs/gssd/clntXX/info: No such file or directory
751f52f
    rpc.gssd[508]: ERROR: failed to read service info
751f52f
751f52f
Add a dummy gssd/clntXX/info file to help silence these messages.
751f52f
751f52f
Signed-off-by: Jeff Layton <jlayton@redhat.com>
751f52f
---
751f52f
 net/sunrpc/rpc_pipe.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++-
751f52f
 1 file changed, 49 insertions(+), 1 deletion(-)
751f52f
751f52f
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
751f52f
index 0b74c61..5d973b2 100644
751f52f
--- a/net/sunrpc/rpc_pipe.c
751f52f
+++ b/net/sunrpc/rpc_pipe.c
751f52f
@@ -17,6 +17,7 @@
751f52f
 #include <linux/fsnotify.h>
751f52f
 #include <linux/kernel.h>
751f52f
 #include <linux/rcupdate.h>
751f52f
+#include <linux/utsname.h>
751f52f
 
751f52f
 #include <asm/ioctls.h>
751f52f
 #include <linux/poll.h>
751f52f
@@ -1275,6 +1276,44 @@ static const struct rpc_pipe_ops gssd_dummy_pipe_ops = {
751f52f
 	.downcall	= dummy_downcall,
751f52f
 };
751f52f
 
751f52f
+/*
751f52f
+ * Here we present a bogus "info" file to keep rpc.gssd happy. We don't expect
751f52f
+ * that it will ever use this info to handle an upcall, but rpc.gssd expects
751f52f
+ * that this file will be there and have a certain format.
751f52f
+ */
751f52f
+static int
751f52f
+rpc_show_dummy_info(struct seq_file *m, void *v)
751f52f
+{
751f52f
+	seq_printf(m, "RPC server: %s\n", utsname()->nodename);
751f52f
+	seq_printf(m, "service: foo (1) version 0\n");
751f52f
+	seq_printf(m, "address: 127.0.0.1\n");
751f52f
+	seq_printf(m, "protocol: tcp\n");
751f52f
+	seq_printf(m, "port: 0\n");
751f52f
+	return 0;
751f52f
+}
751f52f
+
751f52f
+static int
751f52f
+rpc_dummy_info_open(struct inode *inode, struct file *file)
751f52f
+{
751f52f
+	return single_open(file, rpc_show_dummy_info, NULL);
751f52f
+}
751f52f
+
751f52f
+static const struct file_operations rpc_dummy_info_operations = {
751f52f
+	.owner		= THIS_MODULE,
751f52f
+	.open		= rpc_dummy_info_open,
751f52f
+	.read		= seq_read,
751f52f
+	.llseek		= seq_lseek,
751f52f
+	.release	= single_release,
751f52f
+};
751f52f
+
751f52f
+static const struct rpc_filelist gssd_dummy_info_file[] = {
751f52f
+	[0] = {
751f52f
+		.name = "info",
751f52f
+		.i_fop = &rpc_dummy_info_operations,
751f52f
+		.mode = S_IFREG | S_IRUSR,
751f52f
+	},
751f52f
+};
751f52f
+
751f52f
 /**
751f52f
  * rpc_gssd_dummy_populate - create a dummy gssd pipe
751f52f
  * @root:	root of the rpc_pipefs filesystem
751f52f
@@ -1312,9 +1351,18 @@ rpc_gssd_dummy_populate(struct dentry *root, struct rpc_pipe *pipe_data)
751f52f
 		goto out;
751f52f
 	}
751f52f
 
751f52f
+	ret = rpc_populate(clnt_dentry, gssd_dummy_info_file, 0, 1, NULL);
751f52f
+	if (ret) {
751f52f
+		__rpc_depopulate(gssd_dentry, gssd_dummy_clnt_dir, 0, 1);
751f52f
+		pipe_dentry = ERR_PTR(ret);
751f52f
+		goto out;
751f52f
+	}
751f52f
+
751f52f
 	pipe_dentry = rpc_mkpipe_dentry(clnt_dentry, "gssd", NULL, pipe_data);
751f52f
-	if (IS_ERR(pipe_dentry))
751f52f
+	if (IS_ERR(pipe_dentry)) {
751f52f
+		__rpc_depopulate(clnt_dentry, gssd_dummy_info_file, 0, 1);
751f52f
 		__rpc_depopulate(gssd_dentry, gssd_dummy_clnt_dir, 0, 1);
751f52f
+	}
751f52f
 out:
751f52f
 	dput(clnt_dentry);
751f52f
 	dput(gssd_dentry);
751f52f
-- 
751f52f
1.8.4.2