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
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to