constantfetch

package
v0.0.0-...-7c1dae6 Latest Latest
Warning

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

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

Documentation

Overview

Package constantfetch holds constantfetch related files

Package constantfetch holds constantfetch related files

Index

Constants

View Source
const (
	SizeOfInode = "sizeof_inode"
	SizeOfUPID  = "sizeof_upid"
)

Struct sizes

View Source
const (
	OffsetNameSuperBlockStructSFlags    = "sb_flags_offset"
	OffsetNameSuperBlockStructSMagic    = "sb_magic_offset"
	OffsetNameSignalStructStructTTY     = "tty_offset"
	OffsetNameTTYStructStructName       = "tty_name_offset"
	OffsetNameCredStructUID             = "creds_uid_offset"
	OffsetNameCredStructCapInheritable  = "creds_cap_inheritable_offset"
	OffsetNameLinuxBinprmP              = "linux_binprm_p_offset"
	OffsetNameLinuxBinprmArgc           = "linux_binprm_argc_offset"
	OffsetNameLinuxBinprmEnvc           = "linux_binprm_envc_offset"
	OffsetNameVMAreaStructFlags         = "vm_area_struct_flags_offset"
	OffsetNameKernelCloneArgsExitSignal = "kernel_clone_args_exit_signal_offset"
	OffsetNameFileFinode                = "file_f_inode_offset"
	OffsetNameFileFpath                 = "file_f_path_offset"
	OffsetNameDentryDSb                 = "dentry_d_sb_offset"
	OffsetNameMountMntID                = "mount_id_offset"

	// inode times
	OffsetNameInodeCtimeSec  = "inode_ctime_sec_offset"
	OffsetNameInodeCtimeNsec = "inode_ctime_nsec_offset"
	OffsetNameInodeMtimeSec  = "inode_mtime_sec_offset"
	OffsetNameInodeMtimeNsec = "inode_mtime_nsec_offset"

	// rename
	OffsetNameRenameStructOldDentry = "vfs_rename_src_dentry_offset"
	OffsetNameRenameStructNewDentry = "vfs_rename_target_dentry_offset"

	// tracepoints
	OffsetNameSchedProcessForkParentPid = "sched_process_fork_parent_pid_offset"
	OffsetNameSchedProcessForkChildPid  = "sched_process_fork_child_pid_offset"

	// bpf offsets
	OffsetNameBPFMapStructID                  = "bpf_map_id_offset"
	OffsetNameBPFMapStructName                = "bpf_map_name_offset"
	OffsetNameBPFMapStructMapType             = "bpf_map_type_offset"
	OffsetNameBPFProgStructAux                = "bpf_prog_aux_offset"
	OffsetNameBPFProgStructTag                = "bpf_prog_tag_offset"
	OffsetNameBPFProgStructType               = "bpf_prog_type_offset"
	OffsetNameBPFProgStructExpectedAttachType = "bpf_prog_attach_type_offset"
	OffsetNameBPFProgAuxStructID              = "bpf_prog_aux_id_offset"
	OffsetNameBPFProgAuxStructName            = "bpf_prog_aux_name_offset"

	// namespace nr offsets
	OffsetNamePIDStructLevel    = "pid_level_offset"
	OffsetNamePIDStructNumbers  = "pid_numbers_offset"
	OffsetNameDentryStructDSB   = "dentry_sb_offset"
	OffsetNameTaskStructPID     = "task_struct_pid_offset"      // kernels >= 4.19
	OffsetNameTaskStructPIDLink = "task_struct_pid_link_offset" // kernels < 4.19
	OffsetNamePIDLinkStructPID  = "pid_link_pid_offset"         // kernels < 4.19

	// splice event
	OffsetNamePipeInodeInfoStructBufs     = "pipe_inode_info_bufs_offset"
	OffsetNamePipeInodeInfoStructNrbufs   = "pipe_inode_info_nrbufs_offset"    // kernels < 5.5
	OffsetNamePipeInodeInfoStructCurbuf   = "pipe_inode_info_curbuf_offset"    // kernels < 5.5
	OffsetNamePipeInodeInfoStructBuffers  = "pipe_inode_info_buffers_offset"   // kernels < 5.5
	OffsetNamePipeInodeInfoStructHead     = "pipe_inode_info_head_offset"      // kernels >= 5.5
	OffsetNamePipeInodeInfoStructRingsize = "pipe_inode_info_ring_size_offset" // kernels >= 5.5

	// network related constants
	OffsetNameNetDeviceStructIfIndex    = "net_device_ifindex_offset"
	OffsetNameNetDeviceStructName       = "net_device_name_offset"
	OffsetNameNetStructNS               = "net_ns_offset"
	OffsetNameNetStructProcInum         = "net_proc_inum_offset"
	OffsetNameDeviceStructNdNet         = "device_nd_net_net_offset"
	OffsetNameSockCommonStructSKCNet    = "sock_common_skc_net_offset"
	OffsetNameSocketStructSK            = "socket_sock_offset"
	OffsetNameNFConnStructCTNet         = "nf_conn_ct_net_offset"
	OffsetNameSockCommonStructSKCFamily = "sock_common_skc_family_offset"
	OffsetNameFlowI4StructSADDR         = "flowi4_saddr_offset"
	OffsetNameFlowI6StructSADDR         = "flowi6_saddr_offset"
	OffsetNameFlowI4StructULI           = "flowi4_uli_offset"
	OffsetNameFlowI6StructULI           = "flowi6_uli_offset"

	// Interpreter constants
	OffsetNameLinuxBinprmStructFile = "binprm_file_offset"

	// iouring constants
	OffsetNameIoKiocbStructCtx = "iokiocb_ctx_offset"
)

