netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] unix: show socket peer if no addr is given in /proc/net/unix
@ 2014-01-08  5:18 Masatake YAMATO
  2014-01-08  6:00 ` David Miller
  2014-01-08 22:19 ` Sergei Shtylyov
  0 siblings, 2 replies; 4+ messages in thread
From: Masatake YAMATO @ 2014-01-08  5:18 UTC (permalink / raw)
  To: netdev; +Cc: yamato

Path field of /proc/net/unix is empty if an address is not given
to a socket. Typical way to create such socket is calling
socketpair. The empty fields make it difficult to understand the
communication between processes. e.g. lsof cannot resolve the role of
file descriptors well.

This patch fills the empty fields with unix_peer.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
---
 net/unix/af_unix.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 800ca61..1700133 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -2340,7 +2340,9 @@ static int unix_seq_show(struct seq_file *seq, void *v)
 	else {
 		struct sock *s = v;
 		struct unix_sock *u = unix_sk(s);
+		struct sock *s_peer;
 		unix_state_lock(s);
+		s_peer = unix_peer(s);
 
 		seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
 			s,
@@ -2367,7 +2369,8 @@ static int unix_seq_show(struct seq_file *seq, void *v)
 			}
 			for ( ; i < len; i++)
 				seq_putc(seq, u->addr->name->sun_path[i]);
-		}
+		} else if (s_peer)
+			seq_printf(seq, " #%pK", s_peer);
 		unix_state_unlock(s);
 		seq_putc(seq, '\n');
 	}
-- 
1.8.4.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] unix: show socket peer if no addr is given in /proc/net/unix
  2014-01-08  5:18 [PATCH] unix: show socket peer if no addr is given in /proc/net/unix Masatake YAMATO
@ 2014-01-08  6:00 ` David Miller
  2014-01-08  6:50   ` Masatake YAMATO
  2014-01-08 22:19 ` Sergei Shtylyov
  1 sibling, 1 reply; 4+ messages in thread
From: David Miller @ 2014-01-08  6:00 UTC (permalink / raw)
  To: yamato; +Cc: netdev

From: Masatake YAMATO <yamato@redhat.com>
Date: Wed,  8 Jan 2014 14:18:08 +0900

> Path field of /proc/net/unix is empty if an address is not given
> to a socket. Typical way to create such socket is calling
> socketpair. The empty fields make it difficult to understand the
> communication between processes. e.g. lsof cannot resolve the role of
> file descriptors well.
> 
> This patch fills the empty fields with unix_peer.
> 
> Signed-off-by: Masatake YAMATO <yamato@redhat.com>

You cannot change the format of a procfs file without potentially
breaking some application which might interpret the output.

In this case an application might be looking for an empty field
as meaning the sockhad has no given address.

I cannot apply this patch.  People have repeatedly tried making
changes to these networking socket procfs files, and I really wish
people would stop trying to do so.

If you want specific pieces of new information, extend the socket
dumping facility that is actually extensible in a way which will not
break existing applications, and that's netlink.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] unix: show socket peer if no addr is given in /proc/net/unix
  2014-01-08  6:00 ` David Miller
@ 2014-01-08  6:50   ` Masatake YAMATO
  0 siblings, 0 replies; 4+ messages in thread
From: Masatake YAMATO @ 2014-01-08  6:50 UTC (permalink / raw)
  To: davem; +Cc: netdev

Thank you for reviwing.
I'll use netlink diag facility.

Masatake YAMATO

On Wed, 08 Jan 2014 01:00:43 -0500 (EST), David Miller <davem@davemloft.net> wrote:
> From: Masatake YAMATO <yamato@redhat.com>
> Date: Wed,  8 Jan 2014 14:18:08 +0900
> 
>> Path field of /proc/net/unix is empty if an address is not given
>> to a socket. Typical way to create such socket is calling
>> socketpair. The empty fields make it difficult to understand the
>> communication between processes. e.g. lsof cannot resolve the role of
>> file descriptors well.
>> 
>> This patch fills the empty fields with unix_peer.
>> 
>> Signed-off-by: Masatake YAMATO <yamato@redhat.com>
> 
> You cannot change the format of a procfs file without potentially
> breaking some application which might interpret the output.
> 
> In this case an application might be looking for an empty field
> as meaning the sockhad has no given address.
> 
> I cannot apply this patch.  People have repeatedly tried making
> changes to these networking socket procfs files, and I really wish
> people would stop trying to do so.
> 
> If you want specific pieces of new information, extend the socket
> dumping facility that is actually extensible in a way which will not
> break existing applications, and that's netlink.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] unix: show socket peer if no addr is given in /proc/net/unix
  2014-01-08  5:18 [PATCH] unix: show socket peer if no addr is given in /proc/net/unix Masatake YAMATO
  2014-01-08  6:00 ` David Miller
@ 2014-01-08 22:19 ` Sergei Shtylyov
  1 sibling, 0 replies; 4+ messages in thread
From: Sergei Shtylyov @ 2014-01-08 22:19 UTC (permalink / raw)
  To: Masatake YAMATO, netdev

Hello.

On 01/08/2014 08:18 AM, Masatake YAMATO wrote:

> Path field of /proc/net/unix is empty if an address is not given
> to a socket. Typical way to create such socket is calling
> socketpair. The empty fields make it difficult to understand the
> communication between processes. e.g. lsof cannot resolve the role of
> file descriptors well.

> This patch fills the empty fields with unix_peer.

> Signed-off-by: Masatake YAMATO <yamato@redhat.com>
> ---
>   net/unix/af_unix.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)

> diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
> index 800ca61..1700133 100644
> --- a/net/unix/af_unix.c
> +++ b/net/unix/af_unix.c
> @@ -2340,7 +2340,9 @@ static int unix_seq_show(struct seq_file *seq, void *v)
>   	else {
>   		struct sock *s = v;
>   		struct unix_sock *u = unix_sk(s);
> +		struct sock *s_peer;
>   		unix_state_lock(s);
> +		s_peer = unix_peer(s);
>
>   		seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
>   			s,
> @@ -2367,7 +2369,8 @@ static int unix_seq_show(struct seq_file *seq, void *v)
>   			}
>   			for ( ; i < len; i++)
>   				seq_putc(seq, u->addr->name->sun_path[i]);
> -		}
> +		} else if (s_peer)
> +			seq_printf(seq, " #%pK", s_peer);

    According to Documentation/CodingStyle, both arms of the *if* statement 
should have {} if one has it.

WBR, Sergei

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-01-08 21:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-08  5:18 [PATCH] unix: show socket peer if no addr is given in /proc/net/unix Masatake YAMATO
2014-01-08  6:00 ` David Miller
2014-01-08  6:50   ` Masatake YAMATO
2014-01-08 22:19 ` Sergei Shtylyov

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).