kernelbypass

package module
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2025 License: MPL-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

kernelbypass

Kernel-bypass networking in Go.

Notes

On Debian you might need to create this symlink to fix bpf compilation issues:

sudo ln -sf /usr/include/$(uname -m)-linux-gnu/asm /usr/include/asm

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler interface {
	// BatchSize returns the maximum number of frames that can be processed
	// in a single batch.
	BatchSize() int
	// Receive is called when new frames are received.
	Receive(queueID int, frames [][]byte)
	// Transmit is called to prepare frames for transmission.
	// It returns the number of frames that were successfully prepared for
	// transmission. The frames should be filled with the data to be sent.
	// The lengths slice should be filled with the lengths of each frame.
	Transmit(queueID int, frames [][]byte, lengths []int) int
}

Handler is an interface that defines methods for processing frames in a kernel-bypass network interface using XDP. The handler should not block.

type NetworkInterface

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

NetworkInterface represents a network interface that uses XDP for high-performance kernel-bypass packet processing.

func Open

func Open(name string, handler Handler, ingressFilter *xdp.Program, opts *NetworkInterfaceOptions) (*NetworkInterface, error)

Open creates a new NetworkInterface for the provided interface name and options.

func (*NetworkInterface) Close

func (nic *NetworkInterface) Close() error

Close closes the NetworkInterface and releases all resources.

func (*NetworkInterface) NumQueues added in v0.2.1

func (nic *NetworkInterface) NumQueues() int

NumQueues returns the number of queues configured for this network interface.

func (*NetworkInterface) Start

func (nic *NetworkInterface) Start(ctx context.Context) error

type NetworkInterfaceOptions

type NetworkInterfaceOptions struct {
	// NumQueues is the number of RX/TX queues to use for the interface.
	NumQueues int
	// AttachFlags are the flags which are passed when the XDP program is
	// attached to the network link, possible values include
	// unix.XDP_FLAGS_DRV_MODE, unix.XDP_FLAGS_HW_MODE, unix.XDP_FLAGS_SKB_MODE,
	// unix.XDP_FLAGS_UPDATE_IF_NOEXIST.
	AttachFlags uint32
	// SocketOpts are the options to use when creating XDP sockets.
	// These options can be used to set buffer sizes, queue sizes, etc.
	SocketOpts *xdp.SocketOptions
}

Directories

Path Synopsis
framing
udp

Jump to

Keyboard shortcuts

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