This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / include / linux / vs_socket.h
1 #ifndef _VX_VS_LIMIT_H
2 #define _VX_VS_LIMIT_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
14
15 /* socket accounting */
16
17 #include <linux/socket.h>
18
19 static inline int vx_sock_type(int family)
20 {
21         int type = 4;
22
23         if (family > 0 && family < 3)
24                 type = family;
25         else if (family == PF_INET6)
26                 type = 3;
27         return type;
28 }
29
30 #define vx_acc_sock(v,f,p,s) \
31         __vx_acc_sock((v), (f), (p), (s), __FILE__, __LINE__)
32
33 static inline void __vx_acc_sock(struct vx_info *vxi,
34         int family, int pos, int size, char *file, int line)
35 {
36         if (vxi) {
37                 int type = vx_sock_type(family);
38
39                 atomic_inc(&vxi->cacct.sock[type][pos].count);
40                 atomic_add(size, &vxi->cacct.sock[type][pos].total);
41         }
42 }
43
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))
50
51
52 #define sock_vx_init(s)  do {           \
53         (s)->sk_xid = 0;                \
54         (s)->sk_vx_info = NULL;         \
55         } while (0)
56
57 #define sock_nx_init(s)  do {           \
58         (s)->sk_nid = 0;                \
59         (s)->sk_nx_info = NULL;         \
60         } while (0)
61
62
63 #else
64 #warning duplicate inclusion
65 #endif