tables

package
v1.15.0-pre.1 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: Apache-2.0 Imports: 9 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: func(idx int) []byte {
			return index.Int(idx)
		},
		Unique: true,
	}

	DeviceNameIndex = statedb.Index[*Device, string]{
		Name: "name",
		FromObject: func(d *Device) index.KeySet {
			return index.NewKeySet(index.String(d.Name))
		},
		FromKey: func(name string) []byte {
			return index.String(name)
		},
	}

	DeviceSelectedIndex = statedb.Index[*Device, bool]{
		Name: "selected",
		FromObject: func(d *Device) index.KeySet {
			return index.NewKeySet(index.Bool(d.Selected))
		},
		FromKey: func(selected bool) []byte {
			return index.Bool(selected)
		},
	}

	DeviceTableCell = statedb.NewTableCell[*Device](
		"devices",
		DeviceIDIndex,
		DeviceNameIndex,
		DeviceSelectedIndex,
	)
)
View Source
var (
	L2AnnounceIDIndex = statedb.Index[*L2AnnounceEntry, L2AnnounceKey]{
		Name: "id",
		FromObject: func(b *L2AnnounceEntry) index.KeySet {
			return index.NewKeySet(b.Key())
		},
		FromKey: func(id L2AnnounceKey) []byte {
			return id.Key()
		},
		Unique: true,
	}

	L2AnnounceOriginIndex = statedb.Index[*L2AnnounceEntry, resource.Key]{
		Name: "origin",
		FromObject: func(b *L2AnnounceEntry) index.KeySet {
			return index.StringerSlice(b.Origins)
		},
		FromKey: func(id resource.Key) []byte {
			return index.Stringer(id)
		},
	}

	L2AnnounceTableCell = statedb.NewTableCell[*L2AnnounceEntry](
		"l2-announce",
		L2AnnounceIDIndex,
		L2AnnounceOriginIndex,
	)
)
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: func(id RouteID) []byte {
			return id.Key()
		},
		Unique: true,
	}

	RouteLinkIndex = statedb.Index[*Route, int]{
		Name: "LinkIndex",
		FromObject: func(r *Route) index.KeySet {
			return index.NewKeySet(index.Int(r.LinkIndex))
		},
		FromKey: func(linkIndex int) []byte {
			return index.Int(linkIndex)
		},
	}

	RouteTableCell = statedb.NewTableCell[*Route](
		"routes",
		RouteIDIndex,
		RouteLinkIndex,
	)
)
View Source
var Cell = cell.Module(
	"datapath-tables",
	"Datapath state tables",

	L2AnnounceTableCell,
	DeviceTableCell,
	RouteTableCell,
)

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

Types

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 net.HardwareAddr // IEEE MAC-48, EUI-48 and EUI-64 form
	Flags        net.Flags        // e.g. net.FlagUp, net.eFlagLoopback, net.FlagMulticast

	Selected    bool            // If true this device can be used by Cilium
	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)
}

Device is a local network device along with addresses associated with it.

func SelectedDevices

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

SelectedDevices returns the network devices selected for Cilium use.

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

type DeviceAddress

type DeviceAddress struct {
	Addr  netip.Addr
	Scope uint8 // Routing table scope
}

func (*DeviceAddress) AsIP

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

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

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() []byte

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

type RouteID

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

func (RouteID) Key

func (id RouteID) Key() []byte

Jump to

Keyboard shortcuts

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