features

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: MIT Imports: 10 Imported by: 19

Documentation

Overview

Package features allows probing for BPF features available to the calling process.

In general, the error return values from feature probes in this package all have the following semantics unless otherwise specified:

err == nil: The feature is available.
errors.Is(err, ebpf.ErrNotSupported): The feature is not available.
err != nil: Any errors encountered during probe execution, wrapped.

Note that the latter case may include false negatives, and that resource creation may succeed despite an error being returned. For example, some map and program types cannot reliably be probed and will return an inconclusive error.

As a rule, only `nil` and `ebpf.ErrNotSupported` are conclusive.

Probe results are cached by the library and persist throughout any changes to the process' environment, like capability changes.

Index

Constants

View Source
const (
	BPF_F_NO_PREALLOC = sys.BPF_F_NO_PREALLOC
	BPF_F_RDONLY_PROG = sys.BPF_F_RDONLY_PROG
	BPF_F_WRONLY_PROG = sys.BPF_F_WRONLY_PROG
	BPF_F_MMAPABLE    = sys.BPF_F_MMAPABLE
	BPF_F_INNER_MAP   = sys.BPF_F_INNER_MAP
)

Flags which may be feature probed.

Variables

View Source
var HaveProgType = HaveProgramType

HaveProgType probes the running kernel for the availability of the specified program type.

Deprecated: use HaveProgramType() instead.

Functions

func HaveBoundedLoops added in v0.9.0

func HaveBoundedLoops() error

HaveBoundedLoops probes the running kernel if bounded loops are supported.

Upstream commit 2589726d12a1 ("bpf: introduce bounded loops").

See the package documentation for the meaning of the error return value.

func HaveLargeInstructions added in v0.9.0

func HaveLargeInstructions() error

HaveLargeInstructions probes the running kernel if more than 4096 instructions per program are supported.

Upstream commit c04c0d2b968a ("bpf: increase complexity limit and maximum program size").

See the package documentation for the meaning of the error return value.

func HaveMapFlag added in v0.9.2

func HaveMapFlag(flag MapFlags) (err error)

HaveMapFlag probes the running kernel for the availability of the specified map flag.

Returns an error if flag is not one of the flags declared in this package. See the package documentation for the meaning of the error return value.

func HaveMapType

func HaveMapType(mt ebpf.MapType) error

HaveMapType probes the running kernel for the availability of the specified map type.

See the package documentation for the meaning of the error return value.

func HaveProgramHelper added in v0.9.0

func HaveProgramHelper(pt ebpf.ProgramType, helper asm.BuiltinFunc) error

HaveProgramHelper probes the running kernel for the availability of the specified helper function to a specified program type. Return values have the following semantics:

err == nil: The feature is available.
errors.Is(err, ebpf.ErrNotSupported): The feature is not available.
err != nil: Any errors encountered during probe execution, wrapped.

Note that the latter case may include false negatives, and that program creation may succeed despite an error being returned. Only `nil` and `ebpf.ErrNotSupported` are conclusive.

Probe results are cached and persist throughout any process capability changes.

func HaveProgramType added in v0.9.0

func HaveProgramType(pt ebpf.ProgramType) (err error)

HaveProgramType probes the running kernel for the availability of the specified program type.

See the package documentation for the meaning of the error return value.

func HaveV2ISA added in v0.9.0

func HaveV2ISA() error

HaveV2ISA probes the running kernel if instructions of the v2 ISA are supported.

Upstream commit 92b31a9af73b ("bpf: add BPF_J{LT,LE,SLT,SLE} instructions").

See the package documentation for the meaning of the error return value.

func HaveV3ISA added in v0.9.0

func HaveV3ISA() error

HaveV3ISA probes the running kernel if instructions of the v3 ISA are supported.

Upstream commit 092ed0968bb6 ("bpf: verifier support JMP32").

See the package documentation for the meaning of the error return value.

func LinuxVersionCode added in v0.9.0

func LinuxVersionCode() (uint32, error)

LinuxVersionCode returns the version of the currently running kernel as defined in the LINUX_VERSION_CODE compile-time macro. It is represented in the format described by the KERNEL_VERSION macro from linux/version.h.

Do not use the version to make assumptions about the presence of certain kernel features, always prefer feature probes in this package. Some distributions backport or disable eBPF features.

Types

type MapFlags added in v0.9.2

type MapFlags = sys.MapFlags

MapFlags document which flags may be feature probed.

Jump to

Keyboard shortcuts

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