internal

package
v0.0.0-...-3fc9ab3 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClosedFd = errors.New("use of closed file descriptor")
View Source
var ErrNotSupported = errors.New("not supported")

ErrNotSupported indicates that a feature is not supported by the current kernel.

View Source
var NativeEndian binary.ByteOrder

NativeEndian is set to either binary.BigEndian or binary.LittleEndian, depending on the host's endianness.

Functions

func BPF

func BPF(cmd int, attr unsafe.Pointer, size uintptr) (uintptr, error)

BPF wraps SYS_BPF.

Any pointers contained in attr must use the Pointer type from this package.

func CString

func CString(in []byte) string

CString turns a NUL / zero terminated byte buffer into a string.

func ErrorWithLog

func ErrorWithLog(err error, log []byte, logErr error) error

ErrorWithLog returns an error that includes logs from the kernel verifier.

logErr should be the error returned by the syscall that generated the log. It is used to check for truncation of the output.

func FeatureTest

func FeatureTest(name, version string, fn func() bool) func() error

FeatureTest wraps a function so that it is run at most once.

name should identify the tested feature, while version must be in the form Major.Minor[.Patch].

Returns a descriptive UnsupportedFeatureError if the feature is not available.

func PossibleCPUs

func PossibleCPUs() (int, error)

PossibleCPUs returns the max number of CPUs a system may possibly have Logical CPU numbers must be of the form 0-n

Types

type DiscardZeroes

type DiscardZeroes struct{}

DiscardZeroes makes sure that all written bytes are zero before discarding them.

func (DiscardZeroes) Write

func (DiscardZeroes) Write(p []byte) (int, error)

type FD

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

func NewFD

func NewFD(value uint32) *FD

func (*FD) Close

func (fd *FD) Close() error

func (*FD) Dup

func (fd *FD) Dup() (*FD, error)

func (*FD) Forget

func (fd *FD) Forget()

func (*FD) String

func (fd *FD) String() string

func (*FD) Value

func (fd *FD) Value() (uint32, error)

type Pointer

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

Pointer wraps an unsafe.Pointer to be 64bit to conform to the syscall specification.

func NewPointer

func NewPointer(ptr unsafe.Pointer) Pointer

NewPointer creates a 64-bit pointer from an unsafe Pointer.

func NewSlicePointer

func NewSlicePointer(buf []byte) Pointer

NewSlicePointer creates a 64-bit pointer from a byte slice.

func NewStringPointer

func NewStringPointer(str string) Pointer

NewStringPointer creates a 64-bit pointer from a string.

type UnsupportedFeatureError

type UnsupportedFeatureError struct {
	// The minimum Linux mainline version required for this feature.
	// Used for the error string, and for sanity checking during testing.
	MinimumVersion Version

	// The name of the feature that isn't supported.
	Name string
}

UnsupportedFeatureError is returned by FeatureTest() functions.

func (*UnsupportedFeatureError) Error

func (ufe *UnsupportedFeatureError) Error() string

func (*UnsupportedFeatureError) Is

func (ufe *UnsupportedFeatureError) Is(target error) bool

Is indicates that UnsupportedFeatureError is ErrNotSupported.

type VerifierError

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

VerifierError includes information from the eBPF verifier.

func (*VerifierError) Error

func (le *VerifierError) Error() string

type Version

type Version [3]uint16

A Version in the form Major.Minor.Patch.

func MustKernelVersion

func MustKernelVersion() Version

MustKernelVersion() return the current kernel version

func NewVersion

func NewVersion(ver string) (Version, error)

NewVersion creates a version from a string like "Major.Minor.Patch".

Patch is optional.

func (Version) Less

func (v Version) Less(other Version) bool

Less returns true if the version is less than another version.

func (Version) String

func (v Version) String() string

Directories

Path Synopsis
Package btf handles data encoded according to the BPF Type Format.
Package btf handles data encoded according to the BPF Type Format.

Jump to

Keyboard shortcuts

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