Offset names in the format "OffsetName[Struct Name]Struct[Field Name]"

View Source
const ErrorSentinel uint64 = ^uint64(0)

ErrorSentinel is the value of an unavailable offset or size

Variables

This section is empty.

Functions

func ClearConstantsCache

func ClearConstantsCache()

ClearConstantsCache clears the constants cache

func CreateConstantEditors

func CreateConstantEditors(constants map[string]uint64) []manager.ConstantEditor

CreateConstantEditors creates constant editors based on the constants fetched

func GetHasUsernamespaceFirstArgWithBtf

func GetHasUsernamespaceFirstArgWithBtf() (bool, error)

GetHasUsernamespaceFirstArgWithBtf not available

func GetHasVFSRenameStructArgs

func GetHasVFSRenameStructArgs() (bool, error)

GetHasVFSRenameStructArgs not available

func ReadTracepointFieldOffset

func ReadTracepointFieldOffset(tracepoint string, field string) (uint64, error)

ReadTracepointFieldOffset reads a field offset from a tracepoint format definition

func ReadTracepointFieldOffsetWithFallback

func ReadTracepointFieldOffsetWithFallback(tracepoint string, field string, fallback uint64) uint64

ReadTracepointFieldOffsetWithFallback reads a field offset from a tracepoint format definition or returns the fallback if any error occurs

Types

type BTFHubConstantFetcher

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

BTFHubConstantFetcher is a constant fetcher based on BTFHub constants

func NewBTFHubConstantFetcher

func NewBTFHubConstantFetcher(kv *kernel.Version) (*BTFHubConstantFetcher, error)

NewBTFHubConstantFetcher returns a new BTFHubConstantFetcher

func (*BTFHubConstantFetcher) AppendOffsetofRequest

func (f *BTFHubConstantFetcher) AppendOffsetofRequest(id, _, _, _ string)

AppendOffsetofRequest appends an offset request

func (*BTFHubConstantFetcher) AppendSizeofRequest

func (f *BTFHubConstantFetcher) AppendSizeofRequest(id, _, _ string)

AppendSizeofRequest appends a sizeof request

func (*BTFHubConstantFetcher) FinishAndGetResults

func (f *BTFHubConstantFetcher) FinishAndGetResults() (map[string]uint64, error)

FinishAndGetResults returns the results

func (*BTFHubConstantFetcher) HasConstantsInStore

func (f *BTFHubConstantFetcher) HasConstantsInStore() bool

HasConstantsInStore returns true if there is constants in store in BTFHub

func (*BTFHubConstantFetcher) String

