network

package
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package network provides network interface management functionality for the AWS Multi-ENI Controller.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsRetryable

func IsRetryable(err error) bool

IsRetryable checks if an error is retryable

func IsValidInterfaceForENI

func IsValidInterfaceForENI(ifaceName string, eniPattern string, ignoreList []string) (bool, error)

IsValidInterfaceForENI checks if an interface name is valid for ENI operations

func NormalizeInterfaceName

func NormalizeInterfaceName(name string) string

NormalizeInterfaceName normalizes an interface name to a standard format

func ParseInterfaceIndex

func ParseInterfaceIndex(ifaceName string) (int, error)

ParseInterfaceIndex extracts the numeric index from an interface name

func RetryWithBackoff

func RetryWithBackoff(ctx context.Context, config RetryConfig, operation string, fn func() error) error

RetryWithBackoff executes a function with exponential backoff retry

func SanitizeInterfaceName

func SanitizeInterfaceName(name string) string

SanitizeInterfaceName sanitizes an interface name by removing invalid characters

func ValidateDeviceIndex

func ValidateDeviceIndex(index int) error

ValidateDeviceIndex validates a device index

func ValidateENIPattern

func ValidateENIPattern(pattern string) error

ValidateENIPattern validates an ENI pattern regex

func ValidateInterfaceName

func ValidateInterfaceName(name string) error

ValidateInterfaceName validates a network interface name

func ValidateInterfaceState

func ValidateInterfaceState(state string) error

ValidateInterfaceState validates an interface state string

func ValidateMACAddress

func ValidateMACAddress(mac string) error

ValidateMACAddress validates a MAC address format

func ValidateMTU

func ValidateMTU(mtu int) error

ValidateMTU validates an MTU value

func ValidateNetworkConfiguration

func ValidateNetworkConfiguration(ifaceName string, mtu int, deviceIndex int, pciAddress string) error

ValidateNetworkConfiguration validates a complete network configuration

func ValidatePCIAddress

func ValidatePCIAddress(addr string) error

ValidatePCIAddress validates a PCI address format

Types

type InterfaceInfo

type InterfaceInfo struct {
	Name        string
	Index       int
	State       string
	MTU         int
	PCIAddress  string
	MACAddress  string
	IsAWSENI    bool
	DeviceIndex int
}

InterfaceInfo represents information about a network interface

type Manager

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

Manager handles network interface operations

func NewManager

func NewManager(cfg *config.ENIManagerConfig) *Manager

NewManager creates a new network interface manager

func (*Manager) BringDownInterface

func (m *Manager) BringDownInterface(ifaceName string) error

BringDownInterface brings down a network interface

func (*Manager) BringDownInterfaceWithRetry

func (m *Manager) BringDownInterfaceWithRetry(ctx context.Context, ifaceName string) error

BringDownInterfaceWithRetry brings down an interface with retry logic

func (*Manager) BringUpInterface

func (m *Manager) BringUpInterface(ifaceName string) error

BringUpInterface brings up a network interface with retry logic

func (*Manager) BringUpInterfaceWithRetry

func (m *Manager) BringUpInterfaceWithRetry(ctx context.Context, ifaceName string) error

BringUpInterfaceWithRetry brings up an interface with retry logic

func (*Manager) ConfigureInterfaceFromNodeENI

func (m *Manager) ConfigureInterfaceFromNodeENI(ifaceName string, nodeENI networkingv1alpha1.NodeENI) error

ConfigureInterfaceFromNodeENI configures an interface based on NodeENI specification

func (*Manager) ConfigureInterfaceWithRetry

func (m *Manager) ConfigureInterfaceWithRetry(ctx context.Context, ifaceName string, nodeENI interface{}) error

ConfigureInterfaceWithRetry configures an interface with retry logic

func (*Manager) GetAllInterfaces

func (m *Manager) GetAllInterfaces() ([]InterfaceInfo, error)

GetAllInterfaces returns information about all network interfaces

func (*Manager) GetInterfaceNameForDeviceIndex

func (m *Manager) GetInterfaceNameForDeviceIndex(deviceIndex int) (string, error)

GetInterfaceNameForDeviceIndex returns the interface name for a given device index

func (*Manager) RetryInterfaceOperation

func (m *Manager) RetryInterfaceOperation(ctx context.Context, operation string, ifaceName string, fn func() error) error

RetryInterfaceOperation retries a network interface operation

func (*Manager) SetMTU

func (m *Manager) SetMTU(ifaceName string, mtu int) error

SetMTU sets the MTU for a network interface

func (*Manager) SetMTUWithRetry

func (m *Manager) SetMTUWithRetry(ctx context.Context, ifaceName string, mtu int) error

SetMTUWithRetry sets MTU with retry logic

func (*Manager) ValidateInterfaceWithRetry

func (m *Manager) ValidateInterfaceWithRetry(ctx context.Context, ifaceName string) error

ValidateInterfaceWithRetry validates an interface configuration with retry logic

func (*Manager) WaitForInterface

func (m *Manager) WaitForInterface(ifaceName string, timeout time.Duration) error

WaitForInterface waits for an interface to appear

func (*Manager) WaitForInterfaceWithRetry

func (m *Manager) WaitForInterfaceWithRetry(ctx context.Context, ifaceName string, timeout time.Duration) error

WaitForInterfaceWithRetry waits for an interface to appear with retry logic

type RetryConfig

type RetryConfig struct {
	MaxAttempts int           // Maximum number of retry attempts
	BaseDelay   time.Duration // Base delay between retries
	MaxDelay    time.Duration // Maximum delay between retries
	Multiplier  float64       // Backoff multiplier
}

RetryConfig holds configuration for retry operations

func DefaultRetryConfig

func DefaultRetryConfig() RetryConfig

DefaultRetryConfig returns default retry configuration

type RetryableError

type RetryableError struct {
	Err       error
	Retryable bool
}

RetryableError represents an error that can be retried

func NewRetryableError

func NewRetryableError(err error, retryable bool) *RetryableError

NewRetryableError creates a new retryable error

func (*RetryableError) Error

func (e *RetryableError) Error() string

func (*RetryableError) Unwrap

func (e *RetryableError) Unwrap() error

Jump to

Keyboard shortcuts

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