diff options
-rw-r--r-- | include/linux/unix_diag.h | 8 | ||||
-rw-r--r-- | net/unix/diag.c | 20 |
2 files changed, 28 insertions, 0 deletions
diff --git a/include/linux/unix_diag.h b/include/linux/unix_diag.h index 445184a85763..cc4df34d4c14 100644 --- a/include/linux/unix_diag.h +++ b/include/linux/unix_diag.h | |||
@@ -11,6 +11,8 @@ struct unix_diag_req { | |||
11 | __u32 udiag_cookie[2]; | 11 | __u32 udiag_cookie[2]; |
12 | }; | 12 | }; |
13 | 13 | ||
14 | #define UDIAG_SHOW_NAME 0x00000001 /* show name (not path) */ | ||
15 | |||
14 | struct unix_diag_msg { | 16 | struct unix_diag_msg { |
15 | __u8 udiag_family; | 17 | __u8 udiag_family; |
16 | __u8 udiag_type; | 18 | __u8 udiag_type; |
@@ -21,4 +23,10 @@ struct unix_diag_msg { | |||
21 | __u32 udiag_cookie[2]; | 23 | __u32 udiag_cookie[2]; |
22 | }; | 24 | }; |
23 | 25 | ||
26 | enum { | ||
27 | UNIX_DIAG_NAME, | ||
28 | |||
29 | UNIX_DIAG_MAX, | ||
30 | }; | ||
31 | |||
24 | #endif | 32 | #endif |
diff --git a/net/unix/diag.c b/net/unix/diag.c index d7bd48c49ee5..161ce6c05e31 100644 --- a/net/unix/diag.c +++ b/net/unix/diag.c | |||
@@ -10,6 +10,22 @@ | |||
10 | #define UNIX_DIAG_PUT(skb, attrtype, attrlen) \ | 10 | #define UNIX_DIAG_PUT(skb, attrtype, attrlen) \ |
11 | RTA_DATA(__RTA_PUT(skb, attrtype, attrlen)) | 11 | RTA_DATA(__RTA_PUT(skb, attrtype, attrlen)) |
12 | 12 | ||
13 | static int sk_diag_dump_name(struct sock *sk, struct sk_buff *nlskb) | ||
14 | { | ||
15 | struct unix_address *addr = unix_sk(sk)->addr; | ||
16 | char *s; | ||
17 | |||
18 | if (addr) { | ||
19 | s = UNIX_DIAG_PUT(nlskb, UNIX_DIAG_NAME, addr->len - sizeof(short)); | ||
20 | memcpy(s, addr->name->sun_path, addr->len - sizeof(short)); | ||
21 | } | ||
22 | |||
23 | return 0; | ||
24 | |||
25 | rtattr_failure: | ||
26 | return -EMSGSIZE; | ||
27 | } | ||
28 | |||
13 | static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct unix_diag_req *req, | 29 | static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct unix_diag_req *req, |
14 | u32 pid, u32 seq, u32 flags, int sk_ino) | 30 | u32 pid, u32 seq, u32 flags, int sk_ino) |
15 | { | 31 | { |
@@ -28,6 +44,10 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct unix_diag_r | |||
28 | rep->udiag_ino = sk_ino; | 44 | rep->udiag_ino = sk_ino; |
29 | sock_diag_save_cookie(sk, rep->udiag_cookie); | 45 | sock_diag_save_cookie(sk, rep->udiag_cookie); |
30 | 46 | ||
47 | if ((req->udiag_show & UDIAG_SHOW_NAME) && | ||
48 | sk_diag_dump_name(sk, skb)) | ||
49 | goto nlmsg_failure; | ||
50 | |||
31 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; | 51 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; |
32 | return skb->len; | 52 | return skb->len; |
33 | 53 | ||