package netns
import "github.com/docker/libnetwork/Godeps/_workspace/src/github.com/vishvananda/netns"
Package netns allows ultra-simple network namespace handling. NsHandles can be retrieved and set. Note that the current namespace is thread local so actions that set and reset namespaces should use LockOSThread to make sure the namespace doesn't change due to a goroutine switch. It is best to close NsHandles when you are done with them. This can be accomplished via a `defer ns.Close()` on the handle. Changing namespaces requires elevated privileges, so in most cases this code needs to be run as root.
Index ¶
- Variables
- func Set(ns NsHandle) (err error)
- type NsHandle
- func Get() (NsHandle, error)
- func GetFromDocker(id string) (NsHandle, error)
- func GetFromName(name string) (NsHandle, error)
- func GetFromPid(pid int) (NsHandle, error)
- func New() (ns NsHandle, err error)
- func None() NsHandle
- func (ns *NsHandle) Close() error
- func (ns NsHandle) Equal(other NsHandle) bool
- func (ns NsHandle) IsOpen() bool
- func (ns NsHandle) String() string
Variables ¶
Functions ¶
func Set ¶
Types ¶
type NsHandle ¶
type NsHandle int
NsHandle is a handle to a network namespace. It can be cast directly to an int and used as a file descriptor.
func Get ¶
func GetFromDocker ¶
func GetFromName ¶
func GetFromPid ¶
func New ¶
func None ¶
func None() NsHandle
Get an empty (closed) NsHandle
func (*NsHandle) Close ¶
Close closes the NsHandle and resets its file descriptor to -1. It is not safe to use an NsHandle after Close() is called.
func (NsHandle) Equal ¶
Equal determines if two network handles refer to the same network namespace. This is done by comparing the device and inode that the file descripors point to.
func (NsHandle) IsOpen ¶
IsOpen returns true if Close() has not been called.
func (NsHandle) String ¶
String shows the file descriptor number and its dev and inode.
Source Files ¶
- Version
- v0.6.1-rc3
- Published
- Feb 11, 2016
- Platform
- windows/amd64
- Imports
- 3 packages
- Last checked
- 1 hour ago –
Tools for package owners.