2012-08-11 20:33:06

by Masatake YAMATO

[permalink] [raw]
Subject: [PATCH v2 01/15] net: proc entry showing inodes on sockfs and their types

I've worked on improving lsof output on linux both lsof and linux
sides. Sometimes lsof cannot resolve socket descriptors and as the
result it prints them like:

[yamato@localhost]/tmp% sudo lsof | grep dbus | grep iden
dbus-daem 652 dbus 6u sock ... 17812 can't identify protocol
dbus-daem 652 dbus 34u sock ... 24689 can't identify protocol
dbus-daem 652 dbus 42u sock ... 24739 can't identify protocol
dbus-daem 652 dbus 48u sock ... 22329 can't identify protocol
...

lsof refers /proc/net/PROTOCOL files to solve the type of socket for
given socket descriptor. lsof looks up inode column of the files.

lsof cannot resolve the type if there is no PROTOCOL file for PROTOCOL
for the given socket descriptor nor there is PROTOCOL file with no
inode column.

About kernel side, bluetooth protocol families didn't have their own
PROTOCOL files. So I added them. netlink protocol had its own PROTOCOL
file but no inode column. So I added the column to it.

About lsof side, I added code to refer /proc/net/netlink to lsof. I
added code to refer /proc/net/icmp to lsof. I have to added code to
refer /proc/net/PROTOCOL files for bluetooth protocol families.

However, it is far from complete.

$ grep -r '^\(static \)*struct proto ' | wc -l
60

It is difficult for me to deal such many protocols. During working on
improving, newer protocol may be implemented. Further more subsystem
mariners don't want to add inode column to /proc/net/PROTOCOL file for
avoiding file format incompatibility.

This patch introduces /proc/net/sockfs, which shows most of all inodes
on sockfs and their socket type. A socket newly associated with socket
descriptor in kernel is stored to a list named
`proc_sockfs_list'. /proc/net/sockfs shows the element of the list.

If a protocol has its own lsof friendly proc entry, a socket of the
protocol should not be stored to `proc_sockfs_list'; lsof can solve
the socket type via protocol the proc entry. A protocol can declare it
has own proc entry with `has_own_proc_entry' field in struct proto.
If the field is non-zero, the socket of the protocol is never added to
`proc_sockfs_list'.

In v2 patch, unnecessary CONFIG_PROC_FS ifdefs are removed as suggested
by Alan Cox. The patches are rebased to net-next.

Signed-off-by: Masatake YAMATO <[email protected]>
---
include/linux/net.h | 8 +++
include/net/sock.h | 3 +
net/socket.c | 169 +++++++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 178 insertions(+), 2 deletions(-)

