containernetwork

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DockerNetnsDir     = "/var/run/docker/netns"
	ContainerdNetnsDir = "/var/run/netns/"

	ContainerHostLinkPrefix = "h_"
	ContainerHostLinkMac    = "ee:ee:ee:ee:ee:ee"
	ContainerInitLinkSuffix = "_c"
	VxlanLinkInfix          = ".vxlan"
	ContainerNicName        = "eth0"

	ProxyArpSysctl       = "/proc/sys/net/ipv4/conf/%s/proxy_arp"
	ProxyDelaySysctl     = "/proc/sys/net/ipv4/neigh/%s/proxy_delay"
	RouteLocalNetSysctl  = "/proc/sys/net/ipv4/conf/%s/route_localnet"
	IPv4ForwardingSysctl = "/proc/sys/net/ipv4/conf/%s/forwarding"

	RpFilterSysctl = "/proc/sys/net/ipv4/conf/%s/rp_filter"

	IPv4NeighGCThresh1 = "/proc/sys/net/ipv4/neigh/default/gc_thresh1"
	IPv4NeighGCThresh2 = "/proc/sys/net/ipv4/neigh/default/gc_thresh2"
	IPv4NeighGCThresh3 = "/proc/sys/net/ipv4/neigh/default/gc_thresh3"

	IPv6NeighGCThresh1 = "/proc/sys/net/ipv6/neigh/default/gc_thresh1"
	IPv6NeighGCThresh2 = "/proc/sys/net/ipv6/neigh/default/gc_thresh2"
	IPv6NeighGCThresh3 = "/proc/sys/net/ipv6/neigh/default/gc_thresh3"

	ProxyNdpSysctl       = "/proc/sys/net/ipv6/conf/%s/proxy_ndp"
	IPv6ForwardingSysctl = "/proc/sys/net/ipv6/conf/%s/forwarding"

	IPv4AppSolicitSysctl = "/proc/sys/net/ipv4/neigh/%s/app_solicit"
	IPv6AppSolicitSysctl = "/proc/sys/net/ipv6/neigh/%s/app_solicit"

	AcceptDADSysctl = "/proc/sys/net/ipv6/conf/%s/accept_dad"
	AcceptRASysctl  = "/proc/sys/net/ipv6/conf/%s/accept_ra"

	IPv4BaseReachableTimeMSSysctl = "/proc/sys/net/ipv4/neigh/%s/base_reachable_time_ms"
	IPv6BaseReachableTimeMSSysctl = "/proc/sys/net/ipv6/neigh/%s/base_reachable_time_ms"

	IPv6DisableModuleParameter = "/sys/module/ipv6/parameters/disable"
	IPv6DisableSysctl          = "/proc/sys/net/ipv6/conf/%s/disable_ipv6"

	// IP Masks that have no effect on IP Address
	DefaultIP4Mask = "255.255.255.255"
	DefaultIP6Mask = "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"
)

Variables

This section is empty.

Functions

func CheckIPIsGlobalUnicast

func CheckIPIsGlobalUnicast(ip net.IP) bool

func CheckIPv6Disabled added in v0.3.1

func CheckIPv6Disabled(nicName string) (bool, error)

func CheckIPv6GlobalDisabled added in v0.3.1

func CheckIPv6GlobalDisabled() (bool, error)
func CheckIfContainerNetworkLink(linkName string) bool

func ConfigureContainerNic

func ConfigureContainerNic(containerNicName, hostNicName, nodeIfName string, allocatedIPs map[networkingv1.IPVersion]*IPInfo,
	macAddr net.HardwareAddr, netID *uint32, netns ns.NetNS, mtu int, vlanCheckTimeout time.Duration,
	networkType networkingv1.NetworkType, neighGCThresh1, neighGCThresh2, neighGCThresh3 int) error

ipAddr is a CIDR notation IP address and prefix length

func ConfigureHostNic

func ConfigureHostNic(nicName string, allocatedIPs map[networkingv1.IPVersion]*IPInfo, localDirectTableNum int) error

func EnsureVlanIf

func EnsureVlanIf(nodeIfName string, vlanID *uint32) (string, error)

func GenerateContainerVethPair

func GenerateContainerVethPair(containerID string) (string, string)

func GenerateIPListString

func GenerateIPListString(addrList []netlink.Addr) string

func GenerateVlanNetIfName

func GenerateVlanNetIfName(parentName string, vlanID *uint32) (string, error)

func GenerateVxlanNetIfName

func GenerateVxlanNetIfName(parentName string, vlanID *uint32) (string, error)

func GetDefaultInterface

func GetDefaultInterface(family int) (*net.Interface, error)

func GetDefaultRoute

func GetDefaultRoute(family int) (*netlink.Route, error)

func GetInterfaceByPreferString

func GetInterfaceByPreferString(preferString string) (*net.Interface, error)

Get first valid interface by prefer string.

func ListAllAddress

func ListAllAddress(link netlink.Link) ([]netlink.Addr, error)
func ListLocalAddressExceptLink(exceptLinkName string) ([]netlink.Addr, error)

Types

type IPInfo

type IPInfo struct {
	Addr net.IP
	Gw   net.IP
	Cidr *net.IPNet
}

Jump to

Keyboard shortcuts

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