Skip to content

fix: bind-mount /proc/thread-self/net over /proc/net in namespaces#5

Merged
Frando merged 1 commit intomainfrom
dig/fix-bind-mount
Mar 23, 2026
Merged

fix: bind-mount /proc/thread-self/net over /proc/net in namespaces#5
Frando merged 1 commit intomainfrom
dig/fix-bind-mount

Conversation

@dignifiedquire
Copy link
Copy Markdown
Contributor

After setns(CLONE_NEWNET), /proc/net (a symlink to self/net) still resolves to the thread group leader's network namespace, not the calling thread's. Only /proc/thread-self/net reflects the new namespace.

This caused libraries like netwatch that read /proc/net/route to get the host's default route interface (e.g. enp7s0) instead of the namespace's eth0, breaking socket binding after link flaps in iroh.

Fix: always create a private mount namespace (CLONE_NEWNS) on every namespace thread and bind-mount /proc/thread-self/net over /proc/net. Also make the tokio blocking pool on_thread_start unconditional so spawned blocking threads get the same fix.

After setns(CLONE_NEWNET), /proc/net (a symlink to self/net) still
resolves to the thread group leader's network namespace, not the
calling thread's. Only /proc/thread-self/net reflects the new namespace.

This caused libraries like netwatch that read /proc/net/route to get the
host's default route interface (e.g. enp7s0) instead of the namespace's
eth0, breaking socket binding after link flaps in iroh.

Fix: always create a private mount namespace (CLONE_NEWNS) on every
namespace thread and bind-mount /proc/thread-self/net over /proc/net.
Also make the tokio blocking pool on_thread_start unconditional so
spawned blocking threads get the same fix.
@dignifiedquire dignifiedquire changed the base branch from feat/server-push to main March 23, 2026 11:59
@Frando Frando merged commit 9bdd7fc into main Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants