From: Benjamin Thery <benjamin.thery-6ktuUTfB/bM@public.gmane.org>
To: Sargun Dhillon <xbmodder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org
Subject: Re: Network namespaces tool
Date: Thu, 11 Dec 2008 10:17:22 +0100 [thread overview]
Message-ID: <4940DAA2.3020308@bull.net> (raw)
In-Reply-To: <7c9d57ea0812110053o4a2753e0m3937ede52955ce4c-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
[-- 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
next prev parent reply other threads:[~2008-12-11 9:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-11 8:53 Network namespaces tool Sargun Dhillon
[not found] ` <7c9d57ea0812110053o4a2753e0m3937ede52955ce4c-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-12-11 9:17 ` Benjamin Thery [this message]
2008-12-11 9:23 ` Daniel Lezcano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4940DAA2.3020308@bull.net \
--to=benjamin.thery-6ktuutfb/bm@public.gmane.org \
--cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
--cc=xbmodder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox