Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 327407
b: refs/heads/master
c: 8a360be
h: refs/heads/master
i:
  327405: 5844580
  327403: b1ec5df
  327399: 3226347
  327391: 3ceb893
v: v3
  • Loading branch information
Pavel Emelyanov authored and David S. Miller committed Aug 14, 2012
1 parent c99fcb0 commit 4debc43
Show file tree
Hide file tree
Showing 3 changed files with 57 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: 96ec6327144e1ac9e6676e34fae8b49c2102fa5a
refs/heads/master: 8a360be0c5f8fe2c46f0a524886fa56596534193
23 changes: 23 additions & 0 deletions trunk/include/linux/packet_diag.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ struct packet_diag_req {
__u32 pdiag_cookie[2];
};

#define PACKET_SHOW_INFO 0x00000001 /* Basic packet_sk information */

struct packet_diag_msg {
__u8 pdiag_family;
__u8 pdiag_type;
Expand All @@ -21,4 +23,25 @@ struct packet_diag_msg {
__u32 pdiag_cookie[2];
};

enum {
PACKET_DIAG_INFO,

PACKET_DIAG_MAX,
};

struct packet_diag_info {
__u32 pdi_index;
__u32 pdi_version;
__u32 pdi_reserve;
__u32 pdi_copy_thresh;
__u32 pdi_tstamp;
__u32 pdi_flags;

#define PDI_RUNNING 0x1
#define PDI_AUXDATA 0x2
#define PDI_ORIGDEV 0x4
#define PDI_VNETHDR 0x8
#define PDI_LOSS 0x10
};

#endif
33 changes: 33 additions & 0 deletions trunk/net/packet/diag.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,31 @@

#include "internal.h"

static int pdiag_put_info(const struct packet_sock *po, struct sk_buff *nlskb)
{
struct packet_diag_info pinfo;

pinfo.pdi_index = po->ifindex;
pinfo.pdi_version = po->tp_version;
pinfo.pdi_reserve = po->tp_reserve;
pinfo.pdi_copy_thresh = po->copy_thresh;
pinfo.pdi_tstamp = po->tp_tstamp;

pinfo.pdi_flags = 0;
if (po->running)
pinfo.pdi_flags |= PDI_RUNNING;
if (po->auxdata)
pinfo.pdi_flags |= PDI_AUXDATA;
if (po->origdev)
pinfo.pdi_flags |= PDI_ORIGDEV;
if (po->has_vnet_hdr)
pinfo.pdi_flags |= PDI_VNETHDR;
if (po->tp_loss)
pinfo.pdi_flags |= PDI_LOSS;

return nla_put(nlskb, PACKET_DIAG_INFO, sizeof(pinfo), &pinfo);
}

static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct packet_diag_req *req,
u32 pid, u32 seq, u32 flags, int sk_ino)
{
Expand All @@ -25,7 +50,15 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct packet_diag
rp->pdiag_ino = sk_ino;
sock_diag_save_cookie(sk, rp->pdiag_cookie);

if ((req->pdiag_show & PACKET_SHOW_INFO) &&
pdiag_put_info(po, skb))
goto out_nlmsg_trim;

return nlmsg_end(skb, nlh);

out_nlmsg_trim:
nlmsg_cancel(skb, nlh);
return -EMSGSIZE;
}

static int packet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
Expand Down

0 comments on commit 4debc43

Please sign in to comment.