Documentation ¶
Index ¶
- Constants
- Variables
- func CalcGatewayIP(ipn *net.IPNet) net.IP
- func Create(name string, options entities.NetworkCreateOptions, ...) (*entities.NetworkCreateReport, error)
- func Exists(config *config.Config, name string) (bool, error)
- func FirstIPInSubnet(addr *net.IPNet) (net.IP, error)
- func GetBridgeNamesFromFileSystem(config *config.Config) ([]string, error)
- func GetCNIConfDir(configArg *config.Config) string
- func GetCNIConfigPathByNameOrID(config *config.Config, name string) (string, error)
- func GetDefaultPodmanNetwork() (*net.IPNet, error)
- func GetFreeDeviceName(config *config.Config) (string, error)
- func GetFreeNetwork(config *config.Config) (*net.IPNet, error)
- func GetInterfaceNameFromConfig(path string) (string, error)
- func GetLiveNetworkNames() ([]string, error)
- func GetLiveNetworks() ([]*net.IPNet, error)
- func GetNetworkNamesFromFileSystem(config *config.Config) ([]string, error)
- func GetNetworksFromFilesystem(config *config.Config) ([]*allocator.Net, error)
- func HasDNSNamePlugin(paths []string) bool
- func IfPassesFilter(netconf *libcni.NetworkConfigList, filters map[string][]string) (bool, error)
- func IfPassesPruneFilter(config *config.Config, netconf *libcni.NetworkConfigList, ...) (bool, error)
- func InspectNetwork(config *config.Config, name string) (map[string]interface{}, error)
- func IsIPv6(netIP net.IP) bool
- func LastIPInSubnet(addr *net.IPNet) (net.IP, error)
- func LoadCNIConfsFromDir(dir string) ([]*libcni.NetworkConfigList, error)
- func NextSubnet(subnet *net.IPNet) (*net.IPNet, error)
- func NormalizeName(config *config.Config, nameOrID string) (string, error)
- func PruneNetworks(rtc *config.Config, usedNetworks map[string]bool) ([]*entities.NetworkPruneReport, error)
- func ReadRawCNIConfByNameOrID(config *config.Config, name string) ([]byte, error)
- func RemoveInterface(interfaceName string) error
- func RemoveNetwork(config *config.Config, name string) error
- func ValidateUserNetworkIsAvailable(config *config.Config, userNet *net.IPNet) error
- type CNILock
- type CNIPlugins
- type DNSNameConfig
- type FirewallConfig
- type HostLocalBridge
- type IPAMConfig
- type IPAMLocalHostRangeConf
- type IPAMRoute
- type MacVLANConfig
- type NcArgs
- type NcLabels
- type NcList
- type PodmanMachineConfig
- type PortMapConfig
- type TuningConfig
Constants ¶
const ( // CNIConfigDir is the path where CNI config files exist CNIConfigDir = "/etc/cni/net.d" // CNIDeviceName is the default network device name and in // reality should have an int appended to it (cni-podman4) CNIDeviceName = "cni-podman" // DefaultPodmanDomainName is used for the dnsname plugin to define // a localized domain name for a created network DefaultPodmanDomainName = "dns.podman" // LockFileName is used for obtaining a lock and is appended // to libpod's tmpdir in practice LockFileName = "cni.lock" )
const PodmanLabelKey = "podman_labels"
PodmanLabelKey key used to store the podman network label in a cni config
Variables ¶
var ( // BridgeNetworkDriver defines the bridge cni driver BridgeNetworkDriver = "bridge" // DefaultNetworkDriver is the default network type used DefaultNetworkDriver = BridgeNetworkDriver // MacVLANNetworkDriver defines the macvlan cni driver MacVLANNetworkDriver = "macvlan" )
var ErrNoSuchNetworkInterface = errors.New("unable to find interface name for network")
ErrNoSuchNetworkInterface indicates that no network interface exists
var SupportedNetworkDrivers = []string{BridgeNetworkDriver, MacVLANNetworkDriver}
SupportedNetworkDrivers describes the list of supported drivers
Functions ¶
func CalcGatewayIP ¶
CalcGatewayIP takes a network and returns the first IP in it.
func Create ¶
func Create(name string, options entities.NetworkCreateOptions, runtimeConfig *config.Config) (*entities.NetworkCreateReport, error)
Create the CNI network
func Exists ¶
Exists says whether a given network exists or not; it meant specifically for restful responses so 404s can be used
func FirstIPInSubnet ¶
FirstIPInSubnet gets the first IP in a subnet
func GetBridgeNamesFromFileSystem ¶
GetBridgeNamesFromFileSystem is a convenience function to get all the bridge names from the configured networks
func GetCNIConfDir ¶
GetCNIConfDir get CNI configuration directory
func GetCNIConfigPathByNameOrID ¶
GetCNIConfigPathByNameOrID finds a CNI network by name and returns its configuration file path
func GetDefaultPodmanNetwork ¶
GetDefaultPodmanNetwork outputs the default network for podman
func GetFreeDeviceName ¶
GetFreeDeviceName returns a device name that is unused; used when no network name is provided by user
func GetFreeNetwork ¶
GetFreeNetwork looks for a free network according to existing cni configuration files and network interfaces.
func GetInterfaceNameFromConfig ¶
GetInterfaceNameFromConfig returns the interface name for the bridge plugin
func GetLiveNetworkNames ¶
GetLiveNetworkNames returns a list of network interfaces on the system
func GetLiveNetworks ¶
GetLiveNetworks returns a slice of networks representing what the system has defined as network interfaces
func GetNetworkNamesFromFileSystem ¶
GetNetworkNamesFromFileSystem gets all the names from the cni network configuration files
func GetNetworksFromFilesystem ¶
GetNetworksFromFilesystem gets all the networks from the cni configuration files
func HasDNSNamePlugin ¶
HasDNSNamePlugin looks to see if the dnsname cni plugin is present
func IfPassesFilter ¶
IfPassesFilter filters NetworkListReport and returns true if the filter match the given config
func IfPassesPruneFilter ¶ added in v3.1.0
func IfPassesPruneFilter(config *config.Config, netconf *libcni.NetworkConfigList, f map[string][]string) (bool, error)
IfPassesPruneFilter filters NetworkListReport and returns true if the prune filter match the given config
func InspectNetwork ¶
InspectNetwork reads a CNI config and returns its configuration
func LastIPInSubnet ¶
LastIPInSubnet gets the last IP in a subnet
func LoadCNIConfsFromDir ¶
func LoadCNIConfsFromDir(dir string) ([]*libcni.NetworkConfigList, error)
LoadCNIConfsFromDir loads all the CNI configurations from a dir
func NextSubnet ¶
NextSubnet returns subnet incremented by 1
func NormalizeName ¶ added in v3.1.0
NormalizeName translates a network ID into a name. If the input is a name the name is returned.
func PruneNetworks ¶ added in v3.1.0
func PruneNetworks(rtc *config.Config, usedNetworks map[string]bool) ([]*entities.NetworkPruneReport, error)
PruneNetworks removes networks that are not being used and that is not the default network. To keep proper fencing for imports, you must provide the used networks to this function as a map. the key is meaningful in the map, the book is a no-op
func ReadRawCNIConfByNameOrID ¶ added in v3.1.0
ReadRawCNIConfByNameOrID reads the raw CNI configuration for a CNI network by name
func RemoveInterface ¶
RemoveInterface removes an interface by the given name
func RemoveNetwork ¶
RemoveNetwork removes a given network by name. If the network has container associated with it, that must be handled outside the context of this.
Types ¶
type CNILock ¶
CNILock is for preventing name collision and unpredictable results when doing some CNI operations.
type CNIPlugins ¶
CNIPlugins is a way of marshalling a CNI network configuration to disk
type DNSNameConfig ¶
type DNSNameConfig struct { PluginType string `json:"type"` DomainName string `json:"domainName"` Capabilities map[string]bool `json:"capabilities"` }
DNSNameConfig describes the dns container name resolution plugin config
func NewDNSNamePlugin ¶
func NewDNSNamePlugin(domainName string) DNSNameConfig
NewDNSNamePlugin creates the dnsname config with a given domainname
func (DNSNameConfig) Bytes ¶
func (d DNSNameConfig) Bytes() ([]byte, error)
Bytes outputs the configuration as []byte
type FirewallConfig ¶
FirewallConfig describes the firewall plugin
func NewFirewallPlugin ¶
func NewFirewallPlugin() FirewallConfig
NewFirewallPlugin creates a generic firewall plugin
func (FirewallConfig) Bytes ¶
func (f FirewallConfig) Bytes() ([]byte, error)
Bytes outputs the configuration as []byte
type HostLocalBridge ¶
type HostLocalBridge struct { PluginType string `json:"type"` BrName string `json:"bridge,omitempty"` IsGW bool `json:"isGateway"` IsDefaultGW bool `json:"isDefaultGateway,omitempty"` ForceAddress bool `json:"forceAddress,omitempty"` IPMasq bool `json:"ipMasq,omitempty"` MTU int `json:"mtu,omitempty"` HairpinMode bool `json:"hairpinMode,omitempty"` PromiscMode bool `json:"promiscMode,omitempty"` Vlan int `json:"vlan,omitempty"` IPAM IPAMConfig `json:"ipam"` }
HostLocalBridge describes a configuration for a bridge plugin https://github.com/containernetworking/plugins/tree/master/plugins/main/bridge#network-configuration-reference
func NewHostLocalBridge ¶
func NewHostLocalBridge(name string, isGateWay, isDefaultGW, ipMasq bool, mtu int, vlan int, ipamConf IPAMConfig) *HostLocalBridge
NewHostLocalBridge creates a new LocalBridge for host-local
func (*HostLocalBridge) Bytes ¶
func (h *HostLocalBridge) Bytes() ([]byte, error)
Bytes outputs []byte
type IPAMConfig ¶ added in v3.2.0
type IPAMConfig struct { PluginType string `json:"type"` Routes []IPAMRoute `json:"routes,omitempty"` ResolveConf string `json:"resolveConf,omitempty"` DataDir string `json:"dataDir,omitempty"` Ranges [][]IPAMLocalHostRangeConf `json:"ranges,omitempty"` }
IPAMConfig describes an IPAM configuration https://github.com/containernetworking/plugins/tree/master/plugins/ipam/host-local#network-configuration-reference
func NewIPAMHostLocalConf ¶
func NewIPAMHostLocalConf(routes []IPAMRoute, ipamRanges [][]IPAMLocalHostRangeConf) (IPAMConfig, error)
NewIPAMHostLocalConf creates a new IPAMHostLocal configuration
func (IPAMConfig) Bytes ¶ added in v3.2.0
func (i IPAMConfig) Bytes() ([]byte, error)
Bytes outputs the configuration as []byte
type IPAMLocalHostRangeConf ¶
type IPAMLocalHostRangeConf struct { Subnet string `json:"subnet"` RangeStart string `json:"rangeStart,omitempty"` RangeEnd string `json:"rangeEnd,omitempty"` Gateway string `json:"gateway,omitempty"` }
IPAMLocalHostRangeConf describes the new style IPAM ranges
func NewIPAMLocalHostRange ¶
func NewIPAMLocalHostRange(subnet *net.IPNet, ipRange *net.IPNet, gw net.IP) ([]IPAMLocalHostRangeConf, error)
NewIPAMLocalHostRange create a new IPAM range
type IPAMRoute ¶
type IPAMRoute struct {
Dest string `json:"dst"`
}
IPAMRoute describes a route in an ipam config
func NewIPAMDefaultRoute ¶
NewIPAMDefaultRoute creates a new IPAMDefault route of 0.0.0.0/0 for IPv4 or ::/0 for IPv6
func NewIPAMRoute ¶
NewIPAMRoute creates a new IPAM route configuration
type MacVLANConfig ¶
type MacVLANConfig struct { PluginType string `json:"type"` Master string `json:"master"` IPAM IPAMConfig `json:"ipam"` MTU int `json:"mtu,omitempty"` }
MacVLANConfig describes the macvlan config
func NewMacVLANPlugin ¶
func NewMacVLANPlugin(device string, gateway net.IP, ipRange *net.IPNet, subnet *net.IPNet, mtu int) (MacVLANConfig, error)
NewMacVLANPlugin creates a macvlanconfig with a given device name
func (MacVLANConfig) Bytes ¶
func (p MacVLANConfig) Bytes() ([]byte, error)
Bytes outputs the configuration as []byte
type NcLabels ¶
NcLabels describes the label map
func GetNetworkLabels ¶
func GetNetworkLabels(list *libcni.NetworkConfigList) NcLabels
GetNetworkLabels returns a list of labels as a string
type PodmanMachineConfig ¶ added in v3.2.0
type PodmanMachineConfig struct { PluginType string `json:"type"` Capabilities map[string]bool `json:"capabilities"` }
PodmanMachineConfig enables port handling on the host OS
func NewPodmanMachinePlugin ¶ added in v3.2.0
func NewPodmanMachinePlugin() PodmanMachineConfig
func (PodmanMachineConfig) Bytes ¶ added in v3.2.0
func (p PodmanMachineConfig) Bytes() ([]byte, error)
Bytes outputs the configuration as []byte
type PortMapConfig ¶
type PortMapConfig struct { PluginType string `json:"type"` Capabilities map[string]bool `json:"capabilities"` }
PortMapConfig describes the default portmapping config
func NewPortMapPlugin ¶
func NewPortMapPlugin() PortMapConfig
NewPortMapPlugin creates a predefined, default portmapping configuration
func (PortMapConfig) Bytes ¶
func (p PortMapConfig) Bytes() ([]byte, error)
Bytes outputs the configuration as []byte
type TuningConfig ¶
type TuningConfig struct {
PluginType string `json:"type"`
}
TuningConfig describes the tuning plugin
func NewTuningPlugin ¶
func NewTuningPlugin() TuningConfig
NewTuningPlugin creates a generic tuning section
func (TuningConfig) Bytes ¶
func (f TuningConfig) Bytes() ([]byte, error)
Bytes outputs the configuration as []byte