filter

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AttachFlags = 0

AttachFlags are the flags passed when attaching the XDP program to an interface. Zero lets the kernel choose the attach mode (native driver XDP if the driver supports it, otherwise generic/SKB), matching the behaviour icx inherited from github.com/slavc/xdp.

IMPORTANT: on drivers that support native XDP (e.g. ixgbe), the kernel's default (native) attach RECONFIGURES the NIC's TX rings, and copy-mode AF_XDP TX frames then never egress — the driver silently drops them while still producing completions (proven on ixgbe: nic_tx_delta=0). The shared-UMEM forwarder runs in copy mode (it cannot use driver zero-copy — see forwarder.phyBindOpts), so it sets this to XDP_FLAGS_SKB_MODE, which leaves the driver's TX path untouched and lets the generic-XDP hook still redirect RX into the AF_XDP sockets. A future driver-zero-copy datapath would use native mode.

Functions

This section is empty.

Types

type Program added in v0.18.0

type Program struct {
	Program *ebpf.Program
	Queues  *ebpf.Map // qidconf_map: rx_queue_index -> enabled(1)
	Sockets *ebpf.Map // xsks_map (XSKMAP): rx_queue_index -> socket fd
}

Program is a loaded XDP redirect program plus the maps that steer packets into AF_XDP sockets. It owns the eBPF program (xdp_sock_prog), the per-queue config map (qidconf_map) that gates which RX queues redirect, and the XSKMAP (xsks_map) that maps a queue index to a bound socket fd.

This replaces github.com/slavc/xdp's Program type: icx built it by hand from a cilium/ebpf collection (see All/Geneve) and only ever used Attach/Detach/ Register/Unregister/Close, so the in-repo version carries just those, with no dependency on the upstream library.

func All

func All() (*Program, error)

All creates an eBPF program that intercepts all incoming packets and redirects them to the XDP socket.

func Geneve added in v0.14.0

func Geneve(addrs ...net.Addr) (*Program, error)

Geneve creates an eBPF program that binds to the specified addresses and redirects all Geneve packets to the XDP socket.

func (*Program) Attach added in v0.18.0

func (p *Program) Attach(ifindex int) error

Attach attaches the XDP program to the interface, replacing any program already attached there (idempotent: a stale program from a previous run is removed first).

func (*Program) Close added in v0.18.0

func (p *Program) Close() error

Close releases the program and both maps. Errors are joined so one failure does not skip closing the rest. Unlike the old library this is actually called (the forwarder leaked these fds by only Detaching), so the program/map fds are freed on teardown.

func (*Program) Detach added in v0.18.0

func (p *Program) Detach(ifindex int) error

Detach removes the XDP program from the interface.

func (*Program) Register added in v0.18.0

func (p *Program) Register(queueID int, fd int) error

Register makes the socket fd the redirect target for packets arriving on queueID: it points the XSKMAP entry at the fd and enables redirect for that queue in qidconf_map. The XSKMAP must be written before qidconf is enabled so the program never redirects to an empty XSKMAP slot.

func (*Program) Unregister added in v0.18.0

func (p *Program) Unregister(queueID int) error

Unregister disables redirect for queueID and drops its XSKMAP entry. qidconf is cleared first so the program stops redirecting before the socket fd is removed.

qidconf_map is a BPF_MAP_TYPE_ARRAY, whose elements cannot be deleted (the kernel returns EINVAL); the disable is therefore a Put(queueID, 0), not a Delete. The previous Delete always errored on the array map and returned before ever clearing the XSKMAP entry, leaving the socket fd a live redirect target — so per-queue teardown never actually unregistered anything.

Jump to

Keyboard shortcuts

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