util

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ControllerName = "kube-ovn-controller"

	AllocatedAnnotation  = "ovn.kubernetes.io/allocated"
	RoutedAnnotation     = "ovn.kubernetes.io/routed"
	MacAddressAnnotation = "ovn.kubernetes.io/mac_address"
	IpAddressAnnotation  = "ovn.kubernetes.io/ip_address"
	CidrAnnotation       = "ovn.kubernetes.io/cidr"
	GatewayAnnotation    = "ovn.kubernetes.io/gateway"
	IpPoolAnnotation     = "ovn.kubernetes.io/ip_pool"
	BgpAnnotation        = "ovn.kubernetes.io/bgp"
	SnatAnnotation       = "ovn.kubernetes.io/snat"
	EipAnnotation        = "ovn.kubernetes.io/eip"
	ChassisAnnotation    = "ovn.kubernetes.io/chassis"

	LogicalRouterAnnotation = "ovn.kubernetes.io/logical_router"
	VpcAnnotation           = "ovn.kubernetes.io/vpc"

	PortSecurityAnnotation = "ovn.kubernetes.io/port_security"
	NorthGatewayAnnotation = "ovn.kubernetes.io/north_gateway"

	AllocatedAnnotationTemplate     = "%s.kubernetes.io/allocated"
	MacAddressAnnotationTemplate    = "%s.kubernetes.io/mac_address"
	IpAddressAnnotationTemplate     = "%s.kubernetes.io/ip_address"
	CidrAnnotationTemplate          = "%s.kubernetes.io/cidr"
	GatewayAnnotationTemplate       = "%s.kubernetes.io/gateway"
	IpPoolAnnotationTemplate        = "%s.kubernetes.io/ip_pool"
	LogicalSwitchAnnotationTemplate = "%s.kubernetes.io/logical_switch"

	ExcludeIpsAnnotation = "ovn.kubernetes.io/exclude_ips"

	IngressRateAnnotation = "ovn.kubernetes.io/ingress_rate"
	EgressRateAnnotation  = "ovn.kubernetes.io/egress_rate"

	PortNameAnnotation      = "ovn.kubernetes.io/port_name"
	LogicalSwitchAnnotation = "ovn.kubernetes.io/logical_switch"

	SubnetNameLabel = "ovn.kubernetes.io/subnet"
	ICGatewayLabel  = "ovn.kubernetes.io/ic-gw"
	ExGatewayLabel  = "ovn.kubernetes.io/external-gw"

	ProtocolTCP = "tcp"
	ProtocolUDP = "udp"

	VlanIdAnnotation      = "ovn.kubernetes.io/vlan_id"
	VlanRangeAnnotation   = "ovn.kubernetes.io/vlan_range"
	NetworkType           = "ovn.kubernetes.io/network_types"
	NetworkTypeVlan       = "vlan"
	ProviderInterfaceName = "ovn.kubernetes.io/provider_interface_name"
	HostInterfaceName     = "ovn.kubernetes.io/host_interface_name"

	NodeNic           = "ovn0"
	NodeAllowPriority = "3000"

	IngressExceptDropPriority = "2002"
	IngressAllowPriority      = "2001"
	IngressDefaultDrop        = "2000"

	EgressExceptDropPriority = "2002"
	EgressAllowPriority      = "2001"
	EgressDefaultDrop        = "2000"

	SubnetAllowPriority = "1001"
	DefaultDropPriority = "1000"

	GeneveHeaderLength = 100
	TcpIpHeaderLength  = 40

	OvnProvider                 = "ovn"
	AttachmentNetworkAnnotation = "k8s.v1.cni.cncf.io/networks"
	DefaultNetworkAnnotation    = "v1.multus-cni.io/default-network"

	SRIOVResourceName = "mellanox.com/cx5_sriov_switchdev"

	InterconnectionConfig = "ovn-ic-config"
	ExternalGatewayConfig = "ovn-external-gw-config"
	InterconnectionSwitch = "ts"
	ExternalGatewaySwitch = "ovn-external"

	DefaultVpc = "ovn-cluster"

	EcmpRouteType   = "ecmp"
	NormalRouteType = "normal"

	ChassisLoc     = "/etc/openvswitch/system-id.conf"
	HostnameEnv    = "KUBE_NODE_NAME"
	ChasRetryTime  = 5
	ChasRetryIntev = 1
)
View Source
const (
	V6Multicast = "ff00::/8"
	V4Multicast = "224.0.0.0/4"
	V4Loopback  = "127.0.0.1/8"
	V6Loopback  = "::1/128"
)

