Documentation
¶
Index ¶
- Variables
- type AdminDistance
- type DesiredRoute
- func (dr *DesiredRoute) Clone() *DesiredRoute
- func (dr *DesiredRoute) GetFullKey() DesiredRouteKey
- func (dr *DesiredRoute) GetOwnerlessKey() DesiredRouteKey
- func (dr *DesiredRoute) GetStatus() reconciler.Status
- func (dr *DesiredRoute) SetStatus(s reconciler.Status) *DesiredRoute
- func (dr *DesiredRoute) TableHeader() []string
- func (dr *DesiredRoute) TableRow() []string
- func (dr *DesiredRoute) ValidateAndSetDefaults() error
- type DesiredRouteKey
- type DesiredRouteManager
- func (m *DesiredRouteManager) DeleteRoute(route DesiredRoute) error
- func (m *DesiredRouteManager) FinalizeInitializer(initializer Initializer)
- func (m *DesiredRouteManager) GetOrRegisterOwner(name string) (*RouteOwner, error)
- func (m *DesiredRouteManager) GetOwner(name string) (*RouteOwner, error)
- func (m *DesiredRouteManager) RegisterInitializer(name string) Initializer
- func (m *DesiredRouteManager) RegisterOwner(name string) (*RouteOwner, error)
- func (m *DesiredRouteManager) RemoveOwner(owner *RouteOwner) error
- func (m *DesiredRouteManager) UpsertRoute(route DesiredRoute) error
- func (m *DesiredRouteManager) UpsertRouteWait(route DesiredRoute) error
- type Initializer
- type MultiPathInfo
- type NexthopInfo
- type RouteOwner
- type RouteReconcilerMetrics
- type Scope
- type TableID
- type Type
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrOwnerExists = errors.New("owner already exists") ErrOwnerDoesNotExist = errors.New("owner does not exist") )
View Source
var ( DesiredRouteIndex = statedb.Index[*DesiredRoute, DesiredRouteKey]{ Name: "id", FromObject: func(d *DesiredRoute) index.KeySet { return index.NewKeySet(d.GetFullKey().Key()) }, FromKey: DesiredRouteKey.Key, FromString: func(s string) (index.Key, error) { parts := strings.Split(s, ":") if len(parts) > 3 { return nil, fmt.Errorf("bad key, expected \"owner[:table[:prefix[:priority]]]\", got %s", s) } var key DesiredRouteKey if len(parts) >= 2 { if err := key.Table.FromString(parts[1]); err != nil { return nil, fmt.Errorf("bad key, expected \"owner[:table[:prefix[:priority]]]\", got %s: %w", s, err) } } if len(parts) >= 3 { var err error key.Prefix, err = netip.ParsePrefix(parts[2]) if err != nil { return nil, fmt.Errorf("bad key, expected \"owner[:table[:prefix[:priority]]]\", got %s: %w", s, err) } } if len(parts) >= 4 { prio, err := strconv.ParseUint(parts[3], 10, 32) if err != nil { return nil, fmt.Errorf("bad key, expected \"owner[:table[:prefix[:priority]]]\", got %s: %w", s, err) } key.Priority = uint32(prio) } return key.Key(), nil }, Unique: true, } DesiredRouteTablePrefixIndex = statedb.Index[*DesiredRoute, DesiredRouteKey]{ Name: "table-prefix", FromObject: func(d *DesiredRoute) index.KeySet { return index.NewKeySet(d.GetOwnerlessKey().Key()) }, FromKey: func(key DesiredRouteKey) index.Key { key.Owner = nil return key.Key() }, FromString: func(s string) (index.Key, error) { parts := strings.Split(s, ":") var key DesiredRouteKey if err := key.Table.FromString(parts[0]); err != nil { return nil, fmt.Errorf("bad key, expected \"table:prefix:priority\", got %s: %w", s, err) } if len(parts) < 2 { return key.Key(), nil } var err error key.Prefix, err = netip.ParsePrefix(parts[1]) if err != nil { return nil, err } if len(parts) < 3 { return key.Key(), nil } prio, err := strconv.ParseUint(parts[2], 10, 32) if err != nil { return nil, fmt.Errorf("bad key, expected \"table:prefix:priority\", got %s: %w", s, err) } key.Priority = uint32(prio) return key.Key(), nil }, Unique: false, } DesiredRouteTableDeviceIndex = statedb.Index[*DesiredRoute, int]{ Name: "device", FromObject: func(obj *DesiredRoute) index.KeySet { if obj.Device == nil { return index.NewKeySet() } return index.NewKeySet(index.Int(obj.Device.Index)) }, FromKey: func(key int) index.Key { return index.Int(key) }, Unique: false, } )
View Source
var Cell = cell.Module( "route-reconciler", "Reconciles desired routes to the Linux kernel routing table", TableCell, cell.Provide(registerReconciler), cell.Invoke(desiredRouteRefresher), )
View Source
var TableCell = cell.Group( cell.Provide(newDesiredRouteManager), cell.ProvidePrivate(newDesiredRouteTable), cell.Provide(statedb.RWTable[*DesiredRoute].ToTable), )
Functions ¶
This section is empty.
Types ¶
type AdminDistance ¶
type AdminDistance int
const ( // AdminDistanceDefault is the default administrative distance for routes // emitted by Cilium itself. AdminDistanceDefault AdminDistance = 100 )
type DesiredRoute ¶
type DesiredRoute struct {
// Composite primary key for the route.
Owner *RouteOwner
Table TableID
Prefix netip.Prefix
Priority uint32
// The administrative distance of the route, lower values are preferred.
AdminDistance AdminDistance
// Optional, if [netip.Addr.IsValid] then nexthop is specified.
Nexthop netip.Addr
// Optional, if [netip.Addr.IsValid] then source address is specified.
Src netip.Addr
// Optional, non-nil if device is specified.
Device *tables.Device
// Optional, if it's empty, no multipath is specified. This is mutually
// exclusive with Nexthop and Device.
MultiPath MultiPathInfo
// Optional, if 0 no MTU is specified.
MTU uint32
// Optional, if 0 no scope is specified.
Scope Scope
// Optional, if 0 no type is specified.
Type Type
// contains filtered or unexported fields
}
func (*DesiredRoute) Clone ¶
func (dr *DesiredRoute) Clone() *DesiredRoute
func (*DesiredRoute) GetFullKey ¶
func (dr *DesiredRoute) GetFullKey() DesiredRouteKey
func (*DesiredRoute) GetOwnerlessKey ¶
func (dr *DesiredRoute) GetOwnerlessKey() DesiredRouteKey
func (*DesiredRoute) GetStatus ¶
func (dr *DesiredRoute) GetStatus() reconciler.Status
func (*DesiredRoute) SetStatus ¶
func (dr *DesiredRoute) SetStatus(s reconciler.Status) *DesiredRoute
func (*DesiredRoute) TableHeader ¶
func (dr *DesiredRoute) TableHeader() []string
func (*DesiredRoute) TableRow ¶
func (dr *DesiredRoute) TableRow() []string
func (*DesiredRoute) ValidateAndSetDefaults ¶
func (dr *DesiredRoute) ValidateAndSetDefaults() error
type DesiredRouteKey ¶
type DesiredRouteKey struct {
Owner *RouteOwner
Table TableID
Prefix netip.Prefix
Priority uint32
}
func (DesiredRouteKey) Key ¶
func (k DesiredRouteKey) Key() index.Key
func (DesiredRouteKey) MarshalBinary ¶
func (k DesiredRouteKey) MarshalBinary() ([]byte, error)
func (DesiredRouteKey) String ¶
func (k DesiredRouteKey) String() string
func (*DesiredRouteKey) UnmarshalBinary ¶
func (k *DesiredRouteKey) UnmarshalBinary(data []byte) error
type DesiredRouteManager ¶
type DesiredRouteManager struct {
// contains filtered or unexported fields
}
func (*DesiredRouteManager) DeleteRoute ¶
func (m *DesiredRouteManager) DeleteRoute(route DesiredRoute) error
func (*DesiredRouteManager) FinalizeInitializer ¶
func (m *DesiredRouteManager) FinalizeInitializer(initializer Initializer)
func (*DesiredRouteManager) GetOrRegisterOwner ¶
func (m *DesiredRouteManager) GetOrRegisterOwner(name string) (*RouteOwner, error)
func (*DesiredRouteManager) GetOwner ¶
func (m *DesiredRouteManager) GetOwner(name string) (*RouteOwner, error)
func (*DesiredRouteManager) RegisterInitializer ¶
func (m *DesiredRouteManager) RegisterInitializer(name string) Initializer
func (*DesiredRouteManager) RegisterOwner ¶
func (m *DesiredRouteManager) RegisterOwner(name string) (*RouteOwner, error)
func (*DesiredRouteManager) RemoveOwner ¶
func (m *DesiredRouteManager) RemoveOwner(owner *RouteOwner) error
func (*DesiredRouteManager) UpsertRoute ¶
func (m *DesiredRouteManager) UpsertRoute(route DesiredRoute) error
func (*DesiredRouteManager) UpsertRouteWait ¶
func (m *DesiredRouteManager) UpsertRouteWait(route DesiredRoute) error
type Initializer ¶
type Initializer struct {
// contains filtered or unexported fields
}
type MultiPathInfo ¶
type MultiPathInfo []*NexthopInfo
func (MultiPathInfo) String ¶
func (m MultiPathInfo) String() string
type NexthopInfo ¶
func (*NexthopInfo) String ¶
func (nh *NexthopInfo) String() string
type RouteOwner ¶
type RouteOwner struct {
// contains filtered or unexported fields
}
func (*RouteOwner) String ¶
func (o *RouteOwner) String() string
func (*RouteOwner) UnmarshalYAML ¶
func (o *RouteOwner) UnmarshalYAML(value *yaml.Node) error
type RouteReconcilerMetrics ¶
type RouteReconcilerMetrics *reconciler.ExpVarMetrics
type Type ¶
type Type uint8
const ( RTN_UNSPEC Type = 0x0 // a gateway or direct route RTN_UNICAST Type = 0x1 // packets matching a local route are sent up the network stack as destined for the local host RTN_LOCAL Type = 0x2 // a local broadcast route (sent as a broadcast) RTN_BROADCAST Type = 0x3 // a local broadcast route (sent as a unicast) RTN_ANYCAST Type = 0x4 // a multicast route RTN_MULTICAST Type = 0x5 // packets matching a blackhole route are silently dropped RTN_BLACKHOLE Type = 0x6 // packets matching an unreachable route are dropped and an ICMP unreachable message is sent RTN_UNREACHABLE Type = 0x7 // packets matching a prohibited route are dropped and an ICMP administratively prohibited message is sent RTN_PROHIBIT Type = 0x8 // packets matching a throw route cause a lookup error RTN_THROW Type = 0x9 // stateless NAT route RTN_NAT Type = 0xa )
func (*Type) FromString ¶
Click to show internal directories.
Click to hide internal directories.