diff options
author | Patrick McHardy <kaber@trash.net> | 2013-04-17 02:47:06 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-04-19 14:57:58 -0400 |
commit | 4ae9fbee1690848a6aace1e0193ab27e981e35a5 (patch) | |
tree | 10390445b761524709f15fb21db79ad83d1b3d91 /net/netlink | |
parent | cd1df525da59c64244d27b4548ff5d132489488a (diff) |
netlink: add RX/TX-ring support to netlink diag
Based on AF_PACKET.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/netlink')
-rw-r--r-- | net/netlink/diag.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/net/netlink/diag.c b/net/netlink/diag.c index 5ffb1d1cf402..4e4aa471cd05 100644 --- a/net/netlink/diag.c +++ b/net/netlink/diag.c | |||
@@ -7,6 +7,34 @@ | |||
7 | 7 | ||
8 | #include "af_netlink.h" | 8 | #include "af_netlink.h" |
9 | 9 | ||
10 | static int sk_diag_put_ring(struct netlink_ring *ring, int nl_type, | ||
11 | struct sk_buff *nlskb) | ||
12 | { | ||
13 | struct netlink_diag_ring ndr; | ||
14 | |||
15 | ndr.ndr_block_size = ring->pg_vec_pages << PAGE_SHIFT; | ||
16 | ndr.ndr_block_nr = ring->pg_vec_len; | ||
17 | ndr.ndr_frame_size = ring->frame_size; | ||
18 | ndr.ndr_frame_nr = ring->frame_max + 1; | ||
19 | |||
20 | return nla_put(nlskb, nl_type, sizeof(ndr), &ndr); | ||
21 | } | ||
22 | |||
23 | static int sk_diag_put_rings_cfg(struct sock *sk, struct sk_buff *nlskb) | ||
24 | { | ||
25 | struct netlink_sock *nlk = nlk_sk(sk); | ||
26 | int ret; | ||
27 | |||
28 | mutex_lock(&nlk->pg_vec_lock); | ||
29 | ret = sk_diag_put_ring(&nlk->rx_ring, NETLINK_DIAG_RX_RING, nlskb); | ||
30 | if (!ret) | ||
31 | ret = sk_diag_put_ring(&nlk->tx_ring, NETLINK_DIAG_TX_RING, | ||
32 | nlskb); | ||
33 | mutex_unlock(&nlk->pg_vec_lock); | ||
34 | |||
35 | return ret; | ||
36 | } | ||
37 | |||
10 | static int sk_diag_dump_groups(struct sock *sk, struct sk_buff *nlskb) | 38 | static int sk_diag_dump_groups(struct sock *sk, struct sk_buff *nlskb) |
11 | { | 39 | { |
12 | struct netlink_sock *nlk = nlk_sk(sk); | 40 | struct netlink_sock *nlk = nlk_sk(sk); |
@@ -51,6 +79,10 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, | |||
51 | sock_diag_put_meminfo(sk, skb, NETLINK_DIAG_MEMINFO)) | 79 | sock_diag_put_meminfo(sk, skb, NETLINK_DIAG_MEMINFO)) |
52 | goto out_nlmsg_trim; | 80 | goto out_nlmsg_trim; |
53 | 81 | ||
82 | if ((req->ndiag_show & NDIAG_SHOW_RING_CFG) && | ||
83 | sk_diag_put_rings_cfg(sk, skb)) | ||
84 | goto out_nlmsg_trim; | ||
85 | |||
54 | return nlmsg_end(skb, nlh); | 86 | return nlmsg_end(skb, nlh); |
55 | 87 | ||
56 | out_nlmsg_trim: | 88 | out_nlmsg_trim: |