apis

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TODO: Reconsider the domain being used when project becomes owned by some
	// SIG. The issue with "dra.net" is that http://dra.net is an actual
	// domain that is totally unrelated to this project and it can be a source
	// of confusion and problems.
	AttrPrefix = "dra.net"

	// TODO: Document meaning of these attributes and re-evaluate if all are needed.
	AttrInterfaceName   = AttrPrefix + "/" + "ifName"
	AttrPCIAddress      = AttrPrefix + "/" + "pciAddress"
	AttrMac             = AttrPrefix + "/" + "mac"
	AttrPCIVendor       = AttrPrefix + "/" + "pciVendor"
	AttrPCIDevice       = AttrPrefix + "/" + "pciDevice"
	AttrPCISubsystem    = AttrPrefix + "/" + "pciSubsystem"
	AttrNUMANode        = AttrPrefix + "/" + "numaNode"
	AttrMTU             = AttrPrefix + "/" + "mtu"
	AttrEncapsulation   = AttrPrefix + "/" + "encapsulation"
	AttrAlias           = AttrPrefix + "/" + "alias"
	AttrState           = AttrPrefix + "/" + "state"
	AttrType            = AttrPrefix + "/" + "type"
	AttrIPv4            = AttrPrefix + "/" + "ipv4"
	AttrIPv6            = AttrPrefix + "/" + "ipv6"
	AttrTCFilterNames   = AttrPrefix + "/" + "tcFilterNames"
	AttrTCXProgramNames = AttrPrefix + "/" + "tcxProgramNames"
	AttrEBPF            = AttrPrefix + "/" + "ebpf"
	AttrSRIOV           = AttrPrefix + "/" + "sriov"
	AttrSRIOVVfs        = AttrPrefix + "/" + "sriovVfs"
	AttrVirtual         = AttrPrefix + "/" + "virtual"
	AttrRDMA            = AttrPrefix + "/" + "rdma"
)
View Source
const (
	// rdmaNetnsModeShared and rdmaNetnsModeExclusive define the RDMA subsystem
	// network namespace mode. An RDMA device can only be assigned to a network
	// namespace when the RDMA subsystem is set to an "exclusive" network
	// namespace mode. When the subsystem is set to "shared" mode, an attempt to
	// assign an RDMA device to a network namespace will result in failure.
	// Additionally, "If there are active network namespaces and if one or more
	// RDMA devices exist, changing mode from shared to exclusive returns error
	// code EBUSY."
	//
	// Ref. https://man7.org/linux/man-pages/man8/rdma-system.8.html
	RdmaNetnsModeShared    = "shared"
	RdmaNetnsModeExclusive = "exclusive"
)
View Source
const (
	// MinMTU is the minimum practical MTU (e.g., for IPv4).
	MinMTU = 68
	// MaxInterfaceNameLen is typically IFNAMSIZ-1 (usually 15 on Linux).
	MaxInterfaceNameLen = 15
)

Variables

This section is empty.

Functions

This section is empty.

Types

type EthtoolConfig added in v0.5.0

type EthtoolConfig struct {
	// Features is a map of ethtool feature names to their desired state (true for on, false for off).
	// Example: {"tcp-segmentation-offload": true, "rx-checksum": true}
	Features map[string]bool `json:"features,omitempty"`

	// PrivateFlags is a map of device-specific private flag names to their desired state.
	// Example: {"my-custom-flag": true}
	PrivateFlags map[string]bool `json:"privateFlags,omitempty"`
}

EthtoolConfig defines ethtool-based optimizations for a network interface. These settings correspond to features typically toggled using `ethtool -K <dev> <feature> on|off`.

type InterfaceConfig

