routetable

package
v0.0.0-...-21cfbab Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: Apache-2.0, Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Use this for targets with no outbound interface.
	InterfaceNone = "*NoOIF*"
)

Variables

View Source
var (
	GetFailed       = errors.New("netlink get operation failed")
	ConnectFailed   = errors.New("connect to netlink failed")
	ListFailed      = errors.New("netlink list operation failed")
	UpdateFailed    = errors.New("netlink update operation failed")
	IfaceNotPresent = errors.New("interface not present")
	IfaceDown       = errors.New("interface down")
	IfaceGrace      = errors.New("interface in cleanup grace period")
)

Functions

This section is empty.

Types

type DummyTable

type DummyTable struct {
}

func (*DummyTable) Apply

func (_ *DummyTable) Apply() error

func (*DummyTable) OnIfaceStateChanged

func (_ *DummyTable) OnIfaceStateChanged(_ string, _ ifacemonitor.State)

func (*DummyTable) QueueResync

func (_ *DummyTable) QueueResync()

func (*DummyTable) RouteRemove

func (_ *DummyTable) RouteRemove(_ string, _ ip.CIDR)

func (*DummyTable) RouteUpdate

func (_ *DummyTable) RouteUpdate(_ string, _ Target)

func (*DummyTable) SetL2Routes

func (_ *DummyTable) SetL2Routes(_ string, _ []L2Target)

func (*DummyTable) SetRoutes

func (_ *DummyTable) SetRoutes(_ string, _ []Target)

type L2Target

type L2Target struct {
	// For VXLAN targets, this is the node's real IP address.
	IP ip.Addr

	// For VXLAN targets, this is the MAC address of the remote VTEP.
	VTEPMAC net.HardwareAddr

	// For VXLAN targets, this is the IP address of the remote VTEP.
	GW ip.Addr
}

type RouteTable

type RouteTable struct {
	// contains filtered or unexported fields
}

RouteTable manages calico routes for a specific table. It reconciles the routes that we desire to have for calico managed devices with what is the current status in the dataplane. That is, it removes any routes that we do not desire and adds those that we do. It skips over devices that we do not manage not to interfare with other users of the route tables.

func New

func New(
	interfaceRegexes []string,
	ipVersion uint8,
	vxlan bool,
	netlinkTimeout time.Duration,
	deviceRouteSourceAddress net.IP,
	deviceRouteProtocol netlink.RouteProtocol,
	removeExternalRoutes bool,
	tableIndex int,
	opReporter logutils.OpRecorder,
	featureDetector environment.FeatureDetectorIface,
	opts ...RouteTableOpt,
) *RouteTable

func NewWithShims

func NewWithShims(
	interfaceRegexes []string,
	ipVersion uint8,
	newNetlinkHandle func() (netlinkshim.Interface, error),
	vxlan bool,
	netlinkTimeout time.Duration,
	addStaticARPEntry func(cidr ip.CIDR, destMAC net.HardwareAddr, ifaceName string) error,
	conntrack conntrackIface,
	timeShim timeshim.Interface,
	deviceRouteSourceAddress net.IP,
	deviceRouteProtocol netlink.RouteProtocol,
	removeExternalRoutes bool,
	tableIndex int,
	opReporter logutils.OpRecorder,
	featureDetector environment.FeatureDetectorIface,
	opts ...RouteTableOpt,
) *RouteTable

NewWithShims is a test constructor, which allows netlink, arp and time to be replaced by shims.

func (*RouteTable) Apply

func (r *RouteTable) Apply() error

func (*RouteTable) OnIfaceStateChanged

func (r *RouteTable) OnIfaceStateChanged(ifaceName string, state ifacemonitor.State)

func (*RouteTable) QueueResync

func (r *RouteTable) QueueResync()

func (*RouteTable) RouteRemove

func (r *RouteTable) RouteRemove(ifaceName string, cidr ip.CIDR)

RouteRemove removes the route with the specified CIDR. These deltas will be applied to any routes set using SetRoute.

func (*RouteTable) RouteUpdate

func (r *RouteTable) RouteUpdate(ifaceName string, target Target)

RouteUpdate updates the route keyed off the target CIDR. These deltas will be applied to any routes set using SetRoute.

func (*RouteTable) SetL2Routes

func (r *RouteTable) SetL2Routes(ifaceName string, targets []L2Target)

func (*RouteTable) SetRoutes

func (r *RouteTable) SetRoutes(ifaceName string, targets []Target)

SetRoutes sets the full set of targets for the specified interface. This recalculates the deltas from the current set of programmed routes.

type RouteTableInterface

type RouteTableInterface interface {
	RouteTableSyncer
	SetRoutes(ifaceName string, targets []Target)
	SetL2Routes(ifaceName string, targets []L2Target)
	RouteRemove(ifaceName string, cidr ip.CIDR)
	RouteUpdate(ifaceName string, target Target)
}

RouteTable is the interface provided by the standard routetable module used to program the RIB.

type RouteTableOpt

type RouteTableOpt func(table *RouteTable)

func WithLivenessCB

func WithLivenessCB(cb func()) RouteTableOpt

func WithRouteCleanupGracePeriod

func WithRouteCleanupGracePeriod(routeCleanupGracePeriod time.Duration) RouteTableOpt

type RouteTableSyncer

type RouteTableSyncer interface {
	OnIfaceStateChanged(string, ifacemonitor.State)
	QueueResync()
	Apply() error
}

RouteTableSyncer is the interface used to manage data-sync of route table managers. This includes notification of interface state changes, hooks to queue a full resync and apply routing updates.

type Target

type Target struct {
	Type    TargetType
	CIDR    ip.CIDR
	GW      ip.Addr
	Src     ip.Addr
	DestMAC net.HardwareAddr
}

func (Target) Equal

func (t Target) Equal(t2 Target) bool

func (Target) Flags

func (t Target) Flags() netlink.NextHopFlag

func (Target) RouteScope

func (t Target) RouteScope() netlink.Scope

func (Target) RouteType

func (t Target) RouteType() int

type TargetType

type TargetType string
const (
	TargetTypeLocal            TargetType = "local"
	TargetTypeVXLAN            TargetType = "vxlan"
	TargetTypeNoEncap          TargetType = "noencap"
	TargetTypeOnLink           TargetType = "onlink"
	TargetTypeGlobalUnicast    TargetType = "global-unicast"
	TargetTypeLinkLocalUnicast TargetType = "local-unicast"

	// The following target types should be used with InterfaceNone.
	TargetTypeBlackhole   TargetType = "blackhole"
	TargetTypeProhibit    TargetType = "prohibit"
	TargetTypeThrow       TargetType = "throw"
	TargetTypeUnreachable TargetType = "unreachable"
)

Jump to

Keyboard shortcuts

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