Documentation ¶
Index ¶
- Constants
- Variables
- func AddAddresses(link netlink.Link, cidrs []*net.IPNet) (newAddrs []*net.IPNet, err error)
- func AddRoute(link netlink.Link, scope netlink.Scope, dst *net.IPNet, gw net.IP) error
- func AttachContainer(netNSPath, id, ifName, bridgeName string, mtu int, withMulticastRoute bool, ...) error
- func CheckAddressOverlap(addr net.IP, ignoreIfaceNames map[string]struct{}) error
- func CheckNetworkFree(subnet *net.IPNet, ignoreIfaceNames map[string]struct{}) error
- func ConfigureARPCache(name string) error
- func ConnectedToBridgeVethPeerIds(bridgeName string) ([]int, error)
- func CreateAndAttachVeth(name, peerName, bridgeName string, mtu int, keepTXOn bool, ...) (*netlink.Veth, error)
- func DetachContainer(netNSPath, id, ifName string, cidrs []*net.IPNet) error
- func DetectHairpin(portIfName string, log *logrus.Logger) error
- func EnsureInterface(ifaceName string) (*net.Interface, error)
- func EnsureInterfaceAndMcastRoute(ifaceName string) (*net.Interface, error)
- func EthtoolTXOff(name string) error
- func ExposeNAT(ipnet net.IPNet) error
- func FindBridgeIP(bridgeName string, subnet *net.IPNet) (net.IP, error)
- func GetSystemPeerName(dbPrefix, hostRoot string) (string, error)
- func ListenUnixSocket(pathname string) (net.Listener, error)
- func MACfromUUID(uuid []byte) net.HardwareAddr
- func NSPathByPid(pid int) string
- func RandomMAC() (net.HardwareAddr, error)
- func WithNetNS(nsPath string, cmd string, args ...string) ([]byte, error)
- func WithNetNSByPid(pid int, cmd string, args ...string) ([]byte, error)
- func WithNetNSLinkUnsafe(ns netns.NsHandle, ifName string, work func(link netlink.Link) error) error
- func WithNetNSUnsafe(ns netns.NsHandle, work func() error) error
- type BridgeType
- type Dev
- type EthtoolValue
- type IFReqData
Constants ¶
const ( SIOCETHTOOL = 0x8946 // linux/sockios.h ETHTOOL_GTXCSUM = 0x00000016 // linux/ethtool.h ETHTOOL_STXCSUM = 0x00000017 // linux/ethtool.h IFNAMSIZ = 16 // linux/if.h )
const (
VethName = "ethwe" // name inside container namespace
)
Variables ¶
var ErrBridgeNoIP = fmt.Errorf("Bridge has no IP address")
var ErrLinkNotFound = errors.New("Link not found")
var WeaveUtilCmd = "weaveutil"
Functions ¶
func AddAddresses ¶ added in v1.6.0
func AttachContainer ¶ added in v1.6.0
func AttachContainer(netNSPath, id, ifName, bridgeName string, mtu int, withMulticastRoute bool, cidrs []*net.IPNet, keepTXOn bool) error
NB: This function can be used only by a process that terminates immediately
after calling the function as it changes netns via WithNetNSLinkUnsafe.
func CheckAddressOverlap ¶ added in v1.1.0
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
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 ¶ added in v1.6.0
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 ConnectedToBridgeVethPeerIds ¶ added in v1.8.0
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(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 ¶ added in v1.6.0
NB: This function can be used only by a process that terminates immediately
after calling the function as it changes netns via WithNetNSLinkUnsafe.
func DetectHairpin ¶ added in v1.8.2
func EnsureInterface ¶
Wait for an interface to come up.
func EnsureInterfaceAndMcastRoute ¶ added in v1.1.0
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
Disable TX checksum offload on specified interface
func FindBridgeIP ¶ added in v1.9.0
func GetSystemPeerName ¶ added in v1.9.0
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 ListenUnixSocket ¶ added in v1.5.0
func MACfromUUID ¶ added in v1.9.0
func MACfromUUID(uuid []byte) net.HardwareAddr
func NSPathByPid ¶ added in v1.7.2
func RandomMAC ¶ added in v1.9.0
func RandomMAC() (net.HardwareAddr, error)
func WithNetNS ¶ added in v1.6.0
A safe version of WithNetNS* which creates a process executing "nsenter --net=<ns-path> weaveutil <cmd> [args]".
func WithNetNSByPid ¶ added in v1.7.2
func WithNetNSLinkUnsafe ¶ added in v1.6.1
func WithNetNSUnsafe ¶ added in v1.6.1
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 ¶ added in v1.6.0
type BridgeType int
const ( WeaveBridgeName = "weave" DatapathName = "datapath" None BridgeType = iota Bridge Fastdp BridgedFastdp Inconsistent )
func DetectBridgeType ¶ added in v1.6.0
func DetectBridgeType(weaveBridgeName, datapathName string) BridgeType
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
Get the weave bridge interface. NB: Should be called from the root network namespace.
func GetNetDevsByVethPeerIds ¶ added in v1.8.0
func GetWeaveNetDevs ¶ added in v1.8.0
Lookup the weave interface of a container
type EthtoolValue ¶ added in v1.6.0
linux/ethtool.h 'struct ethtool_value'