Fwd: Accessing Linux Namespace from Java

Thomas Haller thaller at redhat.com
Sat Sep 19 07:50:16 PDT 2015


On Wed, 2015-09-16 at 20:26 -0700, Bhavesh Mistry wrote:
> Hi libnl Team,
> 
> I was wondering if you know or is there any planing to expose this
> API
> as Java Lib to talk from different Linux namespace (via JNDI ).
> 
> I have posted question on stack-flow to give ability to connect to IP
> address with name space.
> http://stackoverflow.com/questions/32531379/linux-network-namespaces-
> and-connecting-from-java-program-using-linux-network-na

from your description and the link it is not exactly clear to me what
you want to do.

Do you want to connect to a service that runs inside that other netns?
Can you not just setup the routes and addresses properly, and connect
to that namespace from outside?


I guess, you can also switch into that other netns, and connect from
there. I don't know because I never tried that. How about you switch
netns before creating/binding the socket (and thus having the socket
connected inside the other netns). Then you then switch back to your
original netns?

You would switch namespace using the "setns" systemcall (see `man
setns`). AFAIU, you wouldn't use netlink or libnl for that but a
systemcall.


Obviously, you might need proper permissions to do setns, and Java must
give you a way to do that (possibly by calling into native code).


Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/libnl/attachments/20150919/b12dbbf9/attachment.sig>


More information about the libnl mailing list