eni

package
v1.17.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: Apache-2.0 Imports: 54 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResourceTypeLocalIP = 1 << iota
	ResourceTypeVeth
	ResourceTypeRemoteIP
	ResourceTypeRDMA
)
View Source
const IPv6PrefixMaxAddresses uint = 65536

IPv6PrefixMaxAddresses caps the managed address range for large IPv6 prefixes (e.g. /80 with 2^48 host bits). Addresses are formed as:

[prefix bits][zeros][16-bit offset]

so only the lowest 16 bits are used, giving 65536 usable addresses per prefix.

View Source
const (
	LocalIPTypeERDMA = "ERDMA"
)

Variables

This section is empty.

Functions

func Split added in v1.8.18

func Split[T any](arr []T, index int) ([]T, []T)

Types

type AllocRequest

type AllocRequest struct {
	ResourceRequests []ResourceRequest
}

AllocRequest represent a bunch of resource must be met.

type AllocResp

type AllocResp struct {
	Err error

	NetworkConfigs NetworkResources
}

type AllocatingRequests added in v1.8.18

type AllocatingRequests []*LocalIPRequest

func (*AllocatingRequests) Len added in v1.8.18

func (a *AllocatingRequests) Len() int

Len return the valid slice size

type ByPriority

type ByPriority []NetworkInterface

func (ByPriority) Len

func (n ByPriority) Len() int

func (ByPriority) Less

func (n ByPriority) Less(i, j int) bool

func (ByPriority) Swap

func (n ByPriority) Swap(i, j int)

type CRDV2 added in v1.9.6

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

func NewCRDV2 added in v1.9.6

func NewCRDV2(sharedMgr *SharedCRDManager, nodeName string) *CRDV2

func (*CRDV2) Allocate added in v1.9.6

func (r *CRDV2) Allocate(ctx context.Context, cni *daemon.CNI, request ResourceRequest) (chan *AllocResp, []Trace)

func (*CRDV2) Dispose added in v1.9.6

func (r *CRDV2) Dispose(n int) int

func (*CRDV2) Priority added in v1.9.6

func (r *CRDV2) Priority() int

func (*CRDV2) Release added in v1.9.6

func (r *CRDV2) Release(ctx context.Context, cni *daemon.CNI, request NetworkResource) (bool, error)

func (*CRDV2) Run added in v1.9.6

func (r *CRDV2) Run(ctx context.Context, podResources []daemon.PodResources, wg *sync.WaitGroup) error

type Condition

type Condition struct {
	ConditionType ConditionType
	Reason        string
	Last          time.Time
}

type ConditionType

type ConditionType int
const (
	Full ConditionType = iota
	ResourceTypeMismatch
	NetworkInterfaceMismatch
	InsufficientVSwitchIP
)

func (ConditionType) String

func (i ConditionType) String() string

type ENIID added in v1.17.1

type ENIID string

type ENILocalIPAM added in v1.17.1

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

func NewENILocalIPAMFromPrefix added in v1.17.1

func NewENILocalIPAMFromPrefix(eniID, mac string, eni *networkv1beta1.Nic, enableERDMA bool) *ENILocalIPAM

NewENILocalIPAMFromPrefix builds a Prefix-mode IPAM from Node CR's IPv4Prefix/IPv6Prefix.

func (*ENILocalIPAM) AllocateIPv4 added in v1.17.1

func (e *ENILocalIPAM) AllocateIPv4(podID string) (netip.Addr, error)

func (*ENILocalIPAM) AllocateIPv6 added in v1.17.1

func (e *ENILocalIPAM) AllocateIPv6(podID string) (netip.Addr, error)

func (*ENILocalIPAM) AllocationCount added in v1.17.1

func (e *ENILocalIPAM) AllocationCount() int

AllocationCount returns the total number of pod allocations (IPv4 + IPv6) in this IPAM.

func (*ENILocalIPAM) HasAllocations added in v1.17.1

func (e *ENILocalIPAM) HasAllocations() bool