diff --git a/include/linux/net.h b/include/linux/net.h
index 99276c3..c87acff 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -61,6 +61,9 @@ typedef enum {
#include <linux/fcntl.h> /* For O_CLOEXEC and O_NONBLOCK */
#include <linux/kmemcheck.h>
#include <linux/rcupdate.h>
+#ifdef CONFIG_PROC_FS
+#include <linux/list.h>
+#endif

struct poll_table_struct;
struct pipe_inode_info;
@@ -135,6 +138,7 @@ struct socket_wq {
* @file: File back pointer for gc
* @sk: internal networking protocol agnostic socket representation
* @wq: wait queue for several uses
+ * @proc_sockfs_list: list head to link this socket to /proc/net/sockfs
*/
struct socket {
socket_state state;
@@ -150,6 +154,10 @@ struct socket {
struct file *file;
struct sock *sk;
const struct proto_ops *ops;
+
+#ifdef CONFIG_PROC_FS
+ struct list_head proc_sockfs_list;
+#endif
};

struct vm_area_struct;
diff --git a/include/net/sock.h b/include/net/sock.h
index 72132ae..af37a1e 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -955,6 +955,9 @@ struct proto {
void (*destroy_cgroup)(struct mem_cgroup *memcg);
struct cg_proto *(*proto_cgroup)(struct mem_cgroup *memcg);
#endif
+ /* Set non-zero value if this protocol manages its
+ own /proc/net/PROTOCOL entry and the entry has inode column. */
+ int has_own_proc_entry;
};

/*
diff --git a/net/socket.c b/net/socket.c
index dfe5b66..5f4f228 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -104,6 +104,7 @@
#include <linux/route.h>
#include <linux/sockios.h>
#include <linux/atalk.h>
+#include <linux/rwlock_types.h>

static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
@@ -127,6 +128,10 @@ static ssize_t sock_splice_read(struct file *file, loff_t *ppos,
struct pipe_inode_info *pipe, size_t len,
unsigned int flags);

+static int proc_sockfs_init(void);
+static void proc_sockfs_add(struct socket *sock);
+static void proc_sockfs_remove(struct socket *sock);
+
/*
* Socket files have a set of 'special' operations as well as the generic file ones. These don't appear
* in the operation structures but are done directly via the socketcall() multiplexor.
@@ -259,6 +264,7 @@ static struct inode *sock_alloc_inode(struct super_block *sb)
ei->socket.ops = NULL;
ei->socket.sk = NULL;
ei->socket.file = NULL;
+ INIT_LIST_HEAD(&ei->socket.proc_sockfs_list);

return &ei->vfs_inode;
}
@@ -391,8 +397,10 @@ int sock_map_fd(struct socket *sock, int flags)
struct file *newfile;
int fd = sock_alloc_file(sock, &newfile, flags);

- if (likely(fd >= 0))
+ if (likely(fd >= 0)) {
fd_install(fd, newfile);
+ proc_sockfs_add(sock);
+ }

return fd;
}
@@ -512,9 +520,15 @@ const struct file_operations bad_sock_fops = {

void sock_release(struct socket *sock)
{
+ int externally_allocated = test_bit(SOCK_EXTERNALLY_ALLOCATED,
+ &sock->flags);
+
if (sock->ops) {
struct module *owner = sock->ops->owner;

+ if (!externally_allocated)
+ proc_sockfs_remove(sock);
+
sock->ops->release(sock);
sock->ops = NULL;
module_put(owner);
@@ -523,7 +537,7 @@ void sock_release(struct socket *sock)
if (rcu_dereference_protected(sock->wq, 1)->fasync_list)
printk(KERN_ERR "sock_release: fasync list not empty!\n");

- if (test_bit(SOCK_EXTERNALLY_ALLOCATED, &sock->flags))
+ if (externally_allocated)
return;

this_cpu_sub(sockets_in_use, 1);
@@ -1411,7 +1425,9 @@ SYSCALL_DEFINE4(socketpair, int, family, int, type, int, protocol,

audit_fd_pair(fd1, fd2);
fd_install(fd1, newfile1);
+ proc_sockfs_add(sock1);
fd_install(fd2, newfile2);
+ proc_sockfs_add(sock2);
/* fd1 and fd2 may be already another descriptors.
* Not kernel problem.
*/
@@ -1566,6 +1582,7 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
/* File flags are not inherited via accept() unlike another OSes. */

fd_install(newfd, newfile);
+ proc_sockfs_add(newsock);
err = newfd;

out_put:
@@ -2552,6 +2569,9 @@ static int __init sock_init(void)
err = PTR_ERR(sock_mnt);
goto out_mount;
}
+ err = proc_sockfs_init();
+ if (err)
+ goto out_proc_socfs;

/* The real protocol initialization is performed in later initcalls.
*/
@@ -2567,6 +2587,8 @@ static int __init sock_init(void)
out:
return err;

+out_proc_socfs:
+ kern_unmount(sock_mnt);
out_mount:
unregister_filesystem(&sock_fs_type);
out_fs:
@@ -3380,3 +3402,146 @@ int kernel_sock_shutdown(struct socket *sock, enum sock_shutdown_cmd how)
return sock->ops->shutdown(sock, how);
}
EXPORT_SYMBOL(kernel_sock_shutdown);
+
+#ifdef CONFIG_PROC_FS
+static LIST_HEAD(proc_sockfs_list);
+static DEFINE_RWLOCK(proc_sockfs_lock);
+
+static void proc_sockfs_add(struct socket *sock)
+{
+ struct sock *sk = sock->sk;
+
+ if (!sk->sk_prot_creator->has_own_proc_entry) {
+ write_lock(&proc_sockfs_lock);
+ list_add_tail(&sock->proc_sockfs_list, &proc_sockfs_list);
+ write_unlock(&proc_sockfs_lock);
+ }
+}
+
+static void proc_sockfs_remove(struct socket *sock)
+{
+ struct sock *sk = sock->sk;
+
+ if (!sk)
+ return;
+
+ if (!sk->sk_prot_creator->has_own_proc_entry) {
+ if (!list_empty(&sock->proc_sockfs_list)) {
+ write_lock(&proc_sockfs_lock);
+ list_del_init(&sock->proc_sockfs_list);
+ write_unlock(&proc_sockfs_lock);
+ }
+ }
+}
+
+static void *proc_sockfs_seq_start(struct seq_file *seq, loff_t *pos)
+ __acquires(&proc_sockfs_lock)
+{
+ read_lock(&proc_sockfs_lock);
+ return seq_list_start_head(&proc_sockfs_list, *pos);
+}
+
+static void *proc_sockfs_seq_next(struct seq_file *seq, void *v, loff_t *pos)
+{
+ return seq_list_next(v, &proc_sockfs_list, pos);
+}
+
+static void proc_sockfs_seq_stop(struct seq_file *seq, void *v)
+ __releases(&proc_sockfs_lock)
+{
+ read_unlock(&proc_sockfs_lock);
+}
+
+static int proc_sockfs_seq_show_header(struct seq_file *seq)
+{
+ return seq_printf(seq, "Inode name state family type protocol socket net\n");
+}
+
+static int proc_sockfs_seq_show_socket(struct seq_file *seq, struct socket *sock)
+{
+ struct sock *sk;
+ const char *name;
+
+ sk = sock->sk;
+ BUG_ON(sk == NULL);
+
+ name = sk->sk_prot_creator->name;
+ if (name == NULL || name[0] == '\0')
+ name = "UNKNOWN";
+
+ return seq_printf(seq, "%20lu %-8s %5d %6d %4d %8d %p %p\n",
+ sock_i_ino(sk),
+ name,
+ sock->state,
+ sk->sk_family,
+ sock->type,
+ sk->sk_protocol,
+ sock,
+ sock_net(sk));
+}
+
+static int proc_sockfs_seq_show(struct seq_file *seq, void *v)
+{
+ if (v == &proc_sockfs_list)
+ proc_sockfs_seq_show_header(seq);
+ else {
+ struct socket *sock = list_entry(v, struct socket, proc_sockfs_list);
+ proc_sockfs_seq_show_socket(seq, sock);
+ }
+
+ return 0;
+}
+
+static const struct seq_operations proc_sockfs_seq_ops = {
+ .start = proc_sockfs_seq_start,
+ .next = proc_sockfs_seq_next,
+ .stop = proc_sockfs_seq_stop,
+ .show = proc_sockfs_seq_show,
+};
+
+static int proc_sockfs_seq_open(struct inode *inode, struct file *file)
+{
+ return seq_open(file, &proc_sockfs_seq_ops);
+}
+
+static const struct file_operations proc_sockfs_seq_fops = {
+ .owner = THIS_MODULE,
+ .open = proc_sockfs_seq_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = seq_release,
+};
+
+static __net_init int proc_sockfs_init_net(struct net *net)
+{
+ if (!proc_net_fops_create(net, "sockfs", S_IRUGO, &proc_sockfs_seq_fops))
+ return -ENOMEM;
+ return 0;
+}
+
+static __net_exit void proc_sockfs_exit_net(struct net *net)
+{
+ proc_net_remove(net, "sockfs");
+}
+
+static __net_initdata struct pernet_operations proc_sockfs_ops = {
+ .init = proc_sockfs_init_net,
+ .exit = proc_sockfs_exit_net,
+};
+
+static int proc_sockfs_init(void)
+{
+ return register_pernet_subsys(&proc_sockfs_ops);
+}
+#else
+static int proc_sockfs_init(void)
+{
+ return 0;
+}
+static void proc_sockfs_add(struct socket *sock)
+{
+}
+static void proc_sockfs_remove(struct socket *sock)
+{
+}
+#endif /* CONFIG_PROC_FS */
--
1.7.11.2


2012-08-11 20:32:29

by Masatake YAMATO

[permalink] [raw]
Subject: [PATCH v2 05/15] ipv4: declaring raw protocols has its own proc entry

Declaring raw protocols has its own proc entry.

Signed-off-by: Masatake YAMATO <[email protected]>
---
net/ipv4/raw.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index ff0f071..3980a4a 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -901,6 +901,7 @@ struct proto raw_prot = {
.compat_getsockopt = compat_raw_getsockopt,
.compat_ioctl = compat_raw_ioctl,
#endif
+ .has_own_proc_entry= 1,
};

#ifdef CONFIG_PROC_FS
--
1.7.11.2

2012-08-11 20:32:33

by Masatake YAMATO

[permalink] [raw]
Subject: [PATCH v2 02/15] ipv4: declaring udp protocols has its own proc entry

Declaring udp protocols has its own proc entry.

Signed-off-by: Masatake YAMATO <[email protected]>
---
net/ipv4/udp.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index b4c3582..a16c4fa 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1963,6 +1963,7 @@ struct proto udp_prot = {
.compat_getsockopt = compat_udp_getsockopt,
#endif
.clear_sk = sk_prot_clear_portaddr_nulls,
+ .has_own_proc_entry= 1,
};
EXPORT_SYMBOL(udp_prot);

--
1.7.11.2

2012-08-11 20:33:08

by Masatake YAMATO

[permalink] [raw]
Subject: [PATCH v2 14/15] ax25: declaring ax25 protocols has its own proc entry

Declaring ax25 protocols has its own proc entry.

Signed-off-by: Masatake YAMATO <[email protected]>
---
net/ax25/af_ax25.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index 779095d..ff23c8a 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -803,6 +803,7 @@ static struct proto ax25_proto = {
.name = "AX25",
.owner = THIS_MODULE,
.obj_size = sizeof(struct sock),
+ .has_own_proc_entry= 1,
};

static int ax25_create(struct net *net, struct socket *sock, int protocol,
--
1.7.11.2

2012-08-11 20:33:00

by Masatake YAMATO

[permalink] [raw]
Subject: [PATCH v2 12/15] ipv6: declaring udplitev6 protocols has its own proc entry

Declaring udplitev6 protocols has its own proc entry.

Signed-off-by: Masatake YAMATO <[email protected]>
---
net/ipv6/udplite.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/net/ipv6/udplite.c b/net/ipv6/udplite.c
index 1d08e21..9013897 100644
--- a/net/ipv6/udplite.c
+++ b/net/ipv6/udplite.c
@@ -57,6 +57,7 @@ struct proto udplitev6_prot = {
.compat_getsockopt = compat_udpv6_getsockopt,
#endif
.clear_sk = sk_prot_clear_portaddr_nulls,
+ .has_own_proc_entry= 1,
};

static struct inet_protosw udplite6_protosw = {
--
1.7.11.2

2012-08-11 20:33:03

by Masatake YAMATO

[permalink] [raw]
Subject: [PATCH v2 09/15] netlink: declaring netlink protocols has its own proc entry

Declaring netlink protocols has its own proc entry.

Signed-off-by: Masatake YAMATO <[email protected]>
---
net/netlink/af_netlink.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 5463969..9094be5 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -410,6 +410,7 @@ static struct proto netlink_proto = {
.name = "NETLINK",
.owner = THIS_MODULE,
.obj_size = sizeof(struct netlink_sock),
+ .has_own_proc_entry= 1,
};

static int __netlink_create(struct net *net, struct socket *sock,
--
1.7.11.2

2012-08-11 20:32:58

by Masatake YAMATO

[permalink] [raw]
Subject: [PATCH v2 15/15] ipx: declaring ipx protocols has its own proc entry

Declaring ipx protocols has its own proc entry.

Signed-off-by: Masatake YAMATO <[email protected]>
---
net/ipx/af_ipx.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c
index dfd6faa..14be087 100644
--- a/net/ipx/af_ipx.c
+++ b/net/ipx/af_ipx.c
@@ -1345,6 +1345,7 @@ static struct proto ipx_proto = {
.name = "IPX",
.owner = THIS_MODULE,
.obj_size = sizeof(struct ipx_sock),
+ .has_own_proc_entry= 1,
};

static int ipx_create(struct net *net, struct socket *sock, int protocol,
--
1.7.11.2

2012-08-11 20:32:57

by Masatake YAMATO

[permalink] [raw]
Subject: [PATCH v2 04/15] ipv4: declaring udplite protocols has its own proc entry

Declaring udplite protocols has its own proc entry.

Signed-off-by: Masatake YAMATO <[email protected]>
---
net/ipv4/udplite.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/net/ipv4/udplite.c b/net/ipv4/udplite.c
index 2c46acd..14c9dec 100644
--- a/net/ipv4/udplite.c
+++ b/net/ipv4/udplite.c
@@ -62,6 +62,7 @@ struct proto udplite_prot = {
.compat_getsockopt = compat_udp_getsockopt,
#endif
.clear_sk = sk_prot_clear_portaddr_nulls,
+ .has_own_proc_entry= 1,
};
EXPORT_SYMBOL(udplite_prot);

--
1.7.11.2

2012-08-11 20:32:55

by Masatake YAMATO

[permalink] [raw]
Subject: [PATCH v2 10/15] ipv6: declaring tcpv6 protocols has its own proc entry

Declaring tcpv6 protocols has its own proc entry.

Signed-off-by: Masatake YAMATO <[email protected]>
---
net/ipv6/tcp_ipv6.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index aa41b0e..741cb3b 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -2017,6 +2017,7 @@ struct proto tcpv6_prot = {
#ifdef CONFIG_MEMCG_KMEM
.proto_cgroup = tcp_proto_cgroup,
#endif
+ .has_own_proc_entry= 1,
};

static const struct inet6_protocol tcpv6_protocol = {
--
1.7.11.2

2012-08-11 20:32:53

by Masatake YAMATO

[permalink] [raw]
Subject: [PATCH v2 06/15] ipv4: declaring tcp protocols has its own proc entry

Declaring tcp protocols has its own proc entry.

Signed-off-by: Masatake YAMATO <[email protected]>
---
net/ipv4/tcp_ipv4.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index c660d2c..6f36929 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2635,6 +2635,7 @@ struct proto tcp_prot = {
.destroy_cgroup = tcp_destroy_cgroup,
.proto_cgroup = tcp_proto_cgroup,
#endif
+ .has_own_proc_entry= 1,
};
EXPORT_SYMBOL(tcp_prot);

--
1.7.11.2

2012-08-11 20:32:52

by Masatake YAMATO

[permalink] [raw]
Subject: [PATCH v2 07/15] packet: declaring packet protocols has its own proc entry

Declaring packet protocols has its own proc entry.

Signed-off-by: Masatake YAMATO <[email protected]>
---
net/packet/af_packet.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index ceaca7c..6a0e47c 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2564,6 +2564,7 @@ static struct proto packet_proto = {
.name = "PACKET",
.owner = THIS_MODULE,
.obj_size = sizeof(struct packet_sock),
+ .has_own_proc_entry= 1,
};

/*
--
1.7.11.2

2012-08-11 20:32:50

by Masatake YAMATO

[permalink] [raw]
Subject: [PATCH v2 11/15] ipv6: declaring udpv6 protocols has its own proc entry

Declaring udpv6 protocols has its own proc entry.

Signed-off-by: Masatake YAMATO <[email protected]>
---
net/ipv6/udp.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 99d0077..1b28eaf 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -1537,6 +1537,7 @@ struct proto udpv6_prot = {
.compat_getsockopt = compat_udpv6_getsockopt,
#endif
.clear_sk = sk_prot_clear_portaddr_nulls,
+ .has_own_proc_entry= 1,
};

static struct inet_protosw udpv6_protosw = {
--
1.7.11.2

2012-08-11 20:32:31

by Masatake YAMATO

[permalink] [raw]
Subject: [PATCH v2 08/15] unix: declaring unix protocols has its own proc entry

Declaring unix protocols has its own proc entry.

Signed-off-by: Masatake YAMATO <[email protected]>
---
net/unix/af_unix.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index e4768c1..7f109e6 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -616,6 +616,7 @@ static struct proto unix_proto = {
.name = "UNIX",
.owner = THIS_MODULE,
.obj_size = sizeof(struct unix_sock),
+ .has_own_proc_entry= 1,
};

/*
--
1.7.11.2

2012-08-11 20:35:56

by Masatake YAMATO

[permalink] [raw]
Subject: [PATCH v2 03/15] ipv4: declaring icmp protocols has its own proc entry

Declaring icmp protocols has its own proc entry.

Signed-off-by: Masatake YAMATO <[email protected]>
---
net/ipv4/ping.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index 6232d47..c4bb504 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -748,6 +748,7 @@ struct proto ping_prot = {
.unhash = ping_v4_unhash,
.get_port = ping_v4_get_port,
.obj_size = sizeof(struct inet_sock),
+ .has_own_proc_entry= 1,
};
EXPORT_SYMBOL(ping_prot);

--
1.7.11.2

2012-08-11 20:36:30

by Masatake YAMATO

[permalink] [raw]
Subject: [PATCH v2 13/15] ipv6: declaring rawv6 protocols has its own proc entry

Declaring rawv6 protocols has its own proc entry.

Signed-off-by: Masatake YAMATO <[email protected]>
---
net/ipv6/raw.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index ef0579d..62ac59f 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -1226,6 +1226,7 @@ struct proto rawv6_prot = {
.compat_getsockopt = compat_rawv6_getsockopt,
.compat_ioctl = compat_rawv6_ioctl,
#endif
+ .has_own_proc_entry= 1,
};

#ifdef CONFIG_PROC_FS
--
1.7.11.2

2012-08-12 04:04:38

by David Miller

[permalink] [raw]
Subject: Re: [PATCH v2 01/15] net: proc entry showing inodes on sockfs and their types


Sorry, you cannot do this.

You are adding a new lock and insert into a global list for
pretty much every socket created, that will destroy performance.

You also cannnot add new fields to socket listing procfs files,
it will break existing application which depend upon the existing
exact layout of those fields.

2012-08-12 04:05:43

by David Miller

[permalink] [raw]
Subject: Re: [PATCH v2 01/15] net: proc entry showing inodes on sockfs and their types


I also want to mention that I absolutely do not consider better lsof
support important at all.

So if you want to add this, it had to be exactly zero overhead and it
must not break anything that exists already. Your patch set violates
this on both counts.

2012-08-12 06:44:22

by Masatake YAMATO

[permalink] [raw]
Subject: Re: [PATCH v2 01/15] net: proc entry showing inodes on sockfs and their types

>
> Sorry, you cannot do this.
>
> You are adding a new lock and insert into a global list for
> pretty much every socket created, that will destroy performance.

I think there are no serious performance penalty in generally use.
Most frequently used types of sockets like tcp, udp, and unix are not
stored to the global list and don't touch the new lock at all.
Please, look at has_own_proc_entry in struct proto.

> You also cannnot add new fields to socket listing procfs files,
> it will break existing application which depend upon the existing
> exact layout of those fields.

Is there any strcut which can be extended?
Extending struct sock is o.k.?

Masatake YAMATO