Variables

This section is empty.

Functions

func AddressCount added in v0.7.0

func AddressCount(network *net.IPNet) float64

func AppendGwByCidr added in v1.6.1

func AppendGwByCidr(gateway, cidrStr string) (string, error)

func BigInt2Ip added in v0.6.0

func BigInt2Ip(ipInt *big.Int) string

func CIDRConflict added in v0.6.0

func CIDRConflict(a, b string) bool

func CIDRContainIP added in v1.1.0

func CIDRContainIP(cidrStr, ipStr string) bool

func CheckCidrs added in v1.6.0

func CheckCidrs(cidr string) error

func CheckProtocol added in v0.6.0

func CheckProtocol(address string) string

func ContainsIPs added in v1.6.1

func ContainsIPs(excludeIP string, ip string) bool

func ContainsString added in v0.9.1

func ContainsString(slice []string, s string) bool

Helper functions to check and remove string from a slice of strings.

func CountIpNums added in v1.6.1

func CountIpNums(excludeIPs []string) int64

func DiffStringSlice added in v0.5.0

func DiffStringSlice(slice1, slice2 []string) []string

func ExpandExcludeIPs added in v1.6.1

func ExpandExcludeIPs(excludeIPs []string, cidr string) []string

ExpandExcludeIPs used to get exclude ips in range of subnet cidr, excludes cidr addr and broadcast addr

func FirstSubnetIP added in v0.5.0

func FirstSubnetIP(subnet string) (string, error)

func GenerateMac

func GenerateMac() string

GenerateMac generates mac address.

func GenerateRandomV4IP added in v1.4.0

func GenerateRandomV4IP(cidr string) string

func GetGwByCidr added in v1.6.0

func GetGwByCidr(cidrStr string) (string, error)

func GetIpAddrWithMask added in v1.6.0

func GetIpAddrWithMask(ip, cidr string) string

func GetIpWithoutMask added in v1.6.0

func GetIpWithoutMask(ipStr string) string

func GetNodeInternalIP added in v1.6.1

func GetNodeInternalIP(node *v1.Node) string

func GetStringIP added in v1.6.0

func GetStringIP(v4IP, v6IP string) string

func IPToString added in v1.6.0

func IPToString(ip string) string

func Ip2BigInt added in v0.6.0

func Ip2BigInt(ipStr string) *big.Int

func IsNetworkVlan added in v1.2.0

func IsNetworkVlan(networkType string, vlanID string, vlanRange string) bool

func IsProviderVlan added in v1.2.0

func IsProviderVlan(networkType, provider string) bool

func IsStringIn added in v0.9.0

func IsStringIn(str string, slice []string) bool

func IsStringsOverlap added in v0.6.0

func IsStringsOverlap(a, b []string) bool

IsStringsOverlap check if two string slices are overlapped

func IsValidIP added in v1.6.0

func IsValidIP(ip string) bool

func LastIP added in v1.3.0

func LastIP(subnet string) (string, error)

func ParsePodNetworkAnnotation added in v1.1.0

func ParsePodNetworkAnnotation(podNetworks, defaultNamespace string) ([]*types.NetworkSelectionElement, error)

func RemoveString added in v0.9.1

func RemoveString(slice []string, s string) (result []string)

func SplitIpsByProtocol added in v1.6.0

func SplitIpsByProtocol(excludeIps []string) ([]string, []string)

func SplitStringIP added in v1.6.0

func SplitStringIP(ipStr string) (string, string)

func SubnetBroadCast added in v1.3.0

func SubnetBroadCast(subnet string) string

func SubnetNumber added in v1.3.0

func SubnetNumber(subnet string) string

func UniqString added in v0.6.0

func UniqString(a []string) []string

UniqString creates an array of string with unique values.

func ValidatePodCidr added in v1.6.0

func ValidatePodCidr(cidr, ip string) error

func ValidatePodNetwork added in v0.4.0

func ValidatePodNetwork(annotations map[string]string) error

func ValidateSubnet added in v0.6.0

func ValidateSubnet(subnet kubeovnv1.Subnet) error

func ValidateVlan added in v1.2.0

func ValidateVlan(vlan int, vlanRange string) error

Types

type IPTableRule

type IPTableRule struct {
	Table string
	Chain string
	Rule  []string
}

IPTableRule wraps iptables rule

Jump to

Keyboard shortcuts

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