HasAllocations returns true if any pod is currently using an IP from this IPAM.

func (*ENILocalIPAM) IsERDMA added in v1.17.1

func (e *ENILocalIPAM) IsERDMA() bool

IsERDMA returns true when both the node has ERDMA enabled and the NIC is in high-performance traffic mode.

func (*ENILocalIPAM) IsEmpty added in v1.17.1

func (e *ENILocalIPAM) IsEmpty() bool

IsEmpty returns true when the IPAM has no prefixes left (all drained and cleaned up).

func (*ENILocalIPAM) PoolStats added in v1.17.1

func (e *ENILocalIPAM) PoolStats() (int, int, int, int)

PoolStats returns (totalIPv4, idleIPv4, totalIPv6, idleIPv6).

func (*ENILocalIPAM) ReleaseIPv4 added in v1.17.1

func (e *ENILocalIPAM) ReleaseIPv4(podID string)

ReleaseIPv4 releases an IPv4 address.

func (*ENILocalIPAM) ReleaseIPv6 added in v1.17.1

func (e *ENILocalIPAM) ReleaseIPv6(podID string)

ReleaseIPv6 releases an IPv6 address.

func (*ENILocalIPAM) RestorePod added in v1.17.1

func (e *ENILocalIPAM) RestorePod(podID string, ipv4, ipv6 string, eniID string)

RestorePod restores the IP allocation state for a Pod.

func (*ENILocalIPAM) StatusSnapshot added in v1.17.1

func (e *ENILocalIPAM) StatusSnapshot() (eniID, mac string, ipv4 []PrefixStatus, ipv6 []PrefixStatus)

StatusSnapshot exports a point-in-time snapshot of ENI identity and per-prefix allocations.

func (*ENILocalIPAM) UpdatePrefixes added in v1.17.1

func (e *ENILocalIPAM) UpdatePrefixes(prefixes []networkv1beta1.IPPrefix, isIPv6 bool)

UpdatePrefixes syncs the local prefix state with the Node CR's prefix list. Prefixes removed from the CR (or marked Deleting) are set to Deleting locally, which blocks new allocations via sortedValidPrefixes. Once all Pods drain from a Deleting prefix, it is cleaned up on the next call.

type IP

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

func NewIP

func NewIP(ip netip.Addr, primary bool) *IP

func NewValidIP

func NewValidIP(ip netip.Addr, primary bool) *IP

func (*IP) Allocatable

func (ip *IP) Allocatable() bool

func (*IP) Allocate

func (ip *IP) Allocate(podID string)

func (*IP) Deleting

func (ip *IP) Deleting() bool

func (*IP) Dispose

func (ip *IP) Dispose()

func (*IP) InUse

func (ip *IP) InUse() bool

func (*IP) Primary

func (ip *IP) Primary() bool

func (*IP) Release

func (ip *IP) Release(podID string)

func (*IP) SetInvalid

func (ip *IP) SetInvalid()

func (*IP) String

func (ip *IP) String() string

func (*IP) Valid

func (ip *IP) Valid() bool

type Local

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

func NewLocal

func NewLocal(eni *daemon.ENI, eniType string, factory factory.Factory, poolConfig *daemon.PoolConfig) *Local

func (*Local) Allocate

func (l *Local) Allocate(ctx context.Context, cni *daemon.CNI, request ResourceRequest) (chan *AllocResp, []Trace)

func (*Local) Dispose

func (l *Local) Dispose(n int) int

func (*Local) Priority

func (l *Local) Priority() int

Priority for local resource only

func (*Local) Release

func (l *Local) Release(ctx context.Context, cni *daemon.CNI, request NetworkResource) (bool, error)

Release take the cni Del request and release resource to pool

func (*Local) Run

func (l *Local) Run(ctx context.Context, podResources []daemon.PodResources, wg *sync.WaitGroup) error

Run initialize the local eni

func (*Local) Status

func (l *Local) Status() Status

func (*Local) Usage

func (l *Local) Usage() (int, int, error)

type LocalDelegate added in v1.17.1

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

