tunnel

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NumQueues

func NumQueues(link netlink.Link) (int, error)

Types

type Handler

type Handler interface {
	// PhyToVirt converts a physical frame to a virtual frame typically by performing decapsulation.
	// Returns the length of the resulting virtual frame.
	PhyToVirt(phyFrame, virtFrame []byte) int
	// VirtToPhy converts a virtual frame to a physical frame typically by performing encapsulation.
	// Returns the length of the resulting physical frame.
	VirtToPhy(virtFrame, phyFrame []byte) (length int, loopback bool)
	// ToPhy is called periodically to allow the handler to send
	// scheduled frames to the physical interface, e.g. keep-alive packets.
	// Returns the length of the resulting physical frame.
	ToPhy(phyFrame []byte) int
}

Decapsulate and encapsulate frames between physical and virtual interfaces.

type Tunnel

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

Tunnel splices frames between a physical and a virtual interface using XDP sockets. It uses a handler to convert frames between the two interfaces.

func NewTunnel

func NewTunnel(handler Handler, opts ...TunnelOption) (*Tunnel, error)

NewTunnel creates a new Tunnel with the given handler and options.

func (*Tunnel) Close

func (t *Tunnel) Close() (err error)

func (*Tunnel) Start

func (t *Tunnel) Start(ctx context.Context) error

type TunnelOption added in v0.10.0

type TunnelOption func(*tunnelOptions) error

func WithPcapWriter added in v0.10.0

func WithPcapWriter(writer *pcapgo.Writer) TunnelOption

WithPcapWriter sets a pcap writer to log all frames sent and received on both interfaces. If nil, no pcap logging is performed.

func WithPhyFilter added in v0.10.0

func WithPhyFilter(filter *xdp.Program) TunnelOption

WithPhyFilter sets a custom XDP filter program to use on the physical interface. If nil, a default filter is created that accepts all Geneve packets addressed to the default port (6081).

func WithPhyName added in v0.10.0

func WithPhyName(name string) TunnelOption

WithPhyName sets the name of the physical interface to use. Defaults to "eth0".

func WithVirtName added in v0.10.0

func WithVirtName(name string) TunnelOption

WithVirtName sets the name of the virtual interface to use. Defaults to "tun0".

Jump to

Keyboard shortcuts

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