1 #ifndef _NX_VS_NETWORK_H
2 #define _NX_VS_NETWORK_H
4 #include <linux/kernel.h>
5 #include <linux/rcupdate.h>
6 #include <linux/sched.h>
8 #include "vserver/network.h"
9 #include "vserver/debug.h"
12 extern int proc_pid_nx_info(struct task_struct *, char *);
15 #define get_nx_info(i) __get_nx_info(i,__FILE__,__LINE__)
17 static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
18 const char *_file, int _line)
22 vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
23 nxi, nxi?nxi->nx_id:0, nxi?atomic_read(&nxi->nx_usecnt):0,
25 atomic_inc(&nxi->nx_usecnt);
30 #define free_nx_info(i) \
31 call_rcu(&i->nx_rcu, rcu_free_nx_info);
33 #define put_nx_info(i) __put_nx_info(i,__FILE__,__LINE__)
35 static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
39 vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
40 nxi, nxi?nxi->nx_id:0, nxi?atomic_read(&nxi->nx_usecnt):0,
42 if (atomic_dec_and_test(&nxi->nx_usecnt))
47 #define set_nx_info(p,i) __set_nx_info(p,i,__FILE__,__LINE__)
49 static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
50 const char *_file, int _line)
55 vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d.%d])",
56 nxi, nxi?nxi->nx_id:0,
57 nxi?atomic_read(&nxi->nx_usecnt):0,
58 nxi?atomic_read(&nxi->nx_refcnt):0,
60 atomic_inc(&nxi->nx_refcnt);
61 *nxp = __get_nx_info(nxi, _file, _line);
64 #define clr_nx_info(p) __clr_nx_info(p,__FILE__,__LINE__)
66 static inline void __clr_nx_info(struct nx_info **nxp,
67 const char *_file, int _line)
69 struct nx_info *nxo = *nxp;
73 vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d.%d])",
74 nxo, nxo?nxo->nx_id:0,
75 nxo?atomic_read(&nxo->nx_usecnt):0,
76 nxo?atomic_read(&nxo->nx_refcnt):0,
80 if (nxo && atomic_dec_and_test(&nxo->nx_refcnt))
82 __put_nx_info(nxo, _file, _line);
86 #define task_get_nx_info(i) __task_get_nx_info(i,__FILE__,__LINE__)
88 static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
89 const char *_file, int _line)
94 nxi = __get_nx_info(p->nx_info, _file, _line);
95 vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
101 #define nx_verify_info(p,i) \
102 __nx_verify_info((p)->nx_info,i,__FILE__,__LINE__)
104 static __inline__ void __nx_verify_info(
105 struct nx_info *ipa, struct nx_info *ipb,
106 const char *_file, int _line)
110 printk(KERN_ERR "ip bad assumption (%p==%p) at %s:%d\n",
111 ipa, ipb, _file, _line);
115 #define nx_task_nid(t) ((t)->nid)
117 #define nx_current_nid() nx_task_nid(current)
119 #define nx_check(c,m) __nx_check(nx_current_nid(),c,m)
121 #define nx_weak_check(c,m) ((m) ? nx_check(c,m) : 1)
124 #define __nx_flags(v,m,f) (((v) & (m)) ^ (f))
126 #define __nx_task_flags(t,m,f) \
127 (((t) && ((t)->nx_info)) ? \
128 __nx_flags((t)->nx_info->nx_flags,(m),(f)) : 0)
130 #define nx_current_flags() \
131 ((current->nx_info) ? current->nx_info->nx_flags : 0)
133 #define nx_flags(m,f) __nx_flags(nx_current_flags(),(m),(f))
136 #define nx_current_ncaps() \
137 ((current->nx_info) ? current->nx_info->nx_ncaps : 0)
139 #define nx_ncaps(c) (nx_current_ncaps() & (c))
144 #warning duplicate inclusion