#ifndef _VX_CONTEXT_H #define _VX_CONTEXT_H #define VX_INFO_LOCK 1 /* Can't request a new vx_id */ #define VX_INFO_SCHED 2 /* All process in the vx_id */ /* Contribute to the schedular */ #define VX_INFO_NPROC 4 /* Limit number of processes in a context */ #define VX_INFO_PRIVATE 8 /* Noone can join this security context */ #define VX_INFO_INIT 16 /* This process wants to become the */ /* logical process 1 of the security */ /* context */ #define VX_INFO_HIDEINFO 32 /* Hide some information in /proc */ #define VX_INFO_ULIMIT 64 /* Use ulimit of the current process */ /* to become the global limits */ /* of the context */ #define MAX_S_CONTEXT 65535 /* Arbitrary limit */ #define MIN_D_CONTEXT 49152 /* dynamic contexts start here */ #define VX_DYNAMIC_ID (-1UL) /* id for dynamic context */ #define NB_S_CONTEXT 16 #define NB_IPV4ROOT 16 #include #include #include #include #include struct _vx_virt { int nr_threads; int nr_running; int max_threads; unsigned long total_forks; unsigned int bias_cswtch; long bias_jiffies; long bias_idle; struct new_utsname utsname; }; struct _vx_limit { atomic_t ticks; unsigned long rlim[RLIM_NLIMITS]; /* Per context limit */ atomic_t res[RLIM_NLIMITS]; /* Current value */ }; struct _vx_sched { spinlock_t tokens_lock; /* lock for this structure */ int tokens; /* number of CPU tokens in this context */ int tokens_fr; /* Fill rate: add X tokens... */ int tokens_div; /* Divisor: per Y jiffies */ int tokens_max; /* Limit: no more than N tokens */ uint32_t tokens_jfy; /* add an integral multiple of Y to this */ }; struct vx_info { struct list_head vx_list; /* linked list of contexts */ xid_t vx_id; /* context id */ atomic_t vx_refcount; /* refcount */ struct vx_info *vx_parent; /* parent context */ struct proc_dir_entry *vx_procent; /* proc entry */ unsigned int vx_flags; /* VX_INFO_xxx */ pid_t vx_initpid; /* PID of fake init process */ struct _vx_virt virt; /* virtual/bias stuff */ struct _vx_limit limit; /* vserver limits */ struct _vx_sched sched; /* vserver scheduler */ }; extern spinlock_t vxlist_lock; extern struct list_head vx_infos; #define VX_ADMIN 0x0001 #define VX_WATCH 0x0002 #define VX_IDENT 0x0010 #define VX_EQUIV 0x0020 #define VX_PARENT 0x0040 #define VX_CHILD 0x0080 #define VX_ARG_MASK 0x00F0 #define VX_DYNAMIC 0x0100 #define VX_STATIC 0x0200 #define VX_ATR_MASK 0x0F00 #include struct ip_info { struct list_head ip_list; /* linked list of ipinfos */ atomic_t ip_refcount; int nbipv4; __u32 ipv4[NB_IPV4ROOT];/* Process can only bind to these IPs */ /* The first one is used to connect */ /* and for bind any service */ /* The other must be used explicity when */ /* binding */ __u32 mask[NB_IPV4ROOT];/* Netmask for each ipv4 */ /* Used to select the proper source address */ /* for sockets */ __u32 v4_bcast; /* Broadcast address used to receive UDP packets */ }; extern spinlock_t iplist_lock; extern struct list_head ip_infos; int vc_new_s_context(uint32_t, void *); int vc_set_ipv4root(uint32_t, void *); #endif