Documentation
¶
Overview ¶
Package hive wraps the kernel BPF object lifecycle shared by all terrahive resources: pinning, loading, reading back, and unpinning.
Index ¶
- Constants
- func CompileC(source string) ([]byte, error)
- func LoadELF(obj []byte) (*ebpf.ProgramSpec, error)
- func ProgramTypeString(t ebpf.ProgramType) string
- func SourceHash(data []byte) string
- type Hive
- func (h *Hive) LoadAndPinProgram(obj []byte, pinPath string) (string, error)
- func (h *Hive) LoadPinnedLink(pinPath string) (link.Link, error)
- func (h *Hive) LoadPinnedMap(pinPath string) (*ebpf.Map, error)
- func (h *Hive) LoadPinnedProgram(pinPath string) (*ebpf.Program, error)
- func (h *Hive) PinDir() string
- func (h *Hive) PinExists(pinPath string) (bool, error)
- func (h *Hive) PinLink(l link.Link, pinPath string) error
- func (h *Hive) PinPath(parts ...string) string
- func (h *Hive) PinnedProgramInfo(pinPath string) (typ, tag string, err error)
- func (h *Hive) Unpin(pinPath string) error
- type USDT
Constants ¶
const DefaultPinDir = "/sys/fs/bpf/terrahive"
DefaultPinDir is used when the provider block sets no pin_dir.
Variables ¶
This section is empty.
Functions ¶
func LoadELF ¶
func LoadELF(obj []byte) (*ebpf.ProgramSpec, error)
LoadELF parses a BPF object file and returns its single program spec, with the program type already inferred from the ELF section name.
func ProgramTypeString ¶
func ProgramTypeString(t ebpf.ProgramType) string
ProgramTypeString renders a program type in the lowercase form used by the ebpf_program `type` attribute.
func SourceHash ¶
SourceHash fingerprints program source bytes so plans can force replacement when content changes behind a stable path.
Types ¶
type Hive ¶
type Hive struct {
// contains filtered or unexported fields
}
Hive is the handle every resource uses to talk to the kernel.
func New ¶
New validates the environment and returns a Hive rooted at pinDir. It fails if pinDir is not on bpffs or the process lacks BPF privileges, so misconfiguration surfaces at provider configure time, not mid-apply.
func (*Hive) LoadAndPinProgram ¶
LoadAndPinProgram loads the object's single program together with the maps it references and pins the program, returning the kernel-computed tag. Referenced maps are pinned by name under the hive map directory, so several programs (and an ebpf_map of the same name) share one kernel map through a stable bpffs pin. The object must hold exactly one program; callers gate that with LoadELF.
func (*Hive) LoadPinnedLink ¶
LoadPinnedLink resolves a pinned link for Read and import.
func (*Hive) LoadPinnedMap ¶
LoadPinnedMap resolves a pinned map for Read and import.
func (*Hive) LoadPinnedProgram ¶
LoadPinnedProgram resolves a pinned program for Read and import.
func (*Hive) PinLink ¶
PinLink pins l at pinPath, creating parent directories on bpffs so resources can pin under per-kind subdirectories.
func (*Hive) PinPath ¶
PinPath derives the bpffs pin path that doubles as the Terraform resource ID. Parts typically encode kind and resource name.
func (*Hive) PinnedProgramInfo ¶
PinnedProgramInfo returns the type and tag of a pinned program.
type USDT ¶
type USDT struct {
// Address is the probe location as an offset into the executable
// file, ready for a uprobe attach.
Address uint64
// SemaphoreOffset is the file offset of the probe semaphore, zero
// when the probe has none.
SemaphoreOffset uint64
}
USDT locates a statically defined tracepoint inside an executable.
func ResolveUSDT ¶
ResolveUSDT parses the .note.stapsdt section of the executable at path and returns the location of the probe identified by provider and name. terrahive resolves the note itself and attaches a plain uprobe at the resulting offset.