1 #ifndef _VX_VS_SOCKET_H
2 #define _VX_VS_SOCKET_H
4 #include "vserver/debug.h"
7 /* socket accounting */
9 #include <linux/socket.h>
11 static inline int vx_sock_type(int family)
15 if (family > 0 && family < 3)
17 else if (family == PF_INET6)
22 #define vx_acc_sock(v,f,p,s) \
23 __vx_acc_sock((v), (f), (p), (s), __FILE__, __LINE__)
25 static inline void __vx_acc_sock(struct vx_info *vxi,
26 int family, int pos, int size, char *file, int line)
29 int type = vx_sock_type(family);
31 atomic_inc(&vxi->cacct.sock[type][pos].count);
32 atomic_add(size, &vxi->cacct.sock[type][pos].total);
36 #define vx_sock_recv(sk,s) \
37 vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, (s))
38 #define vx_sock_send(sk,s) \
39 vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, (s))
40 #define vx_sock_fail(sk,s) \
41 vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, (s))
44 #define sock_vx_init(s) do { \
46 (s)->sk_vx_info = NULL; \
49 #define sock_nx_init(s) do { \
51 (s)->sk_nx_info = NULL; \
56 #warning duplicate inclusion