* list of all network namespaces
@ 2015-09-17 0:46 Ani Sinha
2015-09-17 0:54 ` Rick Jones
0 siblings, 1 reply; 8+ messages in thread
From: Ani Sinha @ 2015-09-17 0:46 UTC (permalink / raw)
To: netdev@vger.kernel.org
Hi guys
just a stupid question. Is it possible to get a list of all active
network namespaces in the kernel through /proc or some other
interface?
thanks
ani
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: list of all network namespaces
2015-09-17 0:46 list of all network namespaces Ani Sinha
@ 2015-09-17 0:54 ` Rick Jones
2015-09-17 9:40 ` Jiri Benc
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Rick Jones @ 2015-09-17 0:54 UTC (permalink / raw)
To: Ani Sinha, netdev@vger.kernel.org
On 09/16/2015 05:46 PM, Ani Sinha wrote:
> Hi guys
>
> just a stupid question. Is it possible to get a list of all active
> network namespaces in the kernel through /proc or some other
> interface?
Presumably you could copy what "ip netns" does, which appears to be to
look in /var/run/netns . At least that is what an strace of that
command suggests.
rick jones
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: list of all network namespaces
2015-09-17 0:54 ` Rick Jones
@ 2015-09-17 9:40 ` Jiri Benc
2015-09-17 9:46 ` Nicolas Dichtel
2015-09-17 9:51 ` Rosen, Rami
2 siblings, 0 replies; 8+ messages in thread
From: Jiri Benc @ 2015-09-17 9:40 UTC (permalink / raw)
To: Rick Jones; +Cc: Ani Sinha, netdev@vger.kernel.org
On Wed, 16 Sep 2015 17:54:34 -0700, Rick Jones wrote:
> On 09/16/2015 05:46 PM, Ani Sinha wrote:
> > just a stupid question. Is it possible to get a list of all active
> > network namespaces in the kernel through /proc or some other
> > interface?
Not reliably and not efficiently. You can look at what plotnetcfg does:
https://github.com/jbenc/plotnetcfg/blob/master/netns.c
> Presumably you could copy what "ip netns" does, which appears to be to
> look in /var/run/netns . At least that is what an strace of that
> command suggests.
That only works for namespaces added by the ip tool (and presumably a
few other tools which leave a symlink in /var/run/netns as a courtesy).
Depending on what you need, it may be enough. Be aware that you won't
find all net namespaces in the system this way, though.
Jiri
--
Jiri Benc
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: list of all network namespaces
2015-09-17 0:54 ` Rick Jones
2015-09-17 9:40 ` Jiri Benc
@ 2015-09-17 9:46 ` Nicolas Dichtel
2015-09-17 9:51 ` Rosen, Rami
2 siblings, 0 replies; 8+ messages in thread
From: Nicolas Dichtel @ 2015-09-17 9:46 UTC (permalink / raw)
To: Rick Jones, Ani Sinha, netdev@vger.kernel.org
Le 17/09/2015 02:54, Rick Jones a écrit :
> On 09/16/2015 05:46 PM, Ani Sinha wrote:
>> Hi guys
>>
>> just a stupid question. Is it possible to get a list of all active
>> network namespaces in the kernel through /proc or some other
>> interface?
>
> Presumably you could copy what "ip netns" does, which appears to be to look in
> /var/run/netns . At least that is what an strace of that command suggests.
This will only list netns referenced in '/var/run/netns', which is not 'all'
existing netns (most probably only netns created by iproute2).
Regards,
Nicolas
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: list of all network namespaces
2015-09-17 0:54 ` Rick Jones
2015-09-17 9:40 ` Jiri Benc
2015-09-17 9:46 ` Nicolas Dichtel
@ 2015-09-17 9:51 ` Rosen, Rami
2015-09-17 17:39 ` Ani Sinha
2 siblings, 1 reply; 8+ messages in thread
From: Rosen, Rami @ 2015-09-17 9:51 UTC (permalink / raw)
To: Rick Jones, Ani Sinha, netdev@vger.kernel.org
Hi,
>Presumably you could copy what "ip netns" does, which appears to be to look in /var/run/netns . At least that is what an strace of that >command suggests.
This is true, but keep in mind that the output of "ip netns", as well as listing the contents of /var/run/netns, reflects only network namespaces
which were created with the "ip netns" command. The "ip netns" userspace implementation consists of code which enables this,
by creating /var/run/netns, bind mounting it, etc.
Network namespaces which were created by other ways (like userspace applications
using the clone() system call) will *not* be reflected by neither of them.
Regards,
Rami Rosen
Intel Corporation
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: list of all network namespaces
2015-09-17 9:51 ` Rosen, Rami
@ 2015-09-17 17:39 ` Ani Sinha
2015-09-17 18:11 ` Cong Wang
2015-09-17 18:14 ` Jiri Benc
0 siblings, 2 replies; 8+ messages in thread
From: Ani Sinha @ 2015-09-17 17:39 UTC (permalink / raw)
To: Rosen, Rami; +Cc: Rick Jones, netdev@vger.kernel.org
On Thu, Sep 17, 2015 at 2:51 AM, Rosen, Rami <rami.rosen@intel.com> wrote:
> Network namespaces which were created by other ways (like userspace applications
> using the clone() system call) will *not* be reflected by neither of them.
Will there be any interest if I cook up a kernel patch that lists all
network namespaces through /proc?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: list of all network namespaces
2015-09-17 17:39 ` Ani Sinha
@ 2015-09-17 18:11 ` Cong Wang
2015-09-17 18:14 ` Jiri Benc
1 sibling, 0 replies; 8+ messages in thread
From: Cong Wang @ 2015-09-17 18:11 UTC (permalink / raw)
To: Ani Sinha; +Cc: Rosen, Rami, Rick Jones, netdev@vger.kernel.org
On Thu, Sep 17, 2015 at 10:39 AM, Ani Sinha <ani@arista.com> wrote:
> On Thu, Sep 17, 2015 at 2:51 AM, Rosen, Rami <rami.rosen@intel.com> wrote:
>
>> Network namespaces which were created by other ways (like userspace applications
>> using the clone() system call) will *not* be reflected by neither of them.
>
> Will there be any interest if I cook up a kernel patch that lists all
> network namespaces through /proc?
How do you list them since they don't have names in kernel, names
are given in user-space.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: list of all network namespaces
2015-09-17 17:39 ` Ani Sinha
2015-09-17 18:11 ` Cong Wang
@ 2015-09-17 18:14 ` Jiri Benc
1 sibling, 0 replies; 8+ messages in thread
From: Jiri Benc @ 2015-09-17 18:14 UTC (permalink / raw)
To: Ani Sinha; +Cc: Rosen, Rami, Rick Jones, netdev@vger.kernel.org
On Thu, 17 Sep 2015 10:39:57 -0700, Ani Sinha wrote:
> Will there be any interest if I cook up a kernel patch that lists all
> network namespaces through /proc?
/proc is a wrong interface for this, enumerating all net namespaces has
nothing to do with processes. Each process has its corresponding
namespaces in /proc already listed, which is as much as belongs
to /proc.
Dumping all net namespaces should be probably netlink based but
obviously, you'll have hard time sending file descriptors over netlink.
You can dump their netnsids but that won't help you much accessing the
namespace contents.
This is not as easy as it seems. But I'd love to have such feature.
Jiri
--
Jiri Benc
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-09-17 18:14 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-17 0:46 list of all network namespaces Ani Sinha
2015-09-17 0:54 ` Rick Jones
2015-09-17 9:40 ` Jiri Benc
2015-09-17 9:46 ` Nicolas Dichtel
2015-09-17 9:51 ` Rosen, Rami
2015-09-17 17:39 ` Ani Sinha
2015-09-17 18:11 ` Cong Wang
2015-09-17 18:14 ` Jiri Benc
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).