diff options
author | Pavel Emelyanov <xemul@parallels.com> | 2011-12-29 19:53:13 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-12-30 16:42:19 -0500 |
commit | 5d2e5f274f9e9a06fb934dd45260e2616a9992e6 (patch) | |
tree | 61ae9157e41b00a19f58518d58d0c739393cbccb /net/core | |
parent | 288461e1546fa4162fa237eeed8ea09a16521dcd (diff) |
sock_diag: Introduce the meminfo nla core (v2)
Add a routine that dumps memory-related values of a socket.
It's made as an array to make it possible to add more stuff
here later without breaking compatibility.
Since v1: The SK_MEMINFO_ constants are in userspace
visible part of sock_diag.h, the rest is under __KERNEL__.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/sock_diag.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c index 711bdefe7753..b9868e1fd62c 100644 --- a/net/core/sock_diag.c +++ b/net/core/sock_diag.c | |||
@@ -4,6 +4,8 @@ | |||
4 | #include <net/netlink.h> | 4 | #include <net/netlink.h> |
5 | #include <net/net_namespace.h> | 5 | #include <net/net_namespace.h> |
6 | #include <linux/module.h> | 6 | #include <linux/module.h> |
7 | #include <linux/rtnetlink.h> | ||
8 | #include <net/sock.h> | ||
7 | 9 | ||
8 | #include <linux/inet_diag.h> | 10 | #include <linux/inet_diag.h> |
9 | #include <linux/sock_diag.h> | 11 | #include <linux/sock_diag.h> |
@@ -31,6 +33,27 @@ void sock_diag_save_cookie(void *sk, __u32 *cookie) | |||
31 | } | 33 | } |
32 | EXPORT_SYMBOL_GPL(sock_diag_save_cookie); | 34 | EXPORT_SYMBOL_GPL(sock_diag_save_cookie); |
33 | 35 | ||
36 | int sock_diag_put_meminfo(struct sock *sk, struct sk_buff *skb, int attrtype) | ||
37 | { | ||
38 | __u32 *mem; | ||
39 | |||
40 | mem = RTA_DATA(__RTA_PUT(skb, attrtype, SK_MEMINFO_VARS * sizeof(__u32))); | ||
41 | |||
42 | mem[SK_MEMINFO_RMEM_ALLOC] = sk_rmem_alloc_get(sk); | ||
43 | mem[SK_MEMINFO_RCVBUF] = sk->sk_rcvbuf; | ||
44 | mem[SK_MEMINFO_WMEM_ALLOC] = sk_wmem_alloc_get(sk); | ||
45 | mem[SK_MEMINFO_SNDBUF] = sk->sk_sndbuf; | ||
46 | mem[SK_MEMINFO_FWD_ALLOC] = sk->sk_forward_alloc; | ||
47 | mem[SK_MEMINFO_WMEM_QUEUED] = sk->sk_wmem_queued; | ||
48 | mem[SK_MEMINFO_OPTMEM] = atomic_read(&sk->sk_omem_alloc); | ||
49 | |||
50 | return 0; | ||
51 | |||
52 | rtattr_failure: | ||
53 | return -EMSGSIZE; | ||
54 | } | ||
55 | EXPORT_SYMBOL_GPL(sock_diag_put_meminfo); | ||
56 | |||
34 | void sock_diag_register_inet_compat(int (*fn)(struct sk_buff *skb, struct nlmsghdr *nlh)) | 57 | void sock_diag_register_inet_compat(int (*fn)(struct sk_buff *skb, struct nlmsghdr *nlh)) |
35 | { | 58 | { |
36 | mutex_lock(&sock_diag_table_mutex); | 59 | mutex_lock(&sock_diag_table_mutex); |