routing

package
v0.10.3 Latest Latest
Warning

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

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

Documentation

Overview

Package routing defines a common interface used to configure the routing tables and policy routing rules in order to reach the remote networks of the peering clusters. Based on the operator the routes are handled differently hence different implementation of the interfaces lives in this package.

Index

Constants

View Source
const (
	// DefaultScope is the default value for the route scope.
	DefaultScope netlink.Scope = 0
	// DefaultFlags is the default value for the route flags.
	DefaultFlags int = 0
)

Variables

This section is empty.

Functions

func AddPolicyRoutingRule

func AddPolicyRoutingRule(fromSubnet, toSubnet string, tableID int) (bool, error)

AddPolicyRoutingRule adds a new policy routing rule.

func AddRoute

func AddRoute(dstNet, gwIP string, iFaceIndex, tableID, flags int, scope netlink.Scope) (bool, error)

AddRoute adds a new route on the given interface.

func DelPolicyRoutingRule

func DelPolicyRoutingRule(fromSubnet, toSubnet string, tableID int) (bool, error)

DelPolicyRoutingRule removes a policy routing rule described by the given parameters.

func DelRoute

func DelRoute(dstNet, gwIP string, iFaceIndex, tableID int) (bool, error)

DelRoute removes a route described by the given parameters.

func EnableIPForwarding

func EnableIPForwarding() error

EnableIPForwarding enables ipv4 forwarding in the current network namespace.

Types

type DirectRoutingManager

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

DirectRoutingManager implements the routing manager interface. Nodes has to be on the same network otherwise this solution will not work.

func (*DirectRoutingManager) CleanPolicyRules

func (drm *DirectRoutingManager) CleanPolicyRules() error

CleanPolicyRules removes all the policy rules pointing to the custom routing table used by the route manager.

func (*DirectRoutingManager) CleanRoutingTable

func (drm *DirectRoutingManager) CleanRoutingTable() error

CleanRoutingTable removes all the routes from the custom routing table used by the route manager.

func (*DirectRoutingManager) EnsureRoutesPerCluster

func (drm *DirectRoutingManager) EnsureRoutesPerCluster(tep *netv1alpha1.TunnelEndpoint) (bool, error)

EnsureRoutesPerCluster accepts as input a netv1alpha.tunnelendpoint. It inserts the routes if they do not exist or updates them if they are outdated. Returns true if the routes have been configured, false if the routes are already configured. An error if something goes wrong and the routes can not be configured.

func (*DirectRoutingManager) RemoveRoutesPerCluster

func (drm *DirectRoutingManager) RemoveRoutesPerCluster(tep *netv1alpha1.TunnelEndpoint) (bool, error)

RemoveRoutesPerCluster accepts as input a netv1alpha.tunnelendpoint. It deletes the routes if they do exist. Returns true if the routes exist and have been deleted, false if nothing is removed. An error if something goes wrong and the routes can not be removed.

type GatewayRoutingManager

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

GatewayRoutingManager implements the routing manager interface. Used by the gateway operator to configure the routes for remote clusters.

func (*GatewayRoutingManager) CleanPolicyRules

func (grm *GatewayRoutingManager) CleanPolicyRules() error

CleanPolicyRules stub function, as the gateway only operates in custom network namespace.

func (*GatewayRoutingManager) CleanRoutingTable

func (grm *GatewayRoutingManager) CleanRoutingTable() error

CleanRoutingTable stub function, as the gateway only operates in custom network namespace.

func (*GatewayRoutingManager) EnsureRoutesPerCluster

func (grm *GatewayRoutingManager) EnsureRoutesPerCluster(tep *netv1alpha1.TunnelEndpoint) (bool, error)

EnsureRoutesPerCluster accepts as input a netv1alpha.tunnelendpoint. It inserts the routes if they do not exist or updates them if they are outdated. Returns true if the routes have been configured, false if the routes are already configured. An error if something goes wrong and the routes can not be configured.

func (*GatewayRoutingManager) RemoveRoutesPerCluster

func (grm *GatewayRoutingManager) RemoveRoutesPerCluster(tep *netv1alpha1.TunnelEndpoint) (bool, error)

RemoveRoutesPerCluster accepts as input a netv1alpha.tunnelendpoint. It deletes the routes if they do exist. Returns true if the routes exist and have been deleted, false if nothing is removed. An error if something goes wrong and the routes can not be removed.

type Routing

type Routing interface {
	EnsureRoutesPerCluster(tep *netv1alpha1.TunnelEndpoint) (bool, error)
	RemoveRoutesPerCluster(tep *netv1alpha1.TunnelEndpoint) (bool, error)
	CleanRoutingTable() error
	CleanPolicyRules() error
}

Routing interface used to configure the routing rules for peering clusters.

func NewDirectRoutingManager

func NewDirectRoutingManager(routingTableID int, podIP string) (Routing, error)

NewDirectRoutingManager accepts as input a routing table ID and the IP address of the pod. Returns a DirectRoutingManager ready to be used or an error.

func NewGatewayRoutingManager

func NewGatewayRoutingManager(routingTableID int, tunnelDevice netlink.Link) (Routing, error)

NewGatewayRoutingManager returns a GatewayRoutingManager ready to be used or an error.

func NewVxlanRoutingManager

func NewVxlanRoutingManager(routingTableID int, podIP, vxlanNetPrefix string, vxlanDevice *overlay.VxlanDevice) (Routing, error)

NewVxlanRoutingManager returns a VxlanRoutingManager ready to be used or an error.

type VxlanRoutingManager

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

VxlanRoutingManager implements the routing manager interface. Used when nodes are not in the same network.

func (*VxlanRoutingManager) CleanPolicyRules

func (vrm *VxlanRoutingManager) CleanPolicyRules() error

CleanPolicyRules removes all the policy rules pointing to the custom routing table used by the route manager.

func (*VxlanRoutingManager) CleanRoutingTable

func (vrm *VxlanRoutingManager) CleanRoutingTable() error

CleanRoutingTable removes all the routes from the custom routing table used by the route manager.

func (*VxlanRoutingManager) EnsureRoutesPerCluster

func (vrm *VxlanRoutingManager) EnsureRoutesPerCluster(tep *netv1alpha1.TunnelEndpoint) (bool, error)

EnsureRoutesPerCluster accepts as input a netv1alpha.tunnelendpoint. It inserts the routes if they do not exist or updates them if they are outdated. Returns true if the routes have been configured, false if the routes are already configured. An error if something goes wrong and the routes can not be configured.

func (*VxlanRoutingManager) RemoveRoutesPerCluster

func (vrm *VxlanRoutingManager) RemoveRoutesPerCluster(tep *netv1alpha1.TunnelEndpoint) (bool, error)

RemoveRoutesPerCluster accepts as input a netv1alpha.tunnelendpoint. It deletes the routes if they do exist. Returns true if the routes exist and have been deleted, false if nothing is removed. An error if something goes wrong and the routes can not be removed.

Jump to

Keyboard shortcuts

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