All of lore.kernel.org
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: David Lamparter <equinox@diac24.net>
Cc: Alex Bligh <alex@alex.org.uk>,
	linux-arch@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Linux Containers <containers@lists.osdl.org>,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 0/7] Network namespace manipulation with file descriptors
Date: Tue, 17 May 2011 07:33:18 -0700	[thread overview]
Message-ID: <m1mxil9z2p.fsf@fess.ebiederm.org> (raw)
In-Reply-To: <20110517111148.GA3762520@jupiter.n2.diac24.net> (David Lamparter's message of "Tue, 17 May 2011 13:11:48 +0200")

David Lamparter <equinox@diac24.net> writes:

> On Sat, May 07, 2011 at 07:18:44AM -0700, Eric W. Biederman wrote:
>> You can read the processes network namespace by opening
>> /proc/<pid>/ns/net.  Unfortunately comparing the network
>> namespaces for identity is another matter.  You will probably
>> be better off simply forcing the routing daemon to start
>> in the desired network namespace in it's initscript.
>> 
>> For purposes of clarity please have a look at my work in
>> progress patch for iproute2.  This demonstrates how I expect
>> userspace to work in a multi-network namespace world.
>> 
> [...]
>> Subject: [PATCH] iproute2:  Add processless netnwork namespace support.
> [...]
>> Configuration specific to a network namespace that
>> would ordinarily be stored under /etc/ is stored under
>> /etc/netns/<name>.  For example if the dns server
>> configuration is different for your vpn you would
>> create a file /etc/netns/myvpn/resolv.conf.
>> 
>> File descriptors that can be used to manipulate a
>> network namespace can be created by opening
>> /var/run/netns/<NAME>.
>> 
>> This adds the following commands to iproute.
>> ip netns add NAME
>> ip netns delete NAME
>> ip netns monitor
>> ip netns list
>> ip netns exec NAME cmd ....
>> ip link set DEV netns NAME
>
> funny, this is almost exactly what my code does - though you're probably
> doing it better and have more features ;)

Well if it has more features it is only because I have managed to keep
everything simple enough that adding features was easy.  I ignored all
of the hard bits.

> http://git.spaceboyz.net/equinox/vrf-tools.git/
> git://spaceboyz.net/equinox/vrf-tools.git
>
> It currently forks off a daemon to keep the namespace open; attaching is
> not possible yet, but opening a socket in a different namespace is.

I went the round of keeping a daemon open, saw how much code that
takes and how fragile that can be in the corner cases and decided to
patch the kernel to make the interfaces better.

> Most of the actual management (mounting things & co.) I offloaded to
> some shell scripts; I use it together with GNU screen (which makes it
> very nice to grab one of the namespaces and start/stop/manage/...
> things).

That does sound like a nice way of doing the management.

> I also have patches for OpenVPN and pptpd floating around that make it
> possible to 'cross' namespace boundaries, i.e. the VPN servers listen in
> one namespace and have their devices in another.

For openvpn I have managed to get away with simply using an up script. 
Mostly the script is:

ip netns add $NSNAME || true
ip netns exec $NSNAME ip link set lo up
ip link set $dev netns $NSNAME
ip netns exec $NSNAME ip link set $dev up
ip netns exec $NSNAME ifconfig $dev $ifconfig_local netmask $ifconfig_netmask broadcast $ifconfig_broadcast

With a few extra bits for dns options and routes.  If I had an openvpn
built with the iproute option I expect I could get away by just wrapping
iproute.  Not that I would mind a patched openvpn.

Personally I think using a vpn in a network namespace seems like a
killer feature.