func NewLocalDelegate added in v1.17.1

func NewLocalDelegate(sharedMgr *SharedCRDManager, nodeName string, enableIPv4, enableIPv6 bool) *LocalDelegate

func (*LocalDelegate) Allocate added in v1.17.1

func (l *LocalDelegate) Allocate(ctx context.Context, cni *daemon.CNI, request ResourceRequest) (chan *AllocResp, []Trace)

Allocate implements NetworkInterface. Returns nil channel when inactive so the Manager falls through to the next NetworkInterface (CRDV2).

func (*LocalDelegate) Dispose added in v1.17.1

func (l *LocalDelegate) Dispose(n int) int

func (*LocalDelegate) Priority added in v1.17.1

func (l *LocalDelegate) Priority() int

func (*LocalDelegate) Release added in v1.17.1

func (l *LocalDelegate) Release(ctx context.Context, cni *daemon.CNI, request NetworkResource) (bool, error)

Release implements NetworkInterface. Returns (false, nil) when inactive so the Manager falls through to the next NetworkInterface (CRDV2).

func (*LocalDelegate) Run added in v1.17.1

func (l *LocalDelegate) Run(ctx context.Context, podResources []daemon.PodResources, wg *sync.WaitGroup) error

Run implements NetworkInterface. It waits for the shared cache to sync, registers Node CR informer handlers, and performs synchronous initialization so the delegate is ready for allocation before Run returns.

func (*LocalDelegate) Statuses added in v1.17.1

func (l *LocalDelegate) Statuses() []Status

type LocalIPRequest

type LocalIPRequest struct {
	NetworkInterfaceID string
	LocalIPType        string
	IPv4               netip.Addr
	IPv6               netip.Addr

	NoCache bool // do not use cached ip
	// contains filtered or unexported fields
}

func NewLocalIPRequest added in v1.8.18

func NewLocalIPRequest() *LocalIPRequest

func (*LocalIPRequest) ResourceType

func (l *LocalIPRequest) ResourceType() ResourceType

type LocalIPResource

type LocalIPResource struct {
	PodID string

	ENI daemon.ENI

	IP types.IPSet2
}

func (*LocalIPResource) ResourceType

func (l *LocalIPResource) ResourceType() ResourceType

func (*LocalIPResource) ToRPC

func (l *LocalIPResource) ToRPC() []*rpc.NetConf

func (*LocalIPResource) ToStore

func (l *LocalIPResource) ToStore() []daemon.ResourceItem

type Manager

type Manager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewManager

func NewManager(pool *daemon.PoolConfig, syncPeriod time.Duration, networkInterfaces []NetworkInterface, selectionPolicy daemon.EniSelectionPolicy, k8s k8s.Kubernetes) *Manager

func (*Manager) Allocate

func (m *Manager) Allocate(ctx context.Context, cni *daemon.CNI, req *AllocRequest) (NetworkResources, error)

Allocate find the resource manager and send the request to it. Caller should roll back the allocated resource if any error happen.

func (*Manager) Release

func (m *Manager) Release(ctx context.Context, cni *daemon.CNI, req *ReleaseRequest) error

Release find the resource manager and send the request to it.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context, wg *sync.WaitGroup, podResources []daemon.PodResources) error

func (*Manager) Status

func (m *Manager) Status() []Status

type MultiReportStatus added in v1.17.1

type MultiReportStatus interface {
	Statuses() []Status
}

type NetworkInterface

type NetworkInterface interface {
	Allocate(ctx context.Context, cni *daemon.CNI, request ResourceRequest) (chan *AllocResp, []Trace)
	Release(ctx context.Context, cni *daemon.CNI, request NetworkResource) (bool, error)
	Priority() int
	Dispose(n int) int
	Run(ctx context.Context, podResources []daemon.PodResources, wg *sync.WaitGroup) error
}

type NetworkResource

type NetworkResource interface {
	ResourceType() ResourceType

	ToRPC() []*rpc.NetConf

	ToStore() []daemon.ResourceItem
}

