netns

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package netns runs code in the network namespace of another process (the sandbox).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do added in v0.3.2

func Do(pid int, fn func() error) error

Do executes fn in the network namespace of the process pid without switching the calling goroutine's network namespace.

Sockets that fn creates belong to the target network namespace for their whole lifetime, even when they are later used from threads in the original namespace.

Do requires CAP_SYS_ADMIN in the caller's user namespace and in the user namespace that owns the target network namespace (setns(2)).

To use this function the main thread of the process must be locked to the main goroutine (LockOSThread called from init()).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL