util

package
v0.59.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommonNetworkCreate

func CommonNetworkCreate(n NetUtil, network *types.Network) error

func CreateBridge

func CreateBridge(n NetUtil, network *types.Network, usedNetworks []*net.IPNet, subnetPools []config.SubnetPool) error

func GetBridgeInterfaceNames

func GetBridgeInterfaceNames(n NetUtil) []string

GetBridgeInterfaceNames returns all bridge interface names already used by network configs

func GetFreeDeviceName

func GetFreeDeviceName(n NetUtil) (string, error)

GetFreeDeviceName returns a free device name which can be used for new configs as name and bridge interface name. The base name is suffixed by a number

func GetFreeIPv4NetworkSubnet

func GetFreeIPv4NetworkSubnet(usedNetworks []*net.IPNet, subnetPools []config.SubnetPool) (*types.Subnet, error)

GetFreeIPv4NetworkSubnet returns a unused ipv4 subnet

func GetFreeIPv6NetworkSubnet

func GetFreeIPv6NetworkSubnet(usedNetworks []*net.IPNet) (*types.Subnet, error)

GetFreeIPv6NetworkSubnet returns a unused ipv6 subnet

func GetLiveNetworkNames

func GetLiveNetworkNames() ([]string, error)

GetLiveNetworkNames returns a list of network interface names on the system

func GetUsedNetworkNames

func GetUsedNetworkNames(n NetUtil) []string

GetUsedNetworkNames returns all network names already used by network configs

func GetUsedSubnets

func GetUsedSubnets(n NetUtil) ([]*net.IPNet, error)

GetUsedSubnets returns a list of all used subnets by network configs and interfaces on the host.

func IpamNoneDisableDNS added in v0.49.0

func IpamNoneDisableDNS(network *types.Network)

func MapDockerBridgeDriverOptions added in v0.52.0

func MapDockerBridgeDriverOptions(n *types.Network)

Map docker driver network options to podman network options

func NetworkIntersectsWithNetworks

func NetworkIntersectsWithNetworks(n *net.IPNet, networklist []*net.IPNet) bool

func NextSubnet

func NextSubnet(subnet *net.IPNet) (*net.IPNet, error)

NextSubnet returns subnet incremented by 1

func ParseIsolate added in v0.54.0

func ParseIsolate(isolate string) (string, error)

ParseIsolate parses the isolate option

func ParseMTU

func ParseMTU(mtu string) (int, error)

ParseMTU parses the mtu option

func ParseVlan

func ParseVlan(vlan string) (int, error)

ParseVlan parses the vlan option

func ValidateRoute added in v0.54.0

func ValidateRoute(route types.Route) error

func ValidateRoutes added in v0.54.0

func ValidateRoutes(routes []types.Route) error

func ValidateSetupOptions

func ValidateSetupOptions(n NetUtil, namespacePath string, options types.SetupOptions) error

func ValidateSubnet

func ValidateSubnet(s *types.Subnet, addGateway bool, usedNetworks []*net.IPNet) error

ValidateSubnet will validate a given Subnet. It checks if the given gateway and lease range are part of this subnet. If the gateway is empty and addGateway is true it will get the first available ip in the subnet assigned.

func ValidateSubnets

func ValidateSubnets(network *types.Network, addGateway bool, usedNetworks []*net.IPNet) error

ValidateSubnets will validate the subnets for this network. It also sets the gateway if the gateway is empty and addGateway is set to true IPv6Enabled to true if at least one subnet is ipv6.

Types

type NetUtil

type NetUtil interface {
	// ForEach executes the given function for each network
	ForEach(func(types.Network))
	// Len returns the number of networks
	Len() int
	// DefaultInterfaceName return the default interface name, this will be suffixed by a number
	DefaultInterfaceName() string
	// Network returns the network with the given name or ID.
	// It returns an error if the network is not found
	Network(nameOrID string) (*types.Network, error)
}

NetUtil is a helper interface which all network interfaces should implement to allow easy code sharing

Jump to

Keyboard shortcuts

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