ebpf

package
v0.0.0-...-c607030 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0, Apache-2.0 Imports: 17 Imported by: 6

Documentation

Overview

Package ebpf contains general eBPF related types and functions

Index

Constants

This section is empty.

Variables

View Source
var (
	// CIncludePattern is the regex for #include headers of C files
	CIncludePattern = `^\s*#\s*include\s+"(.*)"$`
)
View Source
var (
	// ErrNotImplemented will be returned on non-linux environments like Windows and Mac OSX
	ErrNotImplemented = errors.New("BPF-based system probe not implemented on non-linux systems")
)

Functions

func NowNanoseconds added in v0.9.0

func NowNanoseconds() (int64, error)

NowNanoseconds returns a time that can be compared to bpf_ktime_get_ns()

func PreprocessFile added in v0.9.0

func PreprocessFile(bpfDir, fileName string) (*bytes.Buffer, error)

PreprocessFile pre-processes the `#include` of embedded headers. It will only replace top-level includes for files that exist and does not evaluate the content of included files for #include directives.

func VerifyKernelFuncs added in v0.9.0

func VerifyKernelFuncs(requiredKernelFuncs ...string) (map[string]struct{}, error)

VerifyKernelFuncs ensures all kernel functions exist in ksyms located at provided path.

Types

type Config

type Config struct {
	// BPFDebug enables bpf debug logs
	BPFDebug bool

	// BPFDir is the directory to load the eBPF program from
	BPFDir string

	// ExcludedBPFLinuxVersions lists Linux kernel versions that should not use BPF features
	ExcludedBPFLinuxVersions []string

	// ProcRoot is the root path to the proc filesystem
	ProcRoot string

	// InternalTelemetryEnabled indicates whether internal prometheus telemetry is enabled
	InternalTelemetryEnabled bool

	// EnableTracepoints enables use of tracepoints instead of kprobes for probing syscalls (if available on system)
	EnableTracepoints bool

	// EnableCORE enables the use of CO-RE to load eBPF programs
	EnableCORE bool

	// BTFPath is the path to BTF data for the current kernel
	BTFPath string

	// EnableRuntimeCompiler enables the use of the embedded compiler to build eBPF programs on-host
	EnableRuntimeCompiler bool

	// EnableKernelHeaderDownload enables the use of the automatic kernel header downloading
	EnableKernelHeaderDownload bool

	// KernelHeadersDir is the directories of the kernel headers to use for runtime compilation
	KernelHeadersDirs []string

	// KernelHeadersDownloadDir is the directory where the system-probe will attempt to download kernel headers, if necessary
	KernelHeadersDownloadDir string

	// RuntimeCompilerOutputDir is the directory where the runtime compiler will store compiled programs
	RuntimeCompilerOutputDir string

	// AptConfigDir is the path to the apt config directory
	AptConfigDir string

	// YumReposDir is the path to the yum repository directory
	YumReposDir string

	// ZypperReposDir is the path to the zypper repository directory
	ZypperReposDir string

	// AllowPrecompiledFallback indicates whether we are allowed to fallback to the prebuilt probes if runtime compilation fails.
	AllowPrecompiledFallback bool

	// AllowRuntimeCompiledFallback indicates whether we are allowed to fallback to runtime compilation if CO-RE fails.
	AllowRuntimeCompiledFallback bool

	// AttachKprobesWithKprobeEventsABI uses the kprobe_events ABI to attach kprobes rather than the newer perf ABI.
	AttachKprobesWithKprobeEventsABI bool

	// EBPFInstrumentationEnabled enables instrumenting eBPF programs via a trampoline instruction in the beginning of the bytecode sequence.
	EBPFInstrumentationEnabled bool
}

Config stores all common flags used by system-probe

func NewConfig added in v0.9.0

func NewConfig() *Config

NewConfig creates a config with ebpf-related settings

Directories

Path Synopsis
Package bytecode contains types and functions for eBPF bytecode
Package bytecode contains types and functions for eBPF bytecode
Package main is the program to fixup cgo generated types
Package main is the program to fixup cgo generated types
Package ebpftest is utilities for tests against eBPF
Package ebpftest is utilities for tests against eBPF
Package telemetry provides types and functions for kernel telemetry collected by eBPF programs.
Package telemetry provides types and functions for kernel telemetry collected by eBPF programs.
Package verifier is responsible for exposing information the verifier provides for any loaded eBPF program
Package verifier is responsible for exposing information the verifier provides for any loaded eBPF program

Jump to

Keyboard shortcuts

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