mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
Updating dependency github.com/cilium/ebpf to version v0.0.0-20191113100448-d9fb101ca1fb
This commit is contained in:
parent
4274ea2c89
commit
3e43b0722a
2
go.mod
2
go.mod
@ -206,7 +206,7 @@ replace (
|
|||||||
github.com/chai2010/gettext-go => github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5
|
github.com/chai2010/gettext-go => github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5
|
||||||
github.com/checkpoint-restore/go-criu => github.com/checkpoint-restore/go-criu v0.0.0-20181120144056-17b0214f6c48 // 17b0214f6c48 is the SHA for git tag 3.11
|
github.com/checkpoint-restore/go-criu => github.com/checkpoint-restore/go-criu v0.0.0-20181120144056-17b0214f6c48 // 17b0214f6c48 is the SHA for git tag 3.11
|
||||||
github.com/cheekybits/genny => github.com/cheekybits/genny v0.0.0-20170328200008-9127e812e1e9
|
github.com/cheekybits/genny => github.com/cheekybits/genny v0.0.0-20170328200008-9127e812e1e9
|
||||||
github.com/cilium/ebpf => github.com/cilium/ebpf v0.0.0-20191025125908-95b36a581eed
|
github.com/cilium/ebpf => github.com/cilium/ebpf v0.0.0-20191113100448-d9fb101ca1fb
|
||||||
github.com/client9/misspell => github.com/client9/misspell v0.3.4
|
github.com/client9/misspell => github.com/client9/misspell v0.3.4
|
||||||
github.com/clusterhq/flocker-go => github.com/clusterhq/flocker-go v0.0.0-20160920122132-2b8b7259d313
|
github.com/clusterhq/flocker-go => github.com/clusterhq/flocker-go v0.0.0-20160920122132-2b8b7259d313
|
||||||
github.com/cockroachdb/datadriven => github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa
|
github.com/cockroachdb/datadriven => github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa
|
||||||
|
4
go.sum
4
go.sum
@ -84,8 +84,8 @@ github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5/go.mod h1:/iP1
|
|||||||
github.com/checkpoint-restore/go-criu v0.0.0-20181120144056-17b0214f6c48 h1:AQMF0Xixllgf29MKlx/TGEhRk7bEDX5kxz8Ui8lOvEs=
|
github.com/checkpoint-restore/go-criu v0.0.0-20181120144056-17b0214f6c48 h1:AQMF0Xixllgf29MKlx/TGEhRk7bEDX5kxz8Ui8lOvEs=
|
||||||
github.com/checkpoint-restore/go-criu v0.0.0-20181120144056-17b0214f6c48/go.mod h1:TrMrLQfeENAPYPRsJuq3jsqdlRh3lvi6trTZJG8+tho=
|
github.com/checkpoint-restore/go-criu v0.0.0-20181120144056-17b0214f6c48/go.mod h1:TrMrLQfeENAPYPRsJuq3jsqdlRh3lvi6trTZJG8+tho=
|
||||||
github.com/cheekybits/genny v0.0.0-20170328200008-9127e812e1e9/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wXkRAgjxjQ=
|
github.com/cheekybits/genny v0.0.0-20170328200008-9127e812e1e9/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wXkRAgjxjQ=
|
||||||
github.com/cilium/ebpf v0.0.0-20191025125908-95b36a581eed h1:/UgmF+cZTm9kp4uJ122y/9cVhczNJCgAgAeH2FfzPeg=
|
github.com/cilium/ebpf v0.0.0-20191113100448-d9fb101ca1fb h1:bQ0NJ9dAB8vsw7ffajBDX/7Wr64BdLWeJkYY36UkeRY=
|
||||||
github.com/cilium/ebpf v0.0.0-20191025125908-95b36a581eed/go.mod h1:MA5e5Lr8slmEg9bt0VpxxWqJlO4iwu3FBdHUzV7wQVg=
|
github.com/cilium/ebpf v0.0.0-20191113100448-d9fb101ca1fb/go.mod h1:MA5e5Lr8slmEg9bt0VpxxWqJlO4iwu3FBdHUzV7wQVg=
|
||||||
github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI=
|
github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI=
|
||||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||||
github.com/clusterhq/flocker-go v0.0.0-20160920122132-2b8b7259d313 h1:eIHD9GNM3Hp7kcRW5mvcz7WTR3ETeoYYKwpgA04kaXE=
|
github.com/clusterhq/flocker-go v0.0.0-20160920122132-2b8b7259d313 h1:eIHD9GNM3Hp7kcRW5mvcz7WTR3ETeoYYKwpgA04kaXE=
|
||||||
|
253
vendor/github.com/cilium/ebpf/abi.go
generated
vendored
253
vendor/github.com/cilium/ebpf/abi.go
generated
vendored
@ -1,143 +1,88 @@
|
|||||||
package ebpf
|
package ebpf
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CollectionABI describes the interface of an eBPF collection.
|
// MapABI are the attributes of a Map which are available across all supported kernels.
|
||||||
type CollectionABI struct {
|
|
||||||
Maps map[string]*MapABI
|
|
||||||
Programs map[string]*ProgramABI
|
|
||||||
}
|
|
||||||
|
|
||||||
// CheckSpec verifies that all maps and programs mentioned
|
|
||||||
// in the ABI are present in the spec.
|
|
||||||
func (abi *CollectionABI) CheckSpec(cs *CollectionSpec) error {
|
|
||||||
for name := range abi.Maps {
|
|
||||||
if cs.Maps[name] == nil {
|
|
||||||
return errors.Errorf("missing map %s", name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for name := range abi.Programs {
|
|
||||||
if cs.Programs[name] == nil {
|
|
||||||
return errors.Errorf("missing program %s", name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check verifies that all items in a collection conform to this ABI.
|
|
||||||
func (abi *CollectionABI) Check(coll *Collection) error {
|
|
||||||
for name, mapABI := range abi.Maps {
|
|
||||||
m := coll.Maps[name]
|
|
||||||
if m == nil {
|
|
||||||
return errors.Errorf("missing map %s", name)
|
|
||||||
}
|
|
||||||
if err := mapABI.Check(m); err != nil {
|
|
||||||
return errors.Wrapf(err, "map %s", name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for name, progABI := range abi.Programs {
|
|
||||||
p := coll.Programs[name]
|
|
||||||
if p == nil {
|
|
||||||
return errors.Errorf("missing program %s", name)
|
|
||||||
}
|
|
||||||
if err := progABI.Check(p); err != nil {
|
|
||||||
return errors.Wrapf(err, "program %s", name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// MapABI describes a Map.
|
|
||||||
//
|
|
||||||
// Use it to assert that a Map matches what your code expects.
|
|
||||||
type MapABI struct {
|
type MapABI struct {
|
||||||
Type MapType
|
Type MapType
|
||||||
KeySize uint32
|
KeySize uint32
|
||||||
ValueSize uint32
|
ValueSize uint32
|
||||||
MaxEntries uint32
|
MaxEntries uint32
|
||||||
InnerMap *MapABI
|
Flags uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func newMapABIFromSpec(spec *MapSpec) *MapABI {
|
func newMapABIFromSpec(spec *MapSpec) *MapABI {
|
||||||
var inner *MapABI
|
|
||||||
if spec.InnerMap != nil {
|
|
||||||
inner = newMapABIFromSpec(spec.InnerMap)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &MapABI{
|
return &MapABI{
|
||||||
spec.Type,
|
spec.Type,
|
||||||
spec.KeySize,
|
spec.KeySize,
|
||||||
spec.ValueSize,
|
spec.ValueSize,
|
||||||
spec.MaxEntries,
|
spec.MaxEntries,
|
||||||
inner,
|
spec.Flags,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newMapABIFromFd(fd *bpfFD) (*MapABI, error) {
|
func newMapABIFromFd(fd *bpfFD) (string, *MapABI, error) {
|
||||||
info, err := bpfGetMapInfoByFD(fd)
|
info, err := bpfGetMapInfoByFD(fd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
if errors.Cause(err) == syscall.EINVAL {
|
||||||
|
abi, err := newMapABIFromProc(fd)
|
||||||
|
return "", abi, err
|
||||||
|
}
|
||||||
|
return "", nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
mapType := MapType(info.mapType)
|
return "", &MapABI{
|
||||||
if mapType == ArrayOfMaps || mapType == HashOfMaps {
|
MapType(info.mapType),
|
||||||
return nil, errors.New("can't get map info for nested maps")
|
|
||||||
}
|
|
||||||
|
|
||||||
return &MapABI{
|
|
||||||
mapType,
|
|
||||||
info.keySize,
|
info.keySize,
|
||||||
info.valueSize,
|
info.valueSize,
|
||||||
info.maxEntries,
|
info.maxEntries,
|
||||||
nil,
|
info.flags,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check verifies that a Map conforms to the ABI.
|
func newMapABIFromProc(fd *bpfFD) (*MapABI, error) {
|
||||||
//
|
var abi MapABI
|
||||||
// Members of ABI which have the zero value of their type are not checked.
|
err := scanFdInfo(fd, map[string]interface{}{
|
||||||
func (abi *MapABI) Check(m *Map) error {
|
"map_type": &abi.Type,
|
||||||
return abi.check(&m.abi)
|
"key_size": &abi.KeySize,
|
||||||
|
"value_size": &abi.ValueSize,
|
||||||
|
"max_entries": &abi.MaxEntries,
|
||||||
|
"map_flags": &abi.Flags,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &abi, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (abi *MapABI) check(other *MapABI) error {
|
// Equal returns true if two ABIs have the same values.
|
||||||
if abi.Type != UnspecifiedMap && other.Type != abi.Type {
|
func (abi *MapABI) Equal(other *MapABI) bool {
|
||||||
return errors.Errorf("expected map type %s, have %s", abi.Type, other.Type)
|
switch {
|
||||||
|
case abi.Type != other.Type:
|
||||||
|
return false
|
||||||
|
case abi.KeySize != other.KeySize:
|
||||||
|
return false
|
||||||
|
case abi.ValueSize != other.ValueSize:
|
||||||
|
return false
|
||||||
|
case abi.MaxEntries != other.MaxEntries:
|
||||||
|
return false
|
||||||
|
case abi.Flags != other.Flags:
|
||||||
|
return false
|
||||||
|
default:
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
if err := checkUint32("key size", abi.KeySize, other.KeySize); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := checkUint32("value size", abi.ValueSize, other.ValueSize); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := checkUint32("max entries", abi.MaxEntries, other.MaxEntries); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if abi.InnerMap == nil {
|
|
||||||
if abi.Type == ArrayOfMaps || abi.Type == HashOfMaps {
|
|
||||||
return errors.New("missing inner map ABI")
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if other.InnerMap == nil {
|
|
||||||
return errors.New("missing inner map")
|
|
||||||
}
|
|
||||||
|
|
||||||
return errors.Wrap(abi.InnerMap.check(other.InnerMap), "inner map")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProgramABI describes a Program.
|
// ProgramABI are the attributes of a Program which are available across all supported kernels.
|
||||||
//
|
|
||||||
// Use it to assert that a Program matches what your code expects.
|
|
||||||
type ProgramABI struct {
|
type ProgramABI struct {
|
||||||
Type ProgramType
|
Type ProgramType
|
||||||
}
|
}
|
||||||
@ -148,36 +93,102 @@ func newProgramABIFromSpec(spec *ProgramSpec) *ProgramABI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newProgramABIFromFd(fd *bpfFD) (*ProgramABI, error) {
|
func newProgramABIFromFd(fd *bpfFD) (string, *ProgramABI, error) {
|
||||||
info, err := bpfGetProgInfoByFD(fd)
|
info, err := bpfGetProgInfoByFD(fd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
if errors.Cause(err) == syscall.EINVAL {
|
||||||
|
return newProgramABIFromProc(fd)
|
||||||
|
}
|
||||||
|
|
||||||
|
return "", nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return newProgramABIFromInfo(info), nil
|
var name string
|
||||||
}
|
if bpfName := convertCString(info.name[:]); bpfName != "" {
|
||||||
|
name = bpfName
|
||||||
|
} else {
|
||||||
|
name = convertCString(info.tag[:])
|
||||||
|
}
|
||||||
|
|
||||||
func newProgramABIFromInfo(info *bpfProgInfo) *ProgramABI {
|
return name, &ProgramABI{
|
||||||
return &ProgramABI{
|
|
||||||
Type: ProgramType(info.progType),
|
Type: ProgramType(info.progType),
|
||||||
}
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check verifies that a Program conforms to the ABI.
|
func newProgramABIFromProc(fd *bpfFD) (string, *ProgramABI, error) {
|
||||||
//
|
var (
|
||||||
// Members which have the zero value of their type
|
abi ProgramABI
|
||||||
// are not checked.
|
name string
|
||||||
func (abi *ProgramABI) Check(prog *Program) error {
|
)
|
||||||
if abi.Type != UnspecifiedProgram && prog.abi.Type != abi.Type {
|
|
||||||
return errors.Errorf("expected program type %s, have %s", abi.Type, prog.abi.Type)
|
err := scanFdInfo(fd, map[string]interface{}{
|
||||||
|
"prog_type": &abi.Type,
|
||||||
|
"prog_tag": &name,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return "", nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return name, &abi, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func scanFdInfo(fd *bpfFD, fields map[string]interface{}) error {
|
||||||
|
raw, err := fd.value()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fh, err := os.Open(fmt.Sprintf("/proc/self/fdinfo/%d", raw))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer fh.Close()
|
||||||
|
|
||||||
|
return errors.Wrap(scanFdInfoReader(fh, fields), fh.Name())
|
||||||
|
}
|
||||||
|
|
||||||
|
func scanFdInfoReader(r io.Reader, fields map[string]interface{}) error {
|
||||||
|
var (
|
||||||
|
scanner = bufio.NewScanner(r)
|
||||||
|
scanned int
|
||||||
|
)
|
||||||
|
|
||||||
|
for scanner.Scan() {
|
||||||
|
parts := bytes.SplitN(scanner.Bytes(), []byte("\t"), 2)
|
||||||
|
if len(parts) != 2 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
name := bytes.TrimSuffix(parts[0], []byte(":"))
|
||||||
|
field, ok := fields[string(name)]
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if n, err := fmt.Fscanln(bytes.NewReader(parts[1]), field); err != nil || n != 1 {
|
||||||
|
return errors.Wrapf(err, "can't parse field %s", name)
|
||||||
|
}
|
||||||
|
|
||||||
|
scanned++
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := scanner.Err(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if scanned != len(fields) {
|
||||||
|
return errors.Errorf("parsed %d instead of %d fields", scanned, len(fields))
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkUint32(name string, want, have uint32) error {
|
// Equal returns true if two ABIs have the same values.
|
||||||
if want != 0 && have != want {
|
func (abi *ProgramABI) Equal(other *ProgramABI) bool {
|
||||||
return errors.Errorf("expected %s to be %d, have %d", name, want, have)
|
switch {
|
||||||
|
case abi.Type != other.Type:
|
||||||
|
return false
|
||||||
|
default:
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
1
vendor/github.com/cilium/ebpf/internal/unix/types_linux.go
generated
vendored
1
vendor/github.com/cilium/ebpf/internal/unix/types_linux.go
generated
vendored
@ -30,6 +30,7 @@ const (
|
|||||||
PerfBitWatermark = linux.PerfBitWatermark
|
PerfBitWatermark = linux.PerfBitWatermark
|
||||||
PERF_SAMPLE_RAW = linux.PERF_SAMPLE_RAW
|
PERF_SAMPLE_RAW = linux.PERF_SAMPLE_RAW
|
||||||
PERF_FLAG_FD_CLOEXEC = linux.PERF_FLAG_FD_CLOEXEC
|
PERF_FLAG_FD_CLOEXEC = linux.PERF_FLAG_FD_CLOEXEC
|
||||||
|
RLIM_INFINITY = linux.RLIM_INFINITY
|
||||||
)
|
)
|
||||||
|
|
||||||
// Statfs_t is a wrapper
|
// Statfs_t is a wrapper
|
||||||
|
35
vendor/github.com/cilium/ebpf/map.go
generated
vendored
35
vendor/github.com/cilium/ebpf/map.go
generated
vendored
@ -49,8 +49,9 @@ func (ms *MapSpec) Copy() *MapSpec {
|
|||||||
// Implement encoding.BinaryMarshaler or encoding.BinaryUnmarshaler
|
// Implement encoding.BinaryMarshaler or encoding.BinaryUnmarshaler
|
||||||
// if you require custom encoding.
|
// if you require custom encoding.
|
||||||
type Map struct {
|
type Map struct {
|
||||||
fd *bpfFD
|
name string
|
||||||
abi MapABI
|
fd *bpfFD
|
||||||
|
abi MapABI
|
||||||
// Per CPU maps return values larger than the size in the spec
|
// Per CPU maps return values larger than the size in the spec
|
||||||
fullValueSize int
|
fullValueSize int
|
||||||
}
|
}
|
||||||
@ -64,12 +65,12 @@ func NewMapFromFD(fd int) (*Map, error) {
|
|||||||
}
|
}
|
||||||
bpfFd := newBPFFD(uint32(fd))
|
bpfFd := newBPFFD(uint32(fd))
|
||||||
|
|
||||||
abi, err := newMapABIFromFd(bpfFd)
|
name, abi, err := newMapABIFromFd(bpfFd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
bpfFd.forget()
|
bpfFd.forget()
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return newMap(bpfFd, abi)
|
return newMap(bpfFd, name, abi)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewMap creates a new Map.
|
// NewMap creates a new Map.
|
||||||
@ -155,11 +156,12 @@ func createMap(spec *MapSpec, inner *bpfFD) (*Map, error) {
|
|||||||
return nil, errors.Wrap(err, "map create")
|
return nil, errors.Wrap(err, "map create")
|
||||||
}
|
}
|
||||||
|
|
||||||
return newMap(fd, newMapABIFromSpec(spec))
|
return newMap(fd, spec.Name, newMapABIFromSpec(spec))
|
||||||
}
|
}
|
||||||
|
|
||||||
func newMap(fd *bpfFD, abi *MapABI) (*Map, error) {
|
func newMap(fd *bpfFD, name string, abi *MapABI) (*Map, error) {
|
||||||
m := &Map{
|
m := &Map{
|
||||||
|
name,
|
||||||
fd,
|
fd,
|
||||||
*abi,
|
*abi,
|
||||||
int(abi.ValueSize),
|
int(abi.ValueSize),
|
||||||
@ -179,7 +181,10 @@ func newMap(fd *bpfFD, abi *MapABI) (*Map, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Map) String() string {
|
func (m *Map) String() string {
|
||||||
return fmt.Sprintf("%s#%d", m.abi.Type, m.fd)
|
if m.name != "" {
|
||||||
|
return fmt.Sprintf("%s(%s)#%v", m.abi.Type, m.name, m.fd)
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%s#%v", m.abi.Type, m.fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ABI gets the ABI of the Map
|
// ABI gets the ABI of the Map
|
||||||
@ -424,7 +429,7 @@ func (m *Map) Clone() (*Map, error) {
|
|||||||
return nil, errors.Wrap(err, "can't clone map")
|
return nil, errors.Wrap(err, "can't clone map")
|
||||||
}
|
}
|
||||||
|
|
||||||
return newMap(dup, &m.abi)
|
return newMap(dup, m.name, &m.abi)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pin persists the map past the lifetime of the process that created it.
|
// Pin persists the map past the lifetime of the process that created it.
|
||||||
@ -436,19 +441,19 @@ func (m *Map) Pin(fileName string) error {
|
|||||||
|
|
||||||
// LoadPinnedMap load a Map from a BPF file.
|
// LoadPinnedMap load a Map from a BPF file.
|
||||||
//
|
//
|
||||||
// Requires at least Linux 4.13, and is not compatible with
|
// The function is not compatible with nested maps.
|
||||||
// nested maps. Use LoadPinnedMapExplicit in these situations.
|
// Use LoadPinnedMapExplicit in these situations.
|
||||||
func LoadPinnedMap(fileName string) (*Map, error) {
|
func LoadPinnedMap(fileName string) (*Map, error) {
|
||||||
fd, err := bpfGetObject(fileName)
|
fd, err := bpfGetObject(fileName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
abi, err := newMapABIFromFd(fd)
|
name, abi, err := newMapABIFromFd(fd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = fd.close()
|
_ = fd.close()
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return newMap(fd, abi)
|
return newMap(fd, name, abi)
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadPinnedMapExplicit loads a map with explicit parameters.
|
// LoadPinnedMapExplicit loads a map with explicit parameters.
|
||||||
@ -457,7 +462,7 @@ func LoadPinnedMapExplicit(fileName string, abi *MapABI) (*Map, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return newMap(fd, abi)
|
return newMap(fd, "", abi)
|
||||||
}
|
}
|
||||||
|
|
||||||
func unmarshalMap(buf []byte) (*Map, error) {
|
func unmarshalMap(buf []byte) (*Map, error) {
|
||||||
@ -473,13 +478,13 @@ func unmarshalMap(buf []byte) (*Map, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
abi, err := newMapABIFromFd(fd)
|
name, abi, err := newMapABIFromFd(fd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = fd.close()
|
_ = fd.close()
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return newMap(fd, abi)
|
return newMap(fd, name, abi)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarshalBinary implements BinaryMarshaler.
|
// MarshalBinary implements BinaryMarshaler.
|
||||||
|
37
vendor/github.com/cilium/ebpf/prog.go
generated
vendored
37
vendor/github.com/cilium/ebpf/prog.go
generated
vendored
@ -4,7 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@ -145,20 +144,13 @@ func NewProgramFromFD(fd int) (*Program, error) {
|
|||||||
}
|
}
|
||||||
bpfFd := newBPFFD(uint32(fd))
|
bpfFd := newBPFFD(uint32(fd))
|
||||||
|
|
||||||
info, err := bpfGetProgInfoByFD(bpfFd)
|
name, abi, err := newProgramABIFromFd(bpfFd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
bpfFd.forget()
|
bpfFd.forget()
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var name string
|
return newProgram(bpfFd, name, abi), nil
|
||||||
if bpfName := convertCString(info.name[:]); bpfName != "" {
|
|
||||||
name = bpfName
|
|
||||||
} else {
|
|
||||||
name = convertCString(info.tag[:])
|
|
||||||
}
|
|
||||||
|
|
||||||
return newProgram(bpfFd, name, newProgramABIFromInfo(info)), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func newProgram(fd *bpfFD, name string, abi *ProgramABI) *Program {
|
func newProgram(fd *bpfFD, name string, abi *ProgramABI) *Program {
|
||||||
@ -209,9 +201,9 @@ func convertProgramSpec(spec *ProgramSpec, includeName bool) (*bpfProgLoadAttr,
|
|||||||
|
|
||||||
func (p *Program) String() string {
|
func (p *Program) String() string {
|
||||||
if p.name != "" {
|
if p.name != "" {
|
||||||
return fmt.Sprintf("%s(%s)#%s", p.abi.Type, p.name, p.fd)
|
return fmt.Sprintf("%s(%s)#%v", p.abi.Type, p.name, p.fd)
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%s#%s", p.abi.Type, p.fd)
|
return fmt.Sprintf("%s#%v", p.abi.Type, p.fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ABI gets the ABI of the Program
|
// ABI gets the ABI of the Program
|
||||||
@ -392,13 +384,13 @@ func unmarshalProgram(buf []byte) (*Program, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
abi, err := newProgramABIFromFd(fd)
|
name, abi, err := newProgramABIFromFd(fd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = fd.close()
|
_ = fd.close()
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return newProgram(fd, "", abi), nil
|
return newProgram(fd, name, abi), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarshalBinary implements BinaryMarshaler.
|
// MarshalBinary implements BinaryMarshaler.
|
||||||
@ -456,32 +448,19 @@ func (p *Program) Detach(fd int, typ AttachType, flags AttachFlags) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// LoadPinnedProgram loads a Program from a BPF file.
|
// LoadPinnedProgram loads a Program from a BPF file.
|
||||||
//
|
|
||||||
// Requires at least Linux 4.13, use LoadPinnedProgramExplicit on
|
|
||||||
// earlier versions.
|
|
||||||
func LoadPinnedProgram(fileName string) (*Program, error) {
|
func LoadPinnedProgram(fileName string) (*Program, error) {
|
||||||
fd, err := bpfGetObject(fileName)
|
fd, err := bpfGetObject(fileName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
abi, err := newProgramABIFromFd(fd)
|
name, abi, err := newProgramABIFromFd(fd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = fd.close()
|
_ = fd.close()
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return newProgram(fd, filepath.Base(fileName), abi), nil
|
return newProgram(fd, name, abi), nil
|
||||||
}
|
|
||||||
|
|
||||||
// LoadPinnedProgramExplicit loads a program with explicit parameters.
|
|
||||||
func LoadPinnedProgramExplicit(fileName string, abi *ProgramABI) (*Program, error) {
|
|
||||||
fd, err := bpfGetObject(fileName)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return newProgram(fd, filepath.Base(fileName), abi), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SanitizeName replaces all invalid characters in name.
|
// SanitizeName replaces all invalid characters in name.
|
||||||
|
2
vendor/github.com/cilium/ebpf/run-tests.sh
generated
vendored
2
vendor/github.com/cilium/ebpf/run-tests.sh
generated
vendored
@ -50,7 +50,7 @@ test -e "${tmp_dir}/${kernel}" || {
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo Testing on ${kernel_version}
|
echo Testing on ${kernel_version}
|
||||||
$sudo virtme-run --kimg "${tmp_dir}/${kernel}" --memory 256M --pwd --rwdir=/run/output="${output}" --script-sh "$(realpath "$0") --in-vm /run/output"
|
$sudo virtme-run --kimg "${tmp_dir}/${kernel}" --memory 256M --pwd --rwdir=/run/output="${output}" --script-sh "$(realpath "$0") --in-vm /run/output" --qemu-opts -smp 2
|
||||||
|
|
||||||
if [[ ! -e "${output}/success" ]]; then
|
if [[ ! -e "${output}/success" ]]; then
|
||||||
echo "Test failed on ${kernel_version}"
|
echo "Test failed on ${kernel_version}"
|
||||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -155,7 +155,7 @@ github.com/chai2010/gettext-go/gettext/plural
|
|||||||
github.com/chai2010/gettext-go/gettext/po
|
github.com/chai2010/gettext-go/gettext/po
|
||||||
# github.com/checkpoint-restore/go-criu v0.0.0-20190109184317-bdb7599cd87b => github.com/checkpoint-restore/go-criu v0.0.0-20181120144056-17b0214f6c48
|
# github.com/checkpoint-restore/go-criu v0.0.0-20190109184317-bdb7599cd87b => github.com/checkpoint-restore/go-criu v0.0.0-20181120144056-17b0214f6c48
|
||||||
github.com/checkpoint-restore/go-criu/rpc
|
github.com/checkpoint-restore/go-criu/rpc
|
||||||
# github.com/cilium/ebpf v0.0.0-20191113100448-d9fb101ca1fb => github.com/cilium/ebpf v0.0.0-20191025125908-95b36a581eed
|
# github.com/cilium/ebpf v0.0.0-20191113100448-d9fb101ca1fb => github.com/cilium/ebpf v0.0.0-20191113100448-d9fb101ca1fb
|
||||||
github.com/cilium/ebpf
|
github.com/cilium/ebpf
|
||||||
github.com/cilium/ebpf/asm
|
github.com/cilium/ebpf/asm
|
||||||
github.com/cilium/ebpf/internal
|
github.com/cilium/ebpf/internal
|
||||||
|
Loading…
Reference in New Issue
Block a user