Documentation
¶
Index ¶
Constants ¶
const ( // MapName is the name of the subnet map. MapName = "cilium_subnet_map" // MaxEntries is the maximum number of keys that can be present in the // subnet map. MaxEntries = 1024 SubnetKeyIPv4 uint8 = 1 SubnetKeyIPv6 uint8 = 2 )
const TableName = "subnet-identities"
Variables ¶
var Cell = cell.Module( "subnet-map", "Manages the subnet to identity BPF map", cell.Provide( newSubnetMap, newSubnetEntryTable, statedb.RWTable[SubnetTableEntry].ToTable, scriptCommands, ), cell.Invoke( registerReconciler, bpf.TablePressureMetrics[SubnetTableEntry, subnetMap], ), )
Cell manages subnet routing information for hybrid routing mode.
This cell provides:
- A BPF map that stores subnet-to-identity mappings
- A StateDB table for tracking subnet configurations from users
- A reconciler that syncs the table to the BPF map
The BPF map is used by the datapath to look up subnets and determine whether to use tunnel (encapsulation) or native (direct) routing for packets sent to those subnets. This enables different subnets to use different routing modes in the same cluster. The cell is only active when routing mode is set to hybrid.
var SubnetIndex = statedb.Index[SubnetTableEntry, netip.Prefix]{ Name: "prefix", FromObject: func(s SubnetTableEntry) index.KeySet { return index.NewKeySet(index.NetIPPrefix(s.Key)) }, FromKey: index.NetIPPrefix, FromString: index.NetIPPrefixString, Unique: true, }
SubnetIndex is the primary index for SubnetEntry, indexing by Prefix.
Functions ¶
Types ¶
type SubnetMapKey ¶
type SubnetMapKey struct {
Prefixlen uint32 `align:"lpm_key"`
Pad0 uint16 `align:"pad0"`
Pad1 uint8 `align:"pad1"`
Family uint8 `align:"family"`
IP types.IPv6 `align:"$union0"`
}
SubnetMapKey implements the bpf.MapKey interface. Must be in sync with struct subnet_key in <bpf/lib/subnet.h>
func (*SubnetMapKey) New ¶
func (k *SubnetMapKey) New() bpf.MapKey
func (SubnetMapKey) Prefix ¶
func (k SubnetMapKey) Prefix() netip.Prefix
func (SubnetMapKey) String ¶
func (k SubnetMapKey) String() string
type SubnetMapValue ¶
type SubnetMapValue struct {
Identity uint32 `align:"identity"`
}
SubnetMapValue implements the bpf.MapValue interface. Must be in sync with struct subnet_value in <bpf/lib/subnet.h>
func NewValue ¶
func NewValue(identity uint32) SubnetMapValue
NewValue returns a Value based on the provided identity.
func (*SubnetMapValue) New ¶
func (v *SubnetMapValue) New() bpf.MapValue
func (*SubnetMapValue) String ¶
func (v *SubnetMapValue) String() string
type SubnetTableEntry ¶
type SubnetTableEntry struct {
Key netip.Prefix
// Identity is the uint64 identifier associated with this subnet.
Value uint32
// Status represents the reconciliation status of the subnet entry.
Status reconciler.Status
}
func NewSubnetEntry ¶
func NewSubnetEntry(key netip.Prefix, value uint32) SubnetTableEntry
func (SubnetTableEntry) BinaryKey ¶
func (s SubnetTableEntry) BinaryKey() encoding.BinaryMarshaler
BinaryKey returns the binary representation of the subnet prefix for the eBPF map key.
func (SubnetTableEntry) BinaryValue ¶
func (s SubnetTableEntry) BinaryValue() encoding.BinaryMarshaler
BinaryValue returns the binary representation of the identity for the eBPF map value.
func (SubnetTableEntry) TableHeader ¶
func (s SubnetTableEntry) TableHeader() []string
TableHeader returns the header for the table representation of SubnetEntry.
func (SubnetTableEntry) TableRow ¶
func (s SubnetTableEntry) TableRow() []string
TableRow returns the row representation of SubnetEntry.