xdp

package
v1.17.0-pre.3 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cell = cell.Module(
	"datapath-xdp-config",
	"XDP configuration",

	cell.Provide(
		newConfig,

		func(dcfg *option.DaemonConfig) (EnablerOut, error) {
			xdpMode, ok := map[string]AccelerationMode{
				"":                                    AccelerationModeDisabled,
				option.NodePortAccelerationDisabled:   AccelerationModeDisabled,
				option.NodePortAccelerationGeneric:    AccelerationModeGeneric,
				option.NodePortAccelerationBestEffort: AccelerationModeBestEffort,
				option.NodePortAccelerationNative:     AccelerationModeNative,
			}[dcfg.NodePortAcceleration]

			if !ok {
				return NewEnabler(AccelerationModeDisabled), fmt.Errorf("Invalid value for --%s: %s", option.NodePortAcceleration, dcfg.NodePortAcceleration)
			}

			return NewEnabler(xdpMode), nil
		},
	),

	cell.Invoke(func(c Config, l *slog.Logger) {
		l.Info("Determined final XDP mode", "acceleration-mode", c.AccelerationMode(), "mode", c.Mode())
	}),
)

Cell is a cell that provides the configuration parameters for XDP based on requests from external modules.

Functions

func WithEnforceXDPDisabled

func WithEnforceXDPDisabled(reason string) enablerOpt

WithEnforceXDPDisabled registers a validation function that returns an error if XDP is enabled.

func WithValidator

func WithValidator(validator Validator) enablerOpt

WithValidator allows to register extra validation functions to assert that the configured XDP mode the one expected by the given feature.

Types

type AccelerationMode

type AccelerationMode string

AccelerationMode represents the mode to use when loading XDP programs. They are wrappers around the underlying mode names passed to the traffic control (tc) system in the kernel.

const (
	// AccelerationModeNative for loading progs with TCModeLinkDriver
	AccelerationModeNative AccelerationMode = "native"

	// AccelerationModeBestEffort for loading progs with TCModeLinkDriver,
	// falling back to TCModeLinkGeneric if unsupported by the
	// underlying device.
	AccelerationModeBestEffort AccelerationMode = "best-effort"

	// AccelerationModeGeneric for loading progs with TCModeLinkGeneric
	AccelerationModeGeneric AccelerationMode = "testing-only"

	// AccelerationModeDisabled for not having XDP enabled
	AccelerationModeDisabled AccelerationMode = "disabled"
)

type Config

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

Config represents the materialized XDP configuration to be used, depending on its required use by other features.

func (Config) AccelerationMode

func (cfg Config) AccelerationMode() AccelerationMode

AccelerationMode is the high-level XDP operating mode for Cilium.

func (Config) Disabled

func (cfg Config) Disabled() bool

Disabled returns true if XDP is disabled based on the configuration.

func (Config) GetAttachFlags

func (cfg Config) GetAttachFlags() link.XDPAttachFlags

GetAttachFlags returns the XDP attach flags for the configured TCMode.

func (Config) Mode

func (cfg Config) Mode() Mode

Mode, is the underlying mode name that is used for loading the XDP program into the kernel.

type EnablerOut

type EnablerOut struct {
	cell.Out
	Enabler enabler `group:"request-xdp-mode"`
}

EnablerOut allows requesting to enable a certain XDP operating mode.

func NewEnabler

func NewEnabler(mode AccelerationMode, opts ...enablerOpt) EnablerOut

NewEnabler returns an object to be injected through hive to request to enable a specific operating mode for XDP. Extra options are meaningful only when enable is set to true, and are ignored otherwise.

type Mode

type Mode string

Mode represents the name of an XDP mode from the perspective of the kernel.

const (

	// ModeLinkDriver is the tc selector for native XDP
	ModeLinkDriver Mode = "xdpdrv"

	// ModeLinkGeneric is the tc selector for generic XDP
	ModeLinkGeneric Mode = "xdpgeneric"

	// XDPModeLinkNone for not having XDP enabled
	ModeLinkNone Mode = Mode(AccelerationModeDisabled)
)

type Validator

type Validator func(AccelerationMode, Mode) error

Jump to

Keyboard shortcuts

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