Documentation ¶
Index ¶
- Variables
- func DeviceNames(devs []*Device) (names []string)
- func HasDefaultRoute(tbl statedb.Table[*Route], rxn statedb.ReadTxn, linkIndex int) bool
- func NewDeviceTable() (statedb.RWTable[*Device], error)
- func NewL2AnnounceTable() (statedb.RWTable[*L2AnnounceEntry], error)
- func NewNodeAddressTable() (statedb.RWTable[NodeAddress], error)
- func NewNodeAddressing(localNode *node.LocalNodeStore, db *statedb.DB, ...) types.NodeAddressing
- func NewRouteTable() (statedb.RWTable[*Route], error)
- type AddressScopeMax
- type Device
- type DeviceAddress
- type HardwareAddr
- type L2AnnounceEntry
- type L2AnnounceKey
- type NodeAddress
- type NodeAddressConfig
- type Route
- type RouteID
Constants ¶
This section is empty.
Variables ¶
var ( DeviceIDIndex = statedb.Index[*Device, int]{ Name: "id", FromObject: func(d *Device) index.KeySet { return index.NewKeySet(index.Int(d.Index)) }, FromKey: index.Int, Unique: true, } DeviceNameIndex = statedb.Index[*Device, string]{ Name: "name", FromObject: func(d *Device) index.KeySet { return index.NewKeySet(index.String(d.Name)) }, FromKey: index.String, } DeviceSelectedIndex = statedb.Index[*Device, bool]{ Name: "selected", FromObject: func(d *Device) index.KeySet { return index.NewKeySet(index.Bool(d.Selected)) }, FromKey: index.Bool, } )
var ( L2AnnounceIDIndex = statedb.Index[*L2AnnounceEntry, L2AnnounceKey]{ Name: "id", FromObject: func(b *L2AnnounceEntry) index.KeySet { return index.NewKeySet(b.Key()) }, FromKey: L2AnnounceKey.Key, Unique: true, } L2AnnounceOriginIndex = statedb.Index[*L2AnnounceEntry, resource.Key]{ Name: "origin", FromObject: func(b *L2AnnounceEntry) index.KeySet { return index.StringerSlice(b.Origins) }, FromKey: index.Stringer[resource.Key], } )
var ( // NodeAddressIndex is the primary index for node addresses: // // var nodeAddresses Table[NodeAddress] // nodeAddresses.First(txn, NodeAddressIndex.Query(netip.MustParseAddr("1.2.3.4"))) NodeAddressIndex = statedb.Index[NodeAddress, netip.Addr]{ Name: "id", FromObject: func(a NodeAddress) index.KeySet { return index.NewKeySet(index.NetIPAddr(a.Addr)) }, FromKey: index.NetIPAddr, Unique: true, } NodeAddressDeviceNameIndex = statedb.Index[NodeAddress, string]{ Name: "name", FromObject: func(a NodeAddress) index.KeySet { return index.NewKeySet(index.String(a.DeviceName)) }, FromKey: index.String, Unique: false, } NodeAddressTableName statedb.TableName = "node-addresses" // NodeAddressCell provides Table[NodeAddress] and a background controller // that derives the node addresses from the low-level Table[*Device]. // // The Table[NodeAddress] contains the actual assigned addresses on the node, // but not for example external Kubernetes node addresses that may be merely // NATd to a private address. Those can be queried through [node.LocalNodeStore]. NodeAddressCell = cell.Module( "node-address", "Table of node addresses derived from system network devices", cell.ProvidePrivate(NewNodeAddressTable), cell.Provide( newNodeAddressController, newAddressScopeMax, ), cell.Config(NodeAddressConfig{}), ) )
var ( RouteIDIndex = statedb.Index[*Route, RouteID]{ Name: "id", FromObject: func(r *Route) index.KeySet { return index.NewKeySet( RouteID{ Table: r.Table, LinkIndex: r.LinkIndex, Dst: r.Dst, }.Key(), ) }, FromKey: RouteID.Key, Unique: true, } RouteLinkIndex = statedb.Index[*Route, int]{ Name: "LinkIndex", FromObject: func(r *Route) index.KeySet { return index.NewKeySet(index.Int(r.LinkIndex)) }, FromKey: index.Int, } )
var NodeAddressingCell = cell.Module( "node-addressing", "Accessors for looking up local node IP addresses", cell.Provide(NewNodeAddressing), )
NodeAddressingCell provides the [NodeAddressing] interface that provides access to local node addressing information. This will be eventually superceded by Table[NodeAddress].
Functions ¶
func DeviceNames ¶
DeviceNames extracts the device names from a slice of devices.
func HasDefaultRoute ¶
func NewL2AnnounceTable ¶ added in v1.15.0
func NewL2AnnounceTable() (statedb.RWTable[*L2AnnounceEntry], error)
func NewNodeAddressTable ¶ added in v1.15.0
func NewNodeAddressTable() (statedb.RWTable[NodeAddress], error)
func NewNodeAddressing ¶ added in v1.15.0
func NewNodeAddressing(localNode *node.LocalNodeStore, db *statedb.DB, nodeAddresses statedb.Table[NodeAddress], devices statedb.Table[*Device]) types.NodeAddressing
Types ¶
type AddressScopeMax ¶ added in v1.15.0
type AddressScopeMax uint8
AddressScopeMax sets the maximum scope an IP address can have. A scope is defined in rtnetlink(7) as the distance to the destination where a lower number signifies a wider scope with RT_SCOPE_UNIVERSE (0) being the widest. Definitions in Go are in unix package, e.g. unix.RT_SCOPE_UNIVERSE and so on.
This defaults to RT_SCOPE_LINK-1 (defaults.AddressScopeMax) and can be set by the user with --local-max-addr-scope.
type Device ¶
type Device struct { Index int // positive integer that starts at one, zero is never used MTU int // maximum transmission unit Name string // e.g., "en0", "lo0", "eth0.100" HardwareAddr HardwareAddr // IEEE MAC-48, EUI-48 and EUI-64 form Flags net.Flags // e.g. net.FlagUp, net.eFlagLoopback, net.FlagMulticast Addrs []DeviceAddress // Addresses assigned to the device RawFlags uint32 // Raw interface flags Type string // Device type, e.g. "veth" etc. MasterIndex int // Index of the master device (e.g. bridge or bonding device) Selected bool // True if this is an external facing device NotSelectedReason string // Reason why this device was not selected }
Device is a local network device along with addresses associated with it.
The devices that are selected are the external facing native devices that Cilium will use with features such as load-balancing, host firewall and routing. For the selection logic applied see 'pkg/datapath/linux/devices_controller.go'.
func SelectedDevices ¶
SelectedDevices returns the external facing network devices to use for load-balancing, host firewall and routing.
The invalidated channel is closed when devices have changed and should be requeried with a new transaction.
func (*Device) TableHeader ¶ added in v1.15.0
type DeviceAddress ¶
type DeviceAddress struct { Addr netip.Addr Secondary bool Scope uint8 // Address scope, e.g. unix.RT_SCOPE_LINK, unix.RT_SCOPE_HOST etc. }
func SortedAddresses ¶ added in v1.15.5
func SortedAddresses(addrs []DeviceAddress) []DeviceAddress
sortedAddresses returns a copy of the addresses sorted by following predicates (first predicate matching in this order wins): - Primary (e.g. !IFA_F_SECONDARY) - Scope, with lower scope going first (e.g. UNIVERSE before LINK) - Public addresses before private (e.g. 1.2.3.4 before 192.168.1.1) - By address itself (192.168.1.1 before 192.168.1.2)
The sorting order affects which address is marked 'Primary' and which is picked as the 'NodePort' address (when --nodeport-addresses is not specified).
func (*DeviceAddress) AsIP ¶
func (d *DeviceAddress) AsIP() net.IP
func (*DeviceAddress) String ¶ added in v1.15.5
func (d *DeviceAddress) String() string
type HardwareAddr ¶ added in v1.15.0
type HardwareAddr []byte
HardwareAddr is the physical address for a network device. Defined here instead of using net.Hardwareaddr for proper JSON marshalling.
func (HardwareAddr) MarshalJSON ¶ added in v1.15.0
func (a HardwareAddr) MarshalJSON() ([]byte, error)
func (HardwareAddr) String ¶ added in v1.15.0
func (a HardwareAddr) String() string
type L2AnnounceEntry ¶
type L2AnnounceEntry struct { L2AnnounceKey // The key of the services for which this proxy entry was added Origins []resource.Key }
func (*L2AnnounceEntry) DeepCopy ¶
func (pne *L2AnnounceEntry) DeepCopy() *L2AnnounceEntry
func (*L2AnnounceEntry) TableHeader ¶ added in v1.15.0
func (*L2AnnounceEntry) TableHeader() []string
func (*L2AnnounceEntry) TableRow ¶ added in v1.15.0
func (e *L2AnnounceEntry) TableRow() []string
type L2AnnounceKey ¶
type L2AnnounceKey struct { // IP and network interface are the primary key of this entry IP netip.Addr NetworkInterface string }
func (L2AnnounceKey) Key ¶
func (k L2AnnounceKey) Key() index.Key
type NodeAddress ¶ added in v1.15.0
type NodeAddress struct { Addr netip.Addr // NodePort is true if this address is to be used for NodePort. // If --nodeport-addresses is set, then all addresses on native // devices that are contained within the specified CIDRs are chosen. // If it is not set, then only the primary IPv4 and/or IPv6 address // of each native device is used. NodePort bool // Primary is true if this is the primary IPv4 or IPv6 address of this device. // This is mainly used to pick the address for BPF masquerading. Primary bool // DeviceName is the name of the network device from which this address // is derived from. DeviceName string }
NodeAddress is an IP address assigned to a network interface on a Cilium node that is considered a "host" IP address.
func (*NodeAddress) IP ¶ added in v1.15.0
func (n *NodeAddress) IP() net.IP
func (*NodeAddress) String ¶ added in v1.15.0
func (n *NodeAddress) String() string
func (NodeAddress) TableHeader ¶ added in v1.15.0
func (n NodeAddress) TableHeader() []string
func (NodeAddress) TableRow ¶ added in v1.15.0
func (n NodeAddress) TableRow() []string
type NodeAddressConfig ¶ added in v1.15.0
type NodeAddressConfig struct {
NodePortAddresses []*cidr.CIDR `mapstructure:"nodeport-addresses"`
}
func (NodeAddressConfig) Flags ¶ added in v1.15.0
func (NodeAddressConfig) Flags(flags *pflag.FlagSet)