network

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2014 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotValidStrategyType = errors.New("not a valid network strategy type")
)

Functions

func ChangeInterfaceName

func ChangeInterfaceName(old, newName string) error

func CreateVethPair

func CreateVethPair(name1, name2 string, txQueueLen int) error

func InterfaceDown

func InterfaceDown(name string) error

func InterfaceUp

func InterfaceUp(name string) error

func SetDefaultGateway

func SetDefaultGateway(ip, ifaceName string) error

func SetHairpinMode added in v1.4.0

func SetHairpinMode(name string, enabled bool) error

func SetInterfaceInNamespaceFd added in v1.2.0

func SetInterfaceInNamespaceFd(name string, fd uintptr) error

func SetInterfaceInNamespacePid

func SetInterfaceInNamespacePid(name string, nsPid int) error

func SetInterfaceIp

func SetInterfaceIp(name string, rawIp string) error

func SetInterfaceMac added in v1.4.0

func SetInterfaceMac(name string, macaddr string) error

func SetInterfaceMaster

func SetInterfaceMaster(name, master string) error

func SetMtu

func SetMtu(name string, mtu int) error

Types

type Loopback

type Loopback struct {
}

Loopback is a network strategy that provides a basic loopback device

func (*Loopback) Create

func (l *Loopback) Create(n *Network, nspid int, networkState *NetworkState) error

func (*Loopback) Initialize

func (l *Loopback) Initialize(config *Network, networkState *NetworkState) error

type NetNS

type NetNS struct {
}

crosbymichael: could make a network strategy that instead of returning veth pair names it returns a pid to an existing network namespace

func (*NetNS) Create

func (v *NetNS) Create(n *Network, nspid int, networkState *NetworkState) error

func (*NetNS) Initialize

func (v *NetNS) Initialize(config *Network, networkState *NetworkState) error

type Network added in v1.1.0

type Network struct {
	// Type sets the networks type, commonly veth and loopback
	Type string `json:"type,omitempty"`

	// Path to network namespace
	NsPath string `json:"ns_path,omitempty"`

	// The bridge to use.
	Bridge string `json:"bridge,omitempty"`

	// Prefix for the veth interfaces.
	VethPrefix string `json:"veth_prefix,omitempty"`

	// MacAddress contains the MAC address to set on the network interface
	MacAddress string `json:"mac_address,omitempty"`

	// Address contains the IPv4 and mask to set on the network interface
	Address string `json:"address,omitempty"`

	// IPv6Address contains the IPv6 and mask to set on the network interface
	IPv6Address string `json:"ipv6_address,omitempty"`

	// Gateway sets the gateway address that is used as the default for the interface
	Gateway string `json:"gateway,omitempty"`

	// IPv6Gateway sets the ipv6 gateway address that is used as the default for the interface
	IPv6Gateway string `json:"ipv6_gateway,omitempty"`

	// Mtu sets the mtu value for the interface and will be mirrored on both the host and
	// container's interfaces if a pair is created, specifically in the case of type veth
	// Note: This does not apply to loopback interfaces.
	Mtu int `json:"mtu,omitempty"`

	// TxQueueLen sets the tx_queuelen value for the interface and will be mirrored on both the host and
	// container's interfaces if a pair is created, specifically in the case of type veth
	// Note: This does not apply to loopback interfaces.
	TxQueueLen int `json:"txqueuelen,omitempty"`
}

Network defines configuration for a container's networking stack

The network configuration can be omited from a container causing the container to be setup with the host's networking stack

type NetworkState added in v1.1.0

type NetworkState struct {
	// The name of the veth interface on the Host.
	VethHost string `json:"veth_host,omitempty"`
	// The name of the veth interface created inside the container for the child.
	VethChild string `json:"veth_child,omitempty"`
	// Net namespace path.
	NsPath string `json:"ns_path,omitempty"`
}

Struct describing the network specific runtime state that will be maintained by libcontainer for all running containers Do not depend on it outside of libcontainer.

type NetworkStats added in v1.1.0

type NetworkStats struct {
	RxBytes   uint64 `json:"rx_bytes"`
	RxPackets uint64 `json:"rx_packets"`
	RxErrors  uint64 `json:"rx_errors"`
	RxDropped uint64 `json:"rx_dropped"`
	TxBytes   uint64 `json:"tx_bytes"`
	TxPackets uint64 `json:"tx_packets"`
	TxErrors  uint64 `json:"tx_errors"`
	TxDropped uint64 `json:"tx_dropped"`
}

func GetStats added in v1.1.0

func GetStats(networkState *NetworkState) (*NetworkStats, error)

Returns the network statistics for the network interfaces represented by the NetworkRuntimeInfo.

type NetworkStrategy

type NetworkStrategy interface {
	Create(*Network, int, *NetworkState) error
	Initialize(*Network, *NetworkState) error
}

NetworkStrategy represents a specific network configuration for a container's networking stack

func GetStrategy

func GetStrategy(tpe string) (NetworkStrategy, error)

GetStrategy returns the specific network strategy for the provided type. If no strategy is registered for the type an ErrNotValidStrategyType is returned.

type Veth

type Veth struct {
}

Veth is a network strategy that uses a bridge and creates a veth pair, one that stays outside on the host and the other is placed inside the container's namespace

func (*Veth) Create

func (v *Veth) Create(n *Network, nspid int, networkState *NetworkState) error

func (*Veth) Initialize

func (v *Veth) Initialize(config *Network, networkState *NetworkState) error

Jump to

Keyboard shortcuts

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