Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Forwarder ¶
type Forwarder struct {
// contains filtered or unexported fields
}
Forwarder splices frames between a physical and a virtual interface using XDP sockets. It uses a handler to convert frames between the two interfaces.
func NewForwarder ¶
func NewForwarder(handler Handler, opts ...ForwarderOption) (*Forwarder, error)
NewForwarder creates a new Forwarder with the given handler and options.
type ForwarderOption ¶
type ForwarderOption func(*forwarderOptions) error
func WithPcapWriter ¶
func WithPcapWriter(writer *pcapgo.Writer) ForwarderOption
WithPcapWriter sets a pcap writer to log all frames sent and received on both interfaces. If nil, no pcap logging is performed.
func WithPhyFilter ¶
func WithPhyFilter(filter *xdp.Program) ForwarderOption
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 ¶
func WithPhyName(name string) ForwarderOption
WithPhyName sets the name of the physical interface to use. Defaults to "eth0".
func WithVirtName ¶
func WithVirtName(name string) ForwarderOption
WithVirtName sets the name of the virtual interface to use. Defaults to "tun0".
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.