1 #ifndef _VX_VS_SOCKET_H
2 #define _VX_VS_SOCKET_H
5 #include "vserver/debug.h"
8 /* socket accounting */
10 #include <linux/socket.h>
12 static inline int vx_sock_type(int family)
16 if (family > 0 && family < 3)
18 else if (family == PF_INET6)
23 #define vx_acc_sock(v,f,p,s) \
24 __vx_acc_sock((v), (f), (p), (s), __FILE__, __LINE__)
26 static inline void __vx_acc_sock(struct vx_info *vxi,
27 int family, int pos, int size, char *file, int line)
30 int type = vx_sock_type(family);
32 atomic_inc(&vxi->cacct.sock[type][pos].count);
33 atomic_add(size, &vxi->cacct.sock[type][pos].total);
37 #define vx_sock_recv(sk,s) \
38 vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, (s))
39 #define vx_sock_send(sk,s) \
40 vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, (s))
41 #define vx_sock_fail(sk,s) \
42 vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, (s))
45 #define sock_vx_init(s) do { \
47 (s)->sk_vx_info = NULL; \
50 #define sock_nx_init(s) do { \
52 (s)->sk_nx_info = NULL; \
57 #warning duplicate inclusion