Help us shape the future of Go! Take the 2026 Go Developer Survey

network

package
v1.8.16 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 40 Imported by: 1

Documentation

Index

Constants

View Source
const (
	CNI_ADD    = "ADD"
	CNI_DEL    = "DEL"
	CNI_UPDATE = "UPDATE"
)

CNI Operation Types

View Source
const (
	OpModeTransparent = "transparent"
)

Variables

This section is empty.

Functions

func GetEndpointID

func GetEndpointID(args *cniSkel.CmdArgs) string

GetEndpointID returns a unique endpoint ID based on the CNI args.

func HandleIfCniUpdate

func HandleIfCniUpdate(update func(*skel.CmdArgs) error) (bool, error)

func PrintCNIError

func PrintCNIError(msg string)

Types

type AzureIPAMInvoker

type AzureIPAMInvoker struct {
	// contains filtered or unexported fields
}

func NewAzureIpamInvoker

func NewAzureIpamInvoker(plugin *NetPlugin, nwInfo *network.EndpointInfo) *AzureIPAMInvoker

Create an IPAM instance every time a CNI action is called.

func (*AzureIPAMInvoker) Add

func (invoker *AzureIPAMInvoker) Add(addConfig IPAMAddConfig) (IPAMAddResult, error)

func (*AzureIPAMInvoker) Delete

func (invoker *AzureIPAMInvoker) Delete(address *net.IPNet, nwCfg *cni.NetworkConfig, _ *cniSkel.CmdArgs, options map[string]interface{}) error

type AzureNetIOShim

type AzureNetIOShim struct{}

func (AzureNetIOShim) GetInterfaceSubnetWithSpecificIP

func (a AzureNetIOShim) GetInterfaceSubnetWithSpecificIP(ipAddr string) *net.IPNet

type CNSIPAMInvoker

type CNSIPAMInvoker struct {
	// contains filtered or unexported fields
}

func NewCNSInvoker

func NewCNSInvoker(podName, namespace string, cnsClient cnsclient, executionMode util.ExecutionMode, ipamMode util.IpamMode) *CNSIPAMInvoker

func (*CNSIPAMInvoker) Add

func (invoker *CNSIPAMInvoker) Add(addConfig IPAMAddConfig) (IPAMAddResult, error)

Add uses the requestipconfig API in cns, and returns ipv4 and a nil ipv6 as CNS doesn't support IPv6 yet

func (*CNSIPAMInvoker) Delete

func (invoker *CNSIPAMInvoker) Delete(address *net.IPNet, nwCfg *cni.NetworkConfig, args *cniSkel.CmdArgs, _ map[string]interface{}) error

Delete calls into the releaseipconfiguration API in CNS

type IPAMAddConfig

type IPAMAddConfig struct {
	// contains filtered or unexported fields
}

type IPAMAddResult

type IPAMAddResult struct {
	// contains filtered or unexported fields
}

func (IPAMAddResult) PrettyString

func (ipamAddResult IPAMAddResult) PrettyString() string

type IPAMInvoker

type IPAMInvoker interface {
	// Add returns two results, one IPv4, the other IPv6.
	Add(IPAMAddConfig) (IPAMAddResult, error)

	// Delete calls to the invoker source, and returns error. Returning an error here will fail the CNI Delete call.
	Delete(address *net.IPNet, nwCfg *cni.NetworkConfig, args *cniSkel.CmdArgs, options map[string]interface{}) error
}

IPAMInvoker is used by the azure-vnet CNI plugin to call different sources for IPAM. This interface can be used to call into external binaries, like the azure-vnet-ipam binary, or simply act as a client to an external ipam, such as azure-cns.

type IPResultInfo

type IPResultInfo struct {
	// contains filtered or unexported fields
}

func (IPResultInfo) MarshalLogObject

func (i IPResultInfo) MarshalLogObject(encoder zapcore.ObjectEncoder) error

type InterfaceGetter

type InterfaceGetter interface {
	GetNetworkInterfaces() ([]net.Interface, error)
	GetNetworkInterfaceAddrs(iface *net.Interface) ([]net.Addr, error)
	ResolveMasterInterface(iface *net.Interface) (*net.Interface, error)
}

client for getting interface

type MockIpamInvoker

type MockIpamInvoker struct {
	// contains filtered or unexported fields
}

func NewCustomMockIpamInvoker

func NewCustomMockIpamInvoker(customReturn map[string]network.InterfaceInfo) *MockIpamInvoker

func NewMockIpamInvoker

func NewMockIpamInvoker(ipv6, v4Fail, v6Fail, delegatedVMNIC, delegatedVMNICFail bool) *MockIpamInvoker

func (*MockIpamInvoker) Add

func (invoker *MockIpamInvoker) Add(opt IPAMAddConfig) (ipamAddResult IPAMAddResult, err error)

func (*MockIpamInvoker) Delete

func (invoker *MockIpamInvoker) Delete(address *net.IPNet, nwCfg *cni.NetworkConfig, _ *skel.CmdArgs, options map[string]interface{}) error

type MockMultitenancy

type MockMultitenancy struct {
	// contains filtered or unexported fields
}

func NewMockMultitenancy

func NewMockMultitenancy(fail bool, cnsResponses []*cns.GetNetworkContainerResponse) *MockMultitenancy

func (*MockMultitenancy) DetermineSnatFeatureOnHost

