diff options
-rw-r--r-- | include/linux/unix_diag.h | 2 | ||||
-rw-r--r-- | net/unix/diag.c | 24 |
2 files changed, 26 insertions, 0 deletions
diff --git a/include/linux/unix_diag.h b/include/linux/unix_diag.h index 3e53adbe9c7f..2d74a86024ac 100644 --- a/include/linux/unix_diag.h +++ b/include/linux/unix_diag.h | |||
@@ -13,6 +13,7 @@ struct unix_diag_req { | |||
13 | 13 | ||
14 | #define UDIAG_SHOW_NAME 0x00000001 /* show name (not path) */ | 14 | #define UDIAG_SHOW_NAME 0x00000001 /* show name (not path) */ |
15 | #define UDIAG_SHOW_VFS 0x00000002 /* show VFS inode info */ | 15 | #define UDIAG_SHOW_VFS 0x00000002 /* show VFS inode info */ |
16 | #define UDIAG_SHOW_PEER 0x00000004 /* show peer socket info */ | ||
16 | 17 | ||
17 | struct unix_diag_msg { | 18 | struct unix_diag_msg { |
18 | __u8 udiag_family; | 19 | __u8 udiag_family; |
@@ -27,6 +28,7 @@ struct unix_diag_msg { | |||
27 | enum { | 28 | enum { |
28 | UNIX_DIAG_NAME, | 29 | UNIX_DIAG_NAME, |
29 | UNIX_DIAG_VFS, | 30 | UNIX_DIAG_VFS, |
31 | UNIX_DIAG_PEER, | ||
30 | 32 | ||
31 | UNIX_DIAG_MAX, | 33 | UNIX_DIAG_MAX, |
32 | }; | 34 | }; |
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 | ||