route

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2025 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Overview

Package route contains the logic to manage the linux routing rules.

Index

Constants

View Source
const (
	// RouteCategoryTargetKey is the key used by the route controller to reconcile only resources related to a group.
	RouteCategoryTargetKey = "networking.liqo.io/route-category"
	// RouteSubCategoryTargetKey is the key used by the route controller to reconcile only resources related to a subgroup.
	RouteSubCategoryTargetKey = "networking.liqo.io/route-subcategory"
	// RouteUniqueTargetKey is the key used by the route controller to reconcile only resources related to a single component.
	RouteUniqueTargetKey = "networking.liqo.io/route-unique"
)
View Source
const (
	// RTTablesDir contains path to the directory with ID to routing tables IDs mapping in Linux.
	RTTablesDir = "/etc/iproute2"
	// RTTablesFilename contains path to the file with ID to routing tables IDs mapping in Linux.
	RTTablesFilename = RTTablesDir + "/rt_tables"
)

Variables

This section is empty.

Functions

func AddRule

func AddRule(rule *networkingv1beta1.Rule, tableID uint32) error

AddRule adds the given rule to the rules list.

func AddTableID

func AddTableID(tableID uint32, tableName string) error

AddTableID adds the given table ID to the rt_tables file.

func CleanRoutes

func CleanRoutes(routes []networkingv1beta1.Route, tableID uint32) error

CleanRoutes cleans the routes that are not contained in the given route list.

func CleanRules

func CleanRules(rules []networkingv1beta1.Rule, tableID uint32) error

CleanRules deletes all the rules which are not contained anymore in the given rules list.

func DeleteTableID

func DeleteTableID(tableID uint32) error

DeleteTableID deletes the given table ID from the rt_tables file.

func EnsureRoutesAbsence

func EnsureRoutesAbsence(routes []networkingv1beta1.Route, tableID uint32) error

EnsureRoutesAbsence ensures the absence of the given routes.

func EnsureRoutesPresence

func EnsureRoutesPresence(routes []networkingv1beta1.Route, tableID uint32) error

EnsureRoutesPresence ensures the presence of the given routes.

func EnsureRuleAbsence

func EnsureRuleAbsence(rule *networkingv1beta1.Rule, tableID uint32) error

EnsureRuleAbsence ensures the absence of the given rule.

func EnsureRulePresence

func EnsureRulePresence(rule *networkingv1beta1.Rule, tableID uint32) error

EnsureRulePresence ensures the presence of the given rule.

func EnsureTableAbsence

func EnsureTableAbsence(tableID uint32) error

EnsureTableAbsence ensures the absence of the given table.

func EnsureTablePresence

func EnsureTablePresence(routeconfiguration *networkingv1beta1.RouteConfiguration, tableID uint32) error

EnsureTablePresence ensures the presence of the given table.

func ExistsRoute

func ExistsRoute(route *networkingv1beta1.Route, tableID uint32) (*netlink.Route, bool, error)

ExistsRoute checks if the given route is already present in the route list.

func ExistsRule

func ExistsRule(rule *networkingv1beta1.Rule, rules []netlink.Rule) (*netlink.Rule, bool, error)

ExistsRule checks if the given rule is already present in the rules list.

func ExistsTableID

func ExistsTableID(tableID uint32) (exists bool, err error)

ExistsTableID checks if the given table ID is already present in the rt_tables file.

func GetRulesByTableID

func GetRulesByTableID(tableID uint32) ([]netlink.Rule, error)

GetRulesByTableID returns all the rules associated with the given table ID.

func GetTableID

func GetTableID(tableName string) (uint32, error)

GetTableID returns the table ID associated with the given route.

func IsContainedRoute

func IsContainedRoute(route *netlink.Route, routes []networkingv1beta1.Route) bool

IsContainedRoute checks if the given route is contained in the route list.

func IsContainedRule

func IsContainedRule(existingrule *netlink.Rule, rules []networkingv1beta1.Rule) bool

IsContainedRule checks if the given rule is contained in the given rules list.

func IsEqualRoute

func IsEqualRoute(route1, route2 *netlink.Route) bool

IsEqualRoute checks if the two routes are equal.

func NewRouteWatchEventHandler

func NewRouteWatchEventHandler(cl client.Client, labelsSets []labels.Set) handler.EventHandler

NewRouteWatchEventHandler creates a new EventHandler.

func NewRouteWatchSource

func NewRouteWatchSource(src <-chan event.GenericEvent, eh handler.EventHandler) source.Source

NewRouteWatchSource creates a new Source for the Route watcher.

func RuleIsEqual

func RuleIsEqual(rule *networkingv1beta1.Rule, netlinkRule *netlink.Rule) bool

RuleIsEqual checks if the given rule is equal to the given netlink rule.

Types

type RouteConfigurationReconciler

type RouteConfigurationReconciler struct {
	PodName string
	client.Client
	Scheme         *runtime.Scheme
	EventsRecorder record.EventRecorder
	// Labels used to filter the reconciled resources.
	LabelsSets []labels.Set
	// EnableFinalizer is used to enable the finalizer on the reconciled resources.
	EnableFinalizer bool
}

RouteConfigurationReconciler manage Configuration lifecycle.

func NewRouteConfigurationReconcilerWithFinalizer

func NewRouteConfigurationReconcilerWithFinalizer(cl client.Client, s *runtime.Scheme, podname string,
	er record.EventRecorder, labelsSets []labels.Set) (*RouteConfigurationReconciler, error)

NewRouteConfigurationReconcilerWithFinalizer initializes a reconciler that uses finalizers on routeconfigurations.

func NewRouteConfigurationReconcilerWithoutFinalizer

func NewRouteConfigurationReconcilerWithoutFinalizer(cl client.Client, s *runtime.Scheme, podname string,
	er record.EventRecorder, labelsSets []labels.Set) (*RouteConfigurationReconciler, error)

NewRouteConfigurationReconcilerWithoutFinalizer initializes a reconciler that doesn't use finalizers on routeconfigurations.

func (*RouteConfigurationReconciler) Reconcile

Reconcile manage RouteConfigurations, applying nftables configuration.

func (*RouteConfigurationReconciler) SetupWithManager

func (r *RouteConfigurationReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager) error

SetupWithManager register the RouteConfigurationReconciler to the manager.

func (*RouteConfigurationReconciler) UpdateStatus

func (r *RouteConfigurationReconciler) UpdateStatus(ctx context.Context, er record.EventRecorder,
	routeconfiguration *networkingv1beta1.RouteConfiguration, podname string, err error) error

UpdateStatus updates the status of the given RouteConfiguration.

Jump to

Keyboard shortcuts

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