func (m *MockMultitenancy) DetermineSnatFeatureOnHost(snatFile, nmAgentSupportedApisURL string) (snatDNS, snatHost bool, err error)

func (*MockMultitenancy) GetAllNetworkContainers

func (m *MockMultitenancy) GetAllNetworkContainers(
	ctx context.Context,
	nwCfg *cni.NetworkConfig,
	podName string,
	podNamespace string,
	ifName string,
) (IPAMAddResult, error)

func (*MockMultitenancy) GetNetworkContainer

func (m *MockMultitenancy) GetNetworkContainer(
	ctx context.Context,
	nwCfg *cni.NetworkConfig,
	podName string,
	podNamespace string,
) (*cns.GetNetworkContainerResponse, net.IPNet, error)

func (*MockMultitenancy) Init

func (m *MockMultitenancy) Init(cnsclient cnsclient, netnetioshim netioshim)

func (*MockMultitenancy) SetupRoutingForMultitenancy

func (m *MockMultitenancy) SetupRoutingForMultitenancy(
	nwCfg *cni.NetworkConfig,
	cnsNetworkConfig *cns.GetNetworkContainerResponse,
	azIpamResult *current.Result,
	epInfo *network.EndpointInfo,
	_ *network.InterfaceInfo)

type Multitenancy

type Multitenancy struct {
	// contains filtered or unexported fields
}

func (*Multitenancy) DetermineSnatFeatureOnHost

func (m *Multitenancy) DetermineSnatFeatureOnHost(snatFile, nmAgentSupportedApisURL string) (snatForDNS, snatOnHost bool, err error)

DetermineSnatFeatureOnHost - Temporary function to determine whether we need to disable SNAT due to NMAgent support

func (*Multitenancy) GetAllNetworkContainers

func (m *Multitenancy) GetAllNetworkContainers(
	ctx context.Context, nwCfg *cni.NetworkConfig, podName, podNamespace, ifName string,
) (IPAMAddResult, error)

get all network container configuration(s) for given orchestratorContext

func (*Multitenancy) Init

func (m *Multitenancy) Init(cnsclient cnsclient, netioshim netioshim)

func (*Multitenancy) SetupRoutingForMultitenancy

func (m *Multitenancy) SetupRoutingForMultitenancy(
	nwCfg *cni.NetworkConfig,
	cnsNetworkConfig *cns.GetNetworkContainerResponse,
	azIpamResult *cniTypesCurr.Result,
	epInfo *network.EndpointInfo,
	result *network.InterfaceInfo,
)

type MultitenancyClient

type MultitenancyClient interface {
	SetupRoutingForMultitenancy(
		nwCfg *cni.NetworkConfig,
		cnsNetworkConfig *cns.GetNetworkContainerResponse,
		azIpamResult *cniTypesCurr.Result,
		epInfo *network.EndpointInfo,
		result *network.InterfaceInfo)
	DetermineSnatFeatureOnHost(
		snatFile string,
		nmAgentSupportedApisURL string) (bool, bool, error)
	GetAllNetworkContainers(
		ctx context.Context,
		nwCfg *cni.NetworkConfig,
		podName string,
		podNamespace string,
		ifName string) (IPAMAddResult, error)
	Init(cnsclient cnsclient, netioshim netioshim)
}

MultitenancyClient interface

type NetPlugin

type NetPlugin struct {
	*cni.Plugin
	// contains filtered or unexported fields
}

NetPlugin represents the CNI network plugin.

func NewPlugin

func NewPlugin(name string,
	config *common.PluginConfig,
	client NnsClient,
	multitenancyClient MultitenancyClient,
) (*NetPlugin, error)

NewPlugin creates a new NetPlugin object.

func (*NetPlugin) Add

func (plugin *NetPlugin) Add(args *cniSkel.CmdArgs) error

Add handles CNI add commands.

func (*NetPlugin) Delete

func (plugin *NetPlugin) Delete(args *cniSkel.CmdArgs) error

Delete handles CNI delete commands.

func (*NetPlugin) Get

func (plugin *NetPlugin) Get(args *cniSkel.CmdArgs) error

Get handles CNI Get commands.

func (*NetPlugin) GetAllEndpointState

func (plugin *NetPlugin) GetAllEndpointState(networkid string) (*api.AzureCNIState, error)

func (*NetPlugin) Start

func (plugin *NetPlugin) Start(config *common.PluginConfig) error

Starts the plugin.

func (*NetPlugin) Stop

func (plugin *NetPlugin) Stop()

Stops the plugin.

func (*NetPlugin) Update

func (plugin *NetPlugin) Update(args *cniSkel.CmdArgs) error

Update handles CNI update commands. Update is only supported for multitenancy and to update routes.

type NnsClient

type NnsClient interface {
	// Do network port programming for the pod via node network service.
	// podName - name of the pod as received from containerD
	// nwNamesapce - network namespace name as received from containerD
	AddContainerNetworking(ctx context.Context, podName, nwNamespace string) (*nnscontracts.ConfigureContainerNetworkingResponse, error)

	// Undo or delete network port programming for the pod via node network service.
	// podName - name of the pod as received from containerD
	// nwNamesapce - network namespace name as received from containerD
	DeleteContainerNetworking(ctx context.Context, podName, nwNamespace string) (*nnscontracts.ConfigureContainerNetworkingResponse, error)
}

client for node network service

type PolicyArgs

type PolicyArgs struct {
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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