diff options
author | Pavel Emelyanov <xemul@parallels.com> | 2011-12-14 21:45:24 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-12-16 13:48:28 -0500 |
commit | f5248b48a64c221dd6157ab9cbee5a36ee45e6ed (patch) | |
tree | f03c84d11417f77827060f48e1bf09435a28c25b /net/unix | |
parent | 5d3cae8bc39dd38d1aa5fd4bbc788c7b43fcaa71 (diff) |
unix_diag: Unix socket name NLA
Report the sun_path when requested as NLA. With leading '\0' if
present but without the leading AF_UNIX bits.
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 | 20 |
1 files changed, 20 insertions, 0 deletions
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 | ||