net

package
v9.9.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2016 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SIOCETHTOOL     = 0x8946     // linux/sockios.h
	ETHTOOL_GTXCSUM = 0x00000016 // linux/ethtool.h
	ETHTOOL_STXCSUM = 0x00000017 // linux/ethtool.h
	IFNAMSIZ        = 16         // linux/if.h
)
View Source
const (
	VethName = "ethwe" // name inside container namespace

)

Variables

View Source
var ErrLinkNotFound = errors.New("Link not found")

Functions

func AddAddresses

func AddAddresses(link netlink.Link, cidrs []*net.IPNet) (newAddrs []*net.IPNet, err error)

func AddRoute

func AddRoute(link netlink.Link, scope netlink.Scope, dst *net.IPNet, gw net.IP) error

func AttachContainer

func AttachContainer(ns netns.NsHandle, id, ifName, bridgeName string, mtu int, withMulticastRoute bool, cidrs []*net.IPNet, keepTXOn bool) error

func CheckAddressOverlap

func CheckAddressOverlap(addr net.IP, ignoreIfaceNames map[string]struct{}) error

For a specific address, we only care if it is actually *inside* an existing route, because weave-local traffic never hits IP routing.

func CheckNetworkFree

func CheckNetworkFree(subnet *net.IPNet, ignoreIfaceNames map[string]struct{}) error

A network is considered free if it does not overlap any existing routes on this host. This is the same approach taken by Docker.

func ConfigureARPCache

func ConfigureARPCache(name string) error

Configure the ARP cache parameters for the given interface. This makes containers react more quickly to a change in the MAC address associated with an IP address.

func CreateAndAttachVeth

func CreateAndAttachVeth(name, peerName, bridgeName string, mtu int, keepTXOn bool, init func(peer netlink.Link) error) (*netlink.Veth, error)

create and attach a veth to the Weave bridge

func DetachContainer

func DetachContainer(ns netns.NsHandle, id, ifName string, cidrs []*net.IPNet) error

func EnsureInterface

func EnsureInterface(ifaceName string) (*net.Interface, error)

Wait for an interface to come up.

func EnsureInterfaceAndMcastRoute

func EnsureInterfaceAndMcastRoute(ifaceName string) (*net.Interface, error)

Wait for an interface to come up and have a route added to the multicast subnet. This matches the behaviour in 'weave attach', which is the only context in which we expect this to be called. If you change one, change the other to match.

func EthtoolTXOff

func EthtoolTXOff(name string) error

Disable TX checksum offload on specified interface

func ListenUnixSocket

func ListenUnixSocket(pathname string) (net.Listener, error)

func NSPathByPid

func NSPathByPid(pid int) string

func WithNetNS

func WithNetNS(nsPath string, cmd string, args ...string) (string, error)

A safe version of WithNetNS* which creates a process executing "nsenter --net=<ns-path> weaveutil <cmd> [args]".

func WithNetNSByPid

func WithNetNSByPid(pid int, cmd string, args ...string) (string, error)

func WithNetNSLinkByPidUnsafe

func WithNetNSLinkByPidUnsafe(pid int, ifName string, work func(link netlink.Link) error) error

func WithNetNSLinkUnsafe

func WithNetNSLinkUnsafe(ns netns.NsHandle, ifName string, work func(link netlink.Link) error) error

func WithNetNSUnsafe

func WithNetNSUnsafe(ns netns.NsHandle, work func() error) error

Please see https://github.com/weaveworks/weave/issues/2388#issuecomment-228365069 for more details and make sure that you understand the implications before using the function!

Types

type BridgeType

type BridgeType int
const (
	WeaveBridgeName = "weave"
	DatapathName    = "datapath"

	None BridgeType = iota
	Bridge
	Fastdp
	BridgedFastdp
	Inconsistent
)

func DetectBridgeType

func DetectBridgeType(weaveBridgeName, datapathName string) BridgeType

type EthtoolValue

type EthtoolValue struct {
	Cmd  uint32
	Data uint32
}

linux/ethtool.h 'struct ethtool_value'

type IFReqData

type IFReqData struct {
	Name [IFNAMSIZ]byte
	Data uintptr
}

linux/if.h 'struct ifreq'

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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