type NetworkResources

type NetworkResources []NetworkResource

type NodeCondition

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

func (*NodeCondition) Run

func (n *NodeCondition) Run()

func (*NodeCondition) SetIPExhaustive

func (n *NodeCondition) SetIPExhaustive()

func (*NodeCondition) UnsetIPExhaustive

func (n *NodeCondition) UnsetIPExhaustive()

type NodeConditionHandler

type NodeConditionHandler func(status corev1.ConditionStatus, reason, message string) error

type Notifier added in v1.15.1

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

Notifier provides a simple message subscription-based notification mechanism

func NewNotifier added in v1.15.1

func NewNotifier() *Notifier

NewNotifier creates a new notifier

func (*Notifier) Close added in v1.15.1

func (n *Notifier) Close()

Close closes the notifier and cleans up all subscribers

func (*Notifier) GetSubscriberCount added in v1.15.1

func (n *Notifier) GetSubscriberCount() int

GetSubscriberCount gets the current number of subscribers (for debugging and monitoring)

func (*Notifier) IsClosed added in v1.15.1

func (n *Notifier) IsClosed() bool

IsClosed checks if the notifier is closed

func (*Notifier) Notify added in v1.15.1

func (n *Notifier) Notify()

Notify sends notifications to all subscribers

func (*Notifier) Subscribe added in v1.15.1

func (n *Notifier) Subscribe() <-chan struct{}

Subscribe registers a subscriber and returns a subscription channel

func (*Notifier) Unsubscribe added in v1.15.1

func (n *Notifier) Unsubscribe(ch <-chan struct{})

Unsubscribe removes a subscriber by channel reference

type PrefixAllocation added in v1.17.1

type PrefixAllocation struct {
	IP    string
	PodID string
}

type PrefixInfo added in v1.17.1

type PrefixInfo struct {
	Prefix string
	// contains filtered or unexported fields
}

type PrefixStatus added in v1.17.1

type PrefixStatus struct {
	Prefix      string
	Status      string
	Total       int
	Used        int
	Available   int
	Allocations []PrefixAllocation
}

type ReleaseRequest

type ReleaseRequest struct {
	NetworkResources []NetworkResource
}

type Remote

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

func NewRemote

func NewRemote(client client.Client, trunkENI *daemon.ENI, notifier *Notifier) *Remote

func (*Remote) Allocate

func (r *Remote) Allocate(ctx context.Context, cni *daemon.CNI, request ResourceRequest) (chan *AllocResp, []Trace)

func (*Remote) Dispose

func (r *Remote) Dispose(n int) int

func (*Remote) Priority

func (r *Remote) Priority() int

func (*Remote) Release

func (r *Remote) Release(ctx context.Context, cni *daemon.CNI, request NetworkResource) (bool, error)

func (*Remote) Run

func (r *Remote) Run(ctx context.Context, podResources []daemon.PodResources, wg *sync.WaitGroup) error

type RemoteIPRequest

type RemoteIPRequest struct{}

func (*RemoteIPRequest) ResourceType

func (l *RemoteIPRequest) ResourceType() ResourceType

type RemoteIPResource

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

func (*RemoteIPResource) ResourceType

func (l *RemoteIPResource) ResourceType() ResourceType

func (*RemoteIPResource) ToRPC

func (l *RemoteIPResource) ToRPC() []*rpc.NetConf

func (*RemoteIPResource) ToStore

func (l *RemoteIPResource) ToStore() []daemon.ResourceItem

type RemoteV2 added in v1.17.1

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

func NewRemoteV2 added in v1.17.1

func NewRemoteV2(sharedMgr *SharedCRDManager, nodeName string) *RemoteV2

func (*RemoteV2) Allocate added in v1.17.1

func (r *RemoteV2) Allocate(ctx context.Context, cni *daemon.CNI, request ResourceRequest) (chan *AllocResp, []Trace)

func (*RemoteV2) Dispose added in v1.17.1

func (r *RemoteV2) Dispose(n int) int

