tunnel

package
v1.18.7 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// VXLAN specifies VXLAN encapsulation
	VXLAN EncapProtocol = "vxlan"

	// Geneve specifies Geneve encapsulation
	Geneve EncapProtocol = "geneve"

	// Disabled specifies to disable encapsulation
	Disabled EncapProtocol = ""

	IPv4 UnderlayProtocol = "ipv4"
	IPv6 UnderlayProtocol = "ipv6"
)

Variables

View Source
var Cell = cell.Module(
	"datapath-tunnel-config",
	"Tunneling configurations",

	cell.Config(defaultConfig),

	cell.Provide(
		newConfig,

		Config.datapathConfigProvider,

		func(dcfg *option.DaemonConfig) EnablerOut {
			return NewEnabler(dcfg.TunnelingEnabled())
		},

		func(kpr kpr.KPRConfig, lbcfg loadbalancer.Config) EnablerOut {
			return NewEnabler(
				(kpr.EnableNodePort ||
					kpr.KubeProxyReplacement == option.KubeProxyReplacementTrue) &&
					lbcfg.LoadBalancerUsesDSR() &&
					lbcfg.DSRDispatch == loadbalancer.DSRDispatchGeneve,

				WithoutMTUAdaptation(),
			)
		},
	),
)

Cell is a cell that provides the parameters for the Cilium tunnel, based on user configuration and requests from external modules.

Functions

func WithValidator

func WithValidator(validator func(EncapProtocol) error) enablerOpt

WithValidator allows to register extra validation functions to assert that the configured tunnel protocol matches the one expected by the given feature.

func WithoutMTUAdaptation

func WithoutMTUAdaptation() enablerOpt

WithoutMTUAdaptation conveys that the given feature request to enable tunneling, but the MTU adaptation is already handled externally.

Types

type Config

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

Config represents the materialized tunneling configuration to be used, depending on the user configuration and optional overrides required by additional features.

func NewTestConfig

func NewTestConfig(proto EncapProtocol) Config

NewTestConfig returns a new TunnelConfig for testing purposes.

func (Config) DeviceName

func (cfg Config) DeviceName() string

DeviceName returns the name of the tunnel device (empty if disabled).

func (Config) EncapProtocol added in v1.18.0

func (cfg Config) EncapProtocol() EncapProtocol

EncapProtocol returns the enabled tunnel protocol. The tunnel protocol may be set to either VXLAN or Geneve even when the primary mode is native routing, in case an additional feature (e.g., egress gateway) may request some traffic to be routed through a tunnel.

func (Config) Port

func (cfg Config) Port() uint16

Port returns the port used by the tunnel (0 if disabled).

func (Config) ShouldAdaptMTU

func (cfg Config) ShouldAdaptMTU() bool

ShouldAdaptMTU returns whether we should adapt the MTU calculation to account for encapsulation.

func (Config) SrcPortHigh added in v1.17.2

func (cfg Config) SrcPortHigh() uint16

SrcPortHigh returns the upper src port hint to be used by the tunnel (0 if disabled).

func (Config) SrcPortLow added in v1.17.2

func (cfg Config) SrcPortLow() uint16

SrcPortLow returns the lower src port hint to be used by the tunnel (0 if disabled).

func (Config) UnderlayProtocol added in v1.18.0

func (cfg Config) UnderlayProtocol() UnderlayProtocol

type EnablerOut

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

EnablerOut allows requesting to enable tunneling functionalities.

func NewEnabler

func NewEnabler(enable bool, opts ...enablerOpt) EnablerOut

NewEnabler returns an object to be injected through hive to request to enable tunneling functionalities. Extra options are meaningful only when enable is set to true, and are ignored otherwise.

type EncapProtocol added in v1.18.0

type EncapProtocol string

EncapProtocol represents the valid types of encapsulation protocols.

func (EncapProtocol) String added in v1.18.0

func (tp EncapProtocol) String() string

type UnderlayProtocol added in v1.18.0

type UnderlayProtocol string

UnderlayProtocol represents the valid types of underlay protocols for the tunnel.

Jump to

Keyboard shortcuts

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