Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 278810
b: refs/heads/master
c: f5248b4
h: refs/heads/master
v: v3
  • Loading branch information
Pavel Emelyanov authored and David S. Miller committed Dec 16, 2011
1 parent 29b3f32 commit 2cf6fd9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5d3cae8bc39dd38d1aa5fd4bbc788c7b43fcaa71
refs/heads/master: f5248b48a64c221dd6157ab9cbee5a36ee45e6ed
8 changes: 8 additions & 0 deletions trunk/include/linux/unix_diag.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ struct unix_diag_req {
__u32 udiag_cookie[2];
};

#define UDIAG_SHOW_NAME 0x00000001 /* show name (not path) */

struct unix_diag_msg {
__u8 udiag_family;
__u8 udiag_type;
Expand All @@ -21,4 +23,10 @@ struct unix_diag_msg {
__u32 udiag_cookie[2];
};

enum {
UNIX_DIAG_NAME,

UNIX_DIAG_MAX,
};

#endif
20 changes: 20 additions & 0 deletions trunk/net/unix/diag.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;

Expand Down

0 comments on commit 2cf6fd9

Please sign in to comment.