net

package
v2.6.5+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2020 License: Apache-2.0 Imports: 29 Imported by: 74

Documentation

Index

Constants

View Source
const (
	WeaveBridgeName  = "weave"
	DatapathName     = "datapath"
	DatapathIfName   = "vethwe-datapath"
	BridgeIfName     = "vethwe-bridge"
	PcapIfName       = "vethwe-pcap"
	NoMasqLocalIpset = ipset.Name("weaver-no-masq-local")
)
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 ErrBridgeNoIP = fmt.Errorf("Bridge has no IP address")
View Source
var ErrLinkNotFound = errors.New("Link not found")

Functions

func AddAddresses added in v1.6.0

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

func AddChainWithRules

func AddChainWithRules(ipt *iptables.IPTables, table, chain string, rulespecs [][]string) error

AddChainWithRules creates a chain and appends given rules to it.

If the chain exists, but its rules are not the same as the given ones, the function will flush the chain and then will append the rules.

func AddRoute added in v1.6.0

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

func AttachContainer added in v1.6.0

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

func CheckAddressOverlap added in v1.1.0

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 added in v1.0.0

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 ConfigureARP

func ConfigureARP(prefix, procPath string) error

configureARP is a helper for the Docker plugin which doesn't set the addresses itself

func ConnectedToBridgeVethPeerIds added in v1.8.0

func ConnectedToBridgeVethPeerIds(bridgeName string) ([]int, error)

ConnectedToBridgeVethPeerIds returns peer indexes of veth links connected to the given bridge. The peer index is used to query from a container netns whether the container is connected to the bridge.

func CreateAndAttachVeth added in v1.6.0

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

create and attach a veth to the Weave bridge

func DetachContainer added in v1.6.0

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

func DetectHairpin added in v1.8.2

func DetectHairpin(portIfName string, log *logrus.Logger) error

func EnforceAddrAssignType

func EnforceAddrAssignType(bridgeName string) (setAddr bool, err error)

func EnsureInterface

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

Wait for an interface to come up.

func EnsureInterfaceAndMcastRoute added in v1.1.0

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 added in v1.6.0

func EthtoolTXOff(name string) error

Disable TX checksum offload on specified interface

func Expose

func Expose(bridgeName string, ipAddr *net.IPNet, removeDefaultRoute, npc bool, skipNAT bool) error

Expose makes the network accessible from a host by assigning a given IP address to the weave bridge.

List of params: * "bridgeName" - a name of the weave bridge. * "ipAddr" - IP addr to be assigned to the bridge. * "removeDefaultRoute" - whether to remove a default route installed by the kernel (used only in the AWSVPC mode). * "npc" - whether is Weave NPC running. * "skipNAT" - whether to skip adding iptables NAT rules

func FindBridgeIP added in v1.9.0

func FindBridgeIP(bridgeName string, subnet *net.IPNet) (net.IP, error)

func GetSystemPeerName added in v1.9.0

func GetSystemPeerName(dbPrefix, hostRoot string) (string, error)

GetSystemPeerName returns an ID derived from concatenated machine-id (either systemd or dbus), the system (aka bios) UUID and the hypervisor UUID. It is tweaked and formatted to be usable as a mac address

func LinkAddIfNotExist

func LinkAddIfNotExist(link netlink.Link) error

func ListenUnixSocket added in v1.5.0

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

func LocalAddresses

func LocalAddresses() ([]*net.IPNet, error)

func MACfromUUID added in v1.9.0

func MACfromUUID(uuid []byte) net.HardwareAddr

func NSPathByPid added in v1.7.2

func NSPathByPid(pid int) string

func NSPathByPidWithProc

func NSPathByPidWithProc(procPath string, pid int) string

func RandomMAC added in v1.9.0

func RandomMAC() (net.HardwareAddr, error)

func WithNetNS added in v1.6.0

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

func WithNetNSByPath

func WithNetNSByPath(path string, work func() error) error
func WithNetNSLink(ns netns.NsHandle, ifName string, work func(link netlink.Link) error) error

Types

type Bridge added in v1.6.0

type Bridge interface {
	IsFastdp() bool // does this bridge use fastdp?
	String() string // human-readable type string
	// contains filtered or unexported methods
}

func EnsureBridge

func EnsureBridge(procPath string, config *BridgeConfig, log *logrus.Logger, ips ipset.Interface) (Bridge, error)

func ExistingBridgeType

func ExistingBridgeType(weaveBridgeName, datapathName string) (Bridge, error)

type BridgeConfig

type BridgeConfig struct {
	DockerBridgeName string
	WeaveBridgeName  string
	DatapathName     string
	NoFastdp         bool
	NoBridgedFastdp  bool
	AWSVPC           bool
	NPC              bool
	MTU              int
	Mac              string
	Port             int
	ControlPort      string
	NoMasqLocal      bool
}

type Dev added in v1.8.0

type Dev struct {
	Name  string           `json:"Name,omitempty"`
	MAC   net.HardwareAddr `json:"MAC,omitempty"`
	CIDRs []*net.IPNet     `json:"CIDRs,omitempty"`
}

func GetBridgeNetDev added in v1.8.0

func GetBridgeNetDev(bridgeName string) (Dev, error)

Get the weave bridge interface. NB: Should be called from the root network namespace.

func GetNetDevsByVethPeerIds added in v1.8.0

func GetNetDevsByVethPeerIds(processID int, peerIDs []int) ([]Dev, error)

func GetWeaveNetDevs added in v1.8.0

func GetWeaveNetDevs(processID int) ([]Dev, error)

Lookup the weave interface of a container

type EthtoolValue added in v1.6.0

type EthtoolValue struct {
	Cmd  uint32
	Data uint32
}

linux/ethtool.h 'struct ethtool_value'

type IFReqData added in v1.6.0

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

linux/if.h 'struct ifreq'

type NoMasqLocalTracker

type NoMasqLocalTracker struct {
	// contains filtered or unexported fields
}

func NewNoMasqLocalTracker

func NewNoMasqLocalTracker(ips ipset.Interface) *NoMasqLocalTracker

func (*NoMasqLocalTracker) HandleUpdate

func (t *NoMasqLocalTracker) HandleUpdate(prevRanges, currRanges []address.Range, local bool) error

func (*NoMasqLocalTracker) String

func (t *NoMasqLocalTracker) String() string

Directories

Path Synopsis
package IPsec provides primitives for establishing IPsec in the fastdp mode.
package IPsec provides primitives for establishing IPsec in the fastdp mode.

Jump to

Keyboard shortcuts

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