bpfutil

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const BPFFSPath = "/sys/fs/bpf"
View Source
const (
	BTFPATH = "/etc/net-exporter/"
)

Variables

View Source
var (
	FsMagicBPFFS     int32
	INSP_PINNED_PATH = fmt.Sprintf("%s/inspector", BPFFSPath) // nolint
)

Functions

func FindBTFFileWithPath added in v0.1.1

func FindBTFFileWithPath(path string) (string, error)

func GetAddrStr

func GetAddrStr(proto uint16, addr [16]byte) string

GetAddrStr get string format ip address,default in ipv4

func GetBtfFile

func GetBtfFile() (string, error)

func GetCommString

func GetCommString(comm [20]int8) string

func GetHumanTimes

func GetHumanTimes(ns uint64) string

func GetProtoStr

func GetProtoStr(proto uint8) string

GetProtoStr get proto sting, default IP

func GetSkcStateStr

func GetSkcStateStr(state uint8) string
enum {
	TCP_ESTABLISHED = 1,
	TCP_SYN_SENT,
	TCP_SYN_RECV,
	TCP_FIN_WAIT1,
	TCP_FIN_WAIT2,
	TCP_TIME_WAIT,
	TCP_CLOSE,
	TCP_CLOSE_WAIT,
	TCP_LAST_ACK,
	TCP_LISTEN,
	TCP_CLOSING,
	TCP_NEW_SYN_RECV,

	TCP_MAX_STATES
};

func GetSymsStrByStack

func GetSymsStrByStack(stack uint32, stackmap *ebpf.Map) ([]string, error)

func GetTCPState

func GetTCPState(_ uint8) string

func IsMounted

func IsMounted() (bool, error)

IsMounted checks if the BPF fs is mounted already in the default location

func IsMountedAt

func IsMountedAt(mountpoint string) (bool, error)

IsMountedAt checks if the BPF fs is mounted already in the custom location

func KernelArch added in v0.1.1

func KernelArch() (string, error)

func KernelRelease

func KernelRelease() (string, error)

func LoadBTFFromFile

func LoadBTFFromFile(file string) (*btf.Spec, error)

func LoadBTFSpecOrNil

func LoadBTFSpecOrNil() *btf.Spec

LoadBTFSpecOrNil once error occurs in load process, return nil and use system raw spec instead

func Mount

func Mount() error

Mount mounts the BPF fs in the default location (if not already mounted)

func MountAt

func MountAt(mountpoint string) error

MountAt mounts the BPF fs in the custom location (if not already mounted)

func MustLoadPin

func MustLoadPin(name string) (*ebpf.Map, error)

func MustPin

func MustPin(m *ebpf.Map, name string) error

MustPin pin a map, will remove old one default, prevent asynchrouny

Types

type KernelSymbol

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

func GetSymByPt

func GetSymByPt(addr string) (*KernelSymbol, error)

func GetSymPtFromBpfLocation

func GetSymPtFromBpfLocation(pt uint64) (*KernelSymbol, error)

GetSymPtFromBpfLocation return symbol struct/offset/error with bpf location

func GetSymsByStack

func GetSymsByStack(stack uint32, stackmap *ebpf.Map) ([]KernelSymbol, error)

func (*KernelSymbol) GetAddr

func (k *KernelSymbol) GetAddr() uint64

func (*KernelSymbol) GetExpr

func (k *KernelSymbol) GetExpr() string

func (*KernelSymbol) GetName

func (k *KernelSymbol) GetName() string

Jump to

Keyboard shortcuts

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