All of lore.kernel.org
 help / color / mirror / Atom feed
* Network namespaces tool
@ 2008-12-11  8:53 Sargun Dhillon
       [not found] ` <7c9d57ea0812110053o4a2753e0m3937ede52955ce4c-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Sargun Dhillon @ 2008-12-11  8:53 UTC (permalink / raw)
  To: containers-qjLDD68F18O7TbgM5vRIOg

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

Additionally, are there any plans to merge in sysfs support into the kernel?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* 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

* 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: Daniel Lezcano @ 2008-12-11  9:23 UTC (permalink / raw)
  To: Sargun Dhillon
  Cc: containers-qjLDD68F18O7TbgM5vRIOg,
	lxc-devel-pyega4qmqnRoyOMFzWx49A

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
>   

There is the lxc tools at:

http://sourceforge.net/projects/lxc/

In these tools there is the lxc-unshare allowing you to do the same.
    lxc-unshare -n /bin/bash

If you find some problems with it, feel free to ask :)
I will release a new lxc-0.5.1, version fixing a few bugs very soon.
> Additionally, are there any plans to merge in sysfs support into the kernel?
>   
The sysfs patchset has been rejected and the sysfs itself should be 
reworked before submitting the sysfs per namespace. This is a long work, 
Eric can probably say more on that.
In the meantime, a patch to make netns and sysfs to co-exist has been 
pushed upstream, so we can create a network namespace without sysfs 
virtualization. This modification will be available for 2.6.29. Until 
this version is released, you can use the netdev development tree 
available at:

git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6.git

Thanks.
  -- Daniel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-12-11  9:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2008-12-11  9:23   ` Daniel Lezcano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.