package internal
import "github.com/cilium/ebpf/internal"
Index ¶
- Variables
- func BPF(cmd BPFCmd, attr unsafe.Pointer, size uintptr) (uintptr, error)
- func BPFObjGetInfoByFD(fd *FD, info unsafe.Pointer, size uintptr) error
- func BPFObjPin(fileName string, fd *FD) error
- func BPFProgAttach(attr *BPFProgAttachAttr) error
- func BPFProgDetach(attr *BPFProgDetachAttr) error
- func CString(in []byte) string
- func ErrorWithLog(err error, log []byte, logErr error) error
- func FeatureTest(name, version string, fn FeatureTestFn) func() error
- func PossibleCPUs() (int, error)
- type BPFCmd
- type BPFProgAttachAttr
- type BPFProgDetachAttr
- type DiscardZeroes
- type FD
- func BPFObjGet(fileName string) (*FD, error)
- func NewFD(value uint32) *FD
- func (fd *FD) Close() error
- func (fd *FD) Dup() (*FD, error)
- func (fd *FD) File(name string) *os.File
- func (fd *FD) Forget()
- func (fd *FD) String() string
- func (fd *FD) Value() (uint32, error)
- type FeatureTestFn
- type Pointer
- func NewPointer(ptr unsafe.Pointer) Pointer
- func NewSlicePointer(buf []byte) Pointer
- func NewStringPointer(str string) Pointer
- type UnsupportedFeatureError
- func (ufe *UnsupportedFeatureError) Error() string
- func (ufe *UnsupportedFeatureError) Is(target error) bool
- type VerifierError
- type Version
Variables ¶
ErrNotSupported indicates that a feature is not supported by the current kernel.
NativeEndian is set to either binary.BigEndian or binary.LittleEndian, depending on the host's endianness.
Functions ¶
func BPF ¶
BPF wraps SYS_BPF.
Any pointers contained in attr must use the Pointer type from this package.
func BPFObjGetInfoByFD ¶
BPFObjGetInfoByFD wraps BPF_OBJ_GET_INFO_BY_FD.
Available from 4.13.
func BPFObjPin ¶
BPFObjPin wraps BPF_OBJ_PIN.
func BPFProgAttach ¶
func BPFProgAttach(attr *BPFProgAttachAttr) error
func BPFProgDetach ¶
func BPFProgDetach(attr *BPFProgDetachAttr) error
func CString ¶
CString turns a NUL / zero terminated byte buffer into a string.
func ErrorWithLog ¶
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 FeatureTestFn) 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 an error wrapping ErrNotSupported if the feature is not supported.
func PossibleCPUs ¶
PossibleCPUs returns the max number of CPUs a system may possibly have Logical CPU numbers must be of the form 0-n
Types ¶
type BPFCmd ¶
type BPFCmd int
BPFCmd identifies a subcommand of the bpf syscall.
const ( BPF_MAP_CREATE BPFCmd = iota BPF_MAP_LOOKUP_ELEM BPF_MAP_UPDATE_ELEM BPF_MAP_DELETE_ELEM BPF_MAP_GET_NEXT_KEY BPF_PROG_LOAD BPF_OBJ_PIN BPF_OBJ_GET BPF_PROG_ATTACH BPF_PROG_DETACH BPF_PROG_TEST_RUN BPF_PROG_GET_NEXT_ID BPF_MAP_GET_NEXT_ID BPF_PROG_GET_FD_BY_ID BPF_MAP_GET_FD_BY_ID BPF_OBJ_GET_INFO_BY_FD BPF_PROG_QUERY BPF_RAW_TRACEPOINT_OPEN BPF_BTF_LOAD BPF_BTF_GET_FD_BY_ID BPF_TASK_FD_QUERY BPF_MAP_LOOKUP_AND_DELETE_ELEM BPF_MAP_FREEZE BPF_BTF_GET_NEXT_ID BPF_MAP_LOOKUP_BATCH BPF_MAP_LOOKUP_AND_DELETE_BATCH BPF_MAP_UPDATE_BATCH BPF_MAP_DELETE_BATCH BPF_LINK_CREATE BPF_LINK_UPDATE BPF_LINK_GET_FD_BY_ID BPF_LINK_GET_NEXT_ID BPF_ENABLE_STATS BPF_ITER_CREATE )
Well known BPF commands.
func (BPFCmd) String ¶
type BPFProgAttachAttr ¶
type BPFProgAttachAttr struct { TargetFd uint32 AttachBpfFd uint32 AttachType uint32 AttachFlags uint32 ReplaceBpfFd uint32 }
type BPFProgDetachAttr ¶
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 BPFObjGet ¶
BPFObjGet wraps BPF_OBJ_GET.
func NewFD ¶
func (*FD) Close ¶
func (*FD) Dup ¶
func (*FD) File ¶
func (*FD) Forget ¶
func (fd *FD) Forget()
func (*FD) String ¶
func (*FD) Value ¶
type FeatureTestFn ¶
FeatureTestFn is used to determine whether the kernel supports a certain feature.
The return values have the following semantics:
err != nil: the test couldn't be executed err == nil && available: the feature is available err == nil && !available: the feature isn't available
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 ¶
NewPointer creates a 64-bit pointer from an unsafe Pointer.
func NewSlicePointer ¶
NewSlicePointer creates a 64-bit pointer from a byte slice.
func NewStringPointer ¶
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 NewVersion ¶
NewVersion creates a version from a string like "Major.Minor.Patch".
Patch is optional.
func (Version) Less ¶
Less returns true if the version is less than another version.
func (Version) String ¶
func (Version) Unspecified ¶
Unspecified returns true if the version is all zero.
Source Files ¶
cpu.go endian.go errors.go fd.go feature.go io.go ptr.go ptr_64.go syscall.go syscall_string.go
Directories ¶
Path | Synopsis |
---|---|
internal/btf | Package btf handles data encoded according to the BPF Type Format. |
internal/testutils | |
internal/unix |
- Version
- v0.2.0
- Published
- Nov 18, 2020
- Platform
- darwin/amd64
- Imports
- 13 packages
- Last checked
- 1 hour ago –
Tools for package owners.