VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git] / include / linux / vs_socket.h
1 #ifndef _VX_VS_SOCKET_H
2 #define _VX_VS_SOCKET_H
3
4
5 // #define VX_DEBUG
6
7 #include <linux/kernel.h>
8 #include <linux/rcupdate.h>
9 #include <linux/sched.h>
10
11 #include "vserver/context.h"
12 #include "vserver/network.h"
13 #include "vserver/debug.h"
14
15
16 /* socket accounting */
17
18 #include <linux/socket.h>
19
20 static inline int vx_sock_type(int family)
21 {
22         int type = 4;
23
24         if (family > 0 && family < 3)
25                 type = family;
26         else if (family == PF_INET6)
27                 type = 3;
28         return type;
29 }
30
31 #define vx_acc_sock(v,f,p,s) \
32         __vx_acc_sock((v), (f), (p), (s), __FILE__, __LINE__)
33
34 static inline void __vx_acc_sock(struct vx_info *vxi,
35         int family, int pos, int size, char *file, int line)
36 {
37         if (vxi) {
38                 int type = vx_sock_type(family);
39
40                 atomic_inc(&vxi->cacct.sock[type][pos].count);
41                 atomic_add(size, &vxi->cacct.sock[type][pos].total);
42         }
43 }
44
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))
51
52
53 #define sock_vx_init(s)  do {           \
54         (s)->sk_xid = 0;                \
55         (s)->sk_vx_info = NULL;         \
56         } while (0)
57
58 #define sock_nx_init(s)  do {           \
59         (s)->sk_nid = 0;                \
60         (s)->sk_nx_info = NULL;         \
61         } while (0)
62
63
64 #else
65 #warning duplicate inclusion
66 #endif