func (f *BTFHubConstantFetcher) String() string

type BTFHubConstants

type BTFHubConstants struct {
	Commit    string              `json:"commit"`
	Constants []map[string]uint64 `json:"constants"`
	Kernels   []BTFHubKernel      `json:"kernels"`
}

BTFHubConstants represents all the information required for identifying a unique btf file from BTFHub

type BTFHubKernel

type BTFHubKernel struct {
	Distribution   string `json:"distrib"`
	DistribVersion string `json:"version"`
	Arch           string `json:"arch"`
	UnameRelease   string `json:"uname_release"`
	ConstantsIndex int    `json:"cindex"`
}

BTFHubKernel represents all the information required for identifying a unique btf file from BTFHub

type ComposeConstantFetcher

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

ComposeConstantFetcher represents a composition of child constant fetchers It allows the usage of fallbacks if the main source is not working

func ComposeConstantFetchers

func ComposeConstantFetchers(fetchers []ConstantFetcher) *ComposeConstantFetcher

ComposeConstantFetchers creates a new ComposeConstantFetcher based on the passed fetchers

func (*ComposeConstantFetcher) AppendOffsetofRequest

func (f *ComposeConstantFetcher) AppendOffsetofRequest(id, typeName, fieldName, headerName string)

AppendOffsetofRequest appends an offset request

func (*ComposeConstantFetcher) AppendSizeofRequest

func (f *ComposeConstantFetcher) AppendSizeofRequest(id, typeName, headerName string)

AppendSizeofRequest appends a sizeof request

func (*ComposeConstantFetcher) FinishAndGetResults

func (f *ComposeConstantFetcher) FinishAndGetResults() (map[string]uint64, error)

FinishAndGetResults does the actual fetching and returns the results

func (*ComposeConstantFetcher) FinishAndGetStatus

func (f *ComposeConstantFetcher) FinishAndGetStatus() (*ConstantFetcherStatus, error)

FinishAndGetStatus does the actual fetching and returns the status

func (*ComposeConstantFetcher) String

func (f *ComposeConstantFetcher) String() string

type ConstantFetcher

type ConstantFetcher interface {
	fmt.Stringer
	AppendSizeofRequest(id, typeName, headerName string)
	AppendOffsetofRequest(id, typeName, fieldName, headerName string)
	FinishAndGetResults() (map[string]uint64, error)
}

ConstantFetcher represents a source of constants that can be used to fill up eBPF relocations

func GetAvailableConstantFetchers

func GetAvailableConstantFetchers(_ *config.Config, kv *kernel.Version, _ statsd.ClientInterface) []ConstantFetcher

GetAvailableConstantFetchers returns available constant fetchers

type ConstantFetcherStatus

type ConstantFetcherStatus struct {
	Fetchers []string
	Values   map[string]ValueAndSource
}

ConstantFetcherStatus represents the status of the constant fetcher sub-system

type FallbackConstantFetcher

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

FallbackConstantFetcher is a constant fetcher that uses the old fallback heuristics to fetch constants

func NewFallbackConstantFetcher

func NewFallbackConstantFetcher(kv *kernel.Version) *FallbackConstantFetcher

NewFallbackConstantFetcher returns a new FallbackConstantFetcher

func (*FallbackConstantFetcher) AppendOffsetofRequest

func (f *FallbackConstantFetcher) AppendOffsetofRequest(id, _, _, _ string)

AppendOffsetofRequest appends an offset request

func (*FallbackConstantFetcher) AppendSizeofRequest

func (f *FallbackConstantFetcher) AppendSizeofRequest(id, _, _ string)

AppendSizeofRequest appends a sizeof request

func (*FallbackConstantFetcher) FinishAndGetResults

func (f *FallbackConstantFetcher) FinishAndGetResults() (map[string]uint64, error)

FinishAndGetResults returns the results

func (*FallbackConstantFetcher) String

func (f *FallbackConstantFetcher) String() string

type ValueAndSource

type ValueAndSource struct {
	ID          string
	Value       uint64
	FetcherName string
}

ValueAndSource represents the required information about a constant, its id, its value and its source

Jump to

Keyboard shortcuts

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