public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Benc <jbenc@redhat.com>
To: Rick Jones <rick.jones2@hp.com>
Cc: Ani Sinha <ani@arista.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: list of all network namespaces
Date: Thu, 17 Sep 2015 11:40:59 +0200	[thread overview]
Message-ID: <20150917114059.33431bbc@griffin> (raw)
In-Reply-To: <55FA0F4A.3010105@hp.com>

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

  reply	other threads:[~2015-09-17  9:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=20150917114059.33431bbc@griffin \
    --to=jbenc@redhat.com \
    --cc=ani@arista.com \
    --cc=netdev@vger.kernel.org \
    --cc=rick.jones2@hp.com \
    /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