util

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2015 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddDefaultRoute

func AddDefaultRoute(gw net.IP, dev netlink.Link) error

AddDefaultRoute sets the default route on the given gateway.

func AddHostRoute

func AddHostRoute(ipn *net.IPNet, gw net.IP, dev netlink.Link) error

AddHostRoute adds a host-scoped route to a device.

func AddRoute

func AddRoute(ipn *net.IPNet, gw net.IP, dev netlink.Link) error

AddRoute adds a universally-scoped route to a device.

func DelLinkByName

func DelLinkByName(ifName string) error

DelLinkByName removes an interface link.

func LoadNet

func LoadNet(path string, n interface{}) error

LoadNet loads a JSON-encoded Net from the filesystem.

func ParseCIDR

func ParseCIDR(s string) (*net.IPNet, error)

ParseCIDR invokes net.ParseCIDR.

func SetNS

func SetNS(f *os.File, flags uintptr) error

SetNS sets the network namespace on a target file.

func SetupVeth

func SetupVeth(entropy, contVethName string, ipn *net.IPNet, hostNS *os.File) (hostVeth, contVeth netlink.Link, err error)

SetupVeth sets up a virtual ethernet link. Should be in container netns. TODO(eyakubovich): get rid of entropy and ask kernel to pick name via pattern

func WithNetNSPath

func WithNetNSPath(nspath string, f func(*os.File) error) error

WithNetNSPath executes the passed closure under the given network namespace, restoring the original namespace afterwards.

Types

type Net

type Net struct {
	Filename string
	Name     string `json:"name,omitempty"`
	Type     string `json:"type,omitempty"`
	IPAlloc  struct {
		Type   string `json:"type,omitempty"`
		Subnet string `json:"subnet,omitempty"`
	} `json:"ipAlloc,omitempty"`
	Routes []string `json:"routes,omitempty"`
}

Net describes a network.

Jump to

Keyboard shortcuts

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