util

package
v0.11.3 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package util contains utility functions which are used in the agent implementation.

Index

Constants

View Source
const (
	FamilyIPv4 uint8 = 4
	FamilyIPv6 uint8 = 6
)
View Source
const (
	ContainerVNICPrefix = "vEthernet"
	HNSNetworkType      = "Transparent"
	LocalHNSNetwork     = "antrea-hnsnetwork"
	OVSExtensionID      = "583CC151-73EC-4A6A-8B47-578297AD7623"
)

Variables

This section is empty.

Functions

func CallPSCommand added in v0.7.0

func CallPSCommand(cmd string) (string, error)

func ConfigureInterfaceAddress added in v0.7.0

func ConfigureInterfaceAddress(ifaceName string, ipConfig *net.IPNet) error

ConfigureInterfaceAddress adds IPAddress on the specified interface.

func ConfigureInterfaceAddressWithDefaultGateway added in v0.7.0

func ConfigureInterfaceAddressWithDefaultGateway(ifaceName string, ipConfig *net.IPNet, gateway string) error

ConfigureInterfaceAddressWithDefaultGateway adds IPAddress on the specified interface and sets the default gateway for the host.

func ConfigureLinkAddresses added in v0.11.3

func ConfigureLinkAddresses(idx int, ipNets []*net.IPNet) error

ConfigureLinkAddresses adds the provided addresses to the interface identified by index idx, if they are missing from the interface. Any other existing address already configured for the interface will be removed, unless it is a link-local address. At the moment, this function only supports IPv4 addresses and will ignore any address in ipNets that is not IPv4.

func CreateHNSNetwork added in v0.7.0

func CreateHNSNetwork(hnsNetName string, subnetCIDR *net.IPNet, nodeIP *net.IPNet, adapter *net.Interface) (*hcsshim.HNSNetwork, error)

CreateHNSNetwork creates a new HNS Network, whose type is "Transparent". The NetworkAdapter is using the host interface which is configured with Node IP. HNS Network properties "ManagementIP" and "SourceMac" are used to record the original IP and MAC addresses on the network adapter.

func DeleteHNSNetwork added in v0.7.0

func DeleteHNSNetwork(hnsNetName string) error

func DialLocalSocket added in v0.7.0

func DialLocalSocket(address string) (net.Conn, error)

DialLocalSocket connects to a Unix domain socket or a Windows named pipe. - If the specified address starts with "\\.\pipe\", connect to a Windows named pipe path. - Else connect to a Unix domain socket.

func EnableHNSNetworkExtension added in v0.7.0

func EnableHNSNetworkExtension(hnsNetID string, vSwitchExtension string) error

EnableHNSNetworkExtension enables the specified vSwitchExtension on the target HNS Network. Antrea calls this function to enable OVS Extension on the HNS Network.

func EnableHostInterface added in v0.7.0

func EnableHostInterface(ifaceName string) error

EnableHostInterface sets the specified interface status as UP.

func EnableIPForwarding added in v0.7.0

func EnableIPForwarding(ifaceName string) error

EnableIPForwarding enables the IP interface to forward packets that arrive on this interface to other interfaces.

func GenerateContainerInterfaceKey added in v0.3.0

func GenerateContainerInterfaceKey(containerID string) string

GenerateContainerInterfaceKey generates a unique string for a Pod's interface as: container/<Container-ID>. We must use ContainerID instead of PodNamespace + PodName because there could be more than one container associated with the same Pod at some point. For example, when deleting a StatefulSet Pod with 0 second grace period, the Pod will be removed from the Kubernetes API very quickly and a new Pod will be created immediately, and kubelet may process the deletion of the previous Pod and the addition of the new Pod simultaneously.

func GenerateContainerInterfaceName

func GenerateContainerInterfaceName(podName, podNamespace, containerID string) string

GenerateContainerInterfaceName generates a unique interface name using the Pod's namespace, name and containerID. The output should be deterministic (so that multiple calls to GenerateContainerInterfaceName with the same parameters return the same value). The output has the length of interfaceNameLength(15). The probability of collision should be neglectable.

func GenerateNodeTunnelInterfaceKey added in v0.3.0

func GenerateNodeTunnelInterfaceKey(nodeName string) string

GenerateNodeTunnelInterfaceKey generates a unique string for a Node's tunnel interface as: node/<Node-name>.

func GenerateNodeTunnelInterfaceName added in v0.3.0

