On 02/09/2011 02:11 PM, Maheswara Reddy C - ERS, HCL Tech wrote: > Hi, > > I have created a namespace (below sample program) and how can I create a > network name space. > > #include<stdio.h> > #include<sched.h> > #include<alloca.h> > #include<signal.h> > #include<sys/types.h> > #include<unistd.h> > > struct clone_arg { > int (*fn)(void *); > void *arg; > }; > > static int do_start(void *data) > { > printf("do_start"); > } > > static int do_clone(void *arg) > { > struct clone_arg *clone_arg = arg; > printf("inside do_clone"); > return clone_arg->fn(clone_arg->arg); > } > > int main() > { > int (*fn)(void *) ; > fn=do_start; > struct clone_arg clone_arg ={.fn=fn,.arg=NULL }; > long stack_size = sysconf(_SC_PAGESIZE); > void *stack = alloca(stack_size) + stack_size; > int flags= CLONE_NEWNS;
int flags = CLONE_NEWNET; Or instead of clone, do it directly in the current process context: unshare(CLONE_NEWNET); > pid_t ret; > printf("inside main"); > ret = clone(do_clone, stack, flags ,&clone_arg); > > return 1; > > }Lxc-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/lxc-devel ------------------------------------------------------------------------------ The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: Pinpoint memory and threading errors before they happen. Find and fix more than 250 security defects in the development cycle. Locate bottlenecks in serial and parallel code that limit performance. http://p.sf.net/sfu/intel-dev2devfeb _______________________________________________ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel