network

package
v1.6.11 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: MIT Imports: 36 Imported by: 2

Documentation

Index

Constants

View Source
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"
)
View Source
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"
)
View Source
const (
	DisableRPFilterCmd = "sysctl -w net.ipv4.conf.all.rp_filter=0" // Command to disable the rp filter for tunneling

)
View Source
const (
	// ipv6 modes
	IPV6Nat = "ipv6nat"
)
View Source
const (
	InfraVnet = 0
)

Variables

View Source
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")
)
View Source
var Ipv4DefaultRouteDstPrefix = net.IPNet{
	IP:   net.IPv4zero,
	Mask: net.IPv4Mask(0, 0, 0, 0),
}
View Source
var Ipv6DefaultRouteDstPrefix = net.IPNet{
	IP: net.IPv6zero,

	Mask: net.CIDRMask(0, ipv6AddressMask),
}

Functions

func AddInfraEndpointRules

func AddInfraEndpointRules(client *OVSEndpointClient, infraIP net.IPNet, hostPort string) error

func AddInfraVnetEndpoint

func AddInfraVnetEndpoint(client *OVSEndpointClient) error

func AddSnatEndpoint

func AddSnatEndpoint(snatClient *snat.Client) error

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 ConfigureSnatContainerInterface

func ConfigureSnatContainerInterface(snatClient *snat.Client) error

func ConstructEndpointID

func ConstructEndpointID(containerID string, _ string, ifName string) (string, string)

func DeleteInfraVnetEndpoint

func DeleteInfraVnetEndpoint(client *OVSEndpointClient) error

func DeleteInfraVnetEndpointRules

func DeleteInfraVnetEndpointRules(client *OVSEndpointClient, ep *endpoint, hostPort string)

func DeleteSnatEndpoint

func DeleteSnatEndpoint(snatClient *snat.Client) error

func DeleteSnatEndpointRules

func DeleteSnatEndpointRules(snatClient *snat.Client, hostToNC, ncToHost bool)

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 GetPodNameWithoutSuffix(podName string) string

func GetSnatContIfName

func GetSnatContIfName(epInfo *EndpointInfo) string

func GetSnatHostIfName

func GetSnatHostIfName(epInfo *EndpointInfo) string

func IsNetworkNotFoundError

func IsNetworkNotFoundError(err error) bool

func MoveInfraEndpointToContainerNS

func MoveInfraEndpointToContainerNS(client *OVSEndpointClient, netnsPath string, nsID uintptr) error

func MoveSnatEndpointToContainerNS

func MoveSnatEndpointToContainerNS(snatClient *snat.Client, netnsPath string, nsID uintptr) error

func NewErrorMockEndpointClient

func NewErrorMockEndpointClient(errStr string) error

func NewInfraVnetClient

func NewInfraVnetClient(client *OVSEndpointClient, epID string)

func RunWithRetries

func RunWithRetries(f func() error, maxRuns, sleepMs int) error

func SetupInfraVnetContainerInterface

func SetupInfraVnetContainerInterface(client *OVSEndpointClient) error

func SetupSnatContainerInterface

func SetupSnatContainerInterface(snatClient *snat.Client) error

Types

type AzureHNSEndpoint

type AzureHNSEndpoint struct{}

type AzureHNSEndpointClient

type AzureHNSEndpointClient interface{}

type DNSInfo

type DNSInfo struct {
	Suffix  string
	Servers []string
	Options []string
}

DNSInfo contains DNS information for a container network or endpoint.

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
	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
	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 IPConfig

type IPConfig struct {
	Address net.IPNet
	Gateway net.IP
}

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.

func (*Namespace) Close

func (ns *Namespace) Close() error

Close releases the resources associated with the namespace object.

func (*Namespace) Enter

func (ns *Namespace) Enter() error

Enter puts the caller thread inside the namespace.

func (*Namespace) Exit

func (ns *Namespace) Exit() error

Exit puts the caller thread to its previous namespace.

func (*Namespace) GetFd

func (ns *Namespace) GetFd() uintptr

GetFd returns the file descriptor of the namespace.

func (*Namespace) GetName

func (ns *Namespace) GetName() string

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 NamespaceInterface interface {
	GetFd() uintptr
	GetName() string
	Enter() error
	Exit() error
	Close() error
}

type NetworkClient

type NetworkClient interface {
	CreateBridge() error
	DeleteBridge() error
	AddL2Rules(extIf *externalInterface) error
	DeleteL2Rules(extIf *externalInterface)
	SetBridgeMasterToHostInterface() error
	SetHairpinOnHostInterface(bool) error
}

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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