* Re: Network namespaces tool
[not found] ` <7c9d57ea0812110053o4a2753e0m3937ede52955ce4c-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2008-12-11 9:17 ` Benjamin Thery
2008-12-11 9:23 ` Daniel Lezcano
1 sibling, 0 replies; 3+ messages in thread
From: Benjamin Thery @ 2008-12-11 9:17 UTC (permalink / raw)
To: Sargun Dhillon; +Cc: containers-qjLDD68F18O7TbgM5vRIOg
[-- Attachment #1: Type: text/plain, Size: 1323 bytes --]
Sargun Dhillon wrote:
> I'm getting an error when I try to compile the netunshare tool.
> Do you have any ideas to the error:
>
> netunshare.c:50: error: conflicting types for 'unshare'
> /usr/include/bits/sched.h:78: error: previous declaration of 'unshare' was here
are you using the netunshare.c found there
http://lxc.sourceforge.net/tools/netunshare.c
?
I'm not sure it's up-to-date.
If that's the case, here is an quickly-updated version which shold work
better for you.
Build it with: gcc -o netunshare -DHAVE_UNSHARE netunshare.c
Also, if you want to play with network namespaces (and containers), you
can try Daniel's excellent liblxc
(http://sourceforge.net/project/showfiles.php?group_id=163076).
> Additionally, are there any plans to merge in sysfs support into the kernel?
This is a question for Eric I guess.
I don't know what are his plan with the sysfs issue. There are some
stuff to fix in sysfs first, and I don't know if there have been any
progress on this front yet.
Benjamin
> _______________________________________________
> Containers mailing list
> Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
> https://lists.linux-foundation.org/mailman/listinfo/containers
>
>
--
B e n j a m i n T h e r y - BULL/DT/Open Software R&D
http://www.bull.com
[-- Attachment #2: netunshare.c --]
[-- Type: text/x-csrc, Size: 1558 bytes --]
#include <stdio.h>
#include <stdlib.h>
#include <sched.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <libgen.h>
#include <linux/unistd.h>
#ifndef _syscall0
#define _syscall0(type,name) \
type name(void) \
{\
return syscall(__NR_##name);\
}
#endif
#ifndef _syscall1
#define _syscall1(type,name,type1,arg1) \
type name(type1 arg1) \
{\
return syscall(__NR_##name, arg1);\
}
#endif
#ifndef HAVE_UNSHARE
#if __i386__
# define __NR_unshare 310
#elif __x86_64__
# define __NR_unshare 272
#elif __ia64__
# define __NR_unshare 1296
#elif __s390x__
# define __NR_unshare 303
#elif __powerpc__
# define __NR_unshare 282
#else
# error "Architecture not supported"
#endif
#ifndef unshare
static inline _syscall1 (int, unshare, unsigned long, flags)
#endif
#endif /* HAVE_UNSHARE */
#ifndef CLONE_NEWNET
#define CLONE_NEWNET 0x40000000
#endif
static const char* procname;
static void usage(const char *name)
{
printf("usage: %s [-h] [command [arg ...]]\n", name);
printf("\n");
printf(" -h this message\n");
printf("\n");
exit(1);
}
int main(int argc, char *argv[])
{
int c;
unsigned long flags = CLONE_NEWNET;
procname = basename(argv[0]);
while ((c = getopt(argc, argv, "+muiUnNphI:")) != EOF) {
switch (c) {
case 'h':
default:
usage(procname);
}
};
argv = &argv[optind];
argc = argc - optind;
if (unshare(flags) == -1) {
perror("unshare");
return 1;
}
if (argc) {
execve(argv[0], argv, __environ);
perror("execve");
return 1;
}
return 0;
}
[-- Attachment #3: Type: text/plain, Size: 206 bytes --]
_______________________________________________
Containers mailing list
Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
https://lists.linux-foundation.org/mailman/listinfo/containers
^ permalink raw reply [flat|nested] 3+ messages in thread