[lxc-devel] creation of netwok name space
Maheswara Reddy C - ERS, HCL Tech
maheswarareddyc at hcl.com
Wed Feb 9 13:11:58 UTC 2011
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;
pid_t ret;
printf("inside main");
ret = clone(do_clone, stack, flags ,&clone_arg);
return 1;
}
Thanks
Mahesh
________________________________
::DISCLAIMER::
-----------------------------------------------------------------------------------------------------------------------
The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only.
It shall not attach any liability on the originator or HCL or its affiliates. Any views or opinions presented in
this email are solely those of the author and may not necessarily reflect the opinions of HCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of
this message without the prior written consent of the author of this e-mail is strictly prohibited. If you have
received this email in error please delete it and notify the sender immediately. Before opening any mail and
attachments please check them for viruses and defect.
-----------------------------------------------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20110209/88547e3e/attachment.html>
More information about the lxc-devel
mailing list