tables

package
v1.15.4 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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,
	}
)
View Source
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],
	}
)
View Source
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{}),
	)
)
View Source
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,
	}
)
View Source
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

func DeviceNames(devs []*Device) (names []string)

DeviceNames extracts the device names from a slice of devices.

func HasDefaultRoute

func HasDefaultRoute(tbl statedb.Table[*Route], rxn statedb.ReadTxn, linkIndex int) bool

func NewDeviceTable added in v1.15.0

func NewDeviceTable() (statedb.RWTable[*Device], error)

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

func NewRouteTable added in v1.15.0

func NewRouteTable() (statedb.RWTable[*Route], error)

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

func SelectedDevices(tbl statedb.Table[*Device], txn statedb.ReadTxn) ([]*Device, <-chan struct{})

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) DeepCopy

func (d *Device) DeepCopy() *Device

func (*Device) HasIP

func (d *Device) HasIP(ip net.IP) bool

func (*Device) TableHeader added in v1.15.0

func (*Device) TableHeader() []string

func (*Device) TableRow added in v1.15.0

func (d *Device) TableRow() []string

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 (*DeviceAddress) AsIP

func (d *DeviceAddress) AsIP() net.IP

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)

type Route

type Route struct {
	Table     int
	LinkIndex int

	Scope uint8
	Dst   netip.Prefix
	Src   netip.Addr
	Gw    netip.Addr
}

func (*Route) DeepCopy

func (r *Route) DeepCopy() *Route

func (*Route) String

func (r *Route) String() string

func (*Route) TableHeader added in v1.15.0

func (*Route) TableHeader() []string

func (*Route) TableRow added in v1.15.0

func (r *Route) TableRow() []string

type RouteID

type RouteID struct {
	Table     int
	LinkIndex int
	Dst       netip.Prefix
}

func (RouteID) Key

func (id RouteID) Key() index.Key

Jump to

Keyboard shortcuts

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