* [PATCH] net: show protocol type in sockprotoname of fdinfo
@ 2013-12-16 7:19 Masatake YAMATO
2013-12-17 21:38 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Masatake YAMATO @ 2013-12-16 7:19 UTC (permalink / raw)
To: netdev; +Cc: yamato
In 600e177920df936d03b807780ca92c662af98990 "system.sockprotoname"
xattrs is added to sockets enumerated under /proc/$PID/fd.
It is intended mainly to be used from lsof.
The patch was accepted. However, I think using xattrs under procfs is
special hack for lsof. Normally the user of procfs may want to use cat
command(or write syscall) to retrieve informations from the fs.
This patch introduces "sockprotoname" field to /proc/PID/fdinfo of socket.
So the user can use cat command to retrieve the protocol information.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
---
net/socket.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/net/socket.c b/net/socket.c
index 879933a..5e27715 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -132,6 +132,9 @@ static ssize_t sock_sendpage(struct file *file, struct page *page,
static ssize_t sock_splice_read(struct file *file, loff_t *ppos,
struct pipe_inode_info *pipe, size_t len,
unsigned int flags);
+#ifdef CONFIG_PROC_FS
+static int sock_show_fdinfo(struct seq_file *m, struct file *file);
+#endif
/*
* Socket files have a set of 'special' operations as well as the generic file ones. These don't appear
@@ -155,6 +158,9 @@ static const struct file_operations socket_file_ops = {
.sendpage = sock_sendpage,
.splice_write = generic_splice_sendpage,
.splice_read = sock_splice_read,
+#ifdef CONFIG_PROC_FS
+ .show_fdinfo = sock_show_fdinfo,
+#endif
};
/*
@@ -882,6 +888,20 @@ static ssize_t sock_splice_read(struct file *file, loff_t *ppos,
return sock->ops->splice_read(sock, ppos, pipe, len, flags);
}
+#ifdef CONFIG_PROC_FS
+static int sock_show_fdinfo(struct seq_file *m, struct file *file)
+{
+ struct socket *sock;
+ int ret;
+
+ sock = file->private_data;
+ ret = seq_printf(m, "%s: %s\n",
+ XATTR_SOCKPROTONAME_SUFFIX,
+ sock->sk ? sock->sk->sk_prot_creator->name : "-");
+ return ret;
+}
+#endif
+
static struct sock_iocb *alloc_sock_iocb(struct kiocb *iocb,
struct sock_iocb *siocb)
{
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net: show protocol type in sockprotoname of fdinfo
2013-12-16 7:19 [PATCH] net: show protocol type in sockprotoname of fdinfo Masatake YAMATO
@ 2013-12-17 21:38 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2013-12-17 21:38 UTC (permalink / raw)
To: yamato; +Cc: netdev
From: Masatake YAMATO <yamato@redhat.com>
Date: Mon, 16 Dec 2013 16:19:41 +0900
> In 600e177920df936d03b807780ca92c662af98990 "system.sockprotoname"
> xattrs is added to sockets enumerated under /proc/$PID/fd.
> It is intended mainly to be used from lsof.
>
> The patch was accepted. However, I think using xattrs under procfs is
> special hack for lsof. Normally the user of procfs may want to use cat
> command(or write syscall) to retrieve informations from the fs.
>
> This patch introduces "sockprotoname" field to /proc/PID/fdinfo of socket.
> So the user can use cat command to retrieve the protocol information.
>
> Signed-off-by: Masatake YAMATO <yamato@redhat.com>
We're not providing multiple ways of doing the same thing, people
should have considered things more completely when the original
patch was proposed.
Sorry.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-12-17 21:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-16 7:19 [PATCH] net: show protocol type in sockprotoname of fdinfo Masatake YAMATO
2013-12-17 21:38 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).