1 #ifndef _VX_VS_SOCKET_H
2 #define _VX_VS_SOCKET_H
7 #include <linux/kernel.h>
8 #include <linux/rcupdate.h>
9 #include <linux/sched.h>
11 #include "vserver/context.h"
12 #include "vserver/network.h"
13 #include "vserver/debug.h"
16 /* socket accounting */
18 #include <linux/socket.h>
20 static inline int vx_sock_type(int family)
24 if (family > 0 && family < 3)
26 else if (family == PF_INET6)
31 #define vx_acc_sock(v,f,p,s) \
32 __vx_acc_sock((v), (f), (p), (s), __FILE__, __LINE__)
34 static inline void __vx_acc_sock(struct vx_info *vxi,
35 int family, int pos, int size, char *file, int line)
38 int type = vx_sock_type(family);
40 atomic_inc(&vxi->cacct.sock[type][pos].count);
41 atomic_add(size, &vxi->cacct.sock[type][pos].total);
45 #define vx_sock_recv(sk,s) \
46 vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, (s))
47 #define vx_sock_send(sk,s) \
48 vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, (s))
49 #define vx_sock_fail(sk,s) \
50 vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, (s))
53 #define sock_vx_init(s) do { \
55 (s)->sk_vx_info = NULL; \
58 #define sock_nx_init(s) do { \
60 (s)->sk_nx_info = NULL; \
65 #warning duplicate inclusion