diff options
author | Pavel Emelyanov <xemul@parallels.com> | 2011-12-14 21:45:58 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-12-16 13:48:28 -0500 |
commit | ac02be8d96af9f66a4de86781ee9facc2dff99d4 (patch) | |
tree | f9a7ef71f50d5bda679f8603cbfa53c0d4092df4 /net/unix | |
parent | 5f7b0569460b7d8d01ca776430a00505a68b7584 (diff) |
unix_diag: Unix peer inode NLA
Report the peer socket inode ID as NLA. With this it's finally
possible to find out the other end of an interesting unix connection.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/unix')
-rw-r--r-- | net/unix/diag.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/net/unix/diag.c b/net/unix/diag.c index 83799ef19b49..0e0fda786afe 100644 --- a/net/unix/diag.c +++ b/net/unix/diag.c | |||
@@ -43,6 +43,26 @@ rtattr_failure: | |||
43 | return -EMSGSIZE; | 43 | return -EMSGSIZE; |
44 | } | 44 | } |
45 | 45 | ||
46 | static int sk_diag_dump_peer(struct sock *sk, struct sk_buff *nlskb) | ||
47 | { | ||
48 | struct sock *peer; | ||
49 | int ino; | ||
50 | |||
51 | peer = unix_peer_get(sk); | ||
52 | if (peer) { | ||
53 | unix_state_lock(peer); | ||
54 | ino = sock_i_ino(peer); | ||
55 | unix_state_unlock(peer); | ||
56 | sock_put(peer); | ||
57 | |||
58 | RTA_PUT_U32(nlskb, UNIX_DIAG_PEER, ino); | ||
59 | } | ||
60 | |||
61 | return 0; | ||
62 | rtattr_failure: | ||
63 | return -EMSGSIZE; | ||
64 | } | ||
65 | |||
46 | static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct unix_diag_req *req, | 66 | static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct unix_diag_req *req, |
47 | u32 pid, u32 seq, u32 flags, int sk_ino) | 67 | u32 pid, u32 seq, u32 flags, int sk_ino) |
48 | { | 68 | { |
@@ -69,6 +89,10 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct unix_diag_r | |||
69 | sk_diag_dump_vfs(sk, skb)) | 89 | sk_diag_dump_vfs(sk, skb)) |
70 | goto nlmsg_failure; | 90 | goto nlmsg_failure; |
71 | 91 | ||
92 | if ((req->udiag_show & UDIAG_SHOW_PEER) && | ||
93 | sk_diag_dump_peer(sk, skb)) | ||
94 | goto nlmsg_failure; | ||
95 | |||
72 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; | 96 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; |
73 | return skb->len; | 97 | return skb->len; |
74 | 98 | ||