Eric

  reply	other threads:[~2011-05-17 14:33 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-07  2:23 [PATCH 0/7] Network namespace manipulation with file descriptors Eric W. Biederman
2011-05-07  2:23 ` Eric W. Biederman
2011-05-07  2:24 ` [PATCH 1/7] ns: proc files for namespace naming policy Eric W. Biederman
2011-05-07  2:24   ` Eric W. Biederman
     [not found]   ` <1304735101-1824-1-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2011-05-07  2:24     ` [PATCH 2/7] ns: Introduce the setns syscall Eric W. Biederman
2011-05-07  2:24       ` Eric W. Biederman
2011-05-07  2:24       ` Eric W. Biederman
2011-05-07  2:24       ` Eric W. Biederman
     [not found]       ` <1304735101-1824-2-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2011-05-07  8:01         ` Rémi Denis-Courmont
2011-05-07  8:01           ` Rémi Denis-Courmont
2011-05-07 13:57           ` Eric W. Biederman
2011-05-07 13:57             ` Eric W. Biederman
2011-05-07 22:39       ` Daniel Lezcano
2011-05-08  3:51       ` Matt Helsley
2011-05-11 19:21       ` Nathan Lynch
2011-05-11 20:33         ` Eric W. Biederman
2011-05-07  2:25     ` [PATCH 6/7] net: Allow setting the network namespace by fd Eric W. Biederman
2011-05-07  2:25       ` Eric W. Biederman
2011-05-07  2:25       ` Eric W. Biederman
2011-05-07  2:25       ` Eric W. Biederman
2011-05-07 22:46       ` Daniel Lezcano
2011-05-07  2:24   ` [PATCH 3/7] ns proc: Add support for the network namespace Eric W. Biederman
2011-05-07  2:24     ` Eric W. Biederman
2011-05-07 22:41     ` Daniel Lezcano
2011-05-11 19:21     ` Nathan Lynch
2011-05-11 21:34       ` Eric W. Biederman
2011-05-11 21:42         ` Nathan Lynch
2011-05-07  2:24   ` [PATCH 4/7] ns proc: Add support for the uts namespace Eric W. Biederman
2011-05-07  2:24     ` Eric W. Biederman
2011-05-07 22:42     ` Daniel Lezcano
2011-05-07  2:24   ` [PATCH 5/7] ns proc: Add support for the ipc namespace Eric W. Biederman
2011-05-07  2:24     ` Eric W. Biederman
2011-05-07 22:44     ` Daniel Lezcano
2011-05-07  2:25   ` [PATCH 7/7] ns: Wire up the setns system call Eric W. Biederman
2011-05-07  2:25     ` Eric W. Biederman
2011-05-07  8:27     ` Geert Uytterhoeven
2011-05-07 14:09       ` Eric W. Biederman
2011-05-07 14:09         ` Eric W. Biederman
2011-05-07 14:09         ` Eric W. Biederman
2011-05-07 18:22         ` Geert Uytterhoeven
2011-05-07 13:59     ` Mike Frysinger
2011-05-07 20:06     ` James Bottomley
2011-05-08  2:19       ` Eric W. Biederman
2011-05-08  4:02         ` James Bottomley
2011-05-07 22:37   ` [PATCH 1/7] ns: proc files for namespace naming policy Daniel Lezcano
2011-05-11 19:20   ` Nathan Lynch
2011-05-11 22:52     ` Eric W. Biederman
     [not found] ` <m1tyd7p7tq.fsf-+imSwln9KH6u2/kzUuoCbdi2O/JbrIOy@public.gmane.org>
2011-05-07  6:58   ` [PATCH 0/7] Network namespace manipulation with file descriptors Alex Bligh
2011-05-07  6:58     ` Alex Bligh
2011-05-07 14:18     ` Eric W. Biederman
2011-05-07 14:18       ` Eric W. Biederman
2011-05-08 12:31       ` Alex Bligh
     [not found]       ` <m1fwoqoapn.fsf-+imSwln9KH6u2/kzUuoCbdi2O/JbrIOy@public.gmane.org>
2011-05-17 11:11         ` David Lamparter
2011-05-17 11:11           ` David Lamparter
2011-05-17 14:33           ` Eric W. Biederman [this message]
2011-05-17 15:35             ` David Lamparter
2011-05-22  4:19               ` Renato Westphal
2011-05-09 19:04 ` David Miller
2011-05-09 19:59   ` Eric W. Biederman
2011-05-09 20:40     ` David Miller
2011-05-09 20:54       ` Eric W. Biederman
2011-05-09 20:55         ` David Miller
2011-05-10 21:56       ` Luck, Tony
2011-05-10 23:02 ` Eric W. Biederman
2011-05-10 23:02   ` Eric W. Biederman
2011-05-18 12:43 ` Identifying network namespaces (was: Network namespace manipulation with file descriptors) David Lamparter
2011-05-18 13:03   ` Alexey Dobriyan
     [not found]     ` <BANLkTikmrC86hk=W84UBwhJLe_uGAN4w9w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-05-18 13:33       ` David Lamparter
2011-05-18 13:33         ` David Lamparter
2011-05-18 14:13         ` Alexey Dobriyan

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=m1mxil9z2p.fsf@fess.ebiederm.org \
    --to=ebiederm@xmission.com \
    --cc=alex@alex.org.uk \
    --cc=containers@lists.osdl.org \
    --cc=equinox@diac24.net \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.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 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.