Documentation ¶
Overview ¶
Package util contains utility functions which are used in the agent implementation.
Index ¶
- Constants
- func ConfigureLinkAddresses(idx int, ipNets []*net.IPNet) error
- func ConfigureLinkRoutes(link netlink.Link, routes []interface{}) error
- func DeleteOVSPort(brName, portName string) error
- func DialLocalSocket(address string) (net.Conn, error)
- func ExtendCIDRWithIP(ipNet *net.IPNet, ip net.IP) (*net.IPNet, error)
- func GenerateContainerInterfaceKey(containerID string) string
- func GenerateContainerInterfaceName(podName, podNamespace, containerID string) string
- func GenerateNodeTunnelInterfaceKey(nodeName string) string
- func GenerateNodeTunnelInterfaceName(nodeName string) string
- func GenerateRandomMAC() net.HardwareAddr
- func GenerateUplinkInterfaceName(name string) string
- func GetAllIPNetsByName(ifaceName string) ([]*net.IPNet, error)
- func GetAllNodeAddresses(excludeDevices []string) ([]net.IP, []net.IP, error)
- func GetIPNetDeviceByCIDRs(cidrsList []string) (v4IPNet, v6IPNet *net.IPNet, link *net.Interface, err error)
- func GetIPNetDeviceByName(ifaceName string) (v4IPNet *net.IPNet, v6IPNet *net.IPNet, link *net.Interface, err error)
- func GetIPNetDeviceFromIP(localIPs *ip.DualStackIPs, ignoredInterfaces sets.Set[string]) (v4IPNet *net.IPNet, v6IPNet *net.IPNet, iface *net.Interface, err error)
- func GetIPNetsByLink(link *net.Interface) ([]*net.IPNet, error)
- func GetIPWithFamily(ips []net.IP, addrFamily uint8) (net.IP, error)
- func GetIPv4Addr(ips []net.IP) net.IP
- func GetInterfaceConfig(ifName string) (*net.Interface, []*net.IPNet, []interface{}, error)
- func GetNSDevInterface(nsPath, dev string) (*net.Interface, error)
- func GetNSPath(netnsName string) (string, error)
- func GetNSPeerDevBridge(nsPath, dev string) (*net.Interface, string, error)
- func HostInterfaceExists(ifName string) bool
- func ListenLocalSocket(address string) (net.Listener, error)
- func NewIPNet(ip net.IP) *net.IPNet
- func PortToUint16(port int) uint16
- func RemoveLinkIPs(link netlink.Link) error
- func RemoveLinkRoutes(link netlink.Link) error
- func RenameInterface(from, to string) error
- func SetAdapterMACAddress(adapterName string, macConfig *net.HardwareAddr) error
- func SetLinkUp(name string) (net.HardwareAddr, int, error)
- type LinkNotFound
Constants ¶
const ( FamilyIPv4 uint8 = 4 FamilyIPv6 uint8 = 6 )
Variables ¶
This section is empty.
Functions ¶
func ConfigureLinkAddresses ¶
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.
func ConfigureLinkRoutes ¶ added in v1.8.0
func DeleteOVSPort ¶ added in v1.4.0
DeleteOVSPort deletes specific OVS port. This function calls ovs-vsctl command to bypass OVS bridge client to work when agent exiting.
func DialLocalSocket ¶
DialLocalSocket connects to a Unix domain socket.
func ExtendCIDRWithIP ¶ added in v1.4.0
ExtendCIDRWithIP is used for extending an IPNet with an IP.
func GenerateContainerInterfaceKey ¶
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 ¶
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 ¶
GenerateNodeTunnelInterfaceKey generates a unique string for a Node's tunnel interface as: node/<Node-name>.
func GenerateNodeTunnelInterfaceName ¶
GenerateNodeTunnelInterfaceName generates a unique interface name for the tunnel to the Node, using the Node's name.
func GenerateRandomMAC ¶ added in v1.7.2
func GenerateRandomMAC() net.HardwareAddr
func GenerateUplinkInterfaceName ¶ added in v1.7.1
GenerateUplinkInterfaceName generates the uplink interface name after bridged to OVS
func GetAllIPNetsByName ¶ added in v1.7.1
func GetAllNodeAddresses ¶ added in v1.4.0
GetAllNodeAddresses gets all Node IP addresses (not including IPv6 link local address).
func GetIPNetDeviceByCIDRs ¶ added in v1.4.0
func GetIPNetDeviceByName ¶ added in v1.2.4
func GetIPNetDeviceFromIP ¶
func GetIPNetDeviceFromIP(localIPs *ip.DualStackIPs, ignoredInterfaces sets.Set[string]) (v4IPNet *net.IPNet, v6IPNet *net.IPNet, iface *net.Interface, err error)
GetIPNetDeviceFromIP returns local IPs/masks and associated device from IP, and ignores the interfaces which have names in the ignoredInterfaces.
func GetIPNetsByLink ¶ added in v1.8.0
func GetInterfaceConfig ¶ added in v1.8.0
func GetNSDevInterface ¶
GetNSDevInterface returns interface of dev in namespace nsPath.
func GetNSPeerDevBridge ¶
GetNSPeerDevBridge returns peer device and its attached bridge (if applicable) for device dev in network space indicated by nsPath
func HostInterfaceExists ¶ added in v1.8.0
func ListenLocalSocket ¶
ListenLocalSocket creates a listener on a Unix domain socket.
func NewIPNet ¶ added in v1.4.0
Copied from github.com/vishvananda/netlink/netlink.go NewIPNet generates an IPNet from an ip address using a netmask of 32 or 128.
func PortToUint16 ¶ added in v1.7.0
func RemoveLinkIPs ¶ added in v1.8.0
func RemoveLinkRoutes ¶ added in v1.8.0
func RenameInterface ¶ added in v1.7.1
func SetAdapterMACAddress ¶ added in v1.4.0
func SetAdapterMACAddress(adapterName string, macConfig *net.HardwareAddr) error
SetAdapterMACAddress set specified MAC address on interface.
Types ¶
type LinkNotFound ¶
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 |
testing
Package testing is a generated GoMock package.
|
Package testing is a generated GoMock package. |
testing
Package testing is a generated GoMock package.
|
Package testing is a generated GoMock package. |
Package ndp contains functions to send NDP neighbor advertisement on Linux.
|
Package ndp contains functions to send NDP neighbor advertisement on Linux. |
testing
Package testing is a generated GoMock package.
|
Package testing is a generated GoMock package. |
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. |