diff options
author | Pavel Emelyanov <xemul@parallels.com> | 2012-08-13 01:55:46 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-08-14 19:56:33 -0400 |
commit | 8a360be0c5f8fe2c46f0a524886fa56596534193 (patch) | |
tree | 6f97f7711805ef93abe605244440268dcfa4d1f5 /net/packet | |
parent | 96ec6327144e1ac9e6676e34fae8b49c2102fa5a (diff) |
packet: Report more packet sk info via diag module
This reports in one rtattr message all the other scalar values, that can be
set on a packet socket with setsockopt.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/packet')
-rw-r--r-- | net/packet/diag.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/net/packet/diag.c b/net/packet/diag.c index ff2f7f5bfb8f..d5bd0372d004 100644 --- a/net/packet/diag.c +++ b/net/packet/diag.c | |||
@@ -7,6 +7,31 @@ | |||
7 | 7 | ||
8 | #include "internal.h" | 8 | #include "internal.h" |
9 | 9 | ||
10 | static int pdiag_put_info(const struct packet_sock *po, struct sk_buff *nlskb) | ||
11 | { | ||
12 | struct packet_diag_info pinfo; | ||
13 | |||
14 | pinfo.pdi_index = po->ifindex; | ||
15 | pinfo.pdi_version = po->tp_version; | ||
16 | pinfo.pdi_reserve = po->tp_reserve; | ||
17 | pinfo.pdi_copy_thresh = po->copy_thresh; | ||
18 | pinfo.pdi_tstamp = po->tp_tstamp; | ||
19 | |||
20 | pinfo.pdi_flags = 0; | ||
21 | if (po->running) | ||
22 | pinfo.pdi_flags |= PDI_RUNNING; | ||
23 | if (po->auxdata) | ||
24 | pinfo.pdi_flags |= PDI_AUXDATA; | ||
25 | if (po->origdev) | ||
26 | pinfo.pdi_flags |= PDI_ORIGDEV; | ||
27 | if (po->has_vnet_hdr) | ||
28 | pinfo.pdi_flags |= PDI_VNETHDR; | ||
29 | if (po->tp_loss) | ||
30 | pinfo.pdi_flags |= PDI_LOSS; | ||
31 | |||
32 | return nla_put(nlskb, PACKET_DIAG_INFO, sizeof(pinfo), &pinfo); | ||
33 | } | ||
34 | |||
10 | static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct packet_diag_req *req, | 35 | static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct packet_diag_req *req, |
11 | u32 pid, u32 seq, u32 flags, int sk_ino) | 36 | u32 pid, u32 seq, u32 flags, int sk_ino) |
12 | { | 37 | { |
@@ -25,7 +50,15 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct packet_diag | |||
25 | rp->pdiag_ino = sk_ino; | 50 | rp->pdiag_ino = sk_ino; |
26 | sock_diag_save_cookie(sk, rp->pdiag_cookie); | 51 | sock_diag_save_cookie(sk, rp->pdiag_cookie); |
27 | 52 | ||
53 | if ((req->pdiag_show & PACKET_SHOW_INFO) && | ||
54 | pdiag_put_info(po, skb)) | ||
55 | goto out_nlmsg_trim; | ||
56 | |||
28 | return nlmsg_end(skb, nlh); | 57 | return nlmsg_end(skb, nlh); |
58 | |||
59 | out_nlmsg_trim: | ||
60 | nlmsg_cancel(skb, nlh); | ||
61 | return -EMSGSIZE; | ||
29 | } | 62 | } |
30 | 63 | ||
31 | static int packet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb) | 64 | static int packet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb) |