fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / include / linux / vs_socket.h
index 560f2eb..d95fcd3 100644 (file)
@@ -1,16 +1,10 @@
-#ifndef _VX_VS_SOCKET_H
-#define _VX_VS_SOCKET_H
+#ifndef _VS_SOCKET_H
+#define _VS_SOCKET_H
 
-
-// #define VX_DEBUG
-
-#include <linux/kernel.h>
-#include <linux/rcupdate.h>
-#include <linux/sched.h>
-
-#include "vserver/context.h"
-#include "vserver/network.h"
 #include "vserver/debug.h"
+#include "vserver/base.h"
+#include "vserver/cacct.h"
+#include "vserver/context.h"
 
 
 /* socket accounting */
 
 static inline int vx_sock_type(int family)
 {
-       int type = 4;
-
-       if (family > 0 && family < 3)
-               type = family;
-       else if (family == PF_INET6)
-               type = 3;
-       return type;
+       switch (family) {
+       case PF_UNSPEC:
+               return VXA_SOCK_UNSPEC;
+       case PF_UNIX:
+               return VXA_SOCK_UNIX;
+       case PF_INET:
+               return VXA_SOCK_INET;
+       case PF_INET6:
+               return VXA_SOCK_INET6;
+       case PF_PACKET:
+               return VXA_SOCK_PACKET;
+       default:
+               return VXA_SOCK_OTHER;
+       }
 }
 
 #define vx_acc_sock(v,f,p,s) \
@@ -34,12 +35,12 @@ static inline int vx_sock_type(int family)
 static inline void __vx_acc_sock(struct vx_info *vxi,
        int family, int pos, int size, char *file, int line)
 {
-        if (vxi) {
+       if (vxi) {
                int type = vx_sock_type(family);
 
-               atomic_inc(&vxi->cacct.sock[type][pos].count);
-               atomic_add(size, &vxi->cacct.sock[type][pos].total);
-        }
+               atomic_long_inc(&vxi->cacct.sock[type][pos].count);
+               atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
+       }
 }
 
 #define vx_sock_recv(sk,s) \
@@ -50,12 +51,12 @@ static inline void __vx_acc_sock(struct vx_info *vxi,
        vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, (s))
 
 
-#define        sock_vx_init(s)  do {           \
+#define sock_vx_init(s) do {           \
        (s)->sk_xid = 0;                \
        (s)->sk_vx_info = NULL;         \
        } while (0)
 
-#define        sock_nx_init(s)  do {           \
+#define sock_nx_init(s) do {           \
        (s)->sk_nid = 0;                \
        (s)->sk_nx_info = NULL;         \
        } while (0)