4 #include "vserver/debug.h"
5 #include "vserver/base.h"
6 #include "vserver/cacct.h"
7 #include "vserver/context.h"
10 /* socket accounting */
12 #include <linux/socket.h>
14 static inline int vx_sock_type(int family)
18 return VXA_SOCK_UNSPEC;
24 return VXA_SOCK_INET6;
26 return VXA_SOCK_PACKET;
28 return VXA_SOCK_OTHER;
32 #define vx_acc_sock(v,f,p,s) \
33 __vx_acc_sock((v), (f), (p), (s), __FILE__, __LINE__)
35 static inline void __vx_acc_sock(struct vx_info *vxi,
36 int family, int pos, int size, char *file, int line)
39 int type = vx_sock_type(family);
41 atomic_long_inc(&vxi->cacct.sock[type][pos].count);
42 atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
46 #define vx_sock_recv(sk,s) \
47 vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, (s))
48 #define vx_sock_send(sk,s) \
49 vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, (s))
50 #define vx_sock_fail(sk,s) \
51 vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, (s))
54 #define sock_vx_init(s) do { \
56 (s)->sk_vx_info = NULL; \
59 #define sock_nx_init(s) do { \
61 (s)->sk_nx_info = NULL; \
66 #warning duplicate inclusion