func GenerateNodeTunnelInterfaceName(nodeName string) string

GenerateNodeTunnelInterfaceName generates a unique interface name for the tunnel to the Node, using the Node's name.

func GetAdapterIPv4Addr added in v0.7.0

func GetAdapterIPv4Addr(adapterName string) (*net.IPNet, error)

func GetDNServersByInterfaceIndex added in v0.7.0

func GetDNServersByInterfaceIndex(ifIndex int) (string, error)

GetDNServersByInterfaceIndex returns the DNS servers configured on the specified interface.

func GetDefaultGatewayByInterfaceIndex added in v0.7.0

func GetDefaultGatewayByInterfaceIndex(ifIndex int) (string, error)

GetDefaultGatewayByInterfaceIndex returns the default gateway configured on the speicified interface.

func GetIPNetDeviceFromIP added in v0.7.0

func GetIPNetDeviceFromIP(localIP net.IP) (*net.IPNet, *net.Interface, error)

GetIPNetDeviceFromIP returns a local IP/mask and associated device from IP.

func GetIPWithFamily added in v0.11.0

func GetIPWithFamily(ips []net.IP, addrFamily uint8) (net.IP, error)

func GetIPv4Addr added in v0.11.0

func GetIPv4Addr(ips []net.IP) net.IP

func GetLocalBroadcastIP added in v0.7.0

func GetLocalBroadcastIP(ipNet *net.IPNet) net.IP

GetLocalBroadcastIP returns the last IP address in a subnet. This IP is always working as the broadcast address in the subnet on Windows, and an active route entry that uses it as the destination is added by default when a new IP is configured on the interface.

func GetNSPath added in v0.7.0

func GetNSPath(containerNetNS string) (string, error)

func InvokePSCommand added in v0.7.0

func InvokePSCommand(cmd string) error

func ListenLocalSocket added in v0.7.0

func ListenLocalSocket(address string) (net.Listener, error)

ListenLocalSocket creates a listener on a Unix domain socket or a Windows named pipe. - If the specified address starts with "\\.\pipe\", create a listener on the a Windows named pipe path. - Else create a listener on a local Unix domain socket.

func PrepareHNSNetwork added in v0.7.0

func PrepareHNSNetwork(subnetCIDR *net.IPNet, nodeIPNet *net.IPNet, uplinkAdapter *net.Interface) error

PrepareHNSNetwork creates HNS Network for containers.

func RemoveIPv4AddrsFromAdapter added in v0.7.0

func RemoveIPv4AddrsFromAdapter(adapterName string) error

func RemoveInterfaceAddress added in v0.11.3

func RemoveInterfaceAddress(ifaceName string, ipAddr net.IP) error

RemoveInterfaceAddress removes IPAddress from the specified interface.

func RemoveManagementInterface added in v0.7.0

func RemoveManagementInterface(networkName string) error

RemoveManagementInterface removes the management interface of the HNS Network, and then the physical interface can be added to the OVS bridge. This function is called only if Hyper-V feature is installed on the host.

func SetAdapterDNSServers added in v0.7.0

func SetAdapterDNSServers(adapterName, dnsServers string) error

SetAdapterDNSServers configures DNSServers on network adapter.

func SetAdapterMACAddress added in v0.7.0

func SetAdapterMACAddress(adapterName string, macConfig *net.HardwareAddr) error

ConfigureMACAddress set specified MAC address on interface.

func SetLinkUp added in v0.7.0

func SetLinkUp(name string) (net.HardwareAddr, int, error)

func WindowsHyperVInstalled added in v0.7.0

func WindowsHyperVInstalled() (bool, error)

WindowsHyperVInstalled checks if the Hyper-V feature is enabled on the host.

Types

type ExtensionsPolicy added in v0.7.0

type ExtensionsPolicy struct {
	Extensions []vSwitchExtensionPolicy `json:"Extensions"`
}

type LinkNotFound added in v0.7.0

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

Directories

Path Synopsis
Package ethtool provides Go wrappers for ioctl ethtool system calls on Linux
Package ethtool provides Go wrappers for ioctl ethtool system calls on Linux
Package systcl contains utility functions to read and write sysctl configuration on Linux.
Package systcl contains utility functions to read and write sysctl configuration on Linux.
Package winfirewall contains utility functions to configure the Windows firewall.
Package winfirewall contains utility functions to configure the Windows firewall.

Jump to

Keyboard shortcuts

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