summaryrefslogtreecommitdiff
path: root/vendor/github.com/cilium/ebpf/internal
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/cilium/ebpf/internal')
-rw-r--r--vendor/github.com/cilium/ebpf/internal/align.go6
-rw-r--r--vendor/github.com/cilium/ebpf/internal/cpu.go62
-rw-r--r--vendor/github.com/cilium/ebpf/internal/elf.go102
-rw-r--r--vendor/github.com/cilium/ebpf/internal/endian_be.go13
-rw-r--r--vendor/github.com/cilium/ebpf/internal/endian_le.go13
-rw-r--r--vendor/github.com/cilium/ebpf/internal/errors.go206
-rw-r--r--vendor/github.com/cilium/ebpf/internal/feature.go100
-rw-r--r--vendor/github.com/cilium/ebpf/internal/io.go62
-rw-r--r--vendor/github.com/cilium/ebpf/internal/output.go84
-rw-r--r--vendor/github.com/cilium/ebpf/internal/pinning.go77
-rw-r--r--vendor/github.com/cilium/ebpf/internal/sys/doc.go6
-rw-r--r--vendor/github.com/cilium/ebpf/internal/sys/fd.go96
-rw-r--r--vendor/github.com/cilium/ebpf/internal/sys/ptr.go38
-rw-r--r--vendor/github.com/cilium/ebpf/internal/sys/ptr_32_be.go15
-rw-r--r--vendor/github.com/cilium/ebpf/internal/sys/ptr_32_le.go15
-rw-r--r--vendor/github.com/cilium/ebpf/internal/sys/ptr_64.go14
-rw-r--r--vendor/github.com/cilium/ebpf/internal/sys/syscall.go126
-rw-r--r--vendor/github.com/cilium/ebpf/internal/sys/types.go1052
-rw-r--r--vendor/github.com/cilium/ebpf/internal/unix/types_linux.go210
-rw-r--r--vendor/github.com/cilium/ebpf/internal/unix/types_other.go278
-rw-r--r--vendor/github.com/cilium/ebpf/internal/vdso.go150
-rw-r--r--vendor/github.com/cilium/ebpf/internal/version.go122
22 files changed, 0 insertions, 2847 deletions
diff --git a/vendor/github.com/cilium/ebpf/internal/align.go b/vendor/github.com/cilium/ebpf/internal/align.go
deleted file mode 100644
index 8b4f2658e..000000000
--- a/vendor/github.com/cilium/ebpf/internal/align.go
+++ /dev/null
@@ -1,6 +0,0 @@
-package internal
-
-// Align returns 'n' updated to 'alignment' boundary.
-func Align(n, alignment int) int {
- return (int(n) + alignment - 1) / alignment * alignment
-}
diff --git a/vendor/github.com/cilium/ebpf/internal/cpu.go b/vendor/github.com/cilium/ebpf/internal/cpu.go
deleted file mode 100644
index 3affa1efb..000000000
--- a/vendor/github.com/cilium/ebpf/internal/cpu.go
+++ /dev/null
@@ -1,62 +0,0 @@
-package internal
-
-import (
- "fmt"
- "os"
- "strings"
- "sync"
-)
-
-var sysCPU struct {
- once sync.Once
- err error
- num int
-}
-
-// PossibleCPUs returns the max number of CPUs a system may possibly have
-// Logical CPU numbers must be of the form 0-n
-func PossibleCPUs() (int, error) {
- sysCPU.once.Do(func() {
- sysCPU.num, sysCPU.err = parseCPUsFromFile("/sys/devices/system/cpu/possible")
- })
-
- return sysCPU.num, sysCPU.err
-}
-
-func parseCPUsFromFile(path string) (int, error) {
- spec, err := os.ReadFile(path)
- if err != nil {
- return 0, err
- }
-
- n, err := parseCPUs(string(spec))
- if err != nil {
- return 0, fmt.Errorf("can't parse %s: %v", path, err)
- }
-
- return n, nil
-}
-
-// parseCPUs parses the number of cpus from a string produced
-// by bitmap_list_string() in the Linux kernel.
-// Multiple ranges are rejected, since they can't be unified
-// into a single number.
-// This is the format of /sys/devices/system/cpu/possible, it
-// is not suitable for /sys/devices/system/cpu/online, etc.
-func parseCPUs(spec string) (int, error) {
- if strings.Trim(spec, "\n") == "0" {
- return 1, nil
- }
-
- var low, high int
- n, err := fmt.Sscanf(spec, "%d-%d\n", &low, &high)
- if n != 2 || err != nil {
- return 0, fmt.Errorf("invalid format: %s", spec)
- }
- if low != 0 {
- return 0, fmt.Errorf("CPU spec doesn't start at zero: %s", spec)
- }
-
- // cpus is 0 indexed
- return high + 1, nil
-}
diff --git a/vendor/github.com/cilium/ebpf/internal/elf.go b/vendor/github.com/cilium/ebpf/internal/elf.go
deleted file mode 100644
index 011581938..000000000
--- a/vendor/github.com/cilium/ebpf/internal/elf.go
+++ /dev/null
@@ -1,102 +0,0 @@
-package internal
-
-import (
- "debug/elf"
- "fmt"
- "io"
-)
-
-type SafeELFFile struct {
- *elf.File
-}
-
-// NewSafeELFFile reads an ELF safely.
-//
-// Any panic during parsing is turned into an error. This is necessary since
-// there are a bunch of unfixed bugs in debug/elf.
-//
-// https://github.com/golang/go/issues?q=is%3Aissue+is%3Aopen+debug%2Felf+in%3Atitle
-func NewSafeELFFile(r io.ReaderAt) (safe *SafeELFFile, err error) {
- defer func() {
- r := recover()
- if r == nil {
- return
- }
-
- safe = nil
- err = fmt.Errorf("reading ELF file panicked: %s", r)
- }()
-
- file, err := elf.NewFile(r)
- if err != nil {
- return nil, err
- }
-
- return &SafeELFFile{file}, nil
-}
-
-// OpenSafeELFFile reads an ELF from a file.
-//
-// It works like NewSafeELFFile, with the exception that safe.Close will
-// close the underlying file.
-func OpenSafeELFFile(path string) (safe *SafeELFFile, err error) {
- defer func() {
- r := recover()
- if r == nil {
- return
- }
-
- safe = nil
- err = fmt.Errorf("reading ELF file panicked: %s", r)
- }()
-
- file, err := elf.Open(path)
- if err != nil {
- return nil, err
- }
-
- return &SafeELFFile{file}, nil
-}
-
-// Symbols is the safe version of elf.File.Symbols.
-func (se *SafeELFFile) Symbols() (syms []elf.Symbol, err error) {
- defer func() {
- r := recover()
- if r == nil {
- return
- }
-
- syms = nil
- err = fmt.Errorf("reading ELF symbols panicked: %s", r)
- }()
-
- syms, err = se.File.Symbols()
- return
-}
-
-// DynamicSymbols is the safe version of elf.File.DynamicSymbols.
-func (se *SafeELFFile) DynamicSymbols() (syms []elf.Symbol, err error) {
- defer func() {
- r := recover()
- if r == nil {
- return
- }
-
- syms = nil
- err = fmt.Errorf("reading ELF dynamic symbols panicked: %s", r)
- }()
-
- syms, err = se.File.DynamicSymbols()
- return
-}
-
-// SectionsByType returns all sections in the file with the specified section type.
-func (se *SafeELFFile) SectionsByType(typ elf.SectionType) []*elf.Section {
- sections := make([]*elf.Section, 0, 1)
- for _, section := range se.Sections {
- if section.Type == typ {
- sections = append(sections, section)
- }
- }
- return sections
-}
diff --git a/vendor/github.com/cilium/ebpf/internal/endian_be.go b/vendor/github.com/cilium/ebpf/internal/endian_be.go
deleted file mode 100644
index ad33cda85..000000000
--- a/vendor/github.com/cilium/ebpf/internal/endian_be.go
+++ /dev/null
@@ -1,13 +0,0 @@
-//go:build armbe || arm64be || mips || mips64 || mips64p32 || ppc64 || s390 || s390x || sparc || sparc64
-// +build armbe arm64be mips mips64 mips64p32 ppc64 s390 s390x sparc sparc64
-
-package internal
-
-import "encoding/binary"
-
-// NativeEndian is set to either binary.BigEndian or binary.LittleEndian,
-// depending on the host's endianness.
-var NativeEndian binary.ByteOrder = binary.BigEndian
-
-// ClangEndian is set to either "el" or "eb" depending on the host's endianness.
-const ClangEndian = "eb"
diff --git a/vendor/github.com/cilium/ebpf/internal/endian_le.go b/vendor/github.com/cilium/ebpf/internal/endian_le.go
deleted file mode 100644
index 41a68224c..000000000
--- a/vendor/github.com/cilium/ebpf/internal/endian_le.go
+++ /dev/null
@@ -1,13 +0,0 @@
-//go:build 386 || amd64 || amd64p32 || arm || arm64 || mipsle || mips64le || mips64p32le || ppc64le || riscv64
-// +build 386 amd64 amd64p32 arm arm64 mipsle mips64le mips64p32le ppc64le riscv64
-
-package internal
-
-import "encoding/binary"
-
-// NativeEndian is set to either binary.BigEndian or binary.LittleEndian,
-// depending on the host's endianness.
-var NativeEndian binary.ByteOrder = binary.LittleEndian
-
-// ClangEndian is set to either "el" or "eb" depending on the host's endianness.
-const ClangEndian = "el"
diff --git a/vendor/github.com/cilium/ebpf/internal/errors.go b/vendor/github.com/cilium/ebpf/internal/errors.go
deleted file mode 100644
index b5ccdd7d0..000000000
--- a/vendor/github.com/cilium/ebpf/internal/errors.go
+++ /dev/null
@@ -1,206 +0,0 @@
-package internal
-
-import (
- "bytes"
- "fmt"
- "io"
- "strings"
-)
-
-// ErrorWithLog returns an error which includes logs from the kernel verifier.
-//
-// The default error output is a summary of the full log. The latter can be
-// accessed via VerifierError.Log or by formatting the error, see Format.
-//
-// A set of heuristics is used to determine whether the log has been truncated.
-func ErrorWithLog(err error, log []byte) *VerifierError {
- const whitespace = "\t\r\v\n "
-
- // Convert verifier log C string by truncating it on the first 0 byte
- // and trimming trailing whitespace before interpreting as a Go string.
- truncated := false
- if i := bytes.IndexByte(log, 0); i != -1 {
- if i == len(log)-1 && !bytes.HasSuffix(log[:i], []byte{'\n'}) {
- // The null byte is at the end of the buffer and it's not preceded
- // by a newline character. Most likely the buffer was too short.
- truncated = true
- }
-
- log = log[:i]
- } else if len(log) > 0 {
- // No null byte? Dodgy!
- truncated = true
- }
-
- log = bytes.Trim(log, whitespace)
- logLines := bytes.Split(log, []byte{'\n'})
- lines := make([]string, 0, len(logLines))
- for _, line := range logLines {
- // Don't remove leading white space on individual lines. We rely on it
- // when outputting logs.
- lines = append(lines, string(bytes.TrimRight(line, whitespace)))
- }
-
- return &VerifierError{err, lines, truncated}
-}
-
-// VerifierError includes information from the eBPF verifier.
-//
-// It summarises the log output, see Format if you want to output the full contents.
-type VerifierError struct {
- // The error which caused this error.
- Cause error
- // The verifier output split into lines.
- Log []string
- // Whether the log output is truncated, based on several heuristics.
- Truncated bool
-}
-
-func (le *VerifierError) Unwrap() error {
- return le.Cause
-}
-
-func (le *VerifierError) Error() string {
- log := le.Log
- if n := len(log); n > 0 && strings.HasPrefix(log[n-1], "processed ") {
- // Get rid of "processed 39 insns (limit 1000000) ..." from summary.
- log = log[:n-1]
- }
-
- n := len(log)
- if n == 0 {
- return le.Cause.Error()
- }
-
- lines := log[n-1:]
- if n >= 2 && (includePreviousLine(log[n-1]) || le.Truncated) {
- // Add one more line of context if it aids understanding the error.
- lines = log[n-2:]
- }
-
- var b strings.Builder
- fmt.Fprintf(&b, "%s: ", le.Cause.Error())
-
- for i, line := range lines {
- b.WriteString(strings.TrimSpace(line))
- if i != len(lines)-1 {
- b.WriteString(": ")
- }
- }
-
- omitted := len(le.Log) - len(lines)
- if omitted == 0 && !le.Truncated {
- return b.String()
- }
-
- b.WriteString(" (")
- if le.Truncated {
- b.WriteString("truncated")
- }
-
- if omitted > 0 {
- if le.Truncated {
- b.WriteString(", ")
- }
- fmt.Fprintf(&b, "%d line(s) omitted", omitted)
- }
- b.WriteString(")")
-
- return b.String()
-}
-
-// includePreviousLine returns true if the given line likely is better
-// understood with additional context from the preceding line.
-func includePreviousLine(line string) bool {
- // We need to find a good trade off between understandable error messages
- // and too much complexity here. Checking the string prefix is ok, requiring
- // regular expressions to do it is probably overkill.
-
- if strings.HasPrefix(line, "\t") {
- // [13] STRUCT drm_rect size=16 vlen=4
- // \tx1 type_id=2
- return true
- }
-
- if len(line) >= 2 && line[0] == 'R' && line[1] >= '0' && line[1] <= '9' {
- // 0: (95) exit
- // R0 !read_ok
- return true
- }
-
- if strings.HasPrefix(line, "invalid bpf_context access") {
- // 0: (79) r6 = *(u64 *)(r1 +0)
- // func '__x64_sys_recvfrom' arg0 type FWD is not a struct
- // invalid bpf_context access off=0 size=8
- return true
- }
-
- return false
-}
-
-// Format the error.
-//
-// Understood verbs are %s and %v, which are equivalent to calling Error(). %v
-// allows outputting additional information using the following flags:
-//
-// + Output the first <width> lines, or all lines if no width is given.
-// - Output the last <width> lines, or all lines if no width is given.
-//
-// Use width to specify how many lines to output. Use the '-' flag to output
-// lines from the end of the log instead of the beginning.
-func (le *VerifierError) Format(f fmt.State, verb rune) {
- switch verb {
- case 's':
- _, _ = io.WriteString(f, le.Error())
-
- case 'v':
- n, haveWidth := f.Width()
- if !haveWidth || n > len(le.Log) {
- n = len(le.Log)
- }
-
- if !f.Flag('+') && !f.Flag('-') {
- if haveWidth {
- _, _ = io.WriteString(f, "%!v(BADWIDTH)")
- return
- }
-
- _, _ = io.WriteString(f, le.Error())
- return
- }
-
- if f.Flag('+') && f.Flag('-') {
- _, _ = io.WriteString(f, "%!v(BADFLAG)")
- return
- }
-
- fmt.Fprintf(f, "%s:", le.Cause.Error())
-
- omitted := len(le.Log) - n
- lines := le.Log[:n]
- if f.Flag('-') {
- // Print last instead of first lines.
- lines = le.Log[len(le.Log)-n:]
- if omitted > 0 {
- fmt.Fprintf(f, "\n\t(%d line(s) omitted)", omitted)
- }
- }
-
- for _, line := range lines {
- fmt.Fprintf(f, "\n\t%s", line)
- }
-
- if !f.Flag('-') {
- if omitted > 0 {
- fmt.Fprintf(f, "\n\t(%d line(s) omitted)", omitted)
- }
- }
-
- if le.Truncated {
- fmt.Fprintf(f, "\n\t(truncated)")
- }
-
- default:
- fmt.Fprintf(f, "%%!%c(BADVERB)", verb)
- }
-}
diff --git a/vendor/github.com/cilium/ebpf/internal/feature.go b/vendor/github.com/cilium/ebpf/internal/feature.go
deleted file mode 100644
index 0a6c2d1d5..000000000
--- a/vendor/github.com/cilium/ebpf/internal/feature.go
+++ /dev/null
@@ -1,100 +0,0 @@
-package internal
-
-import (
- "errors"
- "fmt"
- "sync"
-)
-
-// ErrNotSupported indicates that a feature is not supported by the current kernel.
-var ErrNotSupported = errors.New("not supported")
-
-// UnsupportedFeatureError is returned by FeatureTest() functions.
-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
-}
-
-func (ufe *UnsupportedFeatureError) Error() string {
- if ufe.MinimumVersion.Unspecified() {
- return fmt.Sprintf("%s not supported", ufe.Name)
- }
- return fmt.Sprintf("%s not supported (requires >= %s)", ufe.Name, ufe.MinimumVersion)
-}
-
-// Is indicates that UnsupportedFeatureError is ErrNotSupported.
-func (ufe *UnsupportedFeatureError) Is(target error) bool {
- return target == ErrNotSupported
-}
-
-type featureTest struct {
- sync.RWMutex
- successful bool
- result error
-}
-
-// FeatureTestFn is used to determine whether the kernel supports
-// a certain feature.
-//
-// The return values have the following semantics:
-//
-// err == ErrNotSupported: the feature is not available
-// err == nil: the feature is available
-// err != nil: the test couldn't be executed
-type 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 FeatureTest(name, version string, fn FeatureTestFn) func() error {
- ft := new(featureTest)
- return func() error {
- ft.RLock()
- if ft.successful {
- defer ft.RUnlock()
- return ft.result
- }
- ft.RUnlock()
- ft.Lock()
- defer ft.Unlock()
- // check one more time on the off
- // chance that two go routines
- // were able to call into the write
- // lock
- if ft.successful {
- return ft.result
- }
- err := fn()
- switch {
- case errors.Is(err, ErrNotSupported):
- v, err := NewVersion(version)
- if err != nil {
- return err
- }
-
- ft.result = &UnsupportedFeatureError{
- MinimumVersion: v,
- Name: name,
- }
- fallthrough
-
- case err == nil:
- ft.successful = true
-
- default:
- // We couldn't execute the feature test to a point
- // where it could make a determination.
- // Don't cache the result, just return it.
- return fmt.Errorf("detect support for %s: %w", name, err)
- }
-
- return ft.result
- }
-}
diff --git a/vendor/github.com/cilium/ebpf/internal/io.go b/vendor/github.com/cilium/ebpf/internal/io.go
deleted file mode 100644
index 30b6641f0..000000000
--- a/vendor/github.com/cilium/ebpf/internal/io.go
+++ /dev/null
@@ -1,62 +0,0 @@
-package internal
-
-import (
- "bufio"
- "compress/gzip"
- "errors"
- "io"
- "os"
-)
-
-// NewBufferedSectionReader wraps an io.ReaderAt in an appropriately-sized
-// buffered reader. It is a convenience function for reading subsections of
-// ELF sections while minimizing the amount of read() syscalls made.
-//
-// Syscall overhead is non-negligible in continuous integration context
-// where ELFs might be accessed over virtual filesystems with poor random
-// access performance. Buffering reads makes sense because (sub)sections
-// end up being read completely anyway.
-//
-// Use instead of the r.Seek() + io.LimitReader() pattern.
-func NewBufferedSectionReader(ra io.ReaderAt, off, n int64) *bufio.Reader {
- // Clamp the size of the buffer to one page to avoid slurping large parts
- // of a file into memory. bufio.NewReader uses a hardcoded default buffer
- // of 4096. Allow arches with larger pages to allocate more, but don't
- // allocate a fixed 4k buffer if we only need to read a small segment.
- buf := n
- if ps := int64(os.Getpagesize()); n > ps {
- buf = ps
- }
-
- return bufio.NewReaderSize(io.NewSectionReader(ra, off, n), int(buf))
-}
-
-// DiscardZeroes makes sure that all written bytes are zero
-// before discarding them.
-type DiscardZeroes struct{}
-
-func (DiscardZeroes) Write(p []byte) (int, error) {
- for _, b := range p {
- if b != 0 {
- return 0, errors.New("encountered non-zero byte")
- }
- }
- return len(p), nil
-}
-
-// ReadAllCompressed decompresses a gzipped file into memory.
-func ReadAllCompressed(file string) ([]byte, error) {
- fh, err := os.Open(file)
- if err != nil {
- return nil, err
- }
- defer fh.Close()
-
- gz, err := gzip.NewReader(fh)
- if err != nil {
- return nil, err
- }
- defer gz.Close()
-
- return io.ReadAll(gz)
-}
diff --git a/vendor/github.com/cilium/ebpf/internal/output.go b/vendor/github.com/cilium/ebpf/internal/output.go
deleted file mode 100644
index aeab37fcf..000000000
--- a/vendor/github.com/cilium/ebpf/internal/output.go
+++ /dev/null
@@ -1,84 +0,0 @@
-package internal
-
-import (
- "bytes"
- "errors"
- "go/format"
- "go/scanner"
- "io"
- "strings"
- "unicode"
-)
-
-// Identifier turns a C style type or field name into an exportable Go equivalent.
-func Identifier(str string) string {
- prev := rune(-1)
- return strings.Map(func(r rune) rune {
- // See https://golang.org/ref/spec#Identifiers
- switch {
- case unicode.IsLetter(r):
- if prev == -1 {
- r = unicode.ToUpper(r)
- }
-
- case r == '_':
- switch {
- // The previous rune was deleted, or we are at the
- // beginning of the string.
- case prev == -1:
- fallthrough
-
- // The previous rune is a lower case letter or a digit.
- case unicode.IsDigit(prev) || (unicode.IsLetter(prev) && unicode.IsLower(prev)):
- // delete the current rune, and force the
- // next character to be uppercased.
- r = -1
- }
-
- case unicode.IsDigit(r):
-
- default:
- // Delete the current rune. prev is unchanged.
- return -1
- }
-
- prev = r
- return r
- }, str)
-}
-
-// WriteFormatted outputs a formatted src into out.
-//
-// If formatting fails it returns an informative error message.
-func WriteFormatted(src []byte, out io.Writer) error {
- formatted, err := format.Source(src)
- if err == nil {
- _, err = out.Write(formatted)
- return err
- }
-
- var el scanner.ErrorList
- if !errors.As(err, &el) {
- return err
- }
-
- var nel scanner.ErrorList
- for _, err := range el {
- if !err.Pos.IsValid() {
- nel = append(nel, err)
- continue
- }
-
- buf := src[err.Pos.Offset:]
- nl := bytes.IndexRune(buf, '\n')
- if nl == -1 {
- nel = append(nel, err)
- continue
- }
-
- err.Msg += ": " + string(buf[:nl])
- nel = append(nel, err)
- }
-
- return nel
-}
diff --git a/vendor/github.com/cilium/ebpf/internal/pinning.go b/vendor/github.com/cilium/ebpf/internal/pinning.go
deleted file mode 100644
index c711353c3..000000000
--- a/vendor/github.com/cilium/ebpf/internal/pinning.go
+++ /dev/null
@@ -1,77 +0,0 @@
-package internal
-
-import (
- "errors"
- "fmt"
- "os"
- "path/filepath"
- "runtime"
- "unsafe"
-
- "github.com/cilium/ebpf/internal/sys"
- "github.com/cilium/ebpf/internal/unix"
-)
-
-func Pin(currentPath, newPath string, fd *sys.FD) error {
- const bpfFSType = 0xcafe4a11
-
- if newPath == "" {
- return errors.New("given pinning path cannot be empty")
- }
- if currentPath == newPath {
- return nil
- }
-
- var statfs unix.Statfs_t
- if err := unix.Statfs(filepath.Dir(newPath), &statfs); err != nil {
- return err
- }
-
- fsType := int64(statfs.Type)
- if unsafe.Sizeof(statfs.Type) == 4 {
- // We're on a 32 bit arch, where statfs.Type is int32. bpfFSType is a
- // negative number when interpreted as int32 so we need to cast via
- // uint32 to avoid sign extension.
- fsType = int64(uint32(statfs.Type))
- }
-
- if fsType != bpfFSType {
- return fmt.Errorf("%s is not on a bpf filesystem", newPath)
- }
-
- defer runtime.KeepAlive(fd)
-
- if currentPath == "" {
- return sys.ObjPin(&sys.ObjPinAttr{
- Pathname: sys.NewStringPointer(newPath),
- BpfFd: fd.Uint(),
- })
- }
-
- // Renameat2 is used instead of os.Rename to disallow the new path replacing
- // an existing path.
- err := unix.Renameat2(unix.AT_FDCWD, currentPath, unix.AT_FDCWD, newPath, unix.RENAME_NOREPLACE)
- if err == nil {
- // Object is now moved to the new pinning path.
- return nil
- }
- if !os.IsNotExist(err) {
- return fmt.Errorf("unable to move pinned object to new path %v: %w", newPath, err)
- }
- // Internal state not in sync with the file system so let's fix it.
- return sys.ObjPin(&sys.ObjPinAttr{
- Pathname: sys.NewStringPointer(newPath),
- BpfFd: fd.Uint(),
- })
-}
-
-func Unpin(pinnedPath string) error {
- if pinnedPath == "" {
- return nil
- }
- err := os.Remove(pinnedPath)
- if err == nil || os.IsNotExist(err) {
- return nil
- }
- return err
-}
diff --git a/vendor/github.com/cilium/ebpf/internal/sys/doc.go b/vendor/github.com/cilium/ebpf/internal/sys/doc.go
deleted file mode 100644
index dfe174448..000000000
--- a/vendor/github.com/cilium/ebpf/internal/sys/doc.go
+++ /dev/null
@@ -1,6 +0,0 @@
-// Package sys contains bindings for the BPF syscall.
-package sys
-
-// Regenerate types.go by invoking go generate in the current directory.
-
-//go:generate go run github.com/cilium/ebpf/internal/cmd/gentypes ../../btf/testdata/vmlinux.btf.gz
diff --git a/vendor/github.com/cilium/ebpf/internal/sys/fd.go b/vendor/github.com/cilium/ebpf/internal/sys/fd.go
deleted file mode 100644
index 65517d45e..000000000
--- a/vendor/github.com/cilium/ebpf/internal/sys/fd.go
+++ /dev/null
@@ -1,96 +0,0 @@
-package sys
-
-import (
- "fmt"
- "math"
- "os"
- "runtime"
- "strconv"
-
- "github.com/cilium/ebpf/internal/unix"
-)
-
-var ErrClosedFd = unix.EBADF
-
-type FD struct {
- raw int
-}
-
-func newFD(value int) *FD {
- fd := &FD{value}
- runtime.SetFinalizer(fd, (*FD).Close)
- return fd
-}
-
-// NewFD wraps a raw fd with a finalizer.
-//
-// You must not use the raw fd after calling this function, since the underlying
-// file descriptor number may change. This is because the BPF UAPI assumes that
-// zero is not a valid fd value.
-func NewFD(value int) (*FD, error) {
- if value < 0 {
- return nil, fmt.Errorf("invalid fd %d", value)
- }
-
- fd := newFD(value)
- if value != 0 {
- return fd, nil
- }
-
- dup, err := fd.Dup()
- _ = fd.Close()
- return dup, err
-}
-
-func (fd *FD) String() string {
- return strconv.FormatInt(int64(fd.raw), 10)
-}
-
-func (fd *FD) Int() int {
- return fd.raw
-}
-
-func (fd *FD) Uint() uint32 {
- if fd.raw < 0 || int64(fd.raw) > math.MaxUint32 {
- // Best effort: this is the number most likely to be an invalid file
- // descriptor. It is equal to -1 (on two's complement arches).
- return math.MaxUint32
- }
- return uint32(fd.raw)
-}
-
-func (fd *FD) Close() error {
- if fd.raw < 0 {
- return nil
- }
-
- value := int(fd.raw)
- fd.raw = -1
-
- fd.Forget()
- return unix.Close(value)
-}
-
-func (fd *FD) Forget() {
- runtime.SetFinalizer(fd, nil)
-}
-
-func (fd *FD) Dup() (*FD, error) {
- if fd.raw < 0 {
- return nil, ErrClosedFd
- }
-
- // Always require the fd to be larger than zero: the BPF API treats the value
- // as "no argument provided".
- dup, err := unix.FcntlInt(uintptr(fd.raw), unix.F_DUPFD_CLOEXEC, 1)
- if err != nil {
- return nil, fmt.Errorf("can't dup fd: %v", err)
- }
-
- return newFD(dup), nil
-}
-
-func (fd *FD) File(name string) *os.File {
- fd.Forget()
- return os.NewFile(uintptr(fd.raw), name)
-}
diff --git a/vendor/github.com/cilium/ebpf/internal/sys/ptr.go b/vendor/github.com/cilium/ebpf/internal/sys/ptr.go
deleted file mode 100644
index a22100688..000000000
--- a/vendor/github.com/cilium/ebpf/internal/sys/ptr.go
+++ /dev/null
@@ -1,38 +0,0 @@
-package sys
-
-import (
- "unsafe"
-
- "github.com/cilium/ebpf/internal/unix"
-)
-
-// NewPointer creates a 64-bit pointer from an unsafe Pointer.
-func NewPointer(ptr unsafe.Pointer) Pointer {
- return Pointer{ptr: ptr}
-}
-
-// NewSlicePointer creates a 64-bit pointer from a byte slice.
-func NewSlicePointer(buf []byte) Pointer {
- if len(buf) == 0 {
- return Pointer{}
- }
-
- return Pointer{ptr: unsafe.Pointer(&buf[0])}
-}
-
-// NewSlicePointer creates a 64-bit pointer from a byte slice.
-//
-// Useful to assign both the pointer and the length in one go.
-func NewSlicePointerLen(buf []byte) (Pointer, uint32) {
- return NewSlicePointer(buf), uint32(len(buf))
-}
-
-// NewStringPointer creates a 64-bit pointer from a string.
-func NewStringPointer(str string) Pointer {
- p, err := unix.BytePtrFromString(str)
- if err != nil {
- return Pointer{}
- }
-
- return Pointer{ptr: unsafe.Pointer(p)}
-}
diff --git a/vendor/github.com/cilium/ebpf/internal/sys/ptr_32_be.go b/vendor/github.com/cilium/ebpf/internal/sys/ptr_32_be.go
deleted file mode 100644
index df903d780..000000000
--- a/vendor/github.com/cilium/ebpf/internal/sys/ptr_32_be.go
+++ /dev/null
@@ -1,15 +0,0 @@
-//go:build armbe || mips || mips64p32
-// +build armbe mips mips64p32
-
-package sys
-
-import (
- "unsafe"
-)
-
-// Pointer wraps an unsafe.Pointer to be 64bit to
-// conform to the syscall specification.
-type Pointer struct {
- pad uint32
- ptr unsafe.Pointer
-}
diff --git a/vendor/github.com/cilium/ebpf/internal/sys/ptr_32_le.go b/vendor/github.com/cilium/ebpf/internal/sys/ptr_32_le.go
deleted file mode 100644
index a6a51edb6..000000000
--- a/vendor/github.com/cilium/ebpf/internal/sys/ptr_32_le.go
+++ /dev/null
@@ -1,15 +0,0 @@
-//go:build 386 || amd64p32 || arm || mipsle || mips64p32le
-// +build 386 amd64p32 arm mipsle mips64p32le
-
-package sys
-
-import (
- "unsafe"
-)
-
-// Pointer wraps an unsafe.Pointer to be 64bit to
-// conform to the syscall specification.
-type Pointer struct {
- ptr unsafe.Pointer
- pad uint32
-}
diff --git a/vendor/github.com/cilium/ebpf/internal/sys/ptr_64.go b/vendor/github.com/cilium/ebpf/internal/sys/ptr_64.go
deleted file mode 100644
index 7c0279e48..000000000
--- a/vendor/github.com/cilium/ebpf/internal/sys/ptr_64.go
+++ /dev/null
@@ -1,14 +0,0 @@
-//go:build !386 && !amd64p32 && !arm && !mipsle && !mips64p32le && !armbe && !mips && !mips64p32
-// +build !386,!amd64p32,!arm,!mipsle,!mips64p32le,!armbe,!mips,!mips64p32
-
-package sys
-
-import (
- "unsafe"
-)
-
-// Pointer wraps an unsafe.Pointer to be 64bit to
-// conform to the syscall specification.
-type Pointer struct {
- ptr unsafe.Pointer
-}
diff --git a/vendor/github.com/cilium/ebpf/internal/sys/syscall.go b/vendor/github.com/cilium/ebpf/internal/sys/syscall.go
deleted file mode 100644
index 2a5935dc9..000000000
--- a/vendor/github.com/cilium/ebpf/internal/sys/syscall.go
+++ /dev/null
@@ -1,126 +0,0 @@
-package sys
-
-import (
- "runtime"
- "syscall"
- "unsafe"
-
- "github.com/cilium/ebpf/internal/unix"
-)
-
-// BPF wraps SYS_BPF.
-//
-// Any pointers contained in attr must use the Pointer type from this package.
-func BPF(cmd Cmd, attr unsafe.Pointer, size uintptr) (uintptr, error) {
- for {
- r1, _, errNo := unix.Syscall(unix.SYS_BPF, uintptr(cmd), uintptr(attr), size)
- runtime.KeepAlive(attr)
-
- // As of ~4.20 the verifier can be interrupted by a signal,
- // and returns EAGAIN in that case.
- if errNo == unix.EAGAIN && cmd == BPF_PROG_LOAD {
- continue
- }
-
- var err error
- if errNo != 0 {
- err = wrappedErrno{errNo}
- }
-
- return r1, err
- }
-}
-
-// Info is implemented by all structs that can be passed to the ObjInfo syscall.
-//
-// MapInfo
-// ProgInfo
-// LinkInfo
-// BtfInfo
-type Info interface {
- info() (unsafe.Pointer, uint32)
-}
-
-var _ Info = (*MapInfo)(nil)
-
-func (i *MapInfo) info() (unsafe.Pointer, uint32) {
- return unsafe.Pointer(i), uint32(unsafe.Sizeof(*i))
-}
-
-var _ Info = (*ProgInfo)(nil)
-
-func (i *ProgInfo) info() (unsafe.Pointer, uint32) {
- return unsafe.Pointer(i), uint32(unsafe.Sizeof(*i))
-}
-
-var _ Info = (*LinkInfo)(nil)
-
-func (i *LinkInfo) info() (unsafe.Pointer, uint32) {
- return unsafe.Pointer(i), uint32(unsafe.Sizeof(*i))
-}
-
-var _ Info = (*BtfInfo)(nil)
-
-func (i *BtfInfo) info() (unsafe.Pointer, uint32) {
- return unsafe.Pointer(i), uint32(unsafe.Sizeof(*i))
-}
-
-// ObjInfo retrieves information about a BPF Fd.
-//
-// info may be one of MapInfo, ProgInfo, LinkInfo and BtfInfo.
-func ObjInfo(fd *FD, info Info) error {
- ptr, len := info.info()
- err := ObjGetInfoByFd(&ObjGetInfoByFdAttr{
- BpfFd: fd.Uint(),
- InfoLen: len,
- Info: NewPointer(ptr),
- })
- runtime.KeepAlive(fd)
- return err
-}
-
-// BPFObjName is a null-terminated string made up of
-// 'A-Za-z0-9_' characters.
-type ObjName [unix.BPF_OBJ_NAME_LEN]byte
-
-// NewObjName truncates the result if it is too long.
-func NewObjName(name string) ObjName {
- var result ObjName
- copy(result[:unix.BPF_OBJ_NAME_LEN-1], name)
- return result
-}
-
-// LinkID uniquely identifies a bpf_link.
-type LinkID uint32
-
-// BTFID uniquely identifies a BTF blob loaded into the kernel.
-type BTFID uint32
-
-// wrappedErrno wraps syscall.Errno to prevent direct comparisons with
-// syscall.E* or unix.E* constants.
-//
-// You should never export an error of this type.
-type wrappedErrno struct {
- syscall.Errno
-}
-
-func (we wrappedErrno) Unwrap() error {
- return we.Errno
-}
-
-type syscallError struct {
- error
- errno syscall.Errno
-}
-
-func Error(err error, errno syscall.Errno) error {
- return &syscallError{err, errno}
-}
-
-func (se *syscallError) Is(target error) bool {
- return target == se.error
-}
-
-func (se *syscallError) Unwrap() error {
- return se.errno
-}
diff --git a/vendor/github.com/cilium/ebpf/internal/sys/types.go b/vendor/github.com/cilium/ebpf/internal/sys/types.go
deleted file mode 100644
index 291e3a619..000000000
--- a/vendor/github.com/cilium/ebpf/internal/sys/types.go
+++ /dev/null
@@ -1,1052 +0,0 @@
-// Code generated by internal/cmd/gentypes; DO NOT EDIT.
-
-package sys
-
-import (
- "unsafe"
-)
-
-type AdjRoomMode int32
-
-const (
- BPF_ADJ_ROOM_NET AdjRoomMode = 0
- BPF_ADJ_ROOM_MAC AdjRoomMode = 1
-)
-
-type AttachType int32
-
-const (
- BPF_CGROUP_INET_INGRESS AttachType = 0
- BPF_CGROUP_INET_EGRESS AttachType = 1
- BPF_CGROUP_INET_SOCK_CREATE AttachType = 2
- BPF_CGROUP_SOCK_OPS AttachType = 3
- BPF_SK_SKB_STREAM_PARSER AttachType = 4
- BPF_SK_SKB_STREAM_VERDICT AttachType = 5
- BPF_CGROUP_DEVICE AttachType = 6
- BPF_SK_MSG_VERDICT AttachType = 7
- BPF_CGROUP_INET4_BIND AttachType = 8
- BPF_CGROUP_INET6_BIND AttachType = 9
- BPF_CGROUP_INET4_CONNECT AttachType = 10
- BPF_CGROUP_INET6_CONNECT AttachType = 11
- BPF_CGROUP_INET4_POST_BIND AttachType = 12
- BPF_CGROUP_INET6_POST_BIND AttachType = 13
- BPF_CGROUP_UDP4_SENDMSG AttachType = 14
- BPF_CGROUP_UDP6_SENDMSG AttachType = 15
- BPF_LIRC_MODE2 AttachType = 16
- BPF_FLOW_DISSECTOR AttachType = 17
- BPF_CGROUP_SYSCTL AttachType = 18
- BPF_CGROUP_UDP4_RECVMSG AttachType = 19
- BPF_CGROUP_UDP6_RECVMSG AttachType = 20
- BPF_CGROUP_GETSOCKOPT AttachType = 21
- BPF_CGROUP_SETSOCKOPT AttachType = 22
- BPF_TRACE_RAW_TP AttachType = 23
- BPF_TRACE_FENTRY AttachType = 24
- BPF_TRACE_FEXIT AttachType = 25
- BPF_MODIFY_RETURN AttachType = 26
- BPF_LSM_MAC AttachType = 27
- BPF_TRACE_ITER AttachType = 28
- BPF_CGROUP_INET4_GETPEERNAME AttachType = 29
- BPF_CGROUP_INET6_GETPEERNAME AttachType = 30
- BPF_CGROUP_INET4_GETSOCKNAME AttachType = 31
- BPF_CGROUP_INET6_GETSOCKNAME AttachType = 32
- BPF_XDP_DEVMAP AttachType = 33
- BPF_CGROUP_INET_SOCK_RELEASE AttachType = 34
- BPF_XDP_CPUMAP AttachType = 35
- BPF_SK_LOOKUP AttachType = 36
- BPF_XDP AttachType = 37
- BPF_SK_SKB_VERDICT AttachType = 38
- BPF_SK_REUSEPORT_SELECT AttachType = 39
- BPF_SK_REUSEPORT_SELECT_OR_MIGRATE AttachType = 40
- BPF_PERF_EVENT AttachType = 41
- BPF_TRACE_KPROBE_MULTI AttachType = 42
- __MAX_BPF_ATTACH_TYPE AttachType = 43
-)
-
-type Cmd int32
-
-const (
- BPF_MAP_CREATE Cmd = 0
- BPF_MAP_LOOKUP_ELEM Cmd = 1
- BPF_MAP_UPDATE_ELEM Cmd = 2
- BPF_MAP_DELETE_ELEM Cmd = 3
- BPF_MAP_GET_NEXT_KEY Cmd = 4
- BPF_PROG_LOAD Cmd = 5
- BPF_OBJ_PIN Cmd = 6
- BPF_OBJ_GET Cmd = 7
- BPF_PROG_ATTACH Cmd = 8
- BPF_PROG_DETACH Cmd = 9
- BPF_PROG_TEST_RUN Cmd = 10
- BPF_PROG_RUN Cmd = 10
- BPF_PROG_GET_NEXT_ID Cmd = 11
- BPF_MAP_GET_NEXT_ID Cmd = 12
- BPF_PROG_GET_FD_BY_ID Cmd = 13
- BPF_MAP_GET_FD_BY_ID Cmd = 14
- BPF_OBJ_GET_INFO_BY_FD Cmd = 15
- BPF_PROG_QUERY Cmd = 16
- BPF_RAW_TRACEPOINT_OPEN Cmd = 17
- BPF_BTF_LOAD Cmd = 18
- BPF_BTF_GET_FD_BY_ID Cmd = 19
- BPF_TASK_FD_QUERY Cmd = 20
- BPF_MAP_LOOKUP_AND_DELETE_ELEM Cmd = 21
- BPF_MAP_FREEZE Cmd = 22
- BPF_BTF_GET_NEXT_ID Cmd = 23
- BPF_MAP_LOOKUP_BATCH Cmd = 24
- BPF_MAP_LOOKUP_AND_DELETE_BATCH Cmd = 25
- BPF_MAP_UPDATE_BATCH Cmd = 26
- BPF_MAP_DELETE_BATCH Cmd = 27
- BPF_LINK_CREATE Cmd = 28
- BPF_LINK_UPDATE Cmd = 29
- BPF_LINK_GET_FD_BY_ID Cmd = 30
- BPF_LINK_GET_NEXT_ID Cmd = 31
- BPF_ENABLE_STATS Cmd = 32
- BPF_ITER_CREATE Cmd = 33
- BPF_LINK_DETACH Cmd = 34
- BPF_PROG_BIND_MAP Cmd = 35
-)
-
-type FunctionId int32
-
-const (
- BPF_FUNC_unspec FunctionId = 0
- BPF_FUNC_map_lookup_elem FunctionId = 1
- BPF_FUNC_map_update_elem FunctionId = 2
- BPF_FUNC_map_delete_elem FunctionId = 3
- BPF_FUNC_probe_read FunctionId = 4
- BPF_FUNC_ktime_get_ns FunctionId = 5
- BPF_FUNC_trace_printk FunctionId = 6
- BPF_FUNC_get_prandom_u32 FunctionId = 7
- BPF_FUNC_get_smp_processor_id FunctionId = 8
- BPF_FUNC_skb_store_bytes FunctionId = 9
- BPF_FUNC_l3_csum_replace FunctionId = 10
- BPF_FUNC_l4_csum_replace FunctionId = 11
- BPF_FUNC_tail_call FunctionId = 12
- BPF_FUNC_clone_redirect FunctionId = 13
- BPF_FUNC_get_current_pid_tgid FunctionId = 14
- BPF_FUNC_get_current_uid_gid FunctionId = 15
- BPF_FUNC_get_current_comm FunctionId = 16
- BPF_FUNC_get_cgroup_classid FunctionId = 17
- BPF_FUNC_skb_vlan_push FunctionId = 18
- BPF_FUNC_skb_vlan_pop FunctionId = 19
- BPF_FUNC_skb_get_tunnel_key FunctionId = 20
- BPF_FUNC_skb_set_tunnel_key FunctionId = 21
- BPF_FUNC_perf_event_read FunctionId = 22
- BPF_FUNC_redirect FunctionId = 23
- BPF_FUNC_get_route_realm FunctionId = 24
- BPF_FUNC_perf_event_output FunctionId = 25
- BPF_FUNC_skb_load_bytes FunctionId = 26
- BPF_FUNC_get_stackid FunctionId = 27
- BPF_FUNC_csum_diff FunctionId = 28
- BPF_FUNC_skb_get_tunnel_opt FunctionId = 29
- BPF_FUNC_skb_set_tunnel_opt FunctionId = 30
- BPF_FUNC_skb_change_proto FunctionId = 31
- BPF_FUNC_skb_change_type FunctionId = 32
- BPF_FUNC_skb_under_cgroup FunctionId = 33
- BPF_FUNC_get_hash_recalc FunctionId = 34
- BPF_FUNC_get_current_task FunctionId = 35
- BPF_FUNC_probe_write_user FunctionId = 36
- BPF_FUNC_current_task_under_cgroup FunctionId = 37
- BPF_FUNC_skb_change_tail FunctionId = 38
- BPF_FUNC_skb_pull_data FunctionId = 39
- BPF_FUNC_csum_update FunctionId = 40
- BPF_FUNC_set_hash_invalid FunctionId = 41
- BPF_FUNC_get_numa_node_id FunctionId = 42
- BPF_FUNC_skb_change_head FunctionId = 43
- BPF_FUNC_xdp_adjust_head FunctionId = 44
- BPF_FUNC_probe_read_str FunctionId = 45
- BPF_FUNC_get_socket_cookie FunctionId = 46
- BPF_FUNC_get_socket_uid FunctionId = 47
- BPF_FUNC_set_hash FunctionId = 48
- BPF_FUNC_setsockopt FunctionId = 49
- BPF_FUNC_skb_adjust_room FunctionId = 50
- BPF_FUNC_redirect_map FunctionId = 51
- BPF_FUNC_sk_redirect_map FunctionId = 52
- BPF_FUNC_sock_map_update FunctionId = 53
- BPF_FUNC_xdp_adjust_meta FunctionId = 54
- BPF_FUNC_perf_event_read_value FunctionId = 55
- BPF_FUNC_perf_prog_read_value FunctionId = 56
- BPF_FUNC_getsockopt FunctionId = 57
- BPF_FUNC_override_return FunctionId = 58
- BPF_FUNC_sock_ops_cb_flags_set FunctionId = 59
- BPF_FUNC_msg_redirect_map FunctionId = 60
- BPF_FUNC_msg_apply_bytes FunctionId = 61
- BPF_FUNC_msg_cork_bytes FunctionId = 62
- BPF_FUNC_msg_pull_data FunctionId = 63
- BPF_FUNC_bind FunctionId = 64
- BPF_FUNC_xdp_adjust_tail FunctionId = 65
- BPF_FUNC_skb_get_xfrm_state FunctionId = 66
- BPF_FUNC_get_stack FunctionId = 67
- BPF_FUNC_skb_load_bytes_relative FunctionId = 68
- BPF_FUNC_fib_lookup FunctionId = 69
- BPF_FUNC_sock_hash_update FunctionId = 70
- BPF_FUNC_msg_redirect_hash FunctionId = 71
- BPF_FUNC_sk_redirect_hash FunctionId = 72
- BPF_FUNC_lwt_push_encap FunctionId = 73
- BPF_FUNC_lwt_seg6_store_bytes FunctionId = 74
- BPF_FUNC_lwt_seg6_adjust_srh FunctionId = 75
- BPF_FUNC_lwt_seg6_action FunctionId = 76
- BPF_FUNC_rc_repeat FunctionId = 77
- BPF_FUNC_rc_keydown FunctionId = 78
- BPF_FUNC_skb_cgroup_id FunctionId = 79
- BPF_FUNC_get_current_cgroup_id FunctionId = 80
- BPF_FUNC_get_local_storage FunctionId = 81
- BPF_FUNC_sk_select_reuseport FunctionId = 82
- BPF_FUNC_skb_ancestor_cgroup_id FunctionId = 83
- BPF_FUNC_sk_lookup_tcp FunctionId = 84
- BPF_FUNC_sk_lookup_udp FunctionId = 85
- BPF_FUNC_sk_release FunctionId = 86
- BPF_FUNC_map_push_elem FunctionId = 87
- BPF_FUNC_map_pop_elem FunctionId = 88
- BPF_FUNC_map_peek_elem FunctionId = 89
- BPF_FUNC_msg_push_data FunctionId = 90
- BPF_FUNC_msg_pop_data FunctionId = 91
- BPF_FUNC_rc_pointer_rel FunctionId = 92
- BPF_FUNC_spin_lock FunctionId = 93
- BPF_FUNC_spin_unlock FunctionId = 94
- BPF_FUNC_sk_fullsock FunctionId = 95
- BPF_FUNC_tcp_sock FunctionId = 96
- BPF_FUNC_skb_ecn_set_ce FunctionId = 97
- BPF_FUNC_get_listener_sock FunctionId = 98
- BPF_FUNC_skc_lookup_tcp FunctionId = 99
- BPF_FUNC_tcp_check_syncookie FunctionId = 100
- BPF_FUNC_sysctl_get_name FunctionId = 101
- BPF_FUNC_sysctl_get_current_value FunctionId = 102
- BPF_FUNC_sysctl_get_new_value FunctionId = 103
- BPF_FUNC_sysctl_set_new_value FunctionId = 104
- BPF_FUNC_strtol FunctionId = 105
- BPF_FUNC_strtoul FunctionId = 106
- BPF_FUNC_sk_storage_get FunctionId = 107
- BPF_FUNC_sk_storage_delete FunctionId = 108
- BPF_FUNC_send_signal FunctionId = 109
- BPF_FUNC_tcp_gen_syncookie FunctionId = 110
- BPF_FUNC_skb_output FunctionId = 111
- BPF_FUNC_probe_read_user FunctionId = 112
- BPF_FUNC_probe_read_kernel FunctionId = 113
- BPF_FUNC_probe_read_user_str FunctionId = 114
- BPF_FUNC_probe_read_kernel_str FunctionId = 115
- BPF_FUNC_tcp_send_ack FunctionId = 116
- BPF_FUNC_send_signal_thread FunctionId = 117
- BPF_FUNC_jiffies64 FunctionId = 118
- BPF_FUNC_read_branch_records FunctionId = 119
- BPF_FUNC_get_ns_current_pid_tgid FunctionId = 120
- BPF_FUNC_xdp_output FunctionId = 121
- BPF_FUNC_get_netns_cookie FunctionId = 122
- BPF_FUNC_get_current_ancestor_cgroup_id FunctionId = 123
- BPF_FUNC_sk_assign FunctionId = 124
- BPF_FUNC_ktime_get_boot_ns FunctionId = 125
- BPF_FUNC_seq_printf FunctionId = 126
- BPF_FUNC_seq_write FunctionId = 127
- BPF_FUNC_sk_cgroup_id FunctionId = 128
- BPF_FUNC_sk_ancestor_cgroup_id FunctionId = 129
- BPF_FUNC_ringbuf_output FunctionId = 130
- BPF_FUNC_ringbuf_reserve FunctionId = 131
- BPF_FUNC_ringbuf_submit FunctionId = 132
- BPF_FUNC_ringbuf_discard FunctionId = 133
- BPF_FUNC_ringbuf_query FunctionId = 134
- BPF_FUNC_csum_level FunctionId = 135
- BPF_FUNC_skc_to_tcp6_sock FunctionId = 136
- BPF_FUNC_skc_to_tcp_sock FunctionId = 137
- BPF_FUNC_skc_to_tcp_timewait_sock FunctionId = 138
- BPF_FUNC_skc_to_tcp_request_sock FunctionId = 139
- BPF_FUNC_skc_to_udp6_sock FunctionId = 140
- BPF_FUNC_get_task_stack FunctionId = 141
- BPF_FUNC_load_hdr_opt FunctionId = 142
- BPF_FUNC_store_hdr_opt FunctionId = 143
- BPF_FUNC_reserve_hdr_opt FunctionId = 144
- BPF_FUNC_inode_storage_get FunctionId = 145
- BPF_FUNC_inode_storage_delete FunctionId = 146
- BPF_FUNC_d_path FunctionId = 147
- BPF_FUNC_copy_from_user FunctionId = 148
- BPF_FUNC_snprintf_btf FunctionId = 149
- BPF_FUNC_seq_printf_btf FunctionId = 150
- BPF_FUNC_skb_cgroup_classid FunctionId = 151
- BPF_FUNC_redirect_neigh FunctionId = 152
- BPF_FUNC_per_cpu_ptr FunctionId = 153
- BPF_FUNC_this_cpu_ptr FunctionId = 154
- BPF_FUNC_redirect_peer FunctionId = 155
- BPF_FUNC_task_storage_get FunctionId = 156
- BPF_FUNC_task_storage_delete FunctionId = 157
- BPF_FUNC_get_current_task_btf FunctionId = 158
- BPF_FUNC_bprm_opts_set FunctionId = 159
- BPF_FUNC_ktime_get_coarse_ns FunctionId = 160
- BPF_FUNC_ima_inode_hash FunctionId = 161
- BPF_FUNC_sock_from_file FunctionId = 162
- BPF_FUNC_check_mtu FunctionId = 163
- BPF_FUNC_for_each_map_elem FunctionId = 164
- BPF_FUNC_snprintf FunctionId = 165
- BPF_FUNC_sys_bpf FunctionId = 166
- BPF_FUNC_btf_find_by_name_kind FunctionId = 167
- BPF_FUNC_sys_close FunctionId = 168
- BPF_FUNC_timer_init FunctionId = 169
- BPF_FUNC_timer_set_callback FunctionId = 170
- BPF_FUNC_timer_start FunctionId = 171
- BPF_FUNC_timer_cancel FunctionId = 172
- BPF_FUNC_get_func_ip FunctionId = 173
- BPF_FUNC_get_attach_cookie FunctionId = 174
- BPF_FUNC_task_pt_regs FunctionId = 175
- BPF_FUNC_get_branch_snapshot FunctionId = 176
- BPF_FUNC_trace_vprintk FunctionId = 177
- BPF_FUNC_skc_to_unix_sock FunctionId = 178
- BPF_FUNC_kallsyms_lookup_name FunctionId = 179
- BPF_FUNC_find_vma FunctionId = 180
- BPF_FUNC_loop FunctionId = 181
- BPF_FUNC_strncmp FunctionId = 182
- BPF_FUNC_get_func_arg FunctionId = 183
- BPF_FUNC_get_func_ret FunctionId = 184
- BPF_FUNC_get_func_arg_cnt FunctionId = 185
- BPF_FUNC_get_retval FunctionId = 186
- BPF_FUNC_set_retval FunctionId = 187
- BPF_FUNC_xdp_get_buff_len FunctionId = 188
- BPF_FUNC_xdp_load_bytes FunctionId = 189
- BPF_FUNC_xdp_store_bytes FunctionId = 190
- BPF_FUNC_copy_from_user_task FunctionId = 191
- BPF_FUNC_skb_set_tstamp FunctionId = 192
- BPF_FUNC_ima_file_hash FunctionId = 193
- __BPF_FUNC_MAX_ID FunctionId = 194
-)
-
-type HdrStartOff int32
-
-const (
- BPF_HDR_START_MAC HdrStartOff = 0
- BPF_HDR_START_NET HdrStartOff = 1
-)
-
-type LinkType int32
-
-const (
- BPF_LINK_TYPE_UNSPEC LinkType = 0
- BPF_LINK_TYPE_RAW_TRACEPOINT LinkType = 1
- BPF_LINK_TYPE_TRACING LinkType = 2
- BPF_LINK_TYPE_CGROUP LinkType = 3
- BPF_LINK_TYPE_ITER LinkType = 4
- BPF_LINK_TYPE_NETNS LinkType = 5
- BPF_LINK_TYPE_XDP LinkType = 6
- BPF_LINK_TYPE_PERF_EVENT LinkType = 7
- BPF_LINK_TYPE_KPROBE_MULTI LinkType = 8
- MAX_BPF_LINK_TYPE LinkType = 9
-)
-
-type MapType int32
-
-const (
- BPF_MAP_TYPE_UNSPEC MapType = 0
- BPF_MAP_TYPE_HASH MapType = 1
- BPF_MAP_TYPE_ARRAY MapType = 2
- BPF_MAP_TYPE_PROG_ARRAY MapType = 3
- BPF_MAP_TYPE_PERF_EVENT_ARRAY MapType = 4
- BPF_MAP_TYPE_PERCPU_HASH MapType = 5
- BPF_MAP_TYPE_PERCPU_ARRAY MapType = 6
- BPF_MAP_TYPE_STACK_TRACE MapType = 7
- BPF_MAP_TYPE_CGROUP_ARRAY MapType = 8
- BPF_MAP_TYPE_LRU_HASH MapType = 9
- BPF_MAP_TYPE_LRU_PERCPU_HASH MapType = 10
- BPF_MAP_TYPE_LPM_TRIE MapType = 11
- BPF_MAP_TYPE_ARRAY_OF_MAPS MapType = 12
- BPF_MAP_TYPE_HASH_OF_MAPS MapType = 13
- BPF_MAP_TYPE_DEVMAP MapType = 14
- BPF_MAP_TYPE_SOCKMAP MapType = 15
- BPF_MAP_TYPE_CPUMAP MapType = 16
- BPF_MAP_TYPE_XSKMAP MapType = 17
- BPF_MAP_TYPE_SOCKHASH MapType = 18
- BPF_MAP_TYPE_CGROUP_STORAGE MapType = 19
- BPF_MAP_TYPE_REUSEPORT_SOCKARRAY MapType = 20
- BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE MapType = 21
- BPF_MAP_TYPE_QUEUE MapType = 22
- BPF_MAP_TYPE_STACK MapType = 23
- BPF_MAP_TYPE_SK_STORAGE MapType = 24
- BPF_MAP_TYPE_DEVMAP_HASH MapType = 25
- BPF_MAP_TYPE_STRUCT_OPS MapType = 26
- BPF_MAP_TYPE_RINGBUF MapType = 27
- BPF_MAP_TYPE_INODE_STORAGE MapType = 28
- BPF_MAP_TYPE_TASK_STORAGE MapType = 29
- BPF_MAP_TYPE_BLOOM_FILTER MapType = 30
-)
-
-type ProgType int32
-
-const (
- BPF_PROG_TYPE_UNSPEC ProgType = 0
- BPF_PROG_TYPE_SOCKET_FILTER ProgType = 1
- BPF_PROG_TYPE_KPROBE ProgType = 2
- BPF_PROG_TYPE_SCHED_CLS ProgType = 3
- BPF_PROG_TYPE_SCHED_ACT ProgType = 4
- BPF_PROG_TYPE_TRACEPOINT ProgType = 5
- BPF_PROG_TYPE_XDP ProgType = 6
- BPF_PROG_TYPE_PERF_EVENT ProgType = 7
- BPF_PROG_TYPE_CGROUP_SKB ProgType = 8
- BPF_PROG_TYPE_CGROUP_SOCK ProgType = 9
- BPF_PROG_TYPE_LWT_IN ProgType = 10
- BPF_PROG_TYPE_LWT_OUT ProgType = 11
- BPF_PROG_TYPE_LWT_XMIT ProgType = 12
- BPF_PROG_TYPE_SOCK_OPS ProgType = 13
- BPF_PROG_TYPE_SK_SKB ProgType = 14
- BPF_PROG_TYPE_CGROUP_DEVICE ProgType = 15
- BPF_PROG_TYPE_SK_MSG ProgType = 16
- BPF_PROG_TYPE_RAW_TRACEPOINT ProgType = 17
- BPF_PROG_TYPE_CGROUP_SOCK_ADDR ProgType = 18
- BPF_PROG_TYPE_LWT_SEG6LOCAL ProgType = 19
- BPF_PROG_TYPE_LIRC_MODE2 ProgType = 20
- BPF_PROG_TYPE_SK_REUSEPORT ProgType = 21
- BPF_PROG_TYPE_FLOW_DISSECTOR ProgType = 22
- BPF_PROG_TYPE_CGROUP_SYSCTL ProgType = 23
- BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE ProgType = 24
- BPF_PROG_TYPE_CGROUP_SOCKOPT ProgType = 25
- BPF_PROG_TYPE_TRACING ProgType = 26
- BPF_PROG_TYPE_STRUCT_OPS ProgType = 27
- BPF_PROG_TYPE_EXT ProgType = 28
- BPF_PROG_TYPE_LSM ProgType = 29
- BPF_PROG_TYPE_SK_LOOKUP ProgType = 30
- BPF_PROG_TYPE_SYSCALL ProgType = 31
-)
-
-type RetCode int32
-
-const (
- BPF_OK RetCode = 0
- BPF_DROP RetCode = 2
- BPF_REDIRECT RetCode = 7
- BPF_LWT_REROUTE RetCode = 128
-)
-
-type SkAction int32
-
-const (
- SK_DROP SkAction = 0
- SK_PASS SkAction = 1
-)
-
-type StackBuildIdStatus int32
-
-const (
- BPF_STACK_BUILD_ID_EMPTY StackBuildIdStatus = 0
- BPF_STACK_BUILD_ID_VALID StackBuildIdStatus = 1
- BPF_STACK_BUILD_ID_IP StackBuildIdStatus = 2
-)
-
-type StatsType int32
-
-const (
- BPF_STATS_RUN_TIME StatsType = 0
-)
-
-type XdpAction int32
-
-const (
- XDP_ABORTED XdpAction = 0
- XDP_DROP XdpAction = 1
- XDP_PASS XdpAction = 2
- XDP_TX XdpAction = 3
- XDP_REDIRECT XdpAction = 4
-)
-
-type BtfInfo struct {
- Btf Pointer
- BtfSize uint32
- Id BTFID
- Name Pointer
- NameLen uint32
- KernelBtf uint32
-}
-
-type FuncInfo struct {
- InsnOff uint32
- TypeId uint32
-}
-
-type LineInfo struct {
- InsnOff uint32
- FileNameOff uint32
- LineOff uint32
- LineCol uint32
-}
-
-type LinkInfo struct {
- Type LinkType
- Id LinkID
- ProgId uint32
- _ [4]byte
- Extra [16]uint8
-}
-
-type MapInfo struct {
- Type uint32
- Id uint32
- KeySize uint32
- ValueSize uint32
- MaxEntries uint32
- MapFlags uint32
- Name ObjName
- Ifindex uint32
- BtfVmlinuxValueTypeId uint32
- NetnsDev uint64
- NetnsIno uint64
- BtfId uint32
- BtfKeyTypeId uint32
- BtfValueTypeId uint32
- _ [4]byte
- MapExtra uint64
-}
-
-type ProgInfo struct {
- Type uint32
- Id uint32
- Tag [8]uint8
- JitedProgLen uint32
- XlatedProgLen uint32
- JitedProgInsns uint64
- XlatedProgInsns Pointer
- LoadTime uint64
- CreatedByUid uint32
- NrMapIds uint32
- MapIds Pointer
- Name ObjName
- Ifindex uint32
- _ [4]byte /* unsupported bitfield */
- NetnsDev uint64
- NetnsIno uint64
- NrJitedKsyms uint32
- NrJitedFuncLens uint32
- JitedKsyms uint64
- JitedFuncLens uint64
- BtfId uint32
- FuncInfoRecSize uint32
- FuncInfo uint64
- NrFuncInfo uint32
- NrLineInfo uint32
- LineInfo uint64
- JitedLineInfo uint64
- NrJitedLineInfo uint32
- LineInfoRecSize uint32
- JitedLineInfoRecSize uint32
- NrProgTags uint32
- ProgTags uint64
- RunTimeNs uint64
- RunCnt uint64
- RecursionMisses uint64
- VerifiedInsns uint32
- _ [4]byte
-}
-
-type SkLookup struct {
- Cookie uint64
- Family uint32
- Protocol uint32
- RemoteIp4 [4]uint8
- RemoteIp6 [16]uint8
- RemotePort uint16
- _ [2]byte
- LocalIp4 [4]uint8
- LocalIp6 [16]uint8
- LocalPort uint32
- IngressIfindex uint32
- _ [4]byte
-}
-
-type XdpMd struct {
- Data uint32
- DataEnd uint32
- DataMeta uint32
- IngressIfindex uint32
- RxQueueIndex uint32
- EgressIfindex uint32
-}
-
-type BtfGetFdByIdAttr struct{ Id uint32 }
-
-func BtfGetFdById(attr *BtfGetFdByIdAttr) (*FD, error) {
- fd, err := BPF(BPF_BTF_GET_FD_BY_ID, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- if err != nil {
- return nil, err
- }
- return NewFD(int(fd))
-}
-
-type BtfGetNextIdAttr struct {
- Id BTFID
- NextId BTFID
-}
-
-func BtfGetNextId(attr *BtfGetNextIdAttr) error {
- _, err := BPF(BPF_BTF_GET_NEXT_ID, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- return err
-}
-
-type BtfLoadAttr struct {
- Btf Pointer
- BtfLogBuf Pointer
- BtfSize uint32
- BtfLogSize uint32
- BtfLogLevel uint32
- _ [4]byte
-}
-
-func BtfLoad(attr *BtfLoadAttr) (*FD, error) {
- fd, err := BPF(BPF_BTF_LOAD, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- if err != nil {
- return nil, err
- }
- return NewFD(int(fd))
-}
-
-type EnableStatsAttr struct{ Type uint32 }
-
-func EnableStats(attr *EnableStatsAttr) (*FD, error) {
- fd, err := BPF(BPF_ENABLE_STATS, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- if err != nil {
- return nil, err
- }
- return NewFD(int(fd))
-}
-
-type IterCreateAttr struct {
- LinkFd uint32
- Flags uint32
-}
-
-func IterCreate(attr *IterCreateAttr) (*FD, error) {
- fd, err := BPF(BPF_ITER_CREATE, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- if err != nil {
- return nil, err
- }
- return NewFD(int(fd))
-}
-
-type LinkCreateAttr struct {
- ProgFd uint32
- TargetFd uint32
- AttachType AttachType
- Flags uint32
- TargetBtfId uint32
- _ [28]byte
-}
-
-func LinkCreate(attr *LinkCreateAttr) (*FD, error) {
- fd, err := BPF(BPF_LINK_CREATE, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- if err != nil {
- return nil, err
- }
- return NewFD(int(fd))
-}
-
-type LinkCreateIterAttr struct {
- ProgFd uint32
- TargetFd uint32
- AttachType AttachType
- Flags uint32
- IterInfo Pointer
- IterInfoLen uint32
- _ [20]byte
-}
-
-func LinkCreateIter(attr *LinkCreateIterAttr) (*FD, error) {
- fd, err := BPF(BPF_LINK_CREATE, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- if err != nil {
- return nil, err
- }
- return NewFD(int(fd))
-}
-
-type LinkCreatePerfEventAttr struct {
- ProgFd uint32
- TargetFd uint32
- AttachType AttachType
- Flags uint32
- BpfCookie uint64
- _ [24]byte
-}
-
-func LinkCreatePerfEvent(attr *LinkCreatePerfEventAttr) (*FD, error) {
- fd, err := BPF(BPF_LINK_CREATE, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- if err != nil {
- return nil, err
- }
- return NewFD(int(fd))
-}
-
-type LinkUpdateAttr struct {
- LinkFd uint32
- NewProgFd uint32
- Flags uint32
- OldProgFd uint32
-}
-
-func LinkUpdate(attr *LinkUpdateAttr) error {
- _, err := BPF(BPF_LINK_UPDATE, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- return err
-}
-
-type MapCreateAttr struct {
- MapType MapType
- KeySize uint32
- ValueSize uint32
- MaxEntries uint32
- MapFlags uint32
- InnerMapFd uint32
- NumaNode uint32
- MapName ObjName
- MapIfindex uint32
- BtfFd uint32
- BtfKeyTypeId uint32
- BtfValueTypeId uint32
- BtfVmlinuxValueTypeId uint32
- MapExtra uint64
-}
-
-func MapCreate(attr *MapCreateAttr) (*FD, error) {
- fd, err := BPF(BPF_MAP_CREATE, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- if err != nil {
- return nil, err
- }
- return NewFD(int(fd))
-}
-
-type MapDeleteBatchAttr struct {
- InBatch Pointer
- OutBatch Pointer
- Keys Pointer
- Values Pointer
- Count uint32
- MapFd uint32
- ElemFlags uint64
- Flags uint64
-}
-
-func MapDeleteBatch(attr *MapDeleteBatchAttr) error {
- _, err := BPF(BPF_MAP_DELETE_BATCH, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- return err
-}
-
-type MapDeleteElemAttr struct {
- MapFd uint32
- _ [4]byte
- Key Pointer
- Value Pointer
- Flags uint64
-}
-
-func MapDeleteElem(attr *MapDeleteElemAttr) error {
- _, err := BPF(BPF_MAP_DELETE_ELEM, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- return err
-}
-
-type MapFreezeAttr struct{ MapFd uint32 }
-
-func MapFreeze(attr *MapFreezeAttr) error {
- _, err := BPF(BPF_MAP_FREEZE, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- return err
-}
-
-type MapGetFdByIdAttr struct{ Id uint32 }
-
-func MapGetFdById(attr *MapGetFdByIdAttr) (*FD, error) {
- fd, err := BPF(BPF_MAP_GET_FD_BY_ID, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- if err != nil {
- return nil, err
- }
- return NewFD(int(fd))
-}
-
-type MapGetNextIdAttr struct {
- Id uint32
- NextId uint32
-}
-
-func MapGetNextId(attr *MapGetNextIdAttr) error {
- _, err := BPF(BPF_MAP_GET_NEXT_ID, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- return err
-}
-
-type MapGetNextKeyAttr struct {
- MapFd uint32
- _ [4]byte
- Key Pointer
- NextKey Pointer
-}
-
-func MapGetNextKey(attr *MapGetNextKeyAttr) error {
- _, err := BPF(BPF_MAP_GET_NEXT_KEY, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- return err
-}
-
-type MapLookupAndDeleteBatchAttr struct {
- InBatch Pointer
- OutBatch Pointer
- Keys Pointer
- Values Pointer
- Count uint32
- MapFd uint32
- ElemFlags uint64
- Flags uint64
-}
-
-func MapLookupAndDeleteBatch(attr *MapLookupAndDeleteBatchAttr) error {
- _, err := BPF(BPF_MAP_LOOKUP_AND_DELETE_BATCH, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- return err
-}
-
-type MapLookupAndDeleteElemAttr struct {
- MapFd uint32
- _ [4]byte
- Key Pointer
- Value Pointer
- Flags uint64
-}
-
-func MapLookupAndDeleteElem(attr *MapLookupAndDeleteElemAttr) error {
- _, err := BPF(BPF_MAP_LOOKUP_AND_DELETE_ELEM, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- return err
-}
-
-type MapLookupBatchAttr struct {
- InBatch Pointer
- OutBatch Pointer
- Keys Pointer
- Values Pointer
- Count uint32
- MapFd uint32
- ElemFlags uint64
- Flags uint64
-}
-
-func MapLookupBatch(attr *MapLookupBatchAttr) error {
- _, err := BPF(BPF_MAP_LOOKUP_BATCH, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- return err
-}
-
-type MapLookupElemAttr struct {
- MapFd uint32
- _ [4]byte
- Key Pointer
- Value Pointer
- Flags uint64
-}
-
-func MapLookupElem(attr *MapLookupElemAttr) error {
- _, err := BPF(BPF_MAP_LOOKUP_ELEM, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- return err
-}
-
-type MapUpdateBatchAttr struct {
- InBatch Pointer
- OutBatch Pointer
- Keys Pointer
- Values Pointer
- Count uint32
- MapFd uint32
- ElemFlags uint64
- Flags uint64
-}
-
-func MapUpdateBatch(attr *MapUpdateBatchAttr) error {
- _, err := BPF(BPF_MAP_UPDATE_BATCH, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- return err
-}
-
-type MapUpdateElemAttr struct {
- MapFd uint32
- _ [4]byte
- Key Pointer
- Value Pointer
- Flags uint64
-}
-
-func MapUpdateElem(attr *MapUpdateElemAttr) error {
- _, err := BPF(BPF_MAP_UPDATE_ELEM, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- return err
-}
-
-type ObjGetAttr struct {
- Pathname Pointer
- BpfFd uint32
- FileFlags uint32
-}
-
-func ObjGet(attr *ObjGetAttr) (*FD, error) {
- fd, err := BPF(BPF_OBJ_GET, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- if err != nil {
- return nil, err
- }
- return NewFD(int(fd))
-}
-
-type ObjGetInfoByFdAttr struct {
- BpfFd uint32
- InfoLen uint32
- Info Pointer
-}
-
-func ObjGetInfoByFd(attr *ObjGetInfoByFdAttr) error {
- _, err := BPF(BPF_OBJ_GET_INFO_BY_FD, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- return err
-}
-
-type ObjPinAttr struct {
- Pathname Pointer
- BpfFd uint32
- FileFlags uint32
-}
-
-func ObjPin(attr *ObjPinAttr) error {
- _, err := BPF(BPF_OBJ_PIN, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- return err
-}
-
-type ProgAttachAttr struct {
- TargetFd uint32
- AttachBpfFd uint32
- AttachType uint32
- AttachFlags uint32
- ReplaceBpfFd uint32
-}
-
-func ProgAttach(attr *ProgAttachAttr) error {
- _, err := BPF(BPF_PROG_ATTACH, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- return err
-}
-
-type ProgBindMapAttr struct {
- ProgFd uint32
- MapFd uint32
- Flags uint32
-}
-
-func ProgBindMap(attr *ProgBindMapAttr) error {
- _, err := BPF(BPF_PROG_BIND_MAP, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- return err
-}
-
-type ProgDetachAttr struct {
- TargetFd uint32
- AttachBpfFd uint32
- AttachType uint32
-}
-
-func ProgDetach(attr *ProgDetachAttr) error {
- _, err := BPF(BPF_PROG_DETACH, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- return err
-}
-
-type ProgGetFdByIdAttr struct{ Id uint32 }
-
-func ProgGetFdById(attr *ProgGetFdByIdAttr) (*FD, error) {
- fd, err := BPF(BPF_PROG_GET_FD_BY_ID, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- if err != nil {
- return nil, err
- }
- return NewFD(int(fd))
-}
-
-type ProgGetNextIdAttr struct {
- Id uint32
- NextId uint32
-}
-
-func ProgGetNextId(attr *ProgGetNextIdAttr) error {
- _, err := BPF(BPF_PROG_GET_NEXT_ID, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- return err
-}
-
-type ProgLoadAttr struct {
- ProgType ProgType
- InsnCnt uint32
- Insns Pointer
- License Pointer
- LogLevel uint32
- LogSize uint32
- LogBuf Pointer
- KernVersion uint32
- ProgFlags uint32
- ProgName ObjName
- ProgIfindex uint32
- ExpectedAttachType AttachType
- ProgBtfFd uint32
- FuncInfoRecSize uint32
- FuncInfo Pointer
- FuncInfoCnt uint32
- LineInfoRecSize uint32
- LineInfo Pointer
- LineInfoCnt uint32
- AttachBtfId uint32
- AttachProgFd uint32
- CoreReloCnt uint32
- FdArray Pointer
- CoreRelos Pointer
- CoreReloRecSize uint32
- _ [4]byte
-}
-
-func ProgLoad(attr *ProgLoadAttr) (*FD, error) {
- fd, err := BPF(BPF_PROG_LOAD, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- if err != nil {
- return nil, err
- }
- return NewFD(int(fd))
-}
-
-type ProgRunAttr struct {
- ProgFd uint32
- Retval uint32
- DataSizeIn uint32
- DataSizeOut uint32
- DataIn Pointer
- DataOut Pointer
- Repeat uint32
- Duration uint32
- CtxSizeIn uint32
- CtxSizeOut uint32
- CtxIn Pointer
- CtxOut Pointer
- Flags uint32
- Cpu uint32
- BatchSize uint32
- _ [4]byte
-}
-
-func ProgRun(attr *ProgRunAttr) error {
- _, err := BPF(BPF_PROG_TEST_RUN, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- return err
-}
-
-type RawTracepointOpenAttr struct {
- Name Pointer
- ProgFd uint32
- _ [4]byte
-}
-
-func RawTracepointOpen(attr *RawTracepointOpenAttr) (*FD, error) {
- fd, err := BPF(BPF_RAW_TRACEPOINT_OPEN, unsafe.Pointer(attr), unsafe.Sizeof(*attr))
- if err != nil {
- return nil, err
- }
- return NewFD(int(fd))
-}
-
-type CgroupLinkInfo struct {
- CgroupId uint64
- AttachType AttachType
- _ [4]byte
-}
-
-type IterLinkInfo struct {
- TargetName Pointer
- TargetNameLen uint32
-}
-
-type NetNsLinkInfo struct {
- NetnsIno uint32
- AttachType AttachType
-}
-
-type RawTracepointLinkInfo struct {
- TpName Pointer
- TpNameLen uint32
- _ [4]byte
-}
-
-type TracingLinkInfo struct {
- AttachType AttachType
- TargetObjId uint32
- TargetBtfId uint32
-}
-
-type XDPLinkInfo struct{ Ifindex uint32 }
diff --git a/vendor/github.com/cilium/ebpf/internal/unix/types_linux.go b/vendor/github.com/cilium/ebpf/internal/unix/types_linux.go
deleted file mode 100644
index db4a1f5bf..000000000
--- a/vendor/github.com/cilium/ebpf/internal/unix/types_linux.go
+++ /dev/null
@@ -1,210 +0,0 @@
-//go:build linux
-// +build linux
-
-package unix
-
-import (
- "syscall"
-
- linux "golang.org/x/sys/unix"
-)
-
-const (
- ENOENT = linux.ENOENT
- EEXIST = linux.EEXIST
- EAGAIN = linux.EAGAIN
- ENOSPC = linux.ENOSPC
- EINVAL = linux.EINVAL
- EPOLLIN = linux.EPOLLIN
- EINTR = linux.EINTR
- EPERM = linux.EPERM
- ESRCH = linux.ESRCH
- ENODEV = linux.ENODEV
- EBADF = linux.EBADF
- E2BIG = linux.E2BIG
- EFAULT = linux.EFAULT
- EACCES = linux.EACCES
- // ENOTSUPP is not the same as ENOTSUP or EOPNOTSUP
- ENOTSUPP = syscall.Errno(0x20c)
-
- BPF_F_NO_PREALLOC = linux.BPF_F_NO_PREALLOC
- BPF_F_NUMA_NODE = linux.BPF_F_NUMA_NODE
- BPF_F_RDONLY = linux.BPF_F_RDONLY
- BPF_F_WRONLY = linux.BPF_F_WRONLY
- BPF_F_RDONLY_PROG = linux.BPF_F_RDONLY_PROG
- BPF_F_WRONLY_PROG = linux.BPF_F_WRONLY_PROG
- BPF_F_SLEEPABLE = linux.BPF_F_SLEEPABLE
- BPF_F_MMAPABLE = linux.BPF_F_MMAPABLE
- BPF_F_INNER_MAP = linux.BPF_F_INNER_MAP
- BPF_OBJ_NAME_LEN = linux.BPF_OBJ_NAME_LEN
- BPF_TAG_SIZE = linux.BPF_TAG_SIZE
- BPF_RINGBUF_BUSY_BIT = linux.BPF_RINGBUF_BUSY_BIT
- BPF_RINGBUF_DISCARD_BIT = linux.BPF_RINGBUF_DISCARD_BIT
- BPF_RINGBUF_HDR_SZ = linux.BPF_RINGBUF_HDR_SZ
- SYS_BPF = linux.SYS_BPF
- F_DUPFD_CLOEXEC = linux.F_DUPFD_CLOEXEC
- EPOLL_CTL_ADD = linux.EPOLL_CTL_ADD
- EPOLL_CLOEXEC = linux.EPOLL_CLOEXEC
- O_CLOEXEC = linux.O_CLOEXEC
- O_NONBLOCK = linux.O_NONBLOCK
- PROT_READ = linux.PROT_READ
- PROT_WRITE = linux.PROT_WRITE
- MAP_SHARED = linux.MAP_SHARED
- PERF_ATTR_SIZE_VER1 = linux.PERF_ATTR_SIZE_VER1
- PERF_TYPE_SOFTWARE = linux.PERF_TYPE_SOFTWARE
- PERF_TYPE_TRACEPOINT = linux.PERF_TYPE_TRACEPOINT
- PERF_COUNT_SW_BPF_OUTPUT = linux.PERF_COUNT_SW_BPF_OUTPUT
- PERF_EVENT_IOC_DISABLE = linux.PERF_EVENT_IOC_DISABLE
- PERF_EVENT_IOC_ENABLE = linux.PERF_EVENT_IOC_ENABLE
- PERF_EVENT_IOC_SET_BPF = linux.PERF_EVENT_IOC_SET_BPF
- PerfBitWatermark = linux.PerfBitWatermark
- PERF_SAMPLE_RAW = linux.PERF_SAMPLE_RAW
- PERF_FLAG_FD_CLOEXEC = linux.PERF_FLAG_FD_CLOEXEC
- RLIM_INFINITY = linux.RLIM_INFINITY
- RLIMIT_MEMLOCK = linux.RLIMIT_MEMLOCK
- BPF_STATS_RUN_TIME = linux.BPF_STATS_RUN_TIME
- PERF_RECORD_LOST = linux.PERF_RECORD_LOST
- PERF_RECORD_SAMPLE = linux.PERF_RECORD_SAMPLE
- AT_FDCWD = linux.AT_FDCWD
- RENAME_NOREPLACE = linux.RENAME_NOREPLACE
- SO_ATTACH_BPF = linux.SO_ATTACH_BPF
- SO_DETACH_BPF = linux.SO_DETACH_BPF
- SOL_SOCKET = linux.SOL_SOCKET
-)
-
-// Statfs_t is a wrapper
-type Statfs_t = linux.Statfs_t
-
-type Stat_t = linux.Stat_t
-
-// Rlimit is a wrapper
-type Rlimit = linux.Rlimit
-
-// Syscall is a wrapper
-func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
- return linux.Syscall(trap, a1, a2, a3)
-}
-
-// FcntlInt is a wrapper
-func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
- return linux.FcntlInt(fd, cmd, arg)
-}
-
-// IoctlSetInt is a wrapper
-func IoctlSetInt(fd int, req uint, value int) error {
- return linux.IoctlSetInt(fd, req, value)
-}
-
-// Statfs is a wrapper
-func Statfs(path string, buf *Statfs_t) (err error) {
- return linux.Statfs(path, buf)
-}
-
-// Close is a wrapper
-func Close(fd int) (err error) {
- return linux.Close(fd)
-}
-
-// EpollEvent is a wrapper
-type EpollEvent = linux.EpollEvent
-
-// EpollWait is a wrapper
-func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) {
- return linux.EpollWait(epfd, events, msec)
-}
-
-// EpollCtl is a wrapper
-func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) {
- return linux.EpollCtl(epfd, op, fd, event)
-}
-
-// Eventfd is a wrapper
-func Eventfd(initval uint, flags int) (fd int, err error) {
- return linux.Eventfd(initval, flags)
-}
-
-// Write is a wrapper
-func Write(fd int, p []byte) (n int, err error) {
- return linux.Write(fd, p)
-}
-
-// EpollCreate1 is a wrapper
-func EpollCreate1(flag int) (fd int, err error) {
- return linux.EpollCreate1(flag)
-}
-
-// PerfEventMmapPage is a wrapper
-type PerfEventMmapPage linux.PerfEventMmapPage
-
-// SetNonblock is a wrapper
-func SetNonblock(fd int, nonblocking bool) (err error) {
- return linux.SetNonblock(fd, nonblocking)
-}
-
-// Mmap is a wrapper
-func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) {
- return linux.Mmap(fd, offset, length, prot, flags)
-}
-
-// Munmap is a wrapper
-func Munmap(b []byte) (err error) {
- return linux.Munmap(b)
-}
-
-// PerfEventAttr is a wrapper
-type PerfEventAttr = linux.PerfEventAttr
-
-// PerfEventOpen is a wrapper
-func PerfEventOpen(attr *PerfEventAttr, pid int, cpu int, groupFd int, flags int) (fd int, err error) {
- return linux.PerfEventOpen(attr, pid, cpu, groupFd, flags)
-}
-
-// Utsname is a wrapper
-type Utsname = linux.Utsname
-
-// Uname is a wrapper
-func Uname(buf *Utsname) (err error) {
- return linux.Uname(buf)
-}
-
-// Getpid is a wrapper
-func Getpid() int {
- return linux.Getpid()
-}
-
-// Gettid is a wrapper
-func Gettid() int {
- return linux.Gettid()
-}
-
-// Tgkill is a wrapper
-func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) {
- return linux.Tgkill(tgid, tid, sig)
-}
-
-// BytePtrFromString is a wrapper
-func BytePtrFromString(s string) (*byte, error) {
- return linux.BytePtrFromString(s)
-}
-
-// ByteSliceToString is a wrapper
-func ByteSliceToString(s []byte) string {
- return linux.ByteSliceToString(s)
-}
-
-// Renameat2 is a wrapper
-func Renameat2(olddirfd int, oldpath string, newdirfd int, newpath string, flags uint) error {
- return linux.Renameat2(olddirfd, oldpath, newdirfd, newpath, flags)
-}
-
-func Prlimit(pid, resource int, new, old *Rlimit) error {
- return linux.Prlimit(pid, resource, new, old)
-}
-
-func Open(path string, mode int, perm uint32) (int, error) {
- return linux.Open(path, mode, perm)
-}
-
-func Fstat(fd int, stat *Stat_t) error {
- return linux.Fstat(fd, stat)
-}
diff --git a/vendor/github.com/cilium/ebpf/internal/unix/types_other.go b/vendor/github.com/cilium/ebpf/internal/unix/types_other.go
deleted file mode 100644
index 133c267db..000000000
--- a/vendor/github.com/cilium/ebpf/internal/unix/types_other.go
+++ /dev/null
@@ -1,278 +0,0 @@
-//go:build !linux
-// +build !linux
-
-package unix
-
-import (
- "fmt"
- "runtime"
- "syscall"
-)
-
-var errNonLinux = fmt.Errorf("unsupported platform %s/%s", runtime.GOOS, runtime.GOARCH)
-
-const (
- ENOENT = syscall.ENOENT
- EEXIST = syscall.EEXIST
- EAGAIN = syscall.EAGAIN
- ENOSPC = syscall.ENOSPC
- EINVAL = syscall.EINVAL
- EINTR = syscall.EINTR
- EPERM = syscall.EPERM
- ESRCH = syscall.ESRCH
- ENODEV = syscall.ENODEV
- EBADF = syscall.Errno(0)
- E2BIG = syscall.Errno(0)
- EFAULT = syscall.EFAULT
- EACCES = syscall.Errno(0)
- // ENOTSUPP is not the same as ENOTSUP or EOPNOTSUP
- ENOTSUPP = syscall.Errno(0x20c)
-
- BPF_F_NO_PREALLOC = 0
- BPF_F_NUMA_NODE = 0
- BPF_F_RDONLY = 0
- BPF_F_WRONLY = 0
- BPF_F_RDONLY_PROG = 0
- BPF_F_WRONLY_PROG = 0
- BPF_F_SLEEPABLE = 0
- BPF_F_MMAPABLE = 0
- BPF_F_INNER_MAP = 0
- BPF_OBJ_NAME_LEN = 0x10
- BPF_TAG_SIZE = 0x8
- BPF_RINGBUF_BUSY_BIT = 0
- BPF_RINGBUF_DISCARD_BIT = 0
- BPF_RINGBUF_HDR_SZ = 0
- SYS_BPF = 321
- F_DUPFD_CLOEXEC = 0x406
- EPOLLIN = 0x1
- EPOLL_CTL_ADD = 0x1
- EPOLL_CLOEXEC = 0x80000
- O_CLOEXEC = 0x80000
- O_NONBLOCK = 0x800
- PROT_READ = 0x1
- PROT_WRITE = 0x2
- MAP_SHARED = 0x1
- PERF_ATTR_SIZE_VER1 = 0
- PERF_TYPE_SOFTWARE = 0x1
- PERF_TYPE_TRACEPOINT = 0
- PERF_COUNT_SW_BPF_OUTPUT = 0xa
- PERF_EVENT_IOC_DISABLE = 0
- PERF_EVENT_IOC_ENABLE = 0
- PERF_EVENT_IOC_SET_BPF = 0
- PerfBitWatermark = 0x4000
- PERF_SAMPLE_RAW = 0x400
- PERF_FLAG_FD_CLOEXEC = 0x8
- RLIM_INFINITY = 0x7fffffffffffffff
- RLIMIT_MEMLOCK = 8
- BPF_STATS_RUN_TIME = 0
- PERF_RECORD_LOST = 2
- PERF_RECORD_SAMPLE = 9
- AT_FDCWD = -0x2
- RENAME_NOREPLACE = 0x1
- SO_ATTACH_BPF = 0x32
- SO_DETACH_BPF = 0x1b
- SOL_SOCKET = 0x1
-)
-
-// Statfs_t is a wrapper
-type Statfs_t struct {
- Type int64
- Bsize int64
- Blocks uint64
- Bfree uint64
- Bavail uint64
- Files uint64
- Ffree uint64
- Fsid [2]int32
- Namelen int64
- Frsize int64
- Flags int64
- Spare [4]int64
-}
-
-type Stat_t struct{}
-
-// Rlimit is a wrapper
-type Rlimit struct {
- Cur uint64
- Max uint64
-}
-
-// Syscall is a wrapper
-func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
- return 0, 0, syscall.Errno(1)
-}
-
-// FcntlInt is a wrapper
-func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
- return -1, errNonLinux
-}
-
-// IoctlSetInt is a wrapper
-func IoctlSetInt(fd int, req uint, value int) error {
- return errNonLinux
-}
-
-// Statfs is a wrapper
-func Statfs(path string, buf *Statfs_t) error {
- return errNonLinux
-}
-
-// Close is a wrapper
-func Close(fd int) (err error) {
- return errNonLinux
-}
-
-// EpollEvent is a wrapper
-type EpollEvent struct {
- Events uint32
- Fd int32
- Pad int32
-}
-
-// EpollWait is a wrapper
-func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) {
- return 0, errNonLinux
-}
-
-// EpollCtl is a wrapper
-func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) {
- return errNonLinux
-}
-
-// Eventfd is a wrapper
-func Eventfd(initval uint, flags int) (fd int, err error) {
- return 0, errNonLinux
-}
-
-// Write is a wrapper
-func Write(fd int, p []byte) (n int, err error) {
- return 0, errNonLinux
-}
-
-// EpollCreate1 is a wrapper
-func EpollCreate1(flag int) (fd int, err error) {
- return 0, errNonLinux
-}
-
-// PerfEventMmapPage is a wrapper
-type PerfEventMmapPage struct {
- Version uint32
- Compat_version uint32
- Lock uint32
- Index uint32
- Offset int64
- Time_enabled uint64
- Time_running uint64
- Capabilities uint64
- Pmc_width uint16
- Time_shift uint16
- Time_mult uint32
- Time_offset uint64
- Time_zero uint64
- Size uint32
-
- Data_head uint64
- Data_tail uint64
- Data_offset uint64
- Data_size uint64
- Aux_head uint64
- Aux_tail uint64
- Aux_offset uint64
- Aux_size uint64
-}
-
-// SetNonblock is a wrapper
-func SetNonblock(fd int, nonblocking bool) (err error) {
- return errNonLinux
-}
-
-// Mmap is a wrapper
-func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) {
- return []byte{}, errNonLinux
-}
-
-// Munmap is a wrapper
-func Munmap(b []byte) (err error) {
- return errNonLinux
-}
-
-// PerfEventAttr is a wrapper
-type PerfEventAttr struct {
- Type uint32
- Size uint32
- Config uint64
- Sample uint64
- Sample_type uint64
- Read_format uint64
- Bits uint64
- Wakeup uint32
- Bp_type uint32
- Ext1 uint64
- Ext2 uint64
- Branch_sample_type uint64
- Sample_regs_user uint64
- Sample_stack_user uint32
- Clockid int32
- Sample_regs_intr uint64
- Aux_watermark uint32
- Sample_max_stack uint16
-}
-
-// PerfEventOpen is a wrapper
-func PerfEventOpen(attr *PerfEventAttr, pid int, cpu int, groupFd int, flags int) (fd int, err error) {
- return 0, errNonLinux
-}
-
-// Utsname is a wrapper
-type Utsname struct {
- Release [65]byte
- Version [65]byte
-}
-
-// Uname is a wrapper
-func Uname(buf *Utsname) (err error) {
- return errNonLinux
-}
-
-// Getpid is a wrapper
-func Getpid() int {
- return -1
-}
-
-// Gettid is a wrapper
-func Gettid() int {
- return -1
-}
-
-// Tgkill is a wrapper
-func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) {
- return errNonLinux
-}
-
-// BytePtrFromString is a wrapper
-func BytePtrFromString(s string) (*byte, error) {
- return nil, errNonLinux
-}
-
-// ByteSliceToString is a wrapper
-func ByteSliceToString(s []byte) string {
- return ""
-}
-
-// Renameat2 is a wrapper
-func Renameat2(olddirfd int, oldpath string, newdirfd int, newpath string, flags uint) error {
- return errNonLinux
-}
-
-func Prlimit(pid, resource int, new, old *Rlimit) error {
- return errNonLinux
-}
-
-func Open(path string, mode int, perm uint32) (int, error) {
- return -1, errNonLinux
-}
-
-func Fstat(fd int, stat *Stat_t) error {
- return errNonLinux
-}
diff --git a/vendor/github.com/cilium/ebpf/internal/vdso.go b/vendor/github.com/cilium/ebpf/internal/vdso.go
deleted file mode 100644
index ae4821de2..000000000
--- a/vendor/github.com/cilium/ebpf/internal/vdso.go
+++ /dev/null
@@ -1,150 +0,0 @@
-package internal
-
-import (
- "debug/elf"
- "encoding/binary"
- "errors"
- "fmt"
- "io"
- "math"
- "os"
-
- "github.com/cilium/ebpf/internal/unix"
-)
-
-var (
- errAuxvNoVDSO = errors.New("no vdso address found in auxv")
-)
-
-// vdsoVersion returns the LINUX_VERSION_CODE embedded in the vDSO library
-// linked into the current process image.
-func vdsoVersion() (uint32, error) {
- // Read data from the auxiliary vector, which is normally passed directly
- // to the process. Go does not expose that data, so we must read it from procfs.
- // https://man7.org/linux/man-pages/man3/getauxval.3.html
- av, err := os.Open("/proc/self/auxv")
- if err != nil {
- return 0, fmt.Errorf("opening auxv: %w", err)
- }
- defer av.Close()
-
- vdsoAddr, err := vdsoMemoryAddress(av)
- if err != nil {
- return 0, fmt.Errorf("finding vDSO memory address: %w", err)
- }
-
- // Use /proc/self/mem rather than unsafe.Pointer tricks.
- mem, err := os.Open("/proc/self/mem")
- if err != nil {
- return 0, fmt.Errorf("opening mem: %w", err)
- }
- defer mem.Close()
-
- // Open ELF at provided memory address, as offset into /proc/self/mem.
- c, err := vdsoLinuxVersionCode(io.NewSectionReader(mem, int64(vdsoAddr), math.MaxInt64))
- if err != nil {
- return 0, fmt.Errorf("reading linux version code: %w", err)
- }
-
- return c, nil
-}
-
-// vdsoMemoryAddress returns the memory address of the vDSO library
-// linked into the current process image. r is an io.Reader into an auxv blob.
-func vdsoMemoryAddress(r io.Reader) (uint64, error) {
- const (
- _AT_NULL = 0 // End of vector
- _AT_SYSINFO_EHDR = 33 // Offset to vDSO blob in process image
- )
-
- // Loop through all tag/value pairs in auxv until we find `AT_SYSINFO_EHDR`,
- // the address of a page containing the virtual Dynamic Shared Object (vDSO).
- aux := struct{ Tag, Val uint64 }{}
- for {
- if err := binary.Read(r, NativeEndian, &aux); err != nil {
- return 0, fmt.Errorf("reading auxv entry: %w", err)
- }
-
- switch aux.Tag {
- case _AT_SYSINFO_EHDR:
- if aux.Val != 0 {
- return aux.Val, nil
- }
- return 0, fmt.Errorf("invalid vDSO address in auxv")
- // _AT_NULL is always the last tag/val pair in the aux vector
- // and can be treated like EOF.
- case _AT_NULL:
- return 0, errAuxvNoVDSO
- }
- }
-}
-
-// format described at https://www.man7.org/linux/man-pages/man5/elf.5.html in section 'Notes (Nhdr)'
-type elfNoteHeader struct {
- NameSize int32
- DescSize int32
- Type int32
-}
-
-// vdsoLinuxVersionCode returns the LINUX_VERSION_CODE embedded in
-// the ELF notes section of the binary provided by the reader.
-func vdsoLinuxVersionCode(r io.ReaderAt) (uint32, error) {
- hdr, err := NewSafeELFFile(r)
- if err != nil {
- return 0, fmt.Errorf("reading vDSO ELF: %w", err)
- }
-
- sections := hdr.SectionsByType(elf.SHT_NOTE)
- if len(sections) == 0 {
- return 0, fmt.Errorf("no note section found in vDSO ELF")
- }
-
- for _, sec := range sections {
- sr := sec.Open()
- var n elfNoteHeader
-
- // Read notes until we find one named 'Linux'.
- for {
- if err := binary.Read(sr, hdr.ByteOrder, &n); err != nil {
- if errors.Is(err, io.EOF) {
- // We looked at all the notes in this section
- break
- }
- return 0, fmt.Errorf("reading note header: %w", err)
- }
-
- // If a note name is defined, it follows the note header.
- var name string
- if n.NameSize > 0 {
- // Read the note name, aligned to 4 bytes.
- buf := make([]byte, Align(int(n.NameSize), 4))
- if err := binary.Read(sr, hdr.ByteOrder, &buf); err != nil {
- return 0, fmt.Errorf("reading note name: %w", err)
- }
-
- // Read nul-terminated string.
- name = unix.ByteSliceToString(buf[:n.NameSize])
- }
-
- // If a note descriptor is defined, it follows the name.
- // It is possible for a note to have a descriptor but not a name.
- if n.DescSize > 0 {
- // LINUX_VERSION_CODE is a uint32 value.
- if name == "Linux" && n.DescSize == 4 && n.Type == 0 {
- var version uint32
- if err := binary.Read(sr, hdr.ByteOrder, &version); err != nil {
- return 0, fmt.Errorf("reading note descriptor: %w", err)
- }
- return version, nil
- }
-
- // Discard the note descriptor if it exists but we're not interested in it.
- if _, err := io.CopyN(io.Discard, sr, int64(Align(int(n.DescSize), 4))); err != nil {
- return 0, err
- }
- }
- }
- }
-
- return 0, fmt.Errorf("no Linux note in ELF")
-}
diff --git a/vendor/github.com/cilium/ebpf/internal/version.go b/vendor/github.com/cilium/ebpf/internal/version.go
deleted file mode 100644
index 370e01e44..000000000
--- a/vendor/github.com/cilium/ebpf/internal/version.go
+++ /dev/null
@@ -1,122 +0,0 @@
-package internal
-
-import (
- "fmt"
- "sync"
-
- "github.com/cilium/ebpf/internal/unix"
-)
-
-const (
- // Version constant used in ELF binaries indicating that the loader needs to
- // substitute the eBPF program's version with the value of the kernel's
- // KERNEL_VERSION compile-time macro. Used for compatibility with BCC, gobpf
- // and RedSift.
- MagicKernelVersion = 0xFFFFFFFE
-)
-
-var (
- kernelVersion = struct {
- once sync.Once
- version Version
- err error
- }{}
-)
-
-// A Version in the form Major.Minor.Patch.
-type Version [3]uint16
-
-// NewVersion creates a version from a string like "Major.Minor.Patch".
-//
-// Patch is optional.
-func NewVersion(ver string) (Version, error) {
- var major, minor, patch uint16
- n, _ := fmt.Sscanf(ver, "%d.%d.%d", &major, &minor, &patch)
- if n < 2 {
- return Version{}, fmt.Errorf("invalid version: %s", ver)
- }
- return Version{major, minor, patch}, nil
-}
-
-// NewVersionFromCode creates a version from a LINUX_VERSION_CODE.
-func NewVersionFromCode(code uint32) Version {
- return Version{
- uint16(uint8(code >> 16)),
- uint16(uint8(code >> 8)),
- uint16(uint8(code)),
- }
-}
-
-func (v Version) String() string {
- if v[2] == 0 {
- return fmt.Sprintf("v%d.%d", v[0], v[1])
- }
- return fmt.Sprintf("v%d.%d.%d", v[0], v[1], v[2])
-}
-
-// Less returns true if the version is less than another version.
-func (v Version) Less(other Version) bool {
- for i, a := range v {
- if a == other[i] {
- continue
- }
- return a < other[i]
- }
- return false
-}
-
-// Unspecified returns true if the version is all zero.
-func (v Version) Unspecified() bool {
- return v[0] == 0 && v[1] == 0 && v[2] == 0
-}
-
-// Kernel implements the kernel's KERNEL_VERSION macro from linux/version.h.
-// It represents the kernel version and patch level as a single value.
-func (v Version) Kernel() uint32 {
-
- // Kernels 4.4 and 4.9 have their SUBLEVEL clamped to 255 to avoid
- // overflowing into PATCHLEVEL.
- // See kernel commit 9b82f13e7ef3 ("kbuild: clamp SUBLEVEL to 255").
- s := v[2]
- if s > 255 {
- s = 255
- }
-
- // Truncate members to uint8 to prevent them from spilling over into
- // each other when overflowing 8 bits.
- return uint32(uint8(v[0]))<<16 | uint32(uint8(v[1]))<<8 | uint32(uint8(s))
-}
-
-// KernelVersion returns the version of the currently running kernel.
-func KernelVersion() (Version, error) {
- kernelVersion.once.Do(func() {
- kernelVersion.version, kernelVersion.err = detectKernelVersion()
- })
-
- if kernelVersion.err != nil {
- return Version{}, kernelVersion.err
- }
- return kernelVersion.version, nil
-}
-
-// detectKernelVersion returns the version of the running kernel.
-func detectKernelVersion() (Version, error) {
- vc, err := vdsoVersion()
- if err != nil {
- return Version{}, err
- }
- return NewVersionFromCode(vc), nil
-}
-
-// KernelRelease returns the release string of the running kernel.
-// Its format depends on the Linux distribution and corresponds to directory
-// names in /lib/modules by convention. Some examples are 5.15.17-1-lts and
-// 4.19.0-16-amd64.
-func KernelRelease() (string, error) {
- var uname unix.Utsname
- if err := unix.Uname(&uname); err != nil {
- return "", fmt.Errorf("uname failed: %w", err)
- }
-
- return unix.ByteSliceToString(uname.Release[:]), nil
-}