aboutsummaryrefslogtreecommitdiffstats
path: root/net/unix/diag.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/unix/diag.c')
-rw-r--r--net/unix/diag.c20
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
13static 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
25rtattr_failure:
26 return -EMSGSIZE;
27}
28
13static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct unix_diag_req *req, 29static 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