Documentation ¶
Index ¶
- Constants
- Variables
- func AddInfraEndpointRules(client *OVSEndpointClient, infraIP net.IPNet, hostPort string) error
- func AddInfraVnetEndpoint(client *OVSEndpointClient) error
- func AddSnatEndpoint(snatClient *snat.Client) error
- func AddSnatEndpointRules(snatClient *snat.Client, hostToNC, ncToHost bool, nl netlink.NetlinkInterface, ...) error
- func AddStaticRoute(nl netlink.NetlinkInterface, netioshim netio.NetIOInterface, ...) error
- func ConfigureInfraVnetContainerInterface(client *OVSEndpointClient, infraIP net.IPNet) error
- func ConfigureSnatContainerInterface(snatClient *snat.Client) error
- func ConstructEndpointID(containerID string, _ string, ifName string) (string, string)
- func DeleteInfraVnetEndpoint(client *OVSEndpointClient) error
- func DeleteInfraVnetEndpointRules(client *OVSEndpointClient, ep *endpoint, hostPort string)
- func DeleteSnatEndpoint(snatClient *snat.Client) error
- func DeleteSnatEndpointRules(snatClient *snat.Client, hostToNC, ncToHost bool)
- func ExecuteInNS(nsc NamespaceClientInterface, nsName string, f func() error) error
- func GetPodNameWithoutSuffix(podName string) string
- func GetSnatContIfName(epInfo *EndpointInfo) string
- func GetSnatHostIfName(epInfo *EndpointInfo) string
- func IsNetworkNotFoundError(err error) bool
- func MoveInfraEndpointToContainerNS(client *OVSEndpointClient, netnsPath string, nsID uintptr) error
- func MoveSnatEndpointToContainerNS(snatClient *snat.Client, netnsPath string, nsID uintptr) error
- func NewErrorMockEndpointClient(errStr string) error
- func NewInfraVnetClient(client *OVSEndpointClient, epID string)
- func RunWithRetries(f func() error, maxRuns, sleepMs int) error
- func SetupInfraVnetContainerInterface(client *OVSEndpointClient) error
- func SetupSnatContainerInterface(snatClient *snat.Client) error
- type AzureHNSEndpoint
- type AzureHNSEndpointClient
- type DNSInfo
- type EndpointClient
- type EndpointInfo
- type IPConfig
- type InterfaceInfo
- type LinuxBridgeClient
- func (client *LinuxBridgeClient) AddL2Rules(extIf *externalInterface) error
- func (client *LinuxBridgeClient) CreateBridge() error
- func (client *LinuxBridgeClient) DeleteBridge() error
- func (client *LinuxBridgeClient) DeleteL2Rules(extIf *externalInterface)
- func (client *LinuxBridgeClient) SetBridgeMasterToHostInterface() error
- func (client *LinuxBridgeClient) SetHairpinOnHostInterface(enable bool) error
- type LinuxBridgeEndpointClient
- func (client *LinuxBridgeEndpointClient) AddEndpointRules(epInfo *EndpointInfo) error
- func (client *LinuxBridgeEndpointClient) AddEndpoints(epInfo *EndpointInfo) error
- func (client *LinuxBridgeEndpointClient) ConfigureContainerInterfacesAndRoutes(epInfo *EndpointInfo) error
- func (client *LinuxBridgeEndpointClient) DeleteEndpointRules(ep *endpoint)
- func (client *LinuxBridgeEndpointClient) DeleteEndpoints(ep *endpoint) error
- func (client *LinuxBridgeEndpointClient) MoveEndpointsToContainerNS(epInfo *EndpointInfo, nsID uintptr) error
- func (client *LinuxBridgeEndpointClient) SetupContainerInterfaces(epInfo *EndpointInfo) error
- type MockEndpointClient
- func (client *MockEndpointClient) AddEndpointRules(_ *EndpointInfo) error
- func (client *MockEndpointClient) AddEndpoints(epInfo *EndpointInfo) error
- func (client *MockEndpointClient) ConfigureContainerInterfacesAndRoutes(_ *EndpointInfo) error
- func (client *MockEndpointClient) DeleteEndpointRules(_ *endpoint)
- func (client *MockEndpointClient) DeleteEndpoints(ep *endpoint) error
- func (client *MockEndpointClient) MoveEndpointsToContainerNS(_ *EndpointInfo, _ uintptr) error
- func (client *MockEndpointClient) SetupContainerInterfaces(_ *EndpointInfo) error
- type MockNamespace
- type MockNamespaceClient
- type MockNetworkManager
- func (nm *MockNetworkManager) AddExternalInterface(ifName, subnet, nicType string) error
- func (nm *MockNetworkManager) AttachEndpoint(networkID string, endpointID string, sandboxKey string) (*endpoint, error)
- func (nm *MockNetworkManager) CreateEndpoint(_ apipaClient, _ string, epInfo *EndpointInfo) error
- func (nm *MockNetworkManager) CreateNetwork(nwInfo *EndpointInfo) error
- func (nm *MockNetworkManager) DeleteEndpoint(_, endpointID string, _ *EndpointInfo) error
- func (nm *MockNetworkManager) DeleteNetwork(networkID string) error
- func (nm *MockNetworkManager) DeleteState(epInfos []*EndpointInfo) error
- func (nm *MockNetworkManager) DetachEndpoint(networkID string, endpointID string) error
- func (nm *MockNetworkManager) EndpointCreate(client apipaClient, epInfos []*EndpointInfo) error
- func (nm *MockNetworkManager) FindNetworkIDFromNetNs(netNs string) (string, error)
- func (nm *MockNetworkManager) GetAllEndpoints(networkID string) (map[string]*EndpointInfo, error)
- func (nm *MockNetworkManager) GetEndpointID(containerID, ifName string) string
- func (nm *MockNetworkManager) GetEndpointInfo(_, endpointID string) (*EndpointInfo, error)
- func (nm *MockNetworkManager) GetEndpointInfoBasedOnPODDetails(networkID string, podName string, podNameSpace string, ...) (*EndpointInfo, error)
- func (nm *MockNetworkManager) GetEndpointInfosFromContainerID(containerID string) []*EndpointInfo
- func (nm *MockNetworkManager) GetEndpointState(_, _ string) ([]*EndpointInfo, error)
- func (nm *MockNetworkManager) GetNetworkInfo(networkID string) (EndpointInfo, error)
- func (nm *MockNetworkManager) GetNumEndpointsByContainerID(_ string) int
- func (nm *MockNetworkManager) GetNumberOfEndpoints(ifName string, networkID string) int
- func (nm *MockNetworkManager) Initialize(config *common.PluginConfig, isRehydrationRequired bool) error
- func (nm *MockNetworkManager) IsStatelessCNIMode() bool
- func (nm *MockNetworkManager) SaveState(eps []*endpoint) error
- func (nm *MockNetworkManager) SetStatelessCNIMode() error
- func (nm *MockNetworkManager) Uninitialize()
- func (nm *MockNetworkManager) UpdateEndpoint(networkID string, existingEpInfo *EndpointInfo, targetEpInfo *EndpointInfo) error
- type Namespace
- type NamespaceClient
- type NamespaceClientInterface
- type NamespaceInterface
- type NetworkClient
- type NetworkInfo
- type NetworkManager
- type OVSEndpointClient
- func (client *OVSEndpointClient) AddEndpointRules(epInfo *EndpointInfo) error
- func (client *OVSEndpointClient) AddEndpoints(epInfo *EndpointInfo) error
- func (client *OVSEndpointClient) AddSnatEndpoint() error
- func (client *OVSEndpointClient) AddSnatEndpointRules() error
- func (client *OVSEndpointClient) ConfigureContainerInterfacesAndRoutes(epInfo *EndpointInfo) error
- func (client *OVSEndpointClient) ConfigureSnatContainerInterface() error
- func (client *OVSEndpointClient) DeleteEndpointRules(ep *endpoint)
- func (client *OVSEndpointClient) DeleteEndpoints(ep *endpoint) error
- func (client *OVSEndpointClient) DeleteSnatEndpoint() error
- func (client *OVSEndpointClient) DeleteSnatEndpointRules()
- func (client *OVSEndpointClient) MoveEndpointsToContainerNS(epInfo *EndpointInfo, nsID uintptr) error
- func (client *OVSEndpointClient) MoveSnatEndpointToContainerNS(netnsPath string, nsID uintptr) error
- func (client *OVSEndpointClient) NewSnatClient(snatBridgeIP, localIP string, epInfo *EndpointInfo)
- func (client *OVSEndpointClient) SetupContainerInterfaces(epInfo *EndpointInfo) error
- func (client *OVSEndpointClient) SetupSnatContainerInterface() error
- type OVSNetworkClient
- func (client *OVSNetworkClient) AddL2Rules(extIf *externalInterface) error
- func (client *OVSNetworkClient) AddRoutes(nwInfo *NetworkInfo, interfaceName string) error
- func (client *OVSNetworkClient) CreateBridge() error
- func (client *OVSNetworkClient) DeleteBridge() error
- func (client *OVSNetworkClient) DeleteL2Rules(extIf *externalInterface)
- func (client *OVSNetworkClient) SetBridgeMasterToHostInterface() error
- func (client *OVSNetworkClient) SetHairpinOnHostInterface(enable bool) error
- type RouteInfo
- type SecondaryEndpointClient
- func (client *SecondaryEndpointClient) AddEndpointRules(_ *EndpointInfo) error
- func (client *SecondaryEndpointClient) AddEndpoints(epInfo *EndpointInfo) error
- func (client *SecondaryEndpointClient) ConfigureContainerInterfacesAndRoutes(epInfo *EndpointInfo) error
- func (client *SecondaryEndpointClient) DeleteEndpointRules(_ *endpoint)
- func (client *SecondaryEndpointClient) DeleteEndpoints(ep *endpoint) error
- func (client *SecondaryEndpointClient) MoveEndpointsToContainerNS(epInfo *EndpointInfo, nsID uintptr) error
- func (client *SecondaryEndpointClient) SetupContainerInterfaces(epInfo *EndpointInfo) error
- type SubnetInfo
- type TransparentEndpointClient
- func (client *TransparentEndpointClient) AddEndpointRules(epInfo *EndpointInfo) error
- func (client *TransparentEndpointClient) AddEndpoints(epInfo *EndpointInfo) error
- func (client *TransparentEndpointClient) ConfigureContainerInterfacesAndRoutes(epInfo *EndpointInfo) error
- func (client *TransparentEndpointClient) DeleteEndpointRules(ep *endpoint)
- func (client *TransparentEndpointClient) DeleteEndpoints(_ *endpoint) error
- func (client *TransparentEndpointClient) MoveEndpointsToContainerNS(epInfo *EndpointInfo, nsID uintptr) error
- func (client *TransparentEndpointClient) SetupContainerInterfaces(epInfo *EndpointInfo) error
- type TransparentVlanEndpointClient
- func (client *TransparentVlanEndpointClient) AddDefaultArp(interfaceName, destMac string) error
- func (client *TransparentVlanEndpointClient) AddEndpointRules(epInfo *EndpointInfo) error
- func (client *TransparentVlanEndpointClient) AddEndpoints(epInfo *EndpointInfo) error
- func (client *TransparentVlanEndpointClient) AddSnatEndpoint() error
- func (client *TransparentVlanEndpointClient) AddSnatEndpointRules() error
- func (client *TransparentVlanEndpointClient) AddVnetRules(epInfo *EndpointInfo) error
- func (client *TransparentVlanEndpointClient) ConfigureContainerInterfacesAndRoutes(epInfo *EndpointInfo) error
- func (client *TransparentVlanEndpointClient) ConfigureContainerInterfacesAndRoutesImpl(epInfo *EndpointInfo) error
- func (client *TransparentVlanEndpointClient) ConfigureSnatContainerInterface() error
- func (client *TransparentVlanEndpointClient) ConfigureVnetInterfacesAndRoutesImpl(epInfo *EndpointInfo) error
- func (client *TransparentVlanEndpointClient) DeleteEndpointRules(ep *endpoint)
- func (client *TransparentVlanEndpointClient) DeleteEndpoints(ep *endpoint) error
- func (client *TransparentVlanEndpointClient) DeleteEndpointsImpl(ep *endpoint, _ func() (int, error)) error
- func (client *TransparentVlanEndpointClient) DeleteSnatEndpoint() error
- func (client *TransparentVlanEndpointClient) DeleteSnatEndpointRules()
- func (client *TransparentVlanEndpointClient) GetVnetRoutes(ipAddresses []net.IPNet) []RouteInfo
- func (client *TransparentVlanEndpointClient) MoveEndpointsToContainerNS(epInfo *EndpointInfo, nsID uintptr) error
- func (client *TransparentVlanEndpointClient) MoveSnatEndpointToContainerNS(netnsPath string, nsID uintptr) error
- func (client *TransparentVlanEndpointClient) NewSnatClient(snatBridgeIP, localIP string, epInfo *EndpointInfo)
- func (client *TransparentVlanEndpointClient) PopulateVM(epInfo *EndpointInfo) error
- func (client *TransparentVlanEndpointClient) PopulateVnet(epInfo *EndpointInfo) error
- func (client *TransparentVlanEndpointClient) SetupContainerInterfaces(epInfo *EndpointInfo) error
- func (client *TransparentVlanEndpointClient) SetupSnatContainerInterface() error
Constants ¶
const ( VlanIDKey = "VlanID" AzureCNS = "azure-cns" SNATIPKey = "NCPrimaryIPKey" RoutesKey = "RoutesKey" IPTablesKey = "IPTablesKey" StateLessCNIIsNotSet = "StateLess CNI mode is not enabled" InfraInterfaceName = "eth0" ContainerIDLength = 8 EndpointIfIndex = 0 // Azure CNI supports only one interface DefaultNetworkID = "azure" )
const ( // OptVethName key for veth name option OptVethName = "vethname" // SnatBridgeIPKey key for the SNAT bridge SnatBridgeIPKey = "snatBridgeIP" // LocalIPKey key for local IP LocalIPKey = "localIP" // InfraVnetIPKey key for infra vnet InfraVnetIPKey = "infraVnetIP" // Ubuntu Release Version for checking which command to use. Ubuntu22 = "22.04" )
const (
DisableRPFilterCmd = "sysctl -w net.ipv4.conf.all.rp_filter=0" // Command to disable the rp filter for tunneling
)
const (
// ipv6 modes
IPV6Nat = "ipv6nat"
)
const (
InfraVnet = 0
)
Variables ¶
var ( ErrEndpointStateNotFound = errors.New("endpoint state could not be found in the statefile") ErrConnectionFailure = errors.New("couldn't connect to CNS") ErrGetEndpointStateFailure = errors.New("failure to obtain the endpoint state") )
Functions ¶
func AddInfraEndpointRules ¶
func AddInfraEndpointRules(client *OVSEndpointClient, infraIP net.IPNet, hostPort string) error
func AddInfraVnetEndpoint ¶
func AddInfraVnetEndpoint(client *OVSEndpointClient) error
func AddSnatEndpoint ¶
func AddSnatEndpointRules ¶
func AddSnatEndpointRules(snatClient *snat.Client, hostToNC, ncToHost bool, nl netlink.NetlinkInterface, plc platform.ExecClient) error
func AddStaticRoute ¶
func AddStaticRoute(nl netlink.NetlinkInterface, netioshim netio.NetIOInterface, ip, interfaceName string) error
AddStaticRoute adds a static route to the interface.
func ConfigureInfraVnetContainerInterface ¶
func ConfigureInfraVnetContainerInterface(client *OVSEndpointClient, infraIP net.IPNet) error
func ConstructEndpointID ¶
func DeleteInfraVnetEndpoint ¶
func DeleteInfraVnetEndpoint(client *OVSEndpointClient) error
func DeleteInfraVnetEndpointRules ¶
func DeleteInfraVnetEndpointRules(client *OVSEndpointClient, ep *endpoint, hostPort string)
func DeleteSnatEndpoint ¶
func DeleteSnatEndpointRules ¶
func ExecuteInNS ¶
func ExecuteInNS(nsc NamespaceClientInterface, nsName string, f func() error) error
Helper function that allows executing a function in a VM namespace Does not work for process namespaces
func GetPodNameWithoutSuffix ¶
func GetSnatContIfName ¶
func GetSnatContIfName(epInfo *EndpointInfo) string
func GetSnatHostIfName ¶
func GetSnatHostIfName(epInfo *EndpointInfo) string
func IsNetworkNotFoundError ¶
func MoveInfraEndpointToContainerNS ¶
func MoveInfraEndpointToContainerNS(client *OVSEndpointClient, netnsPath string, nsID uintptr) error
func NewInfraVnetClient ¶
func NewInfraVnetClient(client *OVSEndpointClient, epID string)
func RunWithRetries ¶
func SetupInfraVnetContainerInterface ¶
func SetupInfraVnetContainerInterface(client *OVSEndpointClient) error
Types ¶
type AzureHNSEndpoint ¶
type AzureHNSEndpoint struct{}
type AzureHNSEndpointClient ¶
type AzureHNSEndpointClient interface{}
type EndpointClient ¶
type EndpointClient interface { AddEndpoints(epInfo *EndpointInfo) error AddEndpointRules(epInfo *EndpointInfo) error DeleteEndpointRules(ep *endpoint) MoveEndpointsToContainerNS(epInfo *EndpointInfo, nsID uintptr) error SetupContainerInterfaces(epInfo *EndpointInfo) error ConfigureContainerInterfacesAndRoutes(epInfo *EndpointInfo) error DeleteEndpoints(ep *endpoint) error }
type EndpointInfo ¶
type EndpointInfo struct { EndpointID string ContainerID string NetNsPath string IfName string // value differs during creation vs. deletion flow; used in statefile, not necessarily the nic name SandboxKey string IfIndex int MacAddress net.HardwareAddr EndpointDNS DNSInfo IPAddresses []net.IPNet IPsToRouteViaHost []string InfraVnetIP net.IPNet Routes []RouteInfo EndpointPolicies []policy.Policy // used in windows NetworkPolicies []policy.Policy // used in windows Gateways []net.IP EnableSnatOnHost bool EnableInfraVnet bool EnableMultiTenancy bool EnableSnatForDns bool AllowInboundFromHostToNC bool AllowInboundFromNCToHost bool NetworkContainerID string PODName string PODNameSpace string Data map[string]interface{} InfraVnetAddressSpace string SkipHotAttachEp bool IPV6Mode string VnetCidrs string ServiceCidrs string NATInfo []policy.NATInfo // windows only NICType cns.NICType SkipDefaultRoutes bool HNSEndpointID string HNSNetworkID string HostIfName string // unused in windows, and in linux // Fields related to the network are below MasterIfName string AdapterName string NetworkID string Mode string Subnets []SubnetInfo BridgeName string NetNs string // used in windows Options map[string]interface{} DisableHairpinOnHostInterface bool IsIPv6Enabled bool HostSubnetPrefix string // can be used later to add an external interface PnPID string }
EndpointInfo contains read-only information about an endpoint.
func (*EndpointInfo) GetEndpointInfoByIPImpl ¶ added in v1.5.21
func (epInfo *EndpointInfo) GetEndpointInfoByIPImpl(_ []net.IPNet, _ string) (*EndpointInfo, error)
GetEndpointInfoByIPImpl returns an endpointInfo that contains corresponding HostVethName. TODO: It needs to be tested to see if HostVethName is required for SingleTenancy, WorkItem: 26606939
func (*EndpointInfo) IsEndpointStateIncomplete ¶ added in v1.5.21
func (epInfo *EndpointInfo) IsEndpointStateIncomplete() bool
IsEndpointStateInComplete returns true if both HNSEndpointID and HostVethName are missing.
func (*EndpointInfo) PrettyString ¶
func (epInfo *EndpointInfo) PrettyString() string
type InterfaceInfo ¶
type InterfaceInfo struct { Name string MacAddress net.HardwareAddr IPConfigs []*IPConfig Routes []RouteInfo DNS DNSInfo NICType cns.NICType SkipDefaultRoutes bool HostSubnetPrefix net.IPNet // Move this field from ipamAddResult NCResponse *cns.GetNetworkContainerResponse PnPID string }
InterfaceInfo contains information for secondary interfaces
func (*InterfaceInfo) PrettyString ¶ added in v1.5.30
func (ifInfo *InterfaceInfo) PrettyString() string
type LinuxBridgeClient ¶
type LinuxBridgeClient struct {
// contains filtered or unexported fields
}
func NewLinuxBridgeClient ¶
func NewLinuxBridgeClient( bridgeName string, hostInterfaceName string, nwInfo EndpointInfo, nl netlink.NetlinkInterface, plc platform.ExecClient, ) *LinuxBridgeClient
func (*LinuxBridgeClient) AddL2Rules ¶
func (client *LinuxBridgeClient) AddL2Rules(extIf *externalInterface) error
func (*LinuxBridgeClient) CreateBridge ¶
func (client *LinuxBridgeClient) CreateBridge() error
func (*LinuxBridgeClient) DeleteBridge ¶
func (client *LinuxBridgeClient) DeleteBridge() error
func (*LinuxBridgeClient) DeleteL2Rules ¶
func (client *LinuxBridgeClient) DeleteL2Rules(extIf *externalInterface)
func (*LinuxBridgeClient) SetBridgeMasterToHostInterface ¶
func (client *LinuxBridgeClient) SetBridgeMasterToHostInterface() error
func (*LinuxBridgeClient) SetHairpinOnHostInterface ¶
func (client *LinuxBridgeClient) SetHairpinOnHostInterface(enable bool) error
type LinuxBridgeEndpointClient ¶
type LinuxBridgeEndpointClient struct {
// contains filtered or unexported fields
}
func NewLinuxBridgeEndpointClient ¶
func NewLinuxBridgeEndpointClient( extIf *externalInterface, hostVethName string, containerVethName string, mode string, nl netlink.NetlinkInterface, plc platform.ExecClient, ) *LinuxBridgeEndpointClient
func (*LinuxBridgeEndpointClient) AddEndpointRules ¶
func (client *LinuxBridgeEndpointClient) AddEndpointRules(epInfo *EndpointInfo) error
func (*LinuxBridgeEndpointClient) AddEndpoints ¶
func (client *LinuxBridgeEndpointClient) AddEndpoints(epInfo *EndpointInfo) error
func (*LinuxBridgeEndpointClient) ConfigureContainerInterfacesAndRoutes ¶
func (client *LinuxBridgeEndpointClient) ConfigureContainerInterfacesAndRoutes(epInfo *EndpointInfo) error
func (*LinuxBridgeEndpointClient) DeleteEndpointRules ¶
func (client *LinuxBridgeEndpointClient) DeleteEndpointRules(ep *endpoint)
func (*LinuxBridgeEndpointClient) DeleteEndpoints ¶
func (client *LinuxBridgeEndpointClient) DeleteEndpoints(ep *endpoint) error
func (*LinuxBridgeEndpointClient) MoveEndpointsToContainerNS ¶
func (client *LinuxBridgeEndpointClient) MoveEndpointsToContainerNS(epInfo *EndpointInfo, nsID uintptr) error
func (*LinuxBridgeEndpointClient) SetupContainerInterfaces ¶
func (client *LinuxBridgeEndpointClient) SetupContainerInterfaces(epInfo *EndpointInfo) error
type MockEndpointClient ¶
type MockEndpointClient struct {
// contains filtered or unexported fields
}
func NewMockEndpointClient ¶
func NewMockEndpointClient(fn func(*EndpointInfo) error) *MockEndpointClient
func (*MockEndpointClient) AddEndpointRules ¶
func (client *MockEndpointClient) AddEndpointRules(_ *EndpointInfo) error
func (*MockEndpointClient) AddEndpoints ¶
func (client *MockEndpointClient) AddEndpoints(epInfo *EndpointInfo) error
func (*MockEndpointClient) ConfigureContainerInterfacesAndRoutes ¶
func (client *MockEndpointClient) ConfigureContainerInterfacesAndRoutes(_ *EndpointInfo) error
func (*MockEndpointClient) DeleteEndpointRules ¶
func (client *MockEndpointClient) DeleteEndpointRules(_ *endpoint)
func (*MockEndpointClient) DeleteEndpoints ¶
func (client *MockEndpointClient) DeleteEndpoints(ep *endpoint) error
func (*MockEndpointClient) MoveEndpointsToContainerNS ¶
func (client *MockEndpointClient) MoveEndpointsToContainerNS(_ *EndpointInfo, _ uintptr) error
func (*MockEndpointClient) SetupContainerInterfaces ¶
func (client *MockEndpointClient) SetupContainerInterfaces(_ *EndpointInfo) error
type MockNamespace ¶
type MockNamespace struct {
// contains filtered or unexported fields
}
func (*MockNamespace) Close ¶
func (ns *MockNamespace) Close() error
Close releases the resources associated with the namespace object.
func (*MockNamespace) Enter ¶
func (ns *MockNamespace) Enter() error
Enter puts the caller thread inside the namespace.
func (*MockNamespace) Exit ¶
func (ns *MockNamespace) Exit() error
Exit puts the caller thread to its previous namespace.
func (*MockNamespace) GetFd ¶
func (ns *MockNamespace) GetFd() uintptr
GetFd returns the file descriptor of the namespace.
func (*MockNamespace) GetName ¶
func (ns *MockNamespace) GetName() string
type MockNamespaceClient ¶
type MockNamespaceClient struct{}
func NewMockNamespaceClient ¶
func NewMockNamespaceClient() *MockNamespaceClient
func (*MockNamespaceClient) GetCurrentThreadNamespace ¶
func (c *MockNamespaceClient) GetCurrentThreadNamespace() (NamespaceInterface, error)
GetCurrentThreadNamespace returns the caller thread's current namespace.
func (*MockNamespaceClient) OpenNamespace ¶
func (c *MockNamespaceClient) OpenNamespace(ns string) (NamespaceInterface, error)
OpenNamespace creates a new namespace object for the given netns path.
type MockNetworkManager ¶
type MockNetworkManager struct { TestNetworkInfoMap map[string]*EndpointInfo TestEndpointInfoMap map[string]*EndpointInfo TestEndpointClient *MockEndpointClient SaveStateMap map[string]*endpoint }
MockNetworkManager is a mock structure for Network Manager
func NewMockNetworkmanager ¶
func NewMockNetworkmanager(mockEndpointclient *MockEndpointClient) *MockNetworkManager
NewMockNetworkmanager returns a new mock
func (*MockNetworkManager) AddExternalInterface ¶
func (nm *MockNetworkManager) AddExternalInterface(ifName, subnet, nicType string) error
AddExternalInterface mock
func (*MockNetworkManager) AttachEndpoint ¶
func (nm *MockNetworkManager) AttachEndpoint(networkID string, endpointID string, sandboxKey string) (*endpoint, error)
AttachEndpoint mock
func (*MockNetworkManager) CreateEndpoint ¶
func (nm *MockNetworkManager) CreateEndpoint(_ apipaClient, _ string, epInfo *EndpointInfo) error
CreateEndpoint mock TODO: Fix mock behavior because create endpoint no longer also saves the state
func (*MockNetworkManager) CreateNetwork ¶
func (nm *MockNetworkManager) CreateNetwork(nwInfo *EndpointInfo) error
CreateNetwork mock
func (*MockNetworkManager) DeleteEndpoint ¶
func (nm *MockNetworkManager) DeleteEndpoint(_, endpointID string, _ *EndpointInfo) error
DeleteEndpoint mock
func (*MockNetworkManager) DeleteNetwork ¶
func (nm *MockNetworkManager) DeleteNetwork(networkID string) error
DeleteNetwork mock
func (*MockNetworkManager) DeleteState ¶ added in v1.5.30
func (nm *MockNetworkManager) DeleteState(epInfos []*EndpointInfo) error
func (*MockNetworkManager) DetachEndpoint ¶
func (nm *MockNetworkManager) DetachEndpoint(networkID string, endpointID string) error
DetachEndpoint mock
func (*MockNetworkManager) EndpointCreate ¶ added in v1.5.30
func (nm *MockNetworkManager) EndpointCreate(client apipaClient, epInfos []*EndpointInfo) error
func (*MockNetworkManager) FindNetworkIDFromNetNs ¶
func (nm *MockNetworkManager) FindNetworkIDFromNetNs(netNs string) (string, error)
func (*MockNetworkManager) GetAllEndpoints ¶
func (nm *MockNetworkManager) GetAllEndpoints(networkID string) (map[string]*EndpointInfo, error)
func (*MockNetworkManager) GetEndpointID ¶ added in v1.5.17
func (nm *MockNetworkManager) GetEndpointID(containerID, ifName string) string
GetEndpointID returns the ContainerID value
func (*MockNetworkManager) GetEndpointInfo ¶
func (nm *MockNetworkManager) GetEndpointInfo(_, endpointID string) (*EndpointInfo, error)
GetEndpointInfo mock
func (*MockNetworkManager) GetEndpointInfoBasedOnPODDetails ¶
func (nm *MockNetworkManager) GetEndpointInfoBasedOnPODDetails(networkID string, podName string, podNameSpace string, doExactMatchForPodName bool) (*EndpointInfo, error)
GetEndpointInfoBasedOnPODDetails mock
func (*MockNetworkManager) GetEndpointInfosFromContainerID ¶ added in v1.5.30
func (nm *MockNetworkManager) GetEndpointInfosFromContainerID(containerID string) []*EndpointInfo
func (*MockNetworkManager) GetEndpointState ¶ added in v1.5.30
func (nm *MockNetworkManager) GetEndpointState(_, _ string) ([]*EndpointInfo, error)
func (*MockNetworkManager) GetNetworkInfo ¶
func (nm *MockNetworkManager) GetNetworkInfo(networkID string) (EndpointInfo, error)
GetNetworkInfo mock
func (*MockNetworkManager) GetNumEndpointsByContainerID ¶
func (nm *MockNetworkManager) GetNumEndpointsByContainerID(_ string) int
GetNumEndpointsByContainerID mock
func (*MockNetworkManager) GetNumberOfEndpoints ¶
func (nm *MockNetworkManager) GetNumberOfEndpoints(ifName string, networkID string) int
GetNumberOfEndpoints mock
func (*MockNetworkManager) Initialize ¶
func (nm *MockNetworkManager) Initialize(config *common.PluginConfig, isRehydrationRequired bool) error
Initialize mock
func (*MockNetworkManager) IsStatelessCNIMode ¶ added in v1.5.17
func (nm *MockNetworkManager) IsStatelessCNIMode() bool
IsStatelessCNIMode checks if the Stateless CNI mode has been enabled or not
func (*MockNetworkManager) SaveState ¶ added in v1.5.30
func (nm *MockNetworkManager) SaveState(eps []*endpoint) error
func (*MockNetworkManager) SetStatelessCNIMode ¶ added in v1.5.17
func (nm *MockNetworkManager) SetStatelessCNIMode() error
SetStatelessCNIMode enable the statelessCNI falg and inititlizes a CNSClient
func (*MockNetworkManager) Uninitialize ¶
func (nm *MockNetworkManager) Uninitialize()
Uninitialize mock
func (*MockNetworkManager) UpdateEndpoint ¶
func (nm *MockNetworkManager) UpdateEndpoint(networkID string, existingEpInfo *EndpointInfo, targetEpInfo *EndpointInfo) error
UpdateEndpoint mock
type Namespace ¶
type Namespace struct {
// contains filtered or unexported fields
}
Namespace represents a network namespace.
type NamespaceClient ¶
type NamespaceClient struct{}
func NewNamespaceClient ¶
func NewNamespaceClient() *NamespaceClient
func (*NamespaceClient) GetCurrentThreadNamespace ¶
func (c *NamespaceClient) GetCurrentThreadNamespace() (NamespaceInterface, error)
GetCurrentThreadNamespace returns the caller thread's current namespace.
func (*NamespaceClient) OpenNamespace ¶
func (c *NamespaceClient) OpenNamespace(nsPath string) (NamespaceInterface, error)
OpenNamespace creates a new namespace object for the given netns path.
type NamespaceClientInterface ¶
type NamespaceClientInterface interface { OpenNamespace(nsPath string) (NamespaceInterface, error) GetCurrentThreadNamespace() (NamespaceInterface, error) }
type NamespaceInterface ¶
type NetworkClient ¶
type NetworkInfo ¶
type NetworkInfo struct { MasterIfName string AdapterName string Id string Mode string Subnets []SubnetInfo PodSubnet SubnetInfo DNS DNSInfo Policies []policy.Policy BridgeName string EnableSnatOnHost bool NetNs string Options map[string]interface{} DisableHairpinOnHostInterface bool IPV6Mode string IPAMType string ServiceCidrs string IsIPv6Enabled bool }
NetworkInfo contains read-only information about a container network. Use EndpointInfo instead when possible.
func (*NetworkInfo) PrettyString ¶
func (nwInfo *NetworkInfo) PrettyString() string
type NetworkManager ¶
type NetworkManager interface { Initialize(config *common.PluginConfig, isRehydrationRequired bool) error Uninitialize() AddExternalInterface(ifName, subnet, nicType string) error CreateNetwork(nwInfo *EndpointInfo) error DeleteNetwork(networkID string) error GetNetworkInfo(networkID string) (EndpointInfo, error) // FindNetworkIDFromNetNs returns the network name that contains an endpoint created for this netNS, errNetworkNotFound if no network is found FindNetworkIDFromNetNs(netNs string) (string, error) GetNumEndpointsByContainerID(containerID string) int CreateEndpoint(client apipaClient, networkID string, epInfo *EndpointInfo) error EndpointCreate(client apipaClient, epInfos []*EndpointInfo) error // TODO: change name DeleteEndpoint(networkID string, endpointID string, epInfo *EndpointInfo) error GetEndpointInfo(networkID string, endpointID string) (*EndpointInfo, error) GetAllEndpoints(networkID string) (map[string]*EndpointInfo, error) GetEndpointInfoBasedOnPODDetails(networkID string, podName string, podNameSpace string, doExactMatchForPodName bool) (*EndpointInfo, error) AttachEndpoint(networkID string, endpointID string, sandboxKey string) (*endpoint, error) DetachEndpoint(networkID string, endpointID string) error UpdateEndpoint(networkID string, existingEpInfo *EndpointInfo, targetEpInfo *EndpointInfo) error GetNumberOfEndpoints(ifName string, networkID string) int GetEndpointID(containerID, ifName string) string IsStatelessCNIMode() bool SaveState(eps []*endpoint) error DeleteState(epInfos []*EndpointInfo) error GetEndpointInfosFromContainerID(containerID string) []*EndpointInfo GetEndpointState(networkID, containerID string) ([]*EndpointInfo, error) }
NetworkManager API.
func NewNetworkManager ¶
func NewNetworkManager(nl netlink.NetlinkInterface, plc platform.ExecClient, netioCli netio.NetIOInterface, nsc NamespaceClientInterface, iptc ipTablesClient, dhcpc dhcpClient, ) (NetworkManager, error)
Creates a new network manager.
type OVSEndpointClient ¶
type OVSEndpointClient struct {
// contains filtered or unexported fields
}
func NewOVSEndpointClient ¶
func NewOVSEndpointClient( nw *network, epInfo *EndpointInfo, hostVethName string, containerVethName string, vlanid int, localIP string, nl netlink.NetlinkInterface, ovs ovsctl.OvsInterface, plc platform.ExecClient, iptc ipTablesClient, ) *OVSEndpointClient
func (*OVSEndpointClient) AddEndpointRules ¶
func (client *OVSEndpointClient) AddEndpointRules(epInfo *EndpointInfo) error
func (*OVSEndpointClient) AddEndpoints ¶
func (client *OVSEndpointClient) AddEndpoints(epInfo *EndpointInfo) error
func (*OVSEndpointClient) AddSnatEndpoint ¶
func (client *OVSEndpointClient) AddSnatEndpoint() error
func (*OVSEndpointClient) AddSnatEndpointRules ¶
func (client *OVSEndpointClient) AddSnatEndpointRules() error
func (*OVSEndpointClient) ConfigureContainerInterfacesAndRoutes ¶
func (client *OVSEndpointClient) ConfigureContainerInterfacesAndRoutes(epInfo *EndpointInfo) error
func (*OVSEndpointClient) ConfigureSnatContainerInterface ¶
func (client *OVSEndpointClient) ConfigureSnatContainerInterface() error
func (*OVSEndpointClient) DeleteEndpointRules ¶
func (client *OVSEndpointClient) DeleteEndpointRules(ep *endpoint)
func (*OVSEndpointClient) DeleteEndpoints ¶
func (client *OVSEndpointClient) DeleteEndpoints(ep *endpoint) error
func (*OVSEndpointClient) DeleteSnatEndpoint ¶
func (client *OVSEndpointClient) DeleteSnatEndpoint() error
func (*OVSEndpointClient) DeleteSnatEndpointRules ¶
func (client *OVSEndpointClient) DeleteSnatEndpointRules()
func (*OVSEndpointClient) MoveEndpointsToContainerNS ¶
func (client *OVSEndpointClient) MoveEndpointsToContainerNS(epInfo *EndpointInfo, nsID uintptr) error
func (*OVSEndpointClient) MoveSnatEndpointToContainerNS ¶
func (client *OVSEndpointClient) MoveSnatEndpointToContainerNS(netnsPath string, nsID uintptr) error
func (*OVSEndpointClient) NewSnatClient ¶
func (client *OVSEndpointClient) NewSnatClient(snatBridgeIP, localIP string, epInfo *EndpointInfo)
func (*OVSEndpointClient) SetupContainerInterfaces ¶
func (client *OVSEndpointClient) SetupContainerInterfaces(epInfo *EndpointInfo) error
func (*OVSEndpointClient) SetupSnatContainerInterface ¶
func (client *OVSEndpointClient) SetupSnatContainerInterface() error
type OVSNetworkClient ¶
type OVSNetworkClient struct {
// contains filtered or unexported fields
}
func NewOVSClient ¶
func NewOVSClient(bridgeName, hostInterfaceName string, ovsctlClient ovsctl.OvsInterface, nl netlink.NetlinkInterface, plc platform.ExecClient, ) *OVSNetworkClient
func (*OVSNetworkClient) AddL2Rules ¶
func (client *OVSNetworkClient) AddL2Rules(extIf *externalInterface) error
func (*OVSNetworkClient) AddRoutes ¶
func (client *OVSNetworkClient) AddRoutes(nwInfo *NetworkInfo, interfaceName string) error
func (*OVSNetworkClient) CreateBridge ¶
func (client *OVSNetworkClient) CreateBridge() error
func (*OVSNetworkClient) DeleteBridge ¶
func (client *OVSNetworkClient) DeleteBridge() error
func (*OVSNetworkClient) DeleteL2Rules ¶
func (client *OVSNetworkClient) DeleteL2Rules(extIf *externalInterface)
func (*OVSNetworkClient) SetBridgeMasterToHostInterface ¶
func (client *OVSNetworkClient) SetBridgeMasterToHostInterface() error
func (*OVSNetworkClient) SetHairpinOnHostInterface ¶
func (client *OVSNetworkClient) SetHairpinOnHostInterface(enable bool) error
type RouteInfo ¶
type RouteInfo struct { Dst net.IPNet Src net.IP Gw net.IP Protocol int DevName string Scope int Priority int Table int }
RouteInfo contains information about an IP route.
type SecondaryEndpointClient ¶
type SecondaryEndpointClient struct {
// contains filtered or unexported fields
}
func NewSecondaryEndpointClient ¶
func NewSecondaryEndpointClient( nl netlink.NetlinkInterface, nioc netio.NetIOInterface, plc platform.ExecClient, nsc NamespaceClientInterface, dhcpClient dhcpClient, endpoint *endpoint, ) *SecondaryEndpointClient
func (*SecondaryEndpointClient) AddEndpointRules ¶
func (client *SecondaryEndpointClient) AddEndpointRules(_ *EndpointInfo) error
func (*SecondaryEndpointClient) AddEndpoints ¶
func (client *SecondaryEndpointClient) AddEndpoints(epInfo *EndpointInfo) error
func (*SecondaryEndpointClient) ConfigureContainerInterfacesAndRoutes ¶
func (client *SecondaryEndpointClient) ConfigureContainerInterfacesAndRoutes(epInfo *EndpointInfo) error
func (*SecondaryEndpointClient) DeleteEndpointRules ¶
func (client *SecondaryEndpointClient) DeleteEndpointRules(_ *endpoint)
func (*SecondaryEndpointClient) DeleteEndpoints ¶
func (client *SecondaryEndpointClient) DeleteEndpoints(ep *endpoint) error
func (*SecondaryEndpointClient) MoveEndpointsToContainerNS ¶
func (client *SecondaryEndpointClient) MoveEndpointsToContainerNS(epInfo *EndpointInfo, nsID uintptr) error
func (*SecondaryEndpointClient) SetupContainerInterfaces ¶
func (client *SecondaryEndpointClient) SetupContainerInterfaces(epInfo *EndpointInfo) error
type SubnetInfo ¶
type SubnetInfo struct { Family platform.AddressFamily Prefix net.IPNet Gateway net.IP PrimaryIP net.IP }
SubnetInfo contains subnet information for a container network.
type TransparentEndpointClient ¶
type TransparentEndpointClient struct {
// contains filtered or unexported fields
}
func NewTransparentEndpointClient ¶
func NewTransparentEndpointClient( extIf *externalInterface, hostVethName string, containerVethName string, mode string, nl netlink.NetlinkInterface, nioc netio.NetIOInterface, plc platform.ExecClient, ) *TransparentEndpointClient
func (*TransparentEndpointClient) AddEndpointRules ¶
func (client *TransparentEndpointClient) AddEndpointRules(epInfo *EndpointInfo) error
func (*TransparentEndpointClient) AddEndpoints ¶
func (client *TransparentEndpointClient) AddEndpoints(epInfo *EndpointInfo) error
func (*TransparentEndpointClient) ConfigureContainerInterfacesAndRoutes ¶
func (client *TransparentEndpointClient) ConfigureContainerInterfacesAndRoutes(epInfo *EndpointInfo) error
func (*TransparentEndpointClient) DeleteEndpointRules ¶
func (client *TransparentEndpointClient) DeleteEndpointRules(ep *endpoint)
func (*TransparentEndpointClient) DeleteEndpoints ¶
func (client *TransparentEndpointClient) DeleteEndpoints(_ *endpoint) error
func (*TransparentEndpointClient) MoveEndpointsToContainerNS ¶
func (client *TransparentEndpointClient) MoveEndpointsToContainerNS(epInfo *EndpointInfo, nsID uintptr) error
func (*TransparentEndpointClient) SetupContainerInterfaces ¶
func (client *TransparentEndpointClient) SetupContainerInterfaces(epInfo *EndpointInfo) error
type TransparentVlanEndpointClient ¶
type TransparentVlanEndpointClient struct {
// contains filtered or unexported fields
}
func NewTransparentVlanEndpointClient ¶
func NewTransparentVlanEndpointClient( nw *network, ep *EndpointInfo, vnetVethName string, containerVethName string, vlanid int, localIP string, nl netlink.NetlinkInterface, plc platform.ExecClient, nsc NamespaceClientInterface, iptc ipTablesClient, ) *TransparentVlanEndpointClient
func (*TransparentVlanEndpointClient) AddDefaultArp ¶
func (client *TransparentVlanEndpointClient) AddDefaultArp(interfaceName, destMac string) error
Helper that creates arp entry for the current NS which maps the virtual gateway (169.254.2.1) to destMac on a particular interfaceName Example: (169.254.2.1) at 12:34:56:78:9a:bc [ether] PERM on <interfaceName>
func (*TransparentVlanEndpointClient) AddEndpointRules ¶
func (client *TransparentVlanEndpointClient) AddEndpointRules(epInfo *EndpointInfo) error
func (*TransparentVlanEndpointClient) AddEndpoints ¶
func (client *TransparentVlanEndpointClient) AddEndpoints(epInfo *EndpointInfo) error
Adds interfaces to the vnet (created if not existing) and vm namespace
func (*TransparentVlanEndpointClient) AddSnatEndpoint ¶
func (client *TransparentVlanEndpointClient) AddSnatEndpoint() error
func (*TransparentVlanEndpointClient) AddSnatEndpointRules ¶
func (client *TransparentVlanEndpointClient) AddSnatEndpointRules() error
func (*TransparentVlanEndpointClient) AddVnetRules ¶
func (client *TransparentVlanEndpointClient) AddVnetRules(epInfo *EndpointInfo) error
Add rules related to tunneling the packet outside of the VM, assumes all calls are idempotent. Namespace: vnet
func (*TransparentVlanEndpointClient) ConfigureContainerInterfacesAndRoutes ¶
func (client *TransparentVlanEndpointClient) ConfigureContainerInterfacesAndRoutes(epInfo *EndpointInfo) error
Adds routes, arp entries, etc. to the vnet and container namespaces
func (*TransparentVlanEndpointClient) ConfigureContainerInterfacesAndRoutesImpl ¶
func (client *TransparentVlanEndpointClient) ConfigureContainerInterfacesAndRoutesImpl(epInfo *EndpointInfo) error
Called from ConfigureContainerInterfacesAndRoutes, Namespace: Container
func (*TransparentVlanEndpointClient) ConfigureSnatContainerInterface ¶
func (client *TransparentVlanEndpointClient) ConfigureSnatContainerInterface() error
func (*TransparentVlanEndpointClient) ConfigureVnetInterfacesAndRoutesImpl ¶
func (client *TransparentVlanEndpointClient) ConfigureVnetInterfacesAndRoutesImpl(epInfo *EndpointInfo) error
Called from ConfigureContainerInterfacesAndRoutes, Namespace: Vnet
func (*TransparentVlanEndpointClient) DeleteEndpointRules ¶
func (client *TransparentVlanEndpointClient) DeleteEndpointRules(ep *endpoint)
func (*TransparentVlanEndpointClient) DeleteEndpoints ¶
func (client *TransparentVlanEndpointClient) DeleteEndpoints(ep *endpoint) error
func (*TransparentVlanEndpointClient) DeleteEndpointsImpl ¶
func (client *TransparentVlanEndpointClient) DeleteEndpointsImpl(ep *endpoint, _ func() (int, error)) error
getNumRoutesLeft is a function which gets the current number of routes in the namespace. Namespace: Vnet
func (*TransparentVlanEndpointClient) DeleteSnatEndpoint ¶
func (client *TransparentVlanEndpointClient) DeleteSnatEndpoint() error
func (*TransparentVlanEndpointClient) DeleteSnatEndpointRules ¶
func (client *TransparentVlanEndpointClient) DeleteSnatEndpointRules()
func (*TransparentVlanEndpointClient) GetVnetRoutes ¶
func (client *TransparentVlanEndpointClient) GetVnetRoutes(ipAddresses []net.IPNet) []RouteInfo
Helper that gets the routes in the vnet NS for a particular list of IP addresses Example: 192.168.0.4 dev <device which connects to NS with that IP> proto static
func (*TransparentVlanEndpointClient) MoveEndpointsToContainerNS ¶
func (client *TransparentVlanEndpointClient) MoveEndpointsToContainerNS(epInfo *EndpointInfo, nsID uintptr) error
func (*TransparentVlanEndpointClient) MoveSnatEndpointToContainerNS ¶
func (client *TransparentVlanEndpointClient) MoveSnatEndpointToContainerNS(netnsPath string, nsID uintptr) error
func (*TransparentVlanEndpointClient) NewSnatClient ¶
func (client *TransparentVlanEndpointClient) NewSnatClient(snatBridgeIP, localIP string, epInfo *EndpointInfo)
func (*TransparentVlanEndpointClient) PopulateVM ¶
func (client *TransparentVlanEndpointClient) PopulateVM(epInfo *EndpointInfo) error
Called from AddEndpoints, Namespace: VM
func (*TransparentVlanEndpointClient) PopulateVnet ¶
func (client *TransparentVlanEndpointClient) PopulateVnet(epInfo *EndpointInfo) error
Called from AddEndpoints, Namespace: Vnet
func (*TransparentVlanEndpointClient) SetupContainerInterfaces ¶
func (client *TransparentVlanEndpointClient) SetupContainerInterfaces(epInfo *EndpointInfo) error
func (*TransparentVlanEndpointClient) SetupSnatContainerInterface ¶
func (client *TransparentVlanEndpointClient) SetupSnatContainerInterface() error
Source Files ¶
- api.go
- bridge_endpointclient_linux.go
- bridge_networkclient_linux.go
- dhcp.go
- endpoint.go
- endpoint_linux.go
- endpoint_snatroute_linux.go
- errors.go
- iptables.go
- manager.go
- manager_mock.go
- mock_endpointclient.go
- mock_namespace.go
- namespace.go
- namespace_linux.go
- network.go
- network_linux.go
- ovs_endpoint_infraroute_linux.go
- ovs_endpoint_snatroute_linux.go
- ovs_endpointclient_linux.go
- ovs_networkclient_linux.go
- secondary_endpoint_client_linux.go
- transparent_endpointclient_linux.go
- transparent_vlan_endpoint_snatroute_linux.go
- transparent_vlan_endpointclient_linux.go