Skip to content

Add support for Linux network namespaces to the socket abstraction #38947

@tonya11en

Description

@tonya11en

This proposes extending SocketAddress to allow us to specify the network namespace. The primary use-case I have in mind is one where we'd have listeners that listen in different network namespaces than the one that the worker threads belong to.

This would not change any existing behavior if the field is unset.

The API changes I have in mind can be found in this draft PR:
#38945

This should not require a change to the threading model, as #29675 suggests. The way we do this should be something like:

  1. Spawn a new thread and change its namespace via setns().
  2. Pass the socket fd back to the primary thread.
  3. You now have a socket in another netns that you can accept connections on.

For sockets that specify another netns, this makes initial socket creation a syscall-heavy operation, but for the use-case above I believe it should only occur during listener instantiation.

Relevant Links:

Metadata

Metadata

Assignees

Labels

area/connectionenhancementFeature requests. Not bugs or questions.no stalebotDisables stalebot from closing an issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions