summaryrefslogtreecommitdiffstats
path: root/net/unix
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@parallels.com>2011-12-15 02:45:24 +0000
committerDavid S. Miller <davem@davemloft.net>2011-12-16 13:48:28 -0500
commitf5248b48a64c221dd6157ab9cbee5a36ee45e6ed (patch)
treef03c84d11417f77827060f48e1bf09435a28c25b /net/unix
parent5d3cae8bc39dd38d1aa5fd4bbc788c7b43fcaa71 (diff)
downloadop-kernel-dev-f5248b48a64c221dd6157ab9cbee5a36ee45e6ed.zip
op-kernel-dev-f5248b48a64c221dd6157ab9cbee5a36ee45e6ed.tar.gz
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.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/net/unix/diag.c b/net/unix/diag.c
index d7bd48c..161ce6c 100644
--- a/net/unix/diag.c
+++ b/net/unix/diag.c
@@ -10,6 +10,22 @@
#define UNIX_DIAG_PUT(skb, attrtype, attrlen) \
RTA_DATA(__RTA_PUT(skb, attrtype, attrlen))
+static int sk_diag_dump_name(struct sock *sk, struct sk_buff *nlskb)
+{
+ struct unix_address *addr = unix_sk(sk)->addr;
+ char *s;
+
+ if (addr) {
+ s = UNIX_DIAG_PUT(nlskb, UNIX_DIAG_NAME, addr->len - sizeof(short));
+ memcpy(s, addr->name->sun_path, addr->len - sizeof(short));
+ }
+
+ return 0;
+
+rtattr_failure:
+ return -EMSGSIZE;
+}
+
static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct unix_diag_req *req,
u32 pid, u32 seq, u32 flags, int sk_ino)
{
@@ -28,6 +44,10 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct unix_diag_r
rep->udiag_ino = sk_ino;
sock_diag_save_cookie(sk, rep->udiag_cookie);
+ if ((req->udiag_show & UDIAG_SHOW_NAME) &&
+ sk_diag_dump_name(sk, skb))
+ goto nlmsg_failure;
+
nlh->nlmsg_len = skb_tail_pointer(skb) - b;
return skb->len;
OpenPOWER on IntegriCloud