func (*RemoteV2) Priority added in v1.17.1

func (r *RemoteV2) Priority() int

func (*RemoteV2) Release added in v1.17.1

func (r *RemoteV2) Release(ctx context.Context, cni *daemon.CNI, request NetworkResource) (bool, error)

func (*RemoteV2) Run added in v1.17.1

func (r *RemoteV2) Run(ctx context.Context, podResources []daemon.PodResources, wg *sync.WaitGroup) error

type ReportStatus

type ReportStatus interface {
	Status() Status
}

type ResourceRequest

type ResourceRequest interface {
	ResourceType() ResourceType
}

type ResourceType

type ResourceType int

type Set

type Set map[netip.Addr]*IP

func (Set) Add

func (s Set) Add(ip *IP)

func (Set) Allocatable

func (s Set) Allocatable() []*IP

func (Set) ByPodID

func (s Set) ByPodID(podID string) *IP

func (Set) Delete

func (s Set) Delete(ip ...netip.Addr)

func (Set) Deleting

func (s Set) Deleting() []netip.Addr

func (Set) Idles

func (s Set) Idles() []*IP

func (Set) InUse

func (s Set) InUse() []*IP

func (Set) PeekAvailable

func (s Set) PeekAvailable(podID string) *IP

func (Set) PutDeleting

func (s Set) PutDeleting(ip ...netip.Addr)

func (Set) PutValid

func (s Set) PutValid(ip ...netip.Addr)

func (Set) Release

func (s Set) Release(podID string, ip netip.Addr)

type SharedCRDManager added in v1.17.1

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

SharedCRDManager holds the controller-runtime manager shared by peer controllers (CRDV2 and LocalDelegate). It owns the manager lifecycle and cache sync signal.

func NewSharedCRDManager added in v1.17.1

func NewSharedCRDManager(restConfig *rest.Config, nodeName, namespace string) (*SharedCRDManager, error)

NewSharedCRDManager creates the shared controller-runtime manager with filtered caches for this node and registers the nodeReconcile controller.

func (*SharedCRDManager) CacheSynced added in v1.17.1

func (s *SharedCRDManager) CacheSynced() <-chan struct{}

func (*SharedCRDManager) Client added in v1.17.1

func (s *SharedCRDManager) Client() client.Client

func (*SharedCRDManager) GetCache added in v1.17.1

func (s *SharedCRDManager) GetCache() cache.Cache

func (*SharedCRDManager) Scheme added in v1.17.1

func (s *SharedCRDManager) Scheme() *runtime.Scheme

func (*SharedCRDManager) Start added in v1.17.1

func (s *SharedCRDManager) Start(ctx context.Context, wg *sync.WaitGroup)

Start begins the controller-runtime manager in a background goroutine.

type Status

type Status struct {
	NetworkInterfaceID   string
	MAC                  string
	Type                 string
	AllocInhibitExpireAt string

	Usage  [][]string
	Status string

	IPv4Prefixes []PrefixStatus
	IPv6Prefixes []PrefixStatus
}

type Trace

type Trace struct {
	Condition ConditionType
	Reason    string
}

type Trunk

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

func NewTrunk

func NewTrunk(client client.Client, local *Local) *Trunk

func (*Trunk) Allocate

func (r *Trunk) Allocate(ctx context.Context, cni *daemon.CNI, request ResourceRequest) (chan *AllocResp, []Trace)

func (*Trunk) Dispose

func (r *Trunk) Dispose(n int) int

func (*Trunk) Priority

func (r *Trunk) Priority() int

func (*Trunk) Release

func (r *Trunk) Release(ctx context.Context, cni *daemon.CNI, request NetworkResource) (bool, error)

func (*Trunk) Run

func (r *Trunk) Run(ctx context.Context, podResources []daemon.PodResources, wg *sync.WaitGroup) error

func (*Trunk) Status

func (r *Trunk) Status() Status

func (*Trunk) Usage

func (r *Trunk) Usage() (int, int, error)

type Usage

type Usage interface {
	Usage() (int, int, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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