Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 369325
b: refs/heads/master
c: 4ae9fbe
h: refs/heads/master
i:
  369323: ba98688
v: v3
  • Loading branch information
Patrick McHardy authored and David S. Miller committed Apr 19, 2013
1 parent a3449fb commit 5e1e533
Show file tree
Hide file tree
Showing 3 changed files with 43 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: cd1df525da59c64244d27b4548ff5d132489488a
refs/heads/master: 4ae9fbee1690848a6aace1e0193ab27e981e35a5
10 changes: 10 additions & 0 deletions trunk/include/uapi/linux/netlink_diag.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,18 @@ struct netlink_diag_msg {
__u32 ndiag_cookie[2];
};

struct netlink_diag_ring {
__u32 ndr_block_size;
__u32 ndr_block_nr;
__u32 ndr_frame_size;
__u32 ndr_frame_nr;
};

enum {
NETLINK_DIAG_MEMINFO,
NETLINK_DIAG_GROUPS,
NETLINK_DIAG_RX_RING,
NETLINK_DIAG_TX_RING,

__NETLINK_DIAG_MAX,
};
Expand All @@ -38,5 +47,6 @@ enum {

#define NDIAG_SHOW_MEMINFO 0x00000001 /* show memory info of a socket */
#define NDIAG_SHOW_GROUPS 0x00000002 /* show groups of a netlink socket */
#define NDIAG_SHOW_RING_CFG 0x00000004 /* show ring configuration */

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

#include "af_netlink.h"

static int sk_diag_put_ring(struct netlink_ring *ring, int nl_type,
struct sk_buff *nlskb)
{
struct netlink_diag_ring ndr;

ndr.ndr_block_size = ring->pg_vec_pages << PAGE_SHIFT;
ndr.ndr_block_nr = ring->pg_vec_len;
ndr.ndr_frame_size = ring->frame_size;
ndr.ndr_frame_nr = ring->frame_max + 1;

return nla_put(nlskb, nl_type, sizeof(ndr), &ndr);
}

static int sk_diag_put_rings_cfg(struct sock *sk, struct sk_buff *nlskb)
{
struct netlink_sock *nlk = nlk_sk(sk);
int ret;

mutex_lock(&nlk->pg_vec_lock);
ret = sk_diag_put_ring(&nlk->rx_ring, NETLINK_DIAG_RX_RING, nlskb);
if (!ret)
ret = sk_diag_put_ring(&nlk->tx_ring, NETLINK_DIAG_TX_RING,
nlskb);
mutex_unlock(&nlk->pg_vec_lock);

return ret;
}

static int sk_diag_dump_groups(struct sock *sk, struct sk_buff *nlskb)
{
struct netlink_sock *nlk = nlk_sk(sk);
Expand Down Expand Up @@ -51,6 +79,10 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb,
sock_diag_put_meminfo(sk, skb, NETLINK_DIAG_MEMINFO))
goto out_nlmsg_trim;

if ((req->ndiag_show & NDIAG_SHOW_RING_CFG) &&
sk_diag_put_rings_cfg(sk, skb))
goto out_nlmsg_trim;

return nlmsg_end(skb, nlh);

out_nlmsg_trim:
Expand Down

0 comments on commit 5e1e533

Please sign in to comment.