type InterfaceConfig struct {
	// Name is the desired logical name of the interface inside the Pod (e.g., "net0", "eth_app").
	// If not specified, DraNet may use or derive a name from the original interface.
	Name string `json:"name,omitempty"`

	// Addresses is a list of IP addresses in CIDR format (e.g., "192.168.1.10/24")
	// to be assigned to the interface.
	Addresses []string `json:"addresses,omitempty"`

	// DHCP, if true, indicates that the interface should be configured via DHCP.
	// This is mutually exclusive with the 'addresses' field.
	DHCP *bool `json:"dhcp,omitempty"`

	// MTU is the Maximum Transmission Unit for the interface.
	MTU *int32 `json:"mtu,omitempty"`

	// HardwareAddr is the MAC address of the interface.
	HardwareAddr *string `json:"hardwareAddr,omitempty"`

	// GSOMaxSize sets the maximum Generic Segmentation Offload size for IPv6.
	// Managed by `ip link set <dev> gso_max_size <val>`. For enabling Big TCP.
	GSOMaxSize *int32 `json:"gsoMaxSize,omitempty"`

	// GROMaxSize sets the maximum Generic Receive Offload size for IPv6.
	// Managed by `ip link set <dev> gro_max_size <val>`. For enabling Big TCP.
	GROMaxSize *int32 `json:"groMaxSize,omitempty"`

	// GSOv4MaxSize sets the maximum Generic Segmentation Offload size.
	// Managed by `ip link set <dev> gso_ipv4_max_size <val>`. For enabling Big TCP.
	GSOIPv4MaxSize *int32 `json:"gsoIPv4MaxSize,omitempty"`

	// GROv4MaxSize sets the maximum Generic Receive Offload size.
	// Managed by `ip link set <dev> gro_ipv4_max_size <val>`. For enabling Big TCP.
	GROIPv4MaxSize *int32 `json:"groIPv4MaxSize,omitempty"`

	// DisableEBPFPrograms, if true, attempts to detach all eBPF programs
	// (both TC and TCX) from the network interface assigned to the Pod.
	DisableEBPFPrograms *bool `json:"disableEbpfPrograms,omitempty"`
}

InterfaceConfig represents the configuration for a single network interface. These are fundamental properties, often managed using `ip link` commands.

type NeighborConfig added in v0.8.0

type NeighborConfig struct {
	// Destination is the target IP address.
	Destination string `json:"destination,omitempty"`
	// HardwareAddr is the MAC address of the neighbor.
	HardwareAddr string `json:"hardwareAddr,omitempty"`
}

NeighborConfig represents a neighbor (ARP/NDP) entry.

type NetworkConfig

type NetworkConfig struct {
	// Interface defines core properties of the network interface.
	// Settings here are typically managed by `ip link` commands.
	Interface InterfaceConfig `json:"interface"`

	// Routes defines static routes to be configured for this interface.
	Routes []RouteConfig `json:"routes,omitempty"`

	// Rules defines routing rules to be configured for this interface.
	Rules []RuleConfig `json:"rules,omitempty"`

	// Neighbors defines permanent neighbor (ARP/NDP) entries to be added for this interface.
	Neighbors []NeighborConfig `json:"neighbors,omitempty"`

	// Ethtool defines hardware offload features and other settings managed by `ethtool`.
	Ethtool *EthtoolConfig `json:"ethtool,omitempty"`
}

NetworkConfig represents the desired state of all network interfaces and their associated routes, along with ethtool and sysctl configurations to be applied within the Pod's network namespace.

func ValidateConfig

func ValidateConfig(raw *runtime.RawExtension) (*NetworkConfig, []error)

ValidateConfig unmarshals and validates the NetworkConfig from a runtime.RawExtension. It performs strict unmarshalling and then calls specific validation functions for each part of the config. Returns the parsed NetworkConfig and a slice of errors if any validation fails.

type RouteConfig

type RouteConfig struct {
	// Destination is the target network in CIDR format (e.g., "0.0.0.0/0", "10.0.0.0/8").
	Destination string `json:"destination,omitempty"`
	// Gateway is the IP address of the gateway for this route.
	Gateway string `json:"gateway,omitempty"`
	// Source is an optional source IP address for policy routing.
	Source string `json:"source,omitempty"`
	// Scope is the scope of the route (e.g., link, host, global).
	// Refers to Linux route scopes (e.g., 0 for RT_SCOPE_UNIVERSE, 253 for RT_SCOPE_LINK).
	Scope uint8 `json:"scope,omitempty"`
	// Table is the routing table to use for the route.
	Table int `json:"table,omitempty"`
}

RouteConfig represents a network route configuration.

type RuleConfig added in v1.0.1

type RuleConfig struct {
	// Priority is the priority of the rule.
	Priority int `json:"priority,omitempty"`
	// Source is the source IP address for the rule.
	Source string `json:"source,omitempty"`
	// Destination is the destination IP address for the rule.
	Destination string `json:"destination,omitempty"`
	// Table is the routing table to use for the rule.
	Table int `json:"table,omitempty"`
}

RuleConfig represents a network rule configuration.

Jump to

Keyboard shortcuts

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