network

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NetplanConfigFile    = "99-elchi-interfaces.yaml"
	NetplanBackupSuffix  = ".backup"
	DefaultTestTimeout   = 10 // seconds
	ConnectionCheckDelay = 3  // seconds grace period for netplan apply
	MaxFailedChecks      = 5  // consecutive failures before rollback
	CheckInterval        = 500 * time.Millisecond
)
View Source
const (
	MinPolicyPriority = 100 // Elchi policies start from priority 100
	MaxPolicyPriority = 999 // Elchi policies end at priority 999
)
View Source
const (
	ElchiTableFile  = "/var/lib/elchi/rt_tables.conf"        // Elchi storage location
	KernelTableLink = "/etc/iproute2/rt_tables.d/elchi.conf" // Kernel reads from here
	MinTableID      = 100                                    // Elchi-managed tables start from 100
	MaxTableID      = 999                                    // Elchi-managed tables end at 999
)

Variables

This section is empty.

Functions

func DeleteDummyInterface

func DeleteDummyInterface(ifaceName string, logger *logger.Logger) error

DeleteDummyInterface removes interface from both runtime (netlink) and persistent config (netplan)

func GetNetworkState

func GetNetworkState(cmd *client.Command, logger *logger.Logger) *client.CommandResponse

GetNetworkState handles SUB_GET_NETWORK_STATE command

func NetplanApply

func NetplanApply(cmd *client.Command, logger *logger.Logger, grpcConn *grpc.ClientConn, clientID string) *client.CommandResponse

NetplanApply handles SUB_NETPLAN_APPLY command

func NetplanGet

func NetplanGet(cmd *client.Command, logger *logger.Logger) *client.CommandResponse

NetplanGet handles SUB_NETPLAN_GET command

func NetplanRollback

func NetplanRollback(cmd *client.Command, logger *logger.Logger) *client.CommandResponse

NetplanRollback handles SUB_NETPLAN_ROLLBACK command

func PolicyList

func PolicyList(cmd *client.Command, logger *logger.Logger) *client.CommandResponse

PolicyList handles SUB_POLICY_LIST command

func PolicyManage

func PolicyManage(cmd *client.Command, logger *logger.Logger) *client.CommandResponse

PolicyManage handles SUB_POLICY_MANAGE command

func RouteList

func RouteList(cmd *client.Command, logger *logger.Logger) *client.CommandResponse

RouteList handles SUB_ROUTE_LIST command

func RouteManage

func RouteManage(cmd *client.Command, logger *logger.Logger) *client.CommandResponse

RouteManage handles SUB_ROUTE_MANAGE command

func SetupDummyInterface

func SetupDummyInterface(filename, ifaceName, downstreamAddress string, port uint32, logger *logger.Logger) (string, string, error)
func SetupDummyInterfaceWithNetlink(ifaceName, downstreamAddress string, logger *logger.Logger) error

func TableList

func TableList(cmd *client.Command, logger *logger.Logger) *client.CommandResponse

TableList handles SUB_TABLE_LIST command

func TableManage

func TableManage(cmd *client.Command, logger *logger.Logger) *client.CommandResponse

TableManage handles SUB_TABLE_MANAGE command

Types

type ConnectionMonitor

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

ConnectionMonitor monitors controller connection during network changes

func NewConnectionMonitor

func NewConnectionMonitor(logger *logger.Logger) *ConnectionMonitor

func (*ConnectionMonitor) MonitorConnectionDuringApply

func (cm *ConnectionMonitor) MonitorConnectionDuringApply(ctx context.Context) bool

MonitorConnectionDuringApply monitors controller connection during netplan apply

func (*ConnectionMonitor) SetGRPCConnection

func (cm *ConnectionMonitor) SetGRPCConnection(conn *grpc.ClientConn, clientID string)

SetGRPCConnection sets the gRPC connection for ping testing

type NetplanInterfaceConfig

type NetplanInterfaceConfig struct {
	RoutingPolicy []NetplanPolicyEntry `yaml:"routing-policy,omitempty"`
}

type NetplanManager

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

func NewNetplanManager

func NewNetplanManager(logger *logger.Logger) *NetplanManager

func (*NetplanManager) ApplyNetplanConfig

func (nm *NetplanManager) ApplyNetplanConfig(config *client.NetplanConfig) error

ApplyNetplanConfig applies netplan configuration with connection protection

func (*NetplanManager) GetCurrentConfig

func (nm *NetplanManager) GetCurrentConfig() (string, error)

GetCurrentConfig returns current netplan configuration

func (*NetplanManager) SetGRPCConnection

func (nm *NetplanManager) SetGRPCConnection(conn *grpc.ClientConn, clientID string)

SetGRPCConnection sets the gRPC connection for ping testing

func (*NetplanManager) ValidateConfig

func (nm *NetplanManager) ValidateConfig(yamlContent string) error

ValidateConfig validates netplan YAML syntax

type NetplanPolicyConfig

type NetplanPolicyConfig struct {
	Network NetplanPolicyNetwork `yaml:"network"`
}

Policy persistence structures for netplan YAML

type NetplanPolicyEntry

type NetplanPolicyEntry struct {
	From     string `yaml:"from,omitempty"`
	To       string `yaml:"to,omitempty"`
	Table    int    `yaml:"table"`
	Priority int    `yaml:"priority"`
}

type NetplanPolicyNetwork

type NetplanPolicyNetwork struct {
	Version   int                               `yaml:"version"`
	Renderer  string                            `yaml:"renderer"`
	Ethernets map[string]NetplanInterfaceConfig `yaml:"ethernets,omitempty"`
}

type NetplanRouteConfig

type NetplanRouteConfig struct {
	Network NetplanRouteNetwork `yaml:"network"`
}

Route persistence structures for netplan YAML

type NetplanRouteEntry

type NetplanRouteEntry struct {
	To     string `yaml:"to"`
	Via    string `yaml:"via,omitempty"`
	Table  int    `yaml:"table,omitempty"`
	Metric int    `yaml:"metric,omitempty"`
	Scope  string `yaml:"scope,omitempty"`
	Onlink bool   `yaml:"on-link,omitempty"`
}

type NetplanRouteInterface

type NetplanRouteInterface struct {
	Routes []NetplanRouteEntry `yaml:"routes,omitempty"`
}

type NetplanRouteNetwork

type NetplanRouteNetwork struct {
	Version   int                              `yaml:"version"`
	Renderer  string                           `yaml:"renderer"`
	Ethernets map[string]NetplanRouteInterface `yaml:"ethernets,omitempty"`
}

type PolicyManager

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

func NewPolicyManager

func NewPolicyManager(logger *logger.Logger) *PolicyManager

func (*PolicyManager) GetCurrentPolicies

func (pm *PolicyManager) GetCurrentPolicies() ([]*client.RoutingPolicy, error)

GetCurrentPolicies returns current routing policies from runtime

func (*PolicyManager) ManagePolicies

func (pm *PolicyManager) ManagePolicies(operations []*client.RoutingPolicyOperation) error

ManagePolicies handles routing policy operations (add/delete/replace)

type RouteManagerNew

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

func NewRouteManagerNew

func NewRouteManagerNew(logger *logger.Logger) *RouteManagerNew

func (*RouteManagerNew) ManageRoutes

func (rm *RouteManagerNew) ManageRoutes(operations []*client.RouteOperation) error

ManageRoutes handles route operations (add/delete/replace)

type TableManager

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

func NewTableManager

func NewTableManager(logger *logger.Logger) *TableManager

func (*TableManager) GetCurrentTables

func (tm *TableManager) GetCurrentTables() ([]*client.RoutingTableDefinition, error)

GetCurrentTables returns current routing table definitions

func (*TableManager) ManageRoutingTables

func (tm *TableManager) ManageRoutingTables(tables []*client.RoutingTableDefinition) error

ManageRoutingTables processes routing table definitions (bulk update)

func (*TableManager) ManageTableOperations

func (tm *TableManager) ManageTableOperations(operations []*client.TableOperation) error

ManageTableOperations processes individual table operations (add/delete/replace)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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