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>
10 #include <linux/vserver/cacct.h>
12 static inline int vx_sock_type(int family)
16 return VXA_SOCK_UNSPEC;
22 return VXA_SOCK_INET6;
24 return VXA_SOCK_PACKET;
26 return VXA_SOCK_OTHER;
30 #define vx_acc_sock(v,f,p,s) \
31 __vx_acc_sock((v), (f), (p), (s), __FILE__, __LINE__)
33 static inline void __vx_acc_sock(struct vx_info *vxi,
34 int family, int pos, int size, char *file, int line)
37 int type = vx_sock_type(family);
39 atomic_inc(&vxi->cacct.sock[type][pos].count);
40 atomic_add(size, &vxi->cacct.sock[type][pos].total);
44 #define vx_sock_recv(sk,s) \
45 vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, (s))
46 #define vx_sock_send(sk,s) \
47 vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, (s))
48 #define vx_sock_fail(sk,s) \
49 vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, (s))
52 #define sock_vx_init(s) do { \
54 (s)->sk_vx_info = NULL; \
57 #define sock_nx_init(s) do { \
59 (s)->sk_nx_info = NULL; \
64 #warning duplicate inclusion