From 582f817812b4865b6c14c5df49691bcb13e0a6a4 Mon Sep 17 00:00:00 2001 From: Jayanth Varavani <1111446+jayanthvn@users.noreply.github.com> Date: Tue, 15 Aug 2023 23:31:03 +0000 Subject: [PATCH 01/29] Mocks for public APIs --- go.mod | 3 + go.sum | 4 ++ pkg/elfparser/elf.go | 37 +++++++--- pkg/elfparser/generate_mocks.go | 15 ++++ pkg/elfparser/mocks/elfparser_mocks.go | 96 ++++++++++++++++++++++++++ 5 files changed, 144 insertions(+), 11 deletions(-) create mode 100644 pkg/elfparser/generate_mocks.go create mode 100644 pkg/elfparser/mocks/elfparser_mocks.go diff --git a/go.mod b/go.mod index 457b91d..9ea4132 100644 --- a/go.mod +++ b/go.mod @@ -16,5 +16,8 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df // indirect go.uber.org/multierr v1.10.0 // indirect + golang.org/x/mod v0.4.2 // indirect + golang.org/x/tools v0.1.1 // indirect + golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index ecc5abd..89bf75d 100644 --- a/go.sum +++ b/go.sum @@ -5,6 +5,7 @@ github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/vishvananda/netlink v1.1.0 h1:1iyaYNBLmP6L0220aDnYQpo1QEV4t4hJ+xEEhhJH8j0= @@ -19,6 +20,7 @@ go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -38,9 +40,11 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.1 h1:wGiQel/hW0NnEkJUk8lbzkX2gFJU6PFxf1v5OlCfuOs= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/pkg/elfparser/elf.go b/pkg/elfparser/elf.go index 6def3f0..877a3ad 100644 --- a/pkg/elfparser/elf.go +++ b/pkg/elfparser/elf.go @@ -47,11 +47,23 @@ var ( var log = logger.Get() var sdkCache = cache.Get() +type AWSeBpfSdkAPIs interface { + IncreaseRlimit() error + LoadBpfFile(path string) (map[string]BpfData, map[string]ebpf_maps.BpfMap, error) + RecoverGlobalMaps() (map[string]ebpf_maps.BpfMap, error) + RecoverAllBpfProgramsAndMaps() (map[string]BpfData, error) +} + type BpfData struct { Program ebpf_progs.BpfProgram // Return the program Maps map[string]ebpf_maps.BpfMap // List of associated maps } +type bpfSDKClient struct { + mapApi ebpf_maps.BpfMapAPIs + progApi ebpf_progs.BpfProgAPIs +} + type relocationEntry struct { relOffset int symbol elf.Symbol @@ -78,6 +90,13 @@ type elfLoader struct { progSectionMap map[uint32]progEntry } +func New() *bpfSDKClient { + return &bpfSDKClient{ + mapApi: &ebpf_maps.BpfMap{}, + progApi: &ebpf_progs.BpfProgram{}, + } +} + // This is not needed 5.11 kernel onwards because per-cgroup mem limits // https://lore.kernel.org/bpf/20201201215900.3569844-1-guro@fb.com/ func IncreaseRlimit() error { @@ -101,7 +120,7 @@ func newElfLoader(elfFile *elf.File, bpfmapapi ebpf_maps.BpfMapAPIs, bpfprogapi return elfloader } -func LoadBpfFile(path, customizedPinPath string) (map[string]BpfData, map[string]ebpf_maps.BpfMap, error) { +func (b *bpfSDKClient) LoadBpfFile(path, customizedPinPath string) (map[string]BpfData, map[string]ebpf_maps.BpfMap, error) { bpfFile, err := os.Open(path) if err != nil { log.Infof("LoadBpfFile failed to open") @@ -114,7 +133,7 @@ func LoadBpfFile(path, customizedPinPath string) (map[string]BpfData, map[string return nil, nil, err } - elfLoader := newElfLoader(elfFile, &ebpf_maps.BpfMap{}, &ebpf_progs.BpfProgram{}, customizedPinPath) + elfLoader := newElfLoader(elfFile, b.mapApi, b.progApi, customizedPinPath) bpfLoadedProg, bpfLoadedMaps, err := elfLoader.doLoadELF() if err != nil { @@ -648,14 +667,13 @@ func IsMapGlobal(pinPath string) bool { return true } -func RecoverGlobalMaps() (map[string]ebpf_maps.BpfMap, error) { +func (b *bpfSDKClient) RecoverGlobalMaps() (map[string]ebpf_maps.BpfMap, error) { _, err := os.Stat(constdef.BPF_DIR_MNT) if err != nil { log.Infof("BPF FS director is not present") return nil, fmt.Errorf("BPF directory is not present %v", err) } loadedGlobalMaps := make(map[string]ebpf_maps.BpfMap) - mapsApi := &ebpf_maps.BpfMap{} var statfs syscall.Statfs_t if err := syscall.Statfs(constdef.BPF_DIR_MNT, &statfs); err == nil && statfs.Type == unix.BPF_FS_MAGIC { if err := filepath.Walk(constdef.MAP_BPF_FS, func(pinPath string, fsinfo os.FileInfo, err error) error { @@ -666,7 +684,7 @@ func RecoverGlobalMaps() (map[string]ebpf_maps.BpfMap, error) { log.Infof("Dumping pinpaths - ", pinPath) if IsMapGlobal(pinPath) { log.Infof("Found global pinpaths - ", pinPath) - bpfMapInfo, err := mapsApi.GetMapFromPinPath(pinPath) + bpfMapInfo, err := b.mapApi.GetMapFromPinPath(pinPath) if err != nil { log.Errorf("error getting mapInfo for Global pin path, this shouldn't happen") return err @@ -717,7 +735,7 @@ func RecoverGlobalMaps() (map[string]ebpf_maps.BpfMap, error) { return loadedGlobalMaps, nil } -func RecoverAllBpfProgramsAndMaps() (map[string]BpfData, error) { +func (b *bpfSDKClient) RecoverAllBpfProgramsAndMaps() (map[string]BpfData, error) { _, err := os.Stat(constdef.BPF_DIR_MNT) if err != nil { log.Infof("BPF FS directory is not present") @@ -726,9 +744,6 @@ func RecoverAllBpfProgramsAndMaps() (map[string]BpfData, error) { var statfs syscall.Statfs_t - mapsApi := &ebpf_maps.BpfMap{} - showProgApi := &ebpf_progs.BpfProgram{} - //Pass DS here loadedPrograms := make(map[string]BpfData) mapIDsToNames := make(map[int]string) @@ -756,7 +771,7 @@ func RecoverAllBpfProgramsAndMaps() (map[string]BpfData, error) { if !fsinfo.IsDir() { log.Infof("Dumping pinpaths - ", pinPath) - bpfMapInfo, err := mapsApi.GetMapFromPinPath(pinPath) + bpfMapInfo, err := b.mapApi.GetMapFromPinPath(pinPath) if err != nil { log.Infof("error getting mapInfo for pin path, this shouldn't happen") return err @@ -811,7 +826,7 @@ func RecoverAllBpfProgramsAndMaps() (map[string]BpfData, error) { } //mapData := [string]ebpf_maps.BPFMap{} - bpfProgInfo, progFD, err := (showProgApi).GetProgFromPinPath(pinPath) + bpfProgInfo, progFD, err := (b.progApi).GetProgFromPinPath(pinPath) if err != nil { log.Infof("Failed to progInfo for pinPath %s", pinPath) return err diff --git a/pkg/elfparser/generate_mocks.go b/pkg/elfparser/generate_mocks.go new file mode 100644 index 0000000..989381f --- /dev/null +++ b/pkg/elfparser/generate_mocks.go @@ -0,0 +1,15 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"). You may +// not use this file except in compliance with the License. A copy of the +// License is located at +// +// http://aws.amazon.com/apache2.0/ +// +// or in the "license" file accompanying this file. This file is distributed +// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +// express or implied. See the License for the specific language governing +// permissions and limitations under the License. +package elfparser + +//go:generate go run github.com/golang/mock/mockgen -destination mocks/elfparser_mocks.go . AWSeBpfSdkAPIs diff --git a/pkg/elfparser/mocks/elfparser_mocks.go b/pkg/elfparser/mocks/elfparser_mocks.go new file mode 100644 index 0000000..0ccda4b --- /dev/null +++ b/pkg/elfparser/mocks/elfparser_mocks.go @@ -0,0 +1,96 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/aws/aws-ebpf-sdk-go/pkg/elfparser (interfaces: AWSeBpfSdkAPIs) + +// Package mock_elfparser is a generated GoMock package. +package mock_elfparser + +import ( + reflect "reflect" + + elfparser "github.com/aws/aws-ebpf-sdk-go/pkg/elfparser" + maps "github.com/aws/aws-ebpf-sdk-go/pkg/maps" + gomock "github.com/golang/mock/gomock" +) + +// MockAWSeBpfSdkAPIs is a mock of AWSeBpfSdkAPIs interface. +type MockAWSeBpfSdkAPIs struct { + ctrl *gomock.Controller + recorder *MockAWSeBpfSdkAPIsMockRecorder +} + +// MockAWSeBpfSdkAPIsMockRecorder is the mock recorder for MockAWSeBpfSdkAPIs. +type MockAWSeBpfSdkAPIsMockRecorder struct { + mock *MockAWSeBpfSdkAPIs +} + +// NewMockAWSeBpfSdkAPIs creates a new mock instance. +func NewMockAWSeBpfSdkAPIs(ctrl *gomock.Controller) *MockAWSeBpfSdkAPIs { + mock := &MockAWSeBpfSdkAPIs{ctrl: ctrl} + mock.recorder = &MockAWSeBpfSdkAPIsMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockAWSeBpfSdkAPIs) EXPECT() *MockAWSeBpfSdkAPIsMockRecorder { + return m.recorder +} + +// IncreaseRlimit mocks base method. +func (m *MockAWSeBpfSdkAPIs) IncreaseRlimit() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IncreaseRlimit") + ret0, _ := ret[0].(error) + return ret0 +} + +// IncreaseRlimit indicates an expected call of IncreaseRlimit. +func (mr *MockAWSeBpfSdkAPIsMockRecorder) IncreaseRlimit() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IncreaseRlimit", reflect.TypeOf((*MockAWSeBpfSdkAPIs)(nil).IncreaseRlimit)) +} + +// LoadBpfFile mocks base method. +func (m *MockAWSeBpfSdkAPIs) LoadBpfFile(arg0 string) (map[string]elfparser.BpfData, map[string]maps.BpfMap, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "LoadBpfFile", arg0) + ret0, _ := ret[0].(map[string]elfparser.BpfData) + ret1, _ := ret[1].(map[string]maps.BpfMap) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// LoadBpfFile indicates an expected call of LoadBpfFile. +func (mr *MockAWSeBpfSdkAPIsMockRecorder) LoadBpfFile(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LoadBpfFile", reflect.TypeOf((*MockAWSeBpfSdkAPIs)(nil).LoadBpfFile), arg0) +} + +// RecoverAllBpfProgramsAndMaps mocks base method. +func (m *MockAWSeBpfSdkAPIs) RecoverAllBpfProgramsAndMaps() (map[string]elfparser.BpfData, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RecoverAllBpfProgramsAndMaps") + ret0, _ := ret[0].(map[string]elfparser.BpfData) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// RecoverAllBpfProgramsAndMaps indicates an expected call of RecoverAllBpfProgramsAndMaps. +func (mr *MockAWSeBpfSdkAPIsMockRecorder) RecoverAllBpfProgramsAndMaps() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecoverAllBpfProgramsAndMaps", reflect.TypeOf((*MockAWSeBpfSdkAPIs)(nil).RecoverAllBpfProgramsAndMaps)) +} + +// RecoverGlobalMaps mocks base method. +func (m *MockAWSeBpfSdkAPIs) RecoverGlobalMaps() (map[string]maps.BpfMap, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RecoverGlobalMaps") + ret0, _ := ret[0].(map[string]maps.BpfMap) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// RecoverGlobalMaps indicates an expected call of RecoverGlobalMaps. +func (mr *MockAWSeBpfSdkAPIsMockRecorder) RecoverGlobalMaps() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecoverGlobalMaps", reflect.TypeOf((*MockAWSeBpfSdkAPIs)(nil).RecoverGlobalMaps)) +} From 151e9e304d2ff4d048671fb810a66d4b3186cee6 Mon Sep 17 00:00:00 2001 From: Jayanth Varavani <1111446+jayanthvn@users.noreply.github.com> Date: Wed, 16 Aug 2023 05:51:13 +0000 Subject: [PATCH 02/29] PR feedback --- pkg/elfparser/elf.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/elfparser/elf.go b/pkg/elfparser/elf.go index 877a3ad..8897e9e 100644 --- a/pkg/elfparser/elf.go +++ b/pkg/elfparser/elf.go @@ -49,7 +49,7 @@ var sdkCache = cache.Get() type AWSeBpfSdkAPIs interface { IncreaseRlimit() error - LoadBpfFile(path string) (map[string]BpfData, map[string]ebpf_maps.BpfMap, error) + LoadBpfFile(path, customizedPinPath string) (map[string]BpfData, map[string]ebpf_maps.BpfMap, error) RecoverGlobalMaps() (map[string]ebpf_maps.BpfMap, error) RecoverAllBpfProgramsAndMaps() (map[string]BpfData, error) } @@ -97,9 +97,11 @@ func New() *bpfSDKClient { } } +var _ AWSeBpfSdkAPIs = (*bpfSDKClient)(nil) + // This is not needed 5.11 kernel onwards because per-cgroup mem limits // https://lore.kernel.org/bpf/20201201215900.3569844-1-guro@fb.com/ -func IncreaseRlimit() error { +func (b *bpfSDKClient) IncreaseRlimit() error { err := unix.Setrlimit(unix.RLIMIT_MEMLOCK, &unix.Rlimit{Cur: unix.RLIM_INFINITY, Max: unix.RLIM_INFINITY}) if err != nil { log.Infof("Failed to bump up the rlimit") From 1c4c6bb116aa2324abff76b46cdcba6676e85a35 Mon Sep 17 00:00:00 2001 From: Jayanth Varavani <1111446+jayanthvn@users.noreply.github.com> Date: Wed, 16 Aug 2023 23:36:29 +0000 Subject: [PATCH 03/29] Make the sdk client global for mocks --- pkg/elfparser/elf.go | 16 ++++++++-------- pkg/elfparser/mocks/elfparser_mocks.go | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/elfparser/elf.go b/pkg/elfparser/elf.go index 8897e9e..9a3ae08 100644 --- a/pkg/elfparser/elf.go +++ b/pkg/elfparser/elf.go @@ -59,7 +59,7 @@ type BpfData struct { Maps map[string]ebpf_maps.BpfMap // List of associated maps } -type bpfSDKClient struct { +type BpfSDKClient struct { mapApi ebpf_maps.BpfMapAPIs progApi ebpf_progs.BpfProgAPIs } @@ -90,18 +90,18 @@ type elfLoader struct { progSectionMap map[uint32]progEntry } -func New() *bpfSDKClient { - return &bpfSDKClient{ +func New() *BpfSDKClient { + return &BpfSDKClient{ mapApi: &ebpf_maps.BpfMap{}, progApi: &ebpf_progs.BpfProgram{}, } } -var _ AWSeBpfSdkAPIs = (*bpfSDKClient)(nil) +var _ AWSeBpfSdkAPIs = (*BpfSDKClient)(nil) // This is not needed 5.11 kernel onwards because per-cgroup mem limits // https://lore.kernel.org/bpf/20201201215900.3569844-1-guro@fb.com/ -func (b *bpfSDKClient) IncreaseRlimit() error { +func (b *BpfSDKClient) IncreaseRlimit() error { err := unix.Setrlimit(unix.RLIMIT_MEMLOCK, &unix.Rlimit{Cur: unix.RLIM_INFINITY, Max: unix.RLIM_INFINITY}) if err != nil { log.Infof("Failed to bump up the rlimit") @@ -122,7 +122,7 @@ func newElfLoader(elfFile *elf.File, bpfmapapi ebpf_maps.BpfMapAPIs, bpfprogapi return elfloader } -func (b *bpfSDKClient) LoadBpfFile(path, customizedPinPath string) (map[string]BpfData, map[string]ebpf_maps.BpfMap, error) { +func (b *BpfSDKClient) LoadBpfFile(path, customizedPinPath string) (map[string]BpfData, map[string]ebpf_maps.BpfMap, error) { bpfFile, err := os.Open(path) if err != nil { log.Infof("LoadBpfFile failed to open") @@ -669,7 +669,7 @@ func IsMapGlobal(pinPath string) bool { return true } -func (b *bpfSDKClient) RecoverGlobalMaps() (map[string]ebpf_maps.BpfMap, error) { +func (b *BpfSDKClient) RecoverGlobalMaps() (map[string]ebpf_maps.BpfMap, error) { _, err := os.Stat(constdef.BPF_DIR_MNT) if err != nil { log.Infof("BPF FS director is not present") @@ -737,7 +737,7 @@ func (b *bpfSDKClient) RecoverGlobalMaps() (map[string]ebpf_maps.BpfMap, error) return loadedGlobalMaps, nil } -func (b *bpfSDKClient) RecoverAllBpfProgramsAndMaps() (map[string]BpfData, error) { +func (b *BpfSDKClient) RecoverAllBpfProgramsAndMaps() (map[string]BpfData, error) { _, err := os.Stat(constdef.BPF_DIR_MNT) if err != nil { log.Infof("BPF FS directory is not present") diff --git a/pkg/elfparser/mocks/elfparser_mocks.go b/pkg/elfparser/mocks/elfparser_mocks.go index 0ccda4b..f7224b6 100644 --- a/pkg/elfparser/mocks/elfparser_mocks.go +++ b/pkg/elfparser/mocks/elfparser_mocks.go @@ -50,9 +50,9 @@ func (mr *MockAWSeBpfSdkAPIsMockRecorder) IncreaseRlimit() *gomock.Call { } // LoadBpfFile mocks base method. -func (m *MockAWSeBpfSdkAPIs) LoadBpfFile(arg0 string) (map[string]elfparser.BpfData, map[string]maps.BpfMap, error) { +func (m *MockAWSeBpfSdkAPIs) LoadBpfFile(arg0, arg1 string) (map[string]elfparser.BpfData, map[string]maps.BpfMap, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "LoadBpfFile", arg0) + ret := m.ctrl.Call(m, "LoadBpfFile", arg0, arg1) ret0, _ := ret[0].(map[string]elfparser.BpfData) ret1, _ := ret[1].(map[string]maps.BpfMap) ret2, _ := ret[2].(error) @@ -60,9 +60,9 @@ func (m *MockAWSeBpfSdkAPIs) LoadBpfFile(arg0 string) (map[string]elfparser.BpfD } // LoadBpfFile indicates an expected call of LoadBpfFile. -func (mr *MockAWSeBpfSdkAPIsMockRecorder) LoadBpfFile(arg0 interface{}) *gomock.Call { +func (mr *MockAWSeBpfSdkAPIsMockRecorder) LoadBpfFile(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LoadBpfFile", reflect.TypeOf((*MockAWSeBpfSdkAPIs)(nil).LoadBpfFile), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LoadBpfFile", reflect.TypeOf((*MockAWSeBpfSdkAPIs)(nil).LoadBpfFile), arg0, arg1) } // RecoverAllBpfProgramsAndMaps mocks base method. From ed84377e6ef9f55e8df4a362af73757803b3aa10 Mon Sep 17 00:00:00 2001 From: Jayanth Varavani <1111446+jayanthvn@users.noreply.github.com> Date: Thu, 17 Aug 2023 12:22:41 -0700 Subject: [PATCH 04/29] Update sdk client for NA mocks (#26) * Update sdk client * fix var --- pkg/elfparser/elf.go | 18 +++++----- pkg/elfparser/generate_mocks.go | 2 +- pkg/elfparser/mocks/elfparser_mocks.go | 48 +++++++++++++------------- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/pkg/elfparser/elf.go b/pkg/elfparser/elf.go index 9a3ae08..d0997a8 100644 --- a/pkg/elfparser/elf.go +++ b/pkg/elfparser/elf.go @@ -47,7 +47,7 @@ var ( var log = logger.Get() var sdkCache = cache.Get() -type AWSeBpfSdkAPIs interface { +type BpfSDKClient interface { IncreaseRlimit() error LoadBpfFile(path, customizedPinPath string) (map[string]BpfData, map[string]ebpf_maps.BpfMap, error) RecoverGlobalMaps() (map[string]ebpf_maps.BpfMap, error) @@ -59,7 +59,7 @@ type BpfData struct { Maps map[string]ebpf_maps.BpfMap // List of associated maps } -type BpfSDKClient struct { +type bpfSDKClient struct { mapApi ebpf_maps.BpfMapAPIs progApi ebpf_progs.BpfProgAPIs } @@ -90,18 +90,18 @@ type elfLoader struct { progSectionMap map[uint32]progEntry } -func New() *BpfSDKClient { - return &BpfSDKClient{ +func New() BpfSDKClient { + return &bpfSDKClient{ mapApi: &ebpf_maps.BpfMap{}, progApi: &ebpf_progs.BpfProgram{}, } } -var _ AWSeBpfSdkAPIs = (*BpfSDKClient)(nil) +var _ BpfSDKClient = &bpfSDKClient{} // This is not needed 5.11 kernel onwards because per-cgroup mem limits // https://lore.kernel.org/bpf/20201201215900.3569844-1-guro@fb.com/ -func (b *BpfSDKClient) IncreaseRlimit() error { +func (b *bpfSDKClient) IncreaseRlimit() error { err := unix.Setrlimit(unix.RLIMIT_MEMLOCK, &unix.Rlimit{Cur: unix.RLIM_INFINITY, Max: unix.RLIM_INFINITY}) if err != nil { log.Infof("Failed to bump up the rlimit") @@ -122,7 +122,7 @@ func newElfLoader(elfFile *elf.File, bpfmapapi ebpf_maps.BpfMapAPIs, bpfprogapi return elfloader } -func (b *BpfSDKClient) LoadBpfFile(path, customizedPinPath string) (map[string]BpfData, map[string]ebpf_maps.BpfMap, error) { +func (b *bpfSDKClient) LoadBpfFile(path, customizedPinPath string) (map[string]BpfData, map[string]ebpf_maps.BpfMap, error) { bpfFile, err := os.Open(path) if err != nil { log.Infof("LoadBpfFile failed to open") @@ -669,7 +669,7 @@ func IsMapGlobal(pinPath string) bool { return true } -func (b *BpfSDKClient) RecoverGlobalMaps() (map[string]ebpf_maps.BpfMap, error) { +func (b *bpfSDKClient) RecoverGlobalMaps() (map[string]ebpf_maps.BpfMap, error) { _, err := os.Stat(constdef.BPF_DIR_MNT) if err != nil { log.Infof("BPF FS director is not present") @@ -737,7 +737,7 @@ func (b *BpfSDKClient) RecoverGlobalMaps() (map[string]ebpf_maps.BpfMap, error) return loadedGlobalMaps, nil } -func (b *BpfSDKClient) RecoverAllBpfProgramsAndMaps() (map[string]BpfData, error) { +func (b *bpfSDKClient) RecoverAllBpfProgramsAndMaps() (map[string]BpfData, error) { _, err := os.Stat(constdef.BPF_DIR_MNT) if err != nil { log.Infof("BPF FS directory is not present") diff --git a/pkg/elfparser/generate_mocks.go b/pkg/elfparser/generate_mocks.go index 989381f..e7fc5a9 100644 --- a/pkg/elfparser/generate_mocks.go +++ b/pkg/elfparser/generate_mocks.go @@ -12,4 +12,4 @@ // permissions and limitations under the License. package elfparser -//go:generate go run github.com/golang/mock/mockgen -destination mocks/elfparser_mocks.go . AWSeBpfSdkAPIs +//go:generate go run github.com/golang/mock/mockgen -destination mocks/elfparser_mocks.go . BpfSDKClient diff --git a/pkg/elfparser/mocks/elfparser_mocks.go b/pkg/elfparser/mocks/elfparser_mocks.go index f7224b6..abb87b2 100644 --- a/pkg/elfparser/mocks/elfparser_mocks.go +++ b/pkg/elfparser/mocks/elfparser_mocks.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/aws/aws-ebpf-sdk-go/pkg/elfparser (interfaces: AWSeBpfSdkAPIs) +// Source: github.com/aws/aws-ebpf-sdk-go/pkg/elfparser (interfaces: BpfSDKClient) // Package mock_elfparser is a generated GoMock package. package mock_elfparser @@ -12,31 +12,31 @@ import ( gomock "github.com/golang/mock/gomock" ) -// MockAWSeBpfSdkAPIs is a mock of AWSeBpfSdkAPIs interface. -type MockAWSeBpfSdkAPIs struct { +// MockBpfSDKClient is a mock of BpfSDKClient interface. +type MockBpfSDKClient struct { ctrl *gomock.Controller - recorder *MockAWSeBpfSdkAPIsMockRecorder + recorder *MockBpfSDKClientMockRecorder } -// MockAWSeBpfSdkAPIsMockRecorder is the mock recorder for MockAWSeBpfSdkAPIs. -type MockAWSeBpfSdkAPIsMockRecorder struct { - mock *MockAWSeBpfSdkAPIs +// MockBpfSDKClientMockRecorder is the mock recorder for MockBpfSDKClient. +type MockBpfSDKClientMockRecorder struct { + mock *MockBpfSDKClient } -// NewMockAWSeBpfSdkAPIs creates a new mock instance. -func NewMockAWSeBpfSdkAPIs(ctrl *gomock.Controller) *MockAWSeBpfSdkAPIs { - mock := &MockAWSeBpfSdkAPIs{ctrl: ctrl} - mock.recorder = &MockAWSeBpfSdkAPIsMockRecorder{mock} +// NewMockBpfSDKClient creates a new mock instance. +func NewMockBpfSDKClient(ctrl *gomock.Controller) *MockBpfSDKClient { + mock := &MockBpfSDKClient{ctrl: ctrl} + mock.recorder = &MockBpfSDKClientMockRecorder{mock} return mock } // EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockAWSeBpfSdkAPIs) EXPECT() *MockAWSeBpfSdkAPIsMockRecorder { +func (m *MockBpfSDKClient) EXPECT() *MockBpfSDKClientMockRecorder { return m.recorder } // IncreaseRlimit mocks base method. -func (m *MockAWSeBpfSdkAPIs) IncreaseRlimit() error { +func (m *MockBpfSDKClient) IncreaseRlimit() error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "IncreaseRlimit") ret0, _ := ret[0].(error) @@ -44,13 +44,13 @@ func (m *MockAWSeBpfSdkAPIs) IncreaseRlimit() error { } // IncreaseRlimit indicates an expected call of IncreaseRlimit. -func (mr *MockAWSeBpfSdkAPIsMockRecorder) IncreaseRlimit() *gomock.Call { +func (mr *MockBpfSDKClientMockRecorder) IncreaseRlimit() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IncreaseRlimit", reflect.TypeOf((*MockAWSeBpfSdkAPIs)(nil).IncreaseRlimit)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IncreaseRlimit", reflect.TypeOf((*MockBpfSDKClient)(nil).IncreaseRlimit)) } // LoadBpfFile mocks base method. -func (m *MockAWSeBpfSdkAPIs) LoadBpfFile(arg0, arg1 string) (map[string]elfparser.BpfData, map[string]maps.BpfMap, error) { +func (m *MockBpfSDKClient) LoadBpfFile(arg0, arg1 string) (map[string]elfparser.BpfData, map[string]maps.BpfMap, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "LoadBpfFile", arg0, arg1) ret0, _ := ret[0].(map[string]elfparser.BpfData) @@ -60,13 +60,13 @@ func (m *MockAWSeBpfSdkAPIs) LoadBpfFile(arg0, arg1 string) (map[string]elfparse } // LoadBpfFile indicates an expected call of LoadBpfFile. -func (mr *MockAWSeBpfSdkAPIsMockRecorder) LoadBpfFile(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBpfSDKClientMockRecorder) LoadBpfFile(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LoadBpfFile", reflect.TypeOf((*MockAWSeBpfSdkAPIs)(nil).LoadBpfFile), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LoadBpfFile", reflect.TypeOf((*MockBpfSDKClient)(nil).LoadBpfFile), arg0, arg1) } // RecoverAllBpfProgramsAndMaps mocks base method. -func (m *MockAWSeBpfSdkAPIs) RecoverAllBpfProgramsAndMaps() (map[string]elfparser.BpfData, error) { +func (m *MockBpfSDKClient) RecoverAllBpfProgramsAndMaps() (map[string]elfparser.BpfData, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "RecoverAllBpfProgramsAndMaps") ret0, _ := ret[0].(map[string]elfparser.BpfData) @@ -75,13 +75,13 @@ func (m *MockAWSeBpfSdkAPIs) RecoverAllBpfProgramsAndMaps() (map[string]elfparse } // RecoverAllBpfProgramsAndMaps indicates an expected call of RecoverAllBpfProgramsAndMaps. -func (mr *MockAWSeBpfSdkAPIsMockRecorder) RecoverAllBpfProgramsAndMaps() *gomock.Call { +func (mr *MockBpfSDKClientMockRecorder) RecoverAllBpfProgramsAndMaps() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecoverAllBpfProgramsAndMaps", reflect.TypeOf((*MockAWSeBpfSdkAPIs)(nil).RecoverAllBpfProgramsAndMaps)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecoverAllBpfProgramsAndMaps", reflect.TypeOf((*MockBpfSDKClient)(nil).RecoverAllBpfProgramsAndMaps)) } // RecoverGlobalMaps mocks base method. -func (m *MockAWSeBpfSdkAPIs) RecoverGlobalMaps() (map[string]maps.BpfMap, error) { +func (m *MockBpfSDKClient) RecoverGlobalMaps() (map[string]maps.BpfMap, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "RecoverGlobalMaps") ret0, _ := ret[0].(map[string]maps.BpfMap) @@ -90,7 +90,7 @@ func (m *MockAWSeBpfSdkAPIs) RecoverGlobalMaps() (map[string]maps.BpfMap, error) } // RecoverGlobalMaps indicates an expected call of RecoverGlobalMaps. -func (mr *MockAWSeBpfSdkAPIsMockRecorder) RecoverGlobalMaps() *gomock.Call { +func (mr *MockBpfSDKClientMockRecorder) RecoverGlobalMaps() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecoverGlobalMaps", reflect.TypeOf((*MockAWSeBpfSdkAPIs)(nil).RecoverGlobalMaps)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecoverGlobalMaps", reflect.TypeOf((*MockBpfSDKClient)(nil).RecoverGlobalMaps)) } From f53b681798783e9153d3652bf87323389e619e5c Mon Sep 17 00:00:00 2001 From: Jayanth Varavani <1111446+jayanthvn@users.noreply.github.com> Date: Fri, 18 Aug 2023 01:20:33 -0700 Subject: [PATCH 05/29] API interface change and UTs for TC functions (#25) * UTs for tc functions * Fix vet * Add mocks * Feedback * PR feedbacl --- .github/workflows/pr-tests.yaml | 2 +- pkg/tc/generate_mocks.go | 15 ++ pkg/tc/mocks/tc_mocks.go | 104 ++++++++++ pkg/tc/tc.go | 68 ++++++- pkg/tc/tc_test.go | 327 ++++++++++++++++++++++++++++++++ 5 files changed, 506 insertions(+), 10 deletions(-) create mode 100644 pkg/tc/generate_mocks.go create mode 100644 pkg/tc/mocks/tc_mocks.go create mode 100644 pkg/tc/tc_test.go diff --git a/.github/workflows/pr-tests.yaml b/.github/workflows/pr-tests.yaml index afd82cc..652d183 100644 --- a/.github/workflows/pr-tests.yaml +++ b/.github/workflows/pr-tests.yaml @@ -33,6 +33,6 @@ jobs: - name: Build run: make build-linux - name: Unit test - run: make unit-test + run: sudo make unit-test - name: Upload code coverage uses: codecov/codecov-action@v3 diff --git a/pkg/tc/generate_mocks.go b/pkg/tc/generate_mocks.go new file mode 100644 index 0000000..ee00dc6 --- /dev/null +++ b/pkg/tc/generate_mocks.go @@ -0,0 +1,15 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"). You may +// not use this file except in compliance with the License. A copy of the +// License is located at +// +// http://aws.amazon.com/apache2.0/ +// +// or in the "license" file accompanying this file. This file is distributed +// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +// express or implied. See the License for the specific language governing +// permissions and limitations under the License. +package tc + +//go:generate go run github.com/golang/mock/mockgen -destination mocks/tc_mocks.go . BpfTc diff --git a/pkg/tc/mocks/tc_mocks.go b/pkg/tc/mocks/tc_mocks.go new file mode 100644 index 0000000..333361a --- /dev/null +++ b/pkg/tc/mocks/tc_mocks.go @@ -0,0 +1,104 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/aws/aws-ebpf-sdk-go/pkg/tc (interfaces: BpfTc) + +// Package mock_tc is a generated GoMock package. +package mock_tc + +import ( + reflect "reflect" + + gomock "github.com/golang/mock/gomock" +) + +// MockBpfTc is a mock of BpfTc interface. +type MockBpfTc struct { + ctrl *gomock.Controller + recorder *MockBpfTcMockRecorder +} + +// MockBpfTcMockRecorder is the mock recorder for MockBpfTc. +type MockBpfTcMockRecorder struct { + mock *MockBpfTc +} + +// NewMockBpfTc creates a new mock instance. +func NewMockBpfTc(ctrl *gomock.Controller) *MockBpfTc { + mock := &MockBpfTc{ctrl: ctrl} + mock.recorder = &MockBpfTcMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockBpfTc) EXPECT() *MockBpfTcMockRecorder { + return m.recorder +} + +// CleanupQdiscs mocks base method. +func (m *MockBpfTc) CleanupQdiscs(arg0, arg1 bool) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CleanupQdiscs", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// CleanupQdiscs indicates an expected call of CleanupQdiscs. +func (mr *MockBpfTcMockRecorder) CleanupQdiscs(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CleanupQdiscs", reflect.TypeOf((*MockBpfTc)(nil).CleanupQdiscs), arg0, arg1) +} + +// TCEgressAttach mocks base method. +func (m *MockBpfTc) TCEgressAttach(arg0 string, arg1 int, arg2 string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "TCEgressAttach", arg0, arg1, arg2) + ret0, _ := ret[0].(error) + return ret0 +} + +// TCEgressAttach indicates an expected call of TCEgressAttach. +func (mr *MockBpfTcMockRecorder) TCEgressAttach(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TCEgressAttach", reflect.TypeOf((*MockBpfTc)(nil).TCEgressAttach), arg0, arg1, arg2) +} + +// TCEgressDetach mocks base method. +func (m *MockBpfTc) TCEgressDetach(arg0 string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "TCEgressDetach", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// TCEgressDetach indicates an expected call of TCEgressDetach. +func (mr *MockBpfTcMockRecorder) TCEgressDetach(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TCEgressDetach", reflect.TypeOf((*MockBpfTc)(nil).TCEgressDetach), arg0) +} + +// TCIngressAttach mocks base method. +func (m *MockBpfTc) TCIngressAttach(arg0 string, arg1 int, arg2 string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "TCIngressAttach", arg0, arg1, arg2) + ret0, _ := ret[0].(error) + return ret0 +} + +// TCIngressAttach indicates an expected call of TCIngressAttach. +func (mr *MockBpfTcMockRecorder) TCIngressAttach(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TCIngressAttach", reflect.TypeOf((*MockBpfTc)(nil).TCIngressAttach), arg0, arg1, arg2) +} + +// TCIngressDetach mocks base method. +func (m *MockBpfTc) TCIngressDetach(arg0 string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "TCIngressDetach", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// TCIngressDetach indicates an expected call of TCIngressDetach. +func (mr *MockBpfTcMockRecorder) TCIngressDetach(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TCIngressDetach", reflect.TypeOf((*MockBpfTc)(nil).TCIngressDetach), arg0) +} diff --git a/pkg/tc/tc.go b/pkg/tc/tc.go index f3a4f01..f71320e 100644 --- a/pkg/tc/tc.go +++ b/pkg/tc/tc.go @@ -31,6 +31,28 @@ const ( var log = logger.Get() +type BpfTc interface { + TCIngressAttach(interfaceName string, progFD int, funcName string) error + TCIngressDetach(interfaceName string) error + TCEgressAttach(interfaceName string, progFD int, funcName string) error + TCEgressDetach(interfaceName string) error + CleanupQdiscs(ingressCleanup bool, egressCleanup bool) error + mismatchedInterfacePrefix(interfaceName string) error +} + +var _ BpfTc = &bpfTc{} + +type bpfTc struct { + InterfacePrefix string +} + +func New(interfacePrefix string) BpfTc { + return &bpfTc{ + InterfacePrefix: interfacePrefix, + } + +} + func enableQdisc(link netlink.Link) bool { qdiscs, err := netlink.QdiscList(link) if err != nil { @@ -54,7 +76,20 @@ func enableQdisc(link netlink.Link) bool { } -func TCIngressAttach(interfaceName string, progFD int, funcName string) error { +func (m *bpfTc) mismatchedInterfacePrefix(interfaceName string) error { + if !strings.HasPrefix(interfaceName, m.InterfacePrefix) { + log.Errorf("expected prefix - %s but got %s", m.InterfacePrefix, interfaceName) + return errors.New("Mismatched initialized prefix name and passed interface name") + } + return nil +} + +func (m *bpfTc) TCIngressAttach(interfaceName string, progFD int, funcName string) error { + + if err := m.mismatchedInterfacePrefix(interfaceName); err != nil { + return err + } + intf, err := netlink.LinkByName(interfaceName) if err != nil { log.Errorf("failed to find device by name %s: %w", interfaceName, err) @@ -101,7 +136,12 @@ func TCIngressAttach(interfaceName string, progFD int, funcName string) error { return nil } -func TCIngressDetach(interfaceName string) error { +func (m *bpfTc) TCIngressDetach(interfaceName string) error { + + if err := m.mismatchedInterfacePrefix(interfaceName); err != nil { + return err + } + intf, err := netlink.LinkByName(interfaceName) if err != nil { log.Errorf("failed to find device by name %s: %w", interfaceName, err) @@ -132,7 +172,12 @@ func TCIngressDetach(interfaceName string) error { return fmt.Errorf("no active filter to detach-%s", interfaceName) } -func TCEgressAttach(interfaceName string, progFD int, funcName string) error { +func (m *bpfTc) TCEgressAttach(interfaceName string, progFD int, funcName string) error { + + if err := m.mismatchedInterfacePrefix(interfaceName); err != nil { + return err + } + intf, err := netlink.LinkByName(interfaceName) if err != nil { log.Errorf("failed to find device by name %s: %w", interfaceName, err) @@ -179,7 +224,12 @@ func TCEgressAttach(interfaceName string, progFD int, funcName string) error { return nil } -func TCEgressDetach(interfaceName string) error { +func (m *bpfTc) TCEgressDetach(interfaceName string) error { + + if err := m.mismatchedInterfacePrefix(interfaceName); err != nil { + return err + } + intf, err := netlink.LinkByName(interfaceName) if err != nil { log.Errorf("failed to find device by name %s: %w", interfaceName, err) @@ -210,9 +260,9 @@ func TCEgressDetach(interfaceName string) error { return fmt.Errorf("no active filter to detach-%s", interfaceName) } -func CleanupQdiscs(prefix string, ingressCleanup bool, egressCleanup bool) error { +func (m *bpfTc) CleanupQdiscs(ingressCleanup bool, egressCleanup bool) error { - if prefix == "" { + if m.InterfacePrefix == "" { log.Errorf("invalid empty prefix") return nil } @@ -225,10 +275,10 @@ func CleanupQdiscs(prefix string, ingressCleanup bool, egressCleanup bool) error for _, link := range linkList { linkName := link.Attrs().Name - if strings.HasPrefix(linkName, prefix) { + if strings.HasPrefix(linkName, m.InterfacePrefix) { if ingressCleanup { log.Infof("Trying to cleanup ingress on %s", linkName) - err = TCIngressDetach(linkName) + err = m.TCIngressDetach(linkName) if err != nil { if err.Error() == FILTER_CLEANUP_FAILED { log.Errorf("failed to detach ingress, might not be present so moving on") @@ -238,7 +288,7 @@ func CleanupQdiscs(prefix string, ingressCleanup bool, egressCleanup bool) error if egressCleanup { log.Infof("Trying to cleanup egress on %s", linkName) - err = TCEgressDetach(linkName) + err = m.TCEgressDetach(linkName) if err != nil { if err.Error() == FILTER_CLEANUP_FAILED { log.Errorf("failed to detach egress, might not be present so moving on") diff --git a/pkg/tc/tc_test.go b/pkg/tc/tc_test.go new file mode 100644 index 0000000..fec7333 --- /dev/null +++ b/pkg/tc/tc_test.go @@ -0,0 +1,327 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"). +// You may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +//limitations under the License. + +package tc + +import ( + "errors" + "fmt" + "os" + "syscall" + "testing" + + constdef "github.com/aws/aws-ebpf-sdk-go/pkg/constants" + "github.com/aws/aws-ebpf-sdk-go/pkg/elfparser" + mock_ebpf_maps "github.com/aws/aws-ebpf-sdk-go/pkg/maps/mocks" + mock_ebpf_progs "github.com/aws/aws-ebpf-sdk-go/pkg/progs/mocks" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" + "github.com/vishvananda/netlink" +) + +const ( + DUMMY_PROG_NAME = "test" +) + +type testMocks struct { + path string + ctrl *gomock.Controller + ebpf_progs *mock_ebpf_progs.MockBpfProgAPIs + ebpf_maps *mock_ebpf_maps.MockBpfMapAPIs + tcClient BpfTc +} + +func setup(t *testing.T, testPath string, interfacePrefix string) *testMocks { + ctrl := gomock.NewController(t) + return &testMocks{ + path: testPath, + ctrl: ctrl, + ebpf_progs: mock_ebpf_progs.NewMockBpfProgAPIs(ctrl), + ebpf_maps: mock_ebpf_maps.NewMockBpfMapAPIs(ctrl), + tcClient: New(interfacePrefix), + } +} + +func mount_bpf_fs() error { + fmt.Println("Let's mount BPF FS") + err := syscall.Mount("bpf", "/sys/fs/bpf", "bpf", 0, "mode=0700") + if err != nil { + fmt.Println("error mounting bpffs") + } + return err +} + +func unmount_bpf_fs() error { + fmt.Println("Let's unmount BPF FS") + err := syscall.Unmount("/sys/fs/bpf", 0) + if err != nil { + fmt.Println("error unmounting bpffs") + } + return err +} + +func setupTest(interfaceNames []string, t *testing.T) { + mount_bpf_fs() + for _, interfaceName := range interfaceNames { + linkAttr := netlink.LinkAttrs{Name: interfaceName} + linkIFB := netlink.Ifb{} + linkIFB.LinkAttrs = linkAttr + if err := netlink.LinkAdd(&linkIFB); err != nil { + assert.NoError(t, err) + } + } +} + +func teardownTest(interfaceNames []string, t *testing.T) { + unmount_bpf_fs() + //Cleanup link + for _, interfaceName := range interfaceNames { + linkAttr := netlink.LinkAttrs{Name: interfaceName} + linkIFB := netlink.Ifb{} + linkIFB.LinkAttrs = linkAttr + if err := netlink.LinkDel(&linkIFB); err != nil { + assert.NoError(t, err) + } + } +} + +func TestMismatchedPrefixName(t *testing.T) { + m := setup(t, "../../test-data/tc.bpf.elf", "eni") + defer m.ctrl.Finish() + + tests := []struct { + name string + interfaceName string + wantErr error + }{ + { + name: "Test Matched Prefix", + interfaceName: "eni1", + wantErr: nil, + }, + { + name: "Test Mismatched Prefix", + interfaceName: "fni1", + wantErr: errors.New("Mismatched initialized prefix name and passed interface name"), + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + + testTcClient := New("eni") + err := testTcClient.mismatchedInterfacePrefix(tt.interfaceName) + if tt.wantErr != nil { + assert.EqualError(t, err, tt.wantErr.Error()) + } else { + assert.NoError(t, err) + } + }) + } +} + +func TestTCIngressAttachDetach(t *testing.T) { + if os.Getuid() != 0 { + t.Skip("Test requires root privileges.") + } + + m := setup(t, "../../test-data/tc.bpf.elf", "f") + defer m.ctrl.Finish() + + interfaceName := "foo" + + var interfaceNames []string + interfaceNames = append(interfaceNames, interfaceName) + setupTest(interfaceNames, t) + defer teardownTest(interfaceNames, t) + + m.ebpf_maps.EXPECT().CreateBPFMap(gomock.Any()).AnyTimes() + m.ebpf_progs.EXPECT().LoadProg(gomock.Any()).AnyTimes() + m.ebpf_maps.EXPECT().PinMap(gomock.Any(), gomock.Any()).AnyTimes() + m.ebpf_maps.EXPECT().GetMapFromPinPath(gomock.Any()).AnyTimes() + m.ebpf_progs.EXPECT().GetProgFromPinPath(gomock.Any()).AnyTimes() + m.ebpf_progs.EXPECT().GetBPFProgAssociatedMapsIDs(gomock.Any()).AnyTimes() + + bpfSDKclient := elfparser.New() + progInfo, _, err := bpfSDKclient.LoadBpfFile(m.path, DUMMY_PROG_NAME) + if err != nil { + assert.NoError(t, err) + } + pinPath := constdef.PROG_BPF_FS + DUMMY_PROG_NAME + "_handle_ingress" + + progFD := progInfo[pinPath].Program.ProgFD + if err := m.tcClient.TCIngressAttach(interfaceName, progFD, DUMMY_PROG_NAME); err != nil { + assert.NoError(t, err) + } + + if err := m.tcClient.TCIngressDetach(interfaceName); err != nil { + assert.NoError(t, err) + } +} + +func TestTCEgressAttachDetach(t *testing.T) { + if os.Getuid() != 0 { + t.Skip("Test requires root privileges.") + } + + m := setup(t, "../../test-data/tc.bpf.elf", "f") + defer m.ctrl.Finish() + + interfaceName := "foo" + + var interfaceNames []string + interfaceNames = append(interfaceNames, interfaceName) + + setupTest(interfaceNames, t) + defer teardownTest(interfaceNames, t) + + m.ebpf_maps.EXPECT().CreateBPFMap(gomock.Any()).AnyTimes() + m.ebpf_progs.EXPECT().LoadProg(gomock.Any()).AnyTimes() + m.ebpf_maps.EXPECT().PinMap(gomock.Any(), gomock.Any()).AnyTimes() + m.ebpf_maps.EXPECT().GetMapFromPinPath(gomock.Any()).AnyTimes() + m.ebpf_progs.EXPECT().GetProgFromPinPath(gomock.Any()).AnyTimes() + m.ebpf_progs.EXPECT().GetBPFProgAssociatedMapsIDs(gomock.Any()).AnyTimes() + + bpfSDKclient := elfparser.New() + progInfo, _, err := bpfSDKclient.LoadBpfFile(m.path, DUMMY_PROG_NAME) + if err != nil { + assert.NoError(t, err) + } + pinPath := constdef.PROG_BPF_FS + DUMMY_PROG_NAME + "_handle_ingress" + + progFD := progInfo[pinPath].Program.ProgFD + if err := m.tcClient.TCEgressAttach(interfaceName, progFD, DUMMY_PROG_NAME); err != nil { + assert.NoError(t, err) + } + + if err := m.tcClient.TCEgressDetach(interfaceName); err != nil { + assert.NoError(t, err) + } +} + +func TestQdiscCleanup(t *testing.T) { + + if os.Getuid() != 0 { + t.Skip("Test requires root privileges.") + } + + m := setup(t, "../../test-data/tc.bpf.elf", "eni") + defer m.ctrl.Finish() + + interfaceName1 := "eni1" + interfaceName2 := "eni2" + + var interfaceNames []string + interfaceNames = append(interfaceNames, interfaceName1) + interfaceNames = append(interfaceNames, interfaceName2) + + setupTest(interfaceNames, t) + defer teardownTest(interfaceNames, t) + + m.ebpf_maps.EXPECT().CreateBPFMap(gomock.Any()).AnyTimes() + m.ebpf_progs.EXPECT().LoadProg(gomock.Any()).AnyTimes() + m.ebpf_maps.EXPECT().PinMap(gomock.Any(), gomock.Any()).AnyTimes() + m.ebpf_maps.EXPECT().GetMapFromPinPath(gomock.Any()).AnyTimes() + m.ebpf_progs.EXPECT().GetProgFromPinPath(gomock.Any()).AnyTimes() + m.ebpf_progs.EXPECT().GetBPFProgAssociatedMapsIDs(gomock.Any()).AnyTimes() + + bpfSDKclient := elfparser.New() + progInfo, _, err := bpfSDKclient.LoadBpfFile(m.path, DUMMY_PROG_NAME) + if err != nil { + assert.NoError(t, err) + } + pinPath := constdef.PROG_BPF_FS + DUMMY_PROG_NAME + "_handle_ingress" + + progFD := progInfo[pinPath].Program.ProgFD + if err := m.tcClient.TCEgressAttach(interfaceName1, progFD, DUMMY_PROG_NAME); err != nil { + assert.NoError(t, err) + } + + if err := m.tcClient.TCIngressAttach(interfaceName2, progFD, DUMMY_PROG_NAME); err != nil { + assert.NoError(t, err) + } + + if err := m.tcClient.CleanupQdiscs(true, true); err != nil { + assert.NoError(t, err) + } +} + +func TestNetLinkAPIs(t *testing.T) { + + netLinktests := []struct { + name string + interfaceName string + overrideName bool + want []int + wantErr error + }{ + { + name: "Failed Link By Name", + interfaceName: "eni1", + want: nil, + overrideName: true, + wantErr: errors.New("Link not found"), + }, + { + name: "Failed to add filter", + interfaceName: "eni1", + overrideName: false, + want: nil, + wantErr: errors.New("invalid argument"), + }, + } + + for _, tt := range netLinktests { + t.Run(tt.name, func(t *testing.T) { + m := setup(t, "../../test-data/tc.bpf.elf", "eni") + defer m.ctrl.Finish() + + var interfaceNames []string + interfaceNames = append(interfaceNames, tt.interfaceName) + + setupTest(interfaceNames, t) + defer teardownTest(interfaceNames, t) + + m.ebpf_maps.EXPECT().CreateBPFMap(gomock.Any()).AnyTimes() + m.ebpf_progs.EXPECT().LoadProg(gomock.Any()).AnyTimes() + m.ebpf_maps.EXPECT().PinMap(gomock.Any(), gomock.Any()).AnyTimes() + m.ebpf_maps.EXPECT().GetMapFromPinPath(gomock.Any()).AnyTimes() + m.ebpf_progs.EXPECT().GetProgFromPinPath(gomock.Any()).AnyTimes() + m.ebpf_progs.EXPECT().GetBPFProgAssociatedMapsIDs(gomock.Any()).AnyTimes() + + bpfSDKclient := elfparser.New() + _, _, err := bpfSDKclient.LoadBpfFile(m.path, DUMMY_PROG_NAME) + if err != nil { + assert.NoError(t, err) + } + + intfName := tt.interfaceName + if tt.overrideName { + intfName = intfName + "10" + } + err = m.tcClient.TCEgressAttach(intfName, -1, "test") + if tt.wantErr != nil { + assert.EqualError(t, err, tt.wantErr.Error()) + } else { + assert.NoError(t, err) + } + err = m.tcClient.TCIngressAttach(intfName, -1, "test") + if tt.wantErr != nil { + assert.EqualError(t, err, tt.wantErr.Error()) + } else { + assert.NoError(t, err) + } + }) + } +} From 3c81de2760422858916e82235886e7fc04807221 Mon Sep 17 00:00:00 2001 From: Jayanth Varavani <1111446+jayanthvn@users.noreply.github.com> Date: Tue, 22 Aug 2023 10:44:56 -0700 Subject: [PATCH 06/29] UTs for recovery and progs (#27) * UTs for recovery and progs * PR feedbacks --- Makefile | 5 +- pkg/elfparser/elf.go | 13 +- pkg/elfparser/elf_test.go | 388 +++++++++++++++++++++++++++++------ pkg/utils/utils.go | 19 ++ test-data/recoverydata.bpf.c | 103 ++++++++++ test-data/test.map.bpf.c | 22 +- 6 files changed, 481 insertions(+), 69 deletions(-) create mode 100644 test-data/recoverydata.bpf.c diff --git a/Makefile b/Makefile index 3a75e1e..139d585 100644 --- a/Makefile +++ b/Makefile @@ -41,13 +41,16 @@ EBPF_TEST_MAP_BINARY := test-data/test.map.bpf.elf EBPF_TEST_LIC_SOURCE := test-data/test_license.bpf.c EBPF_TEST_LIC_BINARY := test-data/test_license.bpf.elf EBPF_TEST_INV_MAP_SOURCE := test-data/invalid_map.bpf.c -EBPF_TEST_INV_MAP_BINARY := test-data/invalid_map.bpf.elf +EBPF_TEST_INV_MAP_BINARY := test-data/invalid_map.bpf.elf +EBPF_TEST_RECOVERY_SOURCE := test-data/recoverydata.bpf.c +EBPF_TEST_RECOVERY_BINARY := test-data/recoverydata.bpf.elf build-bpf: ## Build BPF $(CLANG) $(CLANG_INCLUDE) -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -march=bpf -D__TARGET_ARCH_$(ARCH) -c $(EBPF_SOURCE) -o $(EBPF_BINARY) $(CLANG) $(CLANG_INCLUDE) -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -march=bpf -D__TARGET_ARCH_$(ARCH) -c $(EBPF_TEST_SOURCE) -o $(EBPF_TEST_BINARY) $(CLANG) $(CLANG_INCLUDE) -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -march=bpf -D__TARGET_ARCH_$(ARCH) -c $(EBPF_TEST_MAP_SOURCE) -o $(EBPF_TEST_MAP_BINARY) $(CLANG) $(CLANG_INCLUDE) -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -march=bpf -D__TARGET_ARCH_$(ARCH) -c $(EBPF_TEST_LIC_SOURCE) -o $(EBPF_TEST_LIC_BINARY) $(CLANG) $(CLANG_INCLUDE) -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -march=bpf -D__TARGET_ARCH_$(ARCH) -c $(EBPF_TEST_INV_MAP_SOURCE) -o $(EBPF_TEST_INV_MAP_BINARY) + $(CLANG) $(CLANG_INCLUDE) -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -march=bpf -D__TARGET_ARCH_$(ARCH) -c $(EBPF_TEST_RECOVERY_SOURCE) -o $(EBPF_TEST_RECOVERY_BINARY) vmlinuxh: bpftool btf dump file /sys/kernel/btf/vmlinux format c > $(abspath ./test-data/vmlinux.h) diff --git a/pkg/elfparser/elf.go b/pkg/elfparser/elf.go index d0997a8..c919315 100644 --- a/pkg/elfparser/elf.go +++ b/pkg/elfparser/elf.go @@ -503,6 +503,11 @@ func (e *elfLoader) parseProg(loadedMaps map[string]ebpf_maps.BpfMap) (map[strin return nil, fmt.Errorf("failed to get progEntry Data") } + if len(data) == 0 { + log.Infof("Missing data in prog Section") + return nil, fmt.Errorf("missing data in prog section") + } + var linkedMaps map[int]string //Apply relocation if e.reloSectionMap[progIndex] == nil { @@ -731,8 +736,8 @@ func (b *bpfSDKClient) RecoverGlobalMaps() (map[string]ebpf_maps.BpfMap, error) return nil, fmt.Errorf("error walking the bpfdirectory %v", err) } } else { - log.Infof("error checking BPF FS, might not be mounted %v", err) - return nil, fmt.Errorf("error checking BPF FS might not be mounted %v", err) + log.Infof("error checking BPF FS, please make sure it is mounted %v", err) + return nil, fmt.Errorf("error checking BPF FS, please make sure it is mounted") } return loadedGlobalMaps, nil } @@ -904,8 +909,8 @@ func (b *bpfSDKClient) RecoverAllBpfProgramsAndMaps() (map[string]BpfData, error } } } else { - log.Infof("error checking BPF FS, might not be mounted %v", err) - return nil, fmt.Errorf("error checking BPF FS might not be mounted %v", err) + log.Infof("error checking BPF FS, please make sure it is mounted %v", err) + return nil, fmt.Errorf("error checking BPF FS, please make sure it is mounted") } //Return DS here return loadedPrograms, nil diff --git a/pkg/elfparser/elf_test.go b/pkg/elfparser/elf_test.go index 191d28a..9cafdbf 100644 --- a/pkg/elfparser/elf_test.go +++ b/pkg/elfparser/elf_test.go @@ -22,18 +22,20 @@ import ( "strings" "testing" + constdef "github.com/aws/aws-ebpf-sdk-go/pkg/constants" mock_ebpf_maps "github.com/aws/aws-ebpf-sdk-go/pkg/maps/mocks" mock_ebpf_progs "github.com/aws/aws-ebpf-sdk-go/pkg/progs/mocks" + "github.com/aws/aws-ebpf-sdk-go/pkg/utils" "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" ) var ( MAP_SECTION_INDEX = 8 - MAP_TYPE_1 = 27 - MAP_KEY_SIZE_1 = 0 - MAP_VALUE_SIZE_1 = 0 - MAP_ENTRIES_1 = 262144 + MAP_TYPE_1 = int(constdef.BPF_MAP_TYPE_LRU_HASH.Index()) + MAP_KEY_SIZE_1 = 16 + MAP_VALUE_SIZE_1 = 4 + MAP_ENTRIES_1 = 65536 MAP_FLAGS_1 = 0 ) @@ -54,64 +56,57 @@ func setup(t *testing.T, testPath string) *testMocks { } } -func TestLoadelf(t *testing.T) { - m := setup(t, "../../test-data/tc.ingress.bpf.elf") - defer m.ctrl.Finish() - f, _ := os.Open(m.path) - defer f.Close() - - m.ebpf_maps.EXPECT().CreateBPFMap(gomock.Any()).AnyTimes() - m.ebpf_progs.EXPECT().LoadProg(gomock.Any()).AnyTimes() - m.ebpf_maps.EXPECT().PinMap(gomock.Any(), gomock.Any()).AnyTimes() - m.ebpf_maps.EXPECT().GetMapFromPinPath(gomock.Any()).AnyTimes() - m.ebpf_progs.EXPECT().GetProgFromPinPath(gomock.Any()).AnyTimes() - m.ebpf_progs.EXPECT().GetBPFProgAssociatedMapsIDs(gomock.Any()).AnyTimes() - elfFile, err := elf.NewFile(f) - assert.NoError(t, err) - - elfLoader := newElfLoader(elfFile, m.ebpf_maps, m.ebpf_progs, "test") - _, _, err = elfLoader.doLoadELF() - assert.NoError(t, err) -} +func TestLoad(t *testing.T) { + progtests := []struct { + name string + elfFileName string + wantMap int + wantProg int + }{ + { + name: "Test Load ELF", + elfFileName: "../../test-data/tc.ingress.bpf.elf", + wantMap: 3, + wantProg: 3, + }, + { + name: "Test Load ELF without reloc", + elfFileName: "../../test-data/tc.bpf.elf", + wantMap: 0, + wantProg: 1, + }, + { + name: "Missing prog data", + elfFileName: "../../test-data/test.map.bpf.elf", + wantMap: 1, + wantProg: 0, + }, + } -func TestLoadelfWithoutReloc(t *testing.T) { - m := setup(t, "../../test-data/tc.bpf.elf") - defer m.ctrl.Finish() - f, _ := os.Open(m.path) - defer f.Close() - - m.ebpf_maps.EXPECT().CreateBPFMap(gomock.Any()).AnyTimes() - m.ebpf_progs.EXPECT().LoadProg(gomock.Any()).AnyTimes() - m.ebpf_maps.EXPECT().PinMap(gomock.Any(), gomock.Any()).AnyTimes() - m.ebpf_maps.EXPECT().GetMapFromPinPath(gomock.Any()).AnyTimes() - m.ebpf_progs.EXPECT().GetProgFromPinPath(gomock.Any()).AnyTimes() - m.ebpf_progs.EXPECT().GetBPFProgAssociatedMapsIDs(gomock.Any()).AnyTimes() - - elfFile, err := elf.NewFile(f) - assert.NoError(t, err) - elfLoader := newElfLoader(elfFile, m.ebpf_maps, m.ebpf_progs, "test") - _, _, err = elfLoader.doLoadELF() - assert.NoError(t, err) -} + for _, tt := range progtests { + t.Run(tt.name, func(t *testing.T) { + + m := setup(t, tt.elfFileName) + defer m.ctrl.Finish() + f, _ := os.Open(m.path) + defer f.Close() + + m.ebpf_maps.EXPECT().CreateBPFMap(gomock.Any()).AnyTimes() + m.ebpf_progs.EXPECT().LoadProg(gomock.Any()).AnyTimes() + m.ebpf_maps.EXPECT().PinMap(gomock.Any(), gomock.Any()).AnyTimes() + m.ebpf_maps.EXPECT().GetMapFromPinPath(gomock.Any()).AnyTimes() + m.ebpf_progs.EXPECT().GetProgFromPinPath(gomock.Any()).AnyTimes() + m.ebpf_progs.EXPECT().GetBPFProgAssociatedMapsIDs(gomock.Any()).AnyTimes() -func TestLoadelfWithoutProg(t *testing.T) { - m := setup(t, "../../test-data/test.map.bpf.elf") - defer m.ctrl.Finish() - f, _ := os.Open(m.path) - defer f.Close() - - m.ebpf_maps.EXPECT().CreateBPFMap(gomock.Any()).AnyTimes() - m.ebpf_progs.EXPECT().LoadProg(gomock.Any()).AnyTimes() - m.ebpf_maps.EXPECT().PinMap(gomock.Any(), gomock.Any()).AnyTimes() - m.ebpf_maps.EXPECT().GetMapFromPinPath(gomock.Any()).AnyTimes() - m.ebpf_progs.EXPECT().GetProgFromPinPath(gomock.Any()).AnyTimes() - m.ebpf_progs.EXPECT().GetBPFProgAssociatedMapsIDs(gomock.Any()).AnyTimes() - - elfFile, err := elf.NewFile(f) - assert.NoError(t, err) - elfLoader := newElfLoader(elfFile, m.ebpf_maps, m.ebpf_progs, "test") - _, _, err = elfLoader.doLoadELF() - assert.NoError(t, err) + elfFile, err := elf.NewFile(f) + assert.NoError(t, err) + elfLoader := newElfLoader(elfFile, m.ebpf_maps, m.ebpf_progs, "test") + loadedProgs, loadedMaps, err := elfLoader.doLoadELF() + assert.NoError(t, err) + assert.Equal(t, tt.wantProg, len(loadedProgs)) + assert.Equal(t, tt.wantMap, len(loadedMaps)) + }) + } } func TestParseSection(t *testing.T) { @@ -410,3 +405,276 @@ func TestParseMap(t *testing.T) { } } + +func TestParseProg(t *testing.T) { + progtests := []struct { + name string + elfFileName string + want int + invalidate bool + invalidateRelo bool + wantErr error + }{ + { + name: "Missing prog section", + elfFileName: "../../test-data/test.map.bpf.elf", + want: 0, + wantErr: nil, + }, + { + name: "Test prog data", + elfFileName: "../../test-data/tc.ingress.bpf.elf", + want: 3, + wantErr: nil, + }, + { + name: "Missing prog data", + elfFileName: "../../test-data/tc.ingress.bpf.elf", + invalidate: true, + wantErr: errors.New("missing data in prog section"), + }, + { + name: "Missing relo data", + elfFileName: "../../test-data/tc.ingress.bpf.elf", + invalidateRelo: true, + wantErr: errors.New("failed to apply relocation: unable to parse relocation entries...."), + }, + } + + for _, tt := range progtests { + t.Run(tt.name, func(t *testing.T) { + + m := setup(t, tt.elfFileName) + defer m.ctrl.Finish() + f, _ := os.Open(m.path) + defer f.Close() + + elfFile, err := elf.NewFile(f) + assert.NoError(t, err) + elfLoader := newElfLoader(elfFile, m.ebpf_maps, m.ebpf_progs, "test") + + err = elfLoader.parseSection() + assert.NoError(t, err) + + mapData, err := elfLoader.parseMap() + assert.NoError(t, err) + + m.ebpf_maps.EXPECT().CreateBPFMap(gomock.Any()).AnyTimes() + m.ebpf_maps.EXPECT().PinMap(gomock.Any(), gomock.Any()).AnyTimes() + m.ebpf_maps.EXPECT().GetMapFromPinPath(gomock.Any()).AnyTimes() + + loadedMapData, err := elfLoader.loadMap(mapData) + assert.NoError(t, err) + + if tt.invalidate { + for progIndex, progEntry := range elfLoader.progSectionMap { + var dummySection elf.Section = elf.Section{} + copiedprogSection := *(progEntry.progSection) + copiedprogSection.SectionHeader = dummySection.SectionHeader + progEntry.progSection = &copiedprogSection + elfLoader.progSectionMap[progIndex] = progEntry + } + } + + if tt.invalidateRelo { + for progIndex, reloSection := range elfLoader.reloSectionMap { + var dummySection elf.Section = elf.Section{} + copiedreloSection := *(reloSection) + copiedreloSection.SectionHeader = dummySection.SectionHeader + reloSection = &copiedreloSection + elfLoader.reloSectionMap[progIndex] = reloSection + } + } + + parsedProgData, err := elfLoader.parseProg(loadedMapData) + + if tt.wantErr != nil { + assert.EqualError(t, err, tt.wantErr.Error()) + } else { + progCount := len(parsedProgData) + assert.Equal(t, tt.want, progCount) + } + }) + } + +} + +func TestRecovery(t *testing.T) { + + utils.Mount_bpf_fs() + defer utils.Unmount_bpf_fs() + + progtests := []struct { + name string + elfFileName string + wantMap int + wantProg int + recoverGlobal bool + forceUnMount bool + wantErr error + }{ + { + name: "Recover Global maps", + elfFileName: "../../test-data/test.map.bpf.elf", + wantMap: 1, + recoverGlobal: true, + wantErr: nil, + }, + { + name: "Recover BPF data", + elfFileName: "../../test-data/recoverydata.bpf.elf", + wantProg: 3, + wantErr: nil, + }, + { + name: "Missing BPF mount", + elfFileName: "../../test-data/recoverydata.bpf.elf", + wantProg: 0, + forceUnMount: true, + wantErr: errors.New("error checking BPF FS, please make sure it is mounted"), + }, + } + + for _, tt := range progtests { + t.Run(tt.name, func(t *testing.T) { + + m := setup(t, tt.elfFileName) + defer m.ctrl.Finish() + + bpfSDKclient := New() + + if tt.recoverGlobal { + _, _, err := bpfSDKclient.LoadBpfFile(m.path, "global") + if err != nil { + assert.NoError(t, err) + } + recoveredMaps, err := bpfSDKclient.RecoverGlobalMaps() + if tt.wantErr != nil { + assert.EqualError(t, err, tt.wantErr.Error()) + } else { + assert.Equal(t, tt.wantMap, len(recoveredMaps)) + } + } else { + _, _, err := bpfSDKclient.LoadBpfFile(m.path, "test") + if err != nil { + assert.NoError(t, err) + } + + if tt.forceUnMount { + utils.Unmount_bpf_fs() + } + recoveredData, err := bpfSDKclient.RecoverAllBpfProgramsAndMaps() + if tt.wantErr != nil { + assert.EqualError(t, err, tt.wantErr.Error()) + } else { + assert.Equal(t, tt.wantProg, len(recoveredData)) + } + } + }) + } +} + +func TestGetMapNameFromBPFPinPath(t *testing.T) { + type args struct { + pinPath string + } + + tests := []struct { + name string + args args + want [2]string + }{ + { + name: "Ingress Map Pinpath", + args: args{ + pinPath: "/sys/fs/bpf/globals/aws/maps/hello-udp-748dc8d996-default_ingress_map", + }, + want: [2]string{"ingress_map", "hello-udp-748dc8d996-default"}, + }, + { + name: "Egress Map Pinpath", + args: args{ + pinPath: "/sys/fs/bpf/globals/aws/maps/hello-udp-748dc8d996-default_egress_map", + }, + want: [2]string{"egress_map", "hello-udp-748dc8d996-default"}, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got1, got2 := GetMapNameFromBPFPinPath(tt.args.pinPath) + assert.Equal(t, tt.want[0], got1) + assert.Equal(t, tt.want[1], got2) + }) + } +} + +func TestMapGlobal(t *testing.T) { + type args struct { + pinPath string + } + + tests := []struct { + name string + args args + want bool + }{ + { + name: "Ingress Map", + args: args{ + pinPath: "/sys/fs/bpf/globals/aws/maps/hello-udp-748dc8d996-default_ingress_map", + }, + want: false, + }, + { + name: "Egress Map", + args: args{ + pinPath: "/sys/fs/bpf/globals/aws/maps/hello-udp-748dc8d996-default_egress_map", + }, + want: false, + }, + { + name: "Global", + args: args{ + pinPath: "/sys/fs/bpf/globals/aws/maps/test_global", + }, + want: true, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got := IsMapGlobal(tt.args.pinPath) + assert.Equal(t, tt.want, got) + }) + } +} + +func TestProgType(t *testing.T) { + + tests := []struct { + name string + progType string + want bool + }{ + { + name: "XDP", + progType: "xdp", + want: true, + }, + { + name: "TC", + progType: "tc_cls", + want: true, + }, + { + name: "Invalid prod", + progType: "tcc_cls", + want: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got := isProgTypeSupported(tt.progType) + assert.Equal(t, tt.want, got) + }) + } +} diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index f884d1f..f58a3df 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -19,6 +19,7 @@ import ( "fmt" "os" "runtime" + "syscall" "unsafe" constdef "github.com/aws/aws-ebpf-sdk-go/pkg/constants" @@ -175,3 +176,21 @@ func (b *BPFInsn) ConvertBPFInstructionToByteStream() []byte { return res } + +func Mount_bpf_fs() error { + fmt.Println("Let's mount BPF FS") + err := syscall.Mount("bpf", "/sys/fs/bpf", "bpf", 0, "mode=0700") + if err != nil { + fmt.Println("error mounting bpffs") + } + return err +} + +func Unmount_bpf_fs() error { + fmt.Println("Let's unmount BPF FS") + err := syscall.Unmount("/sys/fs/bpf", 0) + if err != nil { + fmt.Println("error unmounting bpffs") + } + return err +} diff --git a/test-data/recoverydata.bpf.c b/test-data/recoverydata.bpf.c new file mode 100644 index 0000000..dcc289b --- /dev/null +++ b/test-data/recoverydata.bpf.c @@ -0,0 +1,103 @@ +#include "vmlinux.h" +#include +#include +#include + +#define BPF_F_NO_PREALLOC 1 +#define PIN_GLOBAL_NS 2 + +struct bpf_map_def_pvt { + __u32 type; + __u32 key_size; + __u32 value_size; + __u32 max_entries; + __u32 map_flags; + __u32 pinning; + __u32 inner_map_fd; +}; + +struct lpm_trie_key { + __u32 prefixlen; + __u8 ip[4]; +}; + +struct lpm_trie_val { + __u32 protocol; + __u32 start_port; + __u32 end_port; +}; + +struct conntrack_key { + __u32 src_ip; + __u16 src_port; + __u32 dest_ip; + __u16 dest_port; + __u8 protocol; +}; + +struct conntrack_value { + __u8 val[4]; +}; + +struct bpf_map_def_pvt SEC("maps") ingress_map = { + .type = BPF_MAP_TYPE_LPM_TRIE, + .key_size =sizeof(struct lpm_trie_key), + .value_size = sizeof(struct lpm_trie_val[16]), + .max_entries = 100, + .map_flags = BPF_F_NO_PREALLOC, + .pinning = PIN_GLOBAL_NS, +}; + +struct bpf_map_def_pvt SEC("maps") aws_conntrack_map = { + .type = BPF_MAP_TYPE_LRU_HASH, + .key_size =sizeof(struct conntrack_key), + .value_size = sizeof(struct conntrack_value), + .max_entries = 65536, + .pinning = PIN_GLOBAL_NS, +}; + + +SEC("tc_cls") +int handle_ingress(struct __sk_buff *skb) +{ + struct lpm_trie_key trie_key; + trie_key.prefixlen = 32; + trie_key.ip[0] = 10; + trie_key.ip[1] = 1; + trie_key.ip[2] = 1; + trie_key.ip[3] = 100; + + struct lpm_trie_val *trie_val; + trie_val = bpf_map_lookup_elem(&ingress_map, &trie_key); + if (trie_val == NULL) { + return BPF_DROP; + } + return BPF_OK; +} + +SEC("kprobe/nf_ct_delete") +int conn_del(struct pt_regs *ctx) { + struct nf_conn *ct = (struct nf_conn *) PT_REGS_PARM1(ctx); + struct nf_conn new_ct = {}; + bpf_probe_read(&new_ct, sizeof(new_ct), ct); + struct conntrack_key flow_key = {}; + memset(&flow_key, 0, sizeof(flow_key)); + + struct nf_conntrack_tuple_hash tuplehash[IP_CT_DIR_MAX]; + bpf_probe_read(&tuplehash, sizeof(tuplehash), &new_ct.tuplehash); + + bpf_probe_read(&flow_key.src_ip, sizeof(flow_key.src_ip), &tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip); + bpf_probe_read(&flow_key.src_port, sizeof(flow_key.src_port), &tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u.all); + bpf_probe_read(&flow_key.dest_ip, sizeof(flow_key.dest_ip), &tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3.ip); + bpf_probe_read(&flow_key.dest_port, sizeof(flow_key.dest_port), &tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u.all); + bpf_probe_read(&flow_key.protocol, sizeof(flow_key.protocol), &tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum); + + return 0; +} + +SEC("tracepoint/sched/sched_process_fork") +int sched_process_fork(struct sched_process_fork_t *ctx) { + return 0; +} + +char _license[] SEC("license") = "GPL"; diff --git a/test-data/test.map.bpf.c b/test-data/test.map.bpf.c index 2ffb451..aa53ecf 100644 --- a/test-data/test.map.bpf.c +++ b/test-data/test.map.bpf.c @@ -4,7 +4,19 @@ #include #define PIN_GLOBAL_NS 2 -#define BPF_MAP_TYPE_RINGBUF 27 + +struct conntrack_key { + __u32 src_ip; + __u16 src_port; + __u32 dest_ip; + __u16 dest_port; + __u8 protocol; +}; + +struct conntrack_value { + __u8 val[4]; +}; + struct bpf_map_def_pvt { __u32 type; @@ -16,9 +28,11 @@ struct bpf_map_def_pvt { __u32 inner_map_fd; }; -struct bpf_map_def_pvt SEC("maps") policy_events = { - .type = BPF_MAP_TYPE_RINGBUF, - .max_entries = 256 * 1024, +struct bpf_map_def_pvt SEC("maps") aws_conntrack_map = { + .type = BPF_MAP_TYPE_LRU_HASH, + .key_size =sizeof(struct conntrack_key), + .value_size = sizeof(struct conntrack_value), + .max_entries = 65536, .pinning = PIN_GLOBAL_NS, }; From a6944b95736f13bad4ea1eb699716af34806b76a Mon Sep 17 00:00:00 2001 From: Jayanth Varavani <1111446+jayanthvn@users.noreply.github.com> Date: Tue, 22 Aug 2023 11:22:41 -0700 Subject: [PATCH 07/29] UTs for cache and kprobes (#28) --- Makefile | 5 +- pkg/cache/cache.go | 14 ++-- pkg/cache/cache_test.go | 64 ++++++++++++++++++ pkg/kprobe/kprobe.go | 112 +++++++++++++++++++++++-------- pkg/kprobe/kprobe_test.go | 127 ++++++++++++++++++++++++++++++++++++ test-data/test-kprobe.bpf.c | 12 ++++ 6 files changed, 302 insertions(+), 32 deletions(-) create mode 100644 pkg/cache/cache_test.go create mode 100644 pkg/kprobe/kprobe_test.go create mode 100644 test-data/test-kprobe.bpf.c diff --git a/Makefile b/Makefile index 139d585..fff8b14 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,9 @@ EBPF_TEST_LIC_BINARY := test-data/test_license.bpf.elf EBPF_TEST_INV_MAP_SOURCE := test-data/invalid_map.bpf.c EBPF_TEST_INV_MAP_BINARY := test-data/invalid_map.bpf.elf EBPF_TEST_RECOVERY_SOURCE := test-data/recoverydata.bpf.c -EBPF_TEST_RECOVERY_BINARY := test-data/recoverydata.bpf.elf +EBPF_TEST_RECOVERY_BINARY := test-data/recoverydata.bpf.elf +EBPF_TEST_KPROBE_SOURCE := test-data/test-kprobe.bpf.c +EBPF_TEST_KPROBE_BINARY := test-data/test-kprobe.bpf.elf build-bpf: ## Build BPF $(CLANG) $(CLANG_INCLUDE) -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -march=bpf -D__TARGET_ARCH_$(ARCH) -c $(EBPF_SOURCE) -o $(EBPF_BINARY) $(CLANG) $(CLANG_INCLUDE) -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -march=bpf -D__TARGET_ARCH_$(ARCH) -c $(EBPF_TEST_SOURCE) -o $(EBPF_TEST_BINARY) @@ -51,6 +53,7 @@ build-bpf: ## Build BPF $(CLANG) $(CLANG_INCLUDE) -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -march=bpf -D__TARGET_ARCH_$(ARCH) -c $(EBPF_TEST_LIC_SOURCE) -o $(EBPF_TEST_LIC_BINARY) $(CLANG) $(CLANG_INCLUDE) -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -march=bpf -D__TARGET_ARCH_$(ARCH) -c $(EBPF_TEST_INV_MAP_SOURCE) -o $(EBPF_TEST_INV_MAP_BINARY) $(CLANG) $(CLANG_INCLUDE) -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -march=bpf -D__TARGET_ARCH_$(ARCH) -c $(EBPF_TEST_RECOVERY_SOURCE) -o $(EBPF_TEST_RECOVERY_BINARY) + $(CLANG) $(CLANG_INCLUDE) -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -march=bpf -D__TARGET_ARCH_$(ARCH) -c $(EBPF_TEST_KPROBE_SOURCE) -o $(EBPF_TEST_KPROBE_BINARY) vmlinuxh: bpftool btf dump file /sys/kernel/btf/vmlinux format c > $(abspath ./test-data/vmlinux.h) diff --git a/pkg/cache/cache.go b/pkg/cache/cache.go index b3ca805..a60faf8 100644 --- a/pkg/cache/cache.go +++ b/pkg/cache/cache.go @@ -20,7 +20,7 @@ import ( "github.com/aws/aws-ebpf-sdk-go/pkg/logger" ) -var sdkCache *GlobalCacheMap +var sdkCache GlobalCache var log = logger.Get() // Adding a struct if in future we need a cleanup routine @@ -28,6 +28,12 @@ type CacheValue struct { mapFD int } +type GlobalCache interface { + Set(key string, value int) + Get(key string) (int, bool) + Delete(key string) +} + type GlobalCacheMap struct { globalMap *sync.Map } @@ -49,7 +55,7 @@ func (c *GlobalCacheMap) Delete(key string) { c.globalMap.Delete(key) } -func Get() *GlobalCacheMap { +func Get() GlobalCache { if sdkCache == nil { sdkCache = New() log.Info("Initialized new SDK cache as an existing instance was not found") @@ -57,8 +63,8 @@ func Get() *GlobalCacheMap { return sdkCache } -func New() *GlobalCacheMap { - sdkCache := &GlobalCacheMap{ +func New() GlobalCache { + sdkCache = &GlobalCacheMap{ globalMap: new(sync.Map), } return sdkCache diff --git a/pkg/cache/cache_test.go b/pkg/cache/cache_test.go new file mode 100644 index 0000000..4984d0c --- /dev/null +++ b/pkg/cache/cache_test.go @@ -0,0 +1,64 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"). +// You may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +//limitations under the License. + +package cache + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestCache(t *testing.T) { + SdkCache := New() + + value, _ := SdkCache.Get("invalidKey") + assert.Equal(t, -1, value) + + SdkCache.Set("ingress-map", 10) + + value, _ = SdkCache.Get("ingress-map") + assert.Equal(t, 10, value) + + SdkCache.Set("ingress-map", 11) + + value, _ = SdkCache.Get("ingress-map") + assert.Equal(t, 11, value) + + SdkCache.Set("egress-map", 12) + + SdkCache.Delete("egress-map") + + value, _ = SdkCache.Get("egress-map") + assert.Equal(t, -1, value) + + tempSdkCache := Get() + value, _ = tempSdkCache.Get("ingress-map") + assert.Equal(t, 11, value) + +} + +func TestCacheGetSameInstance(t *testing.T) { + cache1 := Get() + cache2 := Get() + + assert.True(t, cache1 == cache2) +} + +func TestCacheNewAndGetSameInstance(t *testing.T) { + cache1 := New() + cache2 := Get() + + assert.True(t, cache1 == cache2) +} diff --git a/pkg/kprobe/kprobe.go b/pkg/kprobe/kprobe.go index 7baa177..da32b68 100644 --- a/pkg/kprobe/kprobe.go +++ b/pkg/kprobe/kprobe.go @@ -16,6 +16,7 @@ package kprobe import ( "fmt" + "io/ioutil" "os" "strconv" "strings" @@ -29,22 +30,55 @@ import ( var log = logger.Get() +type BpfKprobe interface { + KprobeAttach() error + KretprobeAttach() error + KprobeDetach() error + KretprobeDetach() error +} + +var _ BpfKprobe = &bpfKprobe{} + +type bpfKprobe struct { + progFD int + eventName string + funcName string + perfFD int +} + +func New(fd int, eName, fName string) BpfKprobe { + return &bpfKprobe{ + progFD: fd, + eventName: eName, + funcName: fName, + } + +} + +func (k *bpfKprobe) SetPerfFD(perfFD int) { + k.perfFD = perfFD +} + +func (k *bpfKprobe) GetPerfFD() int { + return k.perfFD +} + /* p[:[GRP/]EVENT] [MOD:]SYM[+offs]|MEMADDR [FETCHARGS] : Set a probe r[MAXACTIVE][:[GRP/]EVENT] [MOD:]SYM[+0] [FETCHARGS] : Set a return probe -:[GRP/]EVENT */ -func KprobeAttach(progFD int, eventName string, funcName string) error { +func (k *bpfKprobe) KprobeAttach() error { - if progFD <= 0 { - log.Errorf("invalid BPF prog FD %d", progFD) - return fmt.Errorf("Invalid BPF prog FD %d", progFD) + if k.progFD <= 0 { + log.Errorf("invalid BPF prog FD %d", k.progFD) + return fmt.Errorf("Invalid BPF prog FD %d", k.progFD) } // if event is nil, we pick funcName - if len(eventName) == 0 { - eventName = funcName + if len(k.eventName) == 0 { + k.eventName = k.funcName } // Register the Kprobe event @@ -54,7 +88,7 @@ func KprobeAttach(progFD int, eventName string, funcName string) error { return err } - eventString := fmt.Sprintf("p:kprobes/%s %s", eventName, funcName) + eventString := fmt.Sprintf("p:kprobes/%s %s", k.eventName, k.funcName) _, err = file.WriteString(eventString) if err != nil { log.Errorf("error writing to kprobe_events file: %v", err) @@ -62,7 +96,7 @@ func KprobeAttach(progFD int, eventName string, funcName string) error { } //Get the Kprobe ID - kprobeIDpath := fmt.Sprintf("%s/%s/id", constdef.KPROBE_SYS_DEBUG, eventName) + kprobeIDpath := fmt.Sprintf("%s/%s/id", constdef.KPROBE_SYS_DEBUG, k.eventName) data, err := os.ReadFile(kprobeIDpath) if err != nil { log.Errorf("unable to read the kprobeID: %v", err) @@ -91,9 +125,9 @@ func KprobeAttach(progFD int, eventName string, funcName string) error { return err } - log.Infof("Attach bpf program to perf event Prog FD %d Event FD %d", progFD, fd) + log.Infof("Attach bpf program to perf event Prog FD %d Event FD %d", k.progFD, fd) - if _, _, err := unix.Syscall(unix.SYS_IOCTL, uintptr(int(fd)), uintptr(uint(unix.PERF_EVENT_IOC_SET_BPF)), uintptr(progFD)); err != 0 { + if _, _, err := unix.Syscall(unix.SYS_IOCTL, uintptr(int(fd)), uintptr(uint(unix.PERF_EVENT_IOC_SET_BPF)), uintptr(k.progFD)); err != 0 { log.Errorf("error attaching bpf program to perf event: %v", err) return err } @@ -103,7 +137,10 @@ func KprobeAttach(progFD int, eventName string, funcName string) error { return err } + k.SetPerfFD(fd) + log.Infof("KPROBE Attach done!!! %d", fd) + return nil } @@ -118,16 +155,16 @@ MAXACTIVE : Maximum number of instances of the specified function that can be probed simultaneously, or 0 for the default value as defined in Documentation/kprobes.txt section 1.3.1. */ -func KretprobeAttach(progFD int, eventName string, funcName string) error { +func (k *bpfKprobe) KretprobeAttach() error { - if progFD <= 0 { - log.Infof("invalid BPF prog FD %d", progFD) - return fmt.Errorf("Invalid BPF prog FD %d", progFD) + if k.progFD <= 0 { + log.Infof("invalid BPF prog FD %d", k.progFD) + return fmt.Errorf("Invalid BPF prog FD %d", k.progFD) } // if event is nil, we pick funcName - if len(eventName) == 0 { - eventName = funcName + if len(k.eventName) == 0 { + k.eventName = k.funcName } // Register the Kprobe event @@ -137,7 +174,7 @@ func KretprobeAttach(progFD int, eventName string, funcName string) error { return err } - eventString := fmt.Sprintf("r4096:kretprobes/%s %s", eventName, funcName) + eventString := fmt.Sprintf("r4096:kretprobes/%s %s", k.eventName, k.funcName) _, err = file.WriteString(eventString) if err != nil { log.Errorf("error writing to kprobe_events file: %v", err) @@ -145,7 +182,7 @@ func KretprobeAttach(progFD int, eventName string, funcName string) error { } //Get the Kprobe ID - kprobeIDpath := fmt.Sprintf("%s/%s/id", constdef.KRETPROBE_SYS_DEBUG, eventName) + kprobeIDpath := fmt.Sprintf("%s/%s/id", constdef.KRETPROBE_SYS_DEBUG, k.eventName) data, err := os.ReadFile(kprobeIDpath) if err != nil { log.Errorf("unable to read the kretprobeID: %v", err) @@ -174,9 +211,9 @@ func KretprobeAttach(progFD int, eventName string, funcName string) error { return err } - log.Infof("Attach bpf program to perf event Prog FD %d Event FD %d", progFD, fd) + log.Infof("Attach bpf program to perf event Prog FD %d Event FD %d", k.progFD, fd) - if _, _, err := unix.Syscall(unix.SYS_IOCTL, uintptr(int(fd)), uintptr(uint(unix.PERF_EVENT_IOC_SET_BPF)), uintptr(progFD)); err != 0 { + if _, _, err := unix.Syscall(unix.SYS_IOCTL, uintptr(int(fd)), uintptr(uint(unix.PERF_EVENT_IOC_SET_BPF)), uintptr(k.progFD)); err != 0 { log.Errorf("error attaching bpf program to perf event: %v", err) return err } @@ -186,13 +223,34 @@ func KretprobeAttach(progFD int, eventName string, funcName string) error { return err } + k.SetPerfFD(fd) + log.Infof("KRETPROBE Attach done!!! %d", fd) return nil } -func probeDetach(eventName string) error { +func probeDetach(eventName string, perfFD int, kretProbe bool) error { log.Infof("Calling Detach on %s", eventName) + + if _, _, err := unix.Syscall(unix.SYS_IOCTL, uintptr(int(perfFD)), uintptr(uint(unix.PERF_EVENT_IOC_DISABLE)), 0); err != 0 { + log.Errorf("error enabling perf event: %v", err) + return err + } + unix.Close(perfFD) + + eventEnable := constdef.KPROBE_SYS_DEBUG + "/" + eventName + "/enable" + if kretProbe { + eventEnable = constdef.KRETPROBE_SYS_DEBUG + "/" + eventName + "/enable" + } + + setEnable := []byte("0") + + err := ioutil.WriteFile(eventEnable, setEnable, os.ModePerm) + if err != nil { + return err + } + file, err := os.OpenFile(constdef.KPROBE_SYS_EVENTS, os.O_APPEND|os.O_WRONLY, 0) if err != nil { log.Errorf("cannot open probe events: %v", err) @@ -214,12 +272,12 @@ func probeDetach(eventName string) error { return nil } -func KprobeDetach(eventName string) error { - log.Infof("Calling Kprobe Detach on %s", eventName) - return probeDetach(eventName) +func (k *bpfKprobe) KprobeDetach() error { + log.Infof("Calling Kprobe Detach on %s", k.eventName) + return probeDetach(k.eventName, k.perfFD, false) } -func KretprobeDetach(eventName string) error { - log.Infof("Calling Kretprobe Detach on %s", eventName) - return probeDetach(eventName) +func (k *bpfKprobe) KretprobeDetach() error { + log.Infof("Calling Kretprobe Detach on %s", k.eventName) + return probeDetach(k.eventName, k.perfFD, true) } diff --git a/pkg/kprobe/kprobe_test.go b/pkg/kprobe/kprobe_test.go new file mode 100644 index 0000000..633e53f --- /dev/null +++ b/pkg/kprobe/kprobe_test.go @@ -0,0 +1,127 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"). +// You may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +//limitations under the License. + +package kprobe + +import ( + "os" + "testing" + + constdef "github.com/aws/aws-ebpf-sdk-go/pkg/constants" + "github.com/aws/aws-ebpf-sdk-go/pkg/elfparser" + mock_ebpf_maps "github.com/aws/aws-ebpf-sdk-go/pkg/maps/mocks" + mock_ebpf_progs "github.com/aws/aws-ebpf-sdk-go/pkg/progs/mocks" + "github.com/aws/aws-ebpf-sdk-go/pkg/utils" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" +) + +const ( + DUMMY_PROG_NAME = "test" +) + +type testMocks struct { + path string + ctrl *gomock.Controller + ebpf_progs *mock_ebpf_progs.MockBpfProgAPIs + ebpf_maps *mock_ebpf_maps.MockBpfMapAPIs +} + +func setup(t *testing.T, testPath string) *testMocks { + ctrl := gomock.NewController(t) + return &testMocks{ + path: testPath, + ctrl: ctrl, + ebpf_progs: mock_ebpf_progs.NewMockBpfProgAPIs(ctrl), + ebpf_maps: mock_ebpf_maps.NewMockBpfMapAPIs(ctrl), + } +} + +func TestTCKprobeAttachDetach(t *testing.T) { + if os.Getuid() != 0 { + t.Skip("Test requires root privileges.") + } + + m := setup(t, "../../test-data/test-kprobe.bpf.elf") + defer m.ctrl.Finish() + + utils.Mount_bpf_fs() + defer utils.Unmount_bpf_fs() + + m.ebpf_maps.EXPECT().CreateBPFMap(gomock.Any()).AnyTimes() + m.ebpf_progs.EXPECT().LoadProg(gomock.Any()).AnyTimes() + m.ebpf_maps.EXPECT().PinMap(gomock.Any(), gomock.Any()).AnyTimes() + m.ebpf_maps.EXPECT().GetMapFromPinPath(gomock.Any()).AnyTimes() + m.ebpf_progs.EXPECT().GetProgFromPinPath(gomock.Any()).AnyTimes() + m.ebpf_progs.EXPECT().GetBPFProgAssociatedMapsIDs(gomock.Any()).AnyTimes() + + bpfSDKclient := elfparser.New() + progInfo, _, err := bpfSDKclient.LoadBpfFile(m.path, DUMMY_PROG_NAME) + if err != nil { + assert.NoError(t, err) + } + pinPath := constdef.PROG_BPF_FS + DUMMY_PROG_NAME + "_oom_kill" + + progFD := progInfo[pinPath].Program.ProgFD + funcName := "oom_kill_process" + eventName := funcName + "__goebpf" + + kprobeClient := New(progFD, eventName, funcName) + if err := kprobeClient.KprobeAttach(); err != nil { + assert.NoError(t, err) + } + + if err := kprobeClient.KprobeDetach(); err != nil { + assert.NoError(t, err) + } +} + +func TestTCKretprobeAttachDetach(t *testing.T) { + if os.Getuid() != 0 { + t.Skip("Test requires root privileges.") + } + + m := setup(t, "../../test-data/test-kprobe.bpf.elf") + defer m.ctrl.Finish() + + utils.Mount_bpf_fs() + defer utils.Unmount_bpf_fs() + + m.ebpf_maps.EXPECT().CreateBPFMap(gomock.Any()).AnyTimes() + m.ebpf_progs.EXPECT().LoadProg(gomock.Any()).AnyTimes() + m.ebpf_maps.EXPECT().PinMap(gomock.Any(), gomock.Any()).AnyTimes() + m.ebpf_maps.EXPECT().GetMapFromPinPath(gomock.Any()).AnyTimes() + m.ebpf_progs.EXPECT().GetProgFromPinPath(gomock.Any()).AnyTimes() + m.ebpf_progs.EXPECT().GetBPFProgAssociatedMapsIDs(gomock.Any()).AnyTimes() + + bpfSDKclient := elfparser.New() + progInfo, _, err := bpfSDKclient.LoadBpfFile(m.path, DUMMY_PROG_NAME) + if err != nil { + assert.NoError(t, err) + } + pinPath := constdef.PROG_BPF_FS + DUMMY_PROG_NAME + "_oom_kill" + + progFD := progInfo[pinPath].Program.ProgFD + funcName := "oom_kill_process" + eventName := funcName + "__goebpf" + + kprobeClient := New(progFD, eventName, funcName) + if err := kprobeClient.KretprobeAttach(); err != nil { + assert.NoError(t, err) + } + + if err := kprobeClient.KretprobeDetach(); err != nil { + assert.NoError(t, err) + } +} diff --git a/test-data/test-kprobe.bpf.c b/test-data/test-kprobe.bpf.c new file mode 100644 index 0000000..a377c69 --- /dev/null +++ b/test-data/test-kprobe.bpf.c @@ -0,0 +1,12 @@ +#include "vmlinux.h" +#include +#include +#include + +SEC("kprobe/oom_kill_process") +int oom_kill(struct pt_regs *ctx) { + return 0; +} + + +char _license[] SEC("license") = "GPL"; \ No newline at end of file From 7baafdb5166f3e8bc6473ed9ab93e1af0d2a0388 Mon Sep 17 00:00:00 2001 From: Jayanth Varavani <1111446+jayanthvn@users.noreply.github.com> Date: Fri, 25 Aug 2023 11:19:20 -0700 Subject: [PATCH 08/29] Xdp and Events UT (#29) * XDP and events update * cleanup --- Makefile | 6 + pkg/elfparser/elf_test.go | 10 -- pkg/events/events.go | 70 +++++----- pkg/events/generate_mocks.go | 15 +++ pkg/events/mocks/events_mocks.go | 49 +++++++ pkg/events/poll/epoll.go | 40 +++--- pkg/tc/tc.go | 15 +-- pkg/tc/tc_test.go | 3 +- pkg/xdp/generate_mocks.go | 15 +++ pkg/xdp/mocks/xdp_mocks.go | 62 +++++++++ pkg/xdp/xdp.go | 34 +++-- pkg/xdp/xdp_test.go | 220 +++++++++++++++++++++++++++++++ test-data/ring_buffer.bpf.c | 32 +++++ test-data/xdp.bpf.c | 11 ++ 14 files changed, 504 insertions(+), 78 deletions(-) create mode 100644 pkg/events/generate_mocks.go create mode 100644 pkg/events/mocks/events_mocks.go create mode 100644 pkg/xdp/generate_mocks.go create mode 100644 pkg/xdp/mocks/xdp_mocks.go create mode 100644 pkg/xdp/xdp_test.go create mode 100644 test-data/ring_buffer.bpf.c create mode 100644 test-data/xdp.bpf.c diff --git a/Makefile b/Makefile index fff8b14..9a96937 100644 --- a/Makefile +++ b/Makefile @@ -46,6 +46,10 @@ EBPF_TEST_RECOVERY_SOURCE := test-data/recoverydata.bpf.c EBPF_TEST_RECOVERY_BINARY := test-data/recoverydata.bpf.elf EBPF_TEST_KPROBE_SOURCE := test-data/test-kprobe.bpf.c EBPF_TEST_KPROBE_BINARY := test-data/test-kprobe.bpf.elf +EBPF_TEST_XDP_SOURCE := test-data/xdp.bpf.c +EBPF_TEST_XDP_BINARY := test-data/xdp.bpf.elf +EBPF_TEST_RINGBUFFER_SOURCE := test-data/ring_buffer.bpf.c +EBPF_TEST_RINGBUFFER_BINARY := test-data/ring_buffer.bpf.elf build-bpf: ## Build BPF $(CLANG) $(CLANG_INCLUDE) -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -march=bpf -D__TARGET_ARCH_$(ARCH) -c $(EBPF_SOURCE) -o $(EBPF_BINARY) $(CLANG) $(CLANG_INCLUDE) -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -march=bpf -D__TARGET_ARCH_$(ARCH) -c $(EBPF_TEST_SOURCE) -o $(EBPF_TEST_BINARY) @@ -54,6 +58,8 @@ build-bpf: ## Build BPF $(CLANG) $(CLANG_INCLUDE) -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -march=bpf -D__TARGET_ARCH_$(ARCH) -c $(EBPF_TEST_INV_MAP_SOURCE) -o $(EBPF_TEST_INV_MAP_BINARY) $(CLANG) $(CLANG_INCLUDE) -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -march=bpf -D__TARGET_ARCH_$(ARCH) -c $(EBPF_TEST_RECOVERY_SOURCE) -o $(EBPF_TEST_RECOVERY_BINARY) $(CLANG) $(CLANG_INCLUDE) -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -march=bpf -D__TARGET_ARCH_$(ARCH) -c $(EBPF_TEST_KPROBE_SOURCE) -o $(EBPF_TEST_KPROBE_BINARY) + $(CLANG) $(CLANG_INCLUDE) -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -march=bpf -D__TARGET_ARCH_$(ARCH) -c $(EBPF_TEST_XDP_SOURCE) -o $(EBPF_TEST_XDP_BINARY) + $(CLANG) $(CLANG_INCLUDE) -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -march=bpf -D__TARGET_ARCH_$(ARCH) -c $(EBPF_TEST_RINGBUFFER_SOURCE) -o $(EBPF_TEST_RINGBUFFER_BINARY) vmlinuxh: bpftool btf dump file /sys/kernel/btf/vmlinux format c > $(abspath ./test-data/vmlinux.h) diff --git a/pkg/elfparser/elf_test.go b/pkg/elfparser/elf_test.go index 9cafdbf..056feb6 100644 --- a/pkg/elfparser/elf_test.go +++ b/pkg/elfparser/elf_test.go @@ -526,13 +526,6 @@ func TestRecovery(t *testing.T) { wantProg: 3, wantErr: nil, }, - { - name: "Missing BPF mount", - elfFileName: "../../test-data/recoverydata.bpf.elf", - wantProg: 0, - forceUnMount: true, - wantErr: errors.New("error checking BPF FS, please make sure it is mounted"), - }, } for _, tt := range progtests { @@ -560,9 +553,6 @@ func TestRecovery(t *testing.T) { assert.NoError(t, err) } - if tt.forceUnMount { - utils.Unmount_bpf_fs() - } recoveredData, err := bpfSDKclient.RecoverAllBpfProgramsAndMaps() if tt.wantErr != nil { assert.EqualError(t, err, tt.wantErr.Error()) diff --git a/pkg/events/events.go b/pkg/events/events.go index 8bb90a4..ba04ab6 100644 --- a/pkg/events/events.go +++ b/pkg/events/events.go @@ -30,15 +30,27 @@ import ( var log = logger.Get() -type Events struct { - RingBuffers []*RingBuffer - PageSize int - RingCnt int - stopRingBufferChan chan struct{} - updateRingBufferChan chan *RingBuffer - eventsStopChannel chan struct{} - wg sync.WaitGroup - eventsDataChannel chan []byte +type Events interface { + InitRingBuffer(mapFDlist []int) (map[int]chan []byte, error) +} + +var _ Events = &events{} + +func New() Events { + return &events{ + PageSize: os.Getpagesize(), + RingCnt: 0, + } + +} + +type events struct { + RingBuffers []*RingBuffer + PageSize int + RingCnt int + eventsStopChannel chan struct{} + wg sync.WaitGroup + eventsDataChannel chan []byte epoller *poller.EventPoller } @@ -62,18 +74,13 @@ func isValidMapFDList(mapFDlist []int) bool { return true } -func InitRingBuffer(mapFDlist []int) (map[int]chan []byte, error) { +func (ev *events) InitRingBuffer(mapFDlist []int) (map[int]chan []byte, error) { // Validate mapFD if !isValidMapFDList(mapFDlist) { return nil, fmt.Errorf("mapFDs passed to InitRingBuffer is invalid") } - ev := &Events{ - PageSize: os.Getpagesize(), - RingCnt: 0, - } - epoll, err := poller.NewEventPoller() if err != nil { return nil, fmt.Errorf("failed to create epoll instance: %s", err) @@ -89,9 +96,9 @@ func InitRingBuffer(mapFDlist []int) (map[int]chan []byte, error) { return nil, fmt.Errorf("failed to map info") } - eventsChan, err := ev.SetupRingBuffer(mapFD, mapInfo.MaxEntries) + eventsChan, err := ev.setupRingBuffer(mapFD, mapInfo.MaxEntries) if err != nil { - ev.CleanupRingBuffer() + ev.cleanupRingBuffer() return nil, fmt.Errorf("failed to add ring buffer: %s", err) } @@ -101,7 +108,7 @@ func InitRingBuffer(mapFDlist []int) (map[int]chan []byte, error) { return ringBufferChanList, nil } -func (ev *Events) SetupRingBuffer(mapFD int, maxEntries uint32) (chan []byte, error) { +func (ev *events) setupRingBuffer(mapFD int, maxEntries uint32) (chan []byte, error) { ringbuffer := &RingBuffer{ RingBufferMapFD: mapFD, Mask: uint64(maxEntries - 1), @@ -148,7 +155,7 @@ func (ev *Events) SetupRingBuffer(mapFD int, maxEntries uint32) (chan []byte, er return ev.eventsDataChannel, nil } -func (ev *Events) CleanupRingBuffer() { +func (ev *events) cleanupRingBuffer() { for i := 0; i < ev.RingCnt; i++ { _ = unix.Munmap(ev.RingBuffers[i].Producer) @@ -165,21 +172,14 @@ func (ev *Events) CleanupRingBuffer() { return } -func (ev *Events) reconcileEventsDataChannel() { - - pollerCh := ev.epoller.EpollStart() - defer func() { - ev.wg.Done() - }() - +func (ev *events) reconcileEventsDataChannelHandler(pollerCh <-chan int) { for { select { case bufferPtr, ok := <-pollerCh: - if !ok { return } - ev.ReadRingBuffer(ev.RingBuffers[bufferPtr]) + ev.readRingBuffer(ev.RingBuffers[bufferPtr]) case <-ev.eventsStopChannel: return @@ -187,8 +187,18 @@ func (ev *Events) reconcileEventsDataChannel() { } } +func (ev *events) reconcileEventsDataChannel() { + + pollerCh := ev.epoller.EpollStart() + defer ev.wg.Done() + + go ev.reconcileEventsDataChannelHandler(pollerCh) + + <-ev.eventsStopChannel +} + // Similar to libbpf poll ring -func (ev *Events) ReadRingBuffer(eventRing *RingBuffer) { +func (ev *events) readRingBuffer(eventRing *RingBuffer) { readDone := true consPosition := eventRing.getConsumerPosition() for !readDone { @@ -196,7 +206,7 @@ func (ev *Events) ReadRingBuffer(eventRing *RingBuffer) { } } -func (ev *Events) parseBuffer(consumerPosition uint64, eventRing *RingBuffer) bool { +func (ev *events) parseBuffer(consumerPosition uint64, eventRing *RingBuffer) bool { readDone := true producerPosition := eventRing.getProducerPosition() for consumerPosition < producerPosition { diff --git a/pkg/events/generate_mocks.go b/pkg/events/generate_mocks.go new file mode 100644 index 0000000..919855a --- /dev/null +++ b/pkg/events/generate_mocks.go @@ -0,0 +1,15 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"). You may +// not use this file except in compliance with the License. A copy of the +// License is located at +// +// http://aws.amazon.com/apache2.0/ +// +// or in the "license" file accompanying this file. This file is distributed +// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +// express or implied. See the License for the specific language governing +// permissions and limitations under the License. +package events + +//go:generate go run github.com/golang/mock/mockgen -destination mocks/events_mocks.go . Events diff --git a/pkg/events/mocks/events_mocks.go b/pkg/events/mocks/events_mocks.go new file mode 100644 index 0000000..2e3eebb --- /dev/null +++ b/pkg/events/mocks/events_mocks.go @@ -0,0 +1,49 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/aws/aws-ebpf-sdk-go/pkg/events (interfaces: Events) + +// Package mock_events is a generated GoMock package. +package mock_events + +import ( + reflect "reflect" + + gomock "github.com/golang/mock/gomock" +) + +// MockEvents is a mock of Events interface. +type MockEvents struct { + ctrl *gomock.Controller + recorder *MockEventsMockRecorder +} + +// MockEventsMockRecorder is the mock recorder for MockEvents. +type MockEventsMockRecorder struct { + mock *MockEvents +} + +// NewMockEvents creates a new mock instance. +func NewMockEvents(ctrl *gomock.Controller) *MockEvents { + mock := &MockEvents{ctrl: ctrl} + mock.recorder = &MockEventsMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockEvents) EXPECT() *MockEventsMockRecorder { + return m.recorder +} + +// InitRingBuffer mocks base method. +func (m *MockEvents) InitRingBuffer(arg0 []int) (map[int]chan []byte, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "InitRingBuffer", arg0) + ret0, _ := ret[0].(map[int]chan []byte) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// InitRingBuffer indicates an expected call of InitRingBuffer. +func (mr *MockEventsMockRecorder) InitRingBuffer(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InitRingBuffer", reflect.TypeOf((*MockEvents)(nil).InitRingBuffer), arg0) +} diff --git a/pkg/events/poll/epoll.go b/pkg/events/poll/epoll.go index a74a40d..a0ce64d 100644 --- a/pkg/events/poll/epoll.go +++ b/pkg/events/poll/epoll.go @@ -17,17 +17,19 @@ type EventPoller struct { epollEvent []unix.EpollEvent bufferCnt int - stopEventPollerChan chan struct{} - updateEventPollerChan chan int + stopEventPollerChan chan struct{} + fdEventPollerChan chan int } func NewEventPoller() (*EventPoller, error) { epollFD, err := unix.EpollCreate1(unix.EPOLL_CLOEXEC) if err != nil { - return nil, fmt.Errorf("Failed to create epoll instance: %s", err) + return nil, fmt.Errorf("failed to create epoll instance: %s", err) } e := &EventPoller{ - epollFd: epollFD, + epollFd: epollFD, + stopEventPollerChan: make(chan struct{}), + fdEventPollerChan: make(chan int), } return e, nil } @@ -44,22 +46,28 @@ func (e *EventPoller) AddEpollCtl(mapFD, eventFD int) error { err := unix.EpollCtl(e.epollFd, unix.EPOLL_CTL_ADD, mapFD, &epollEvent) if err != nil { - return fmt.Errorf("Failed to Epoll event: %s", err) + return fmt.Errorf("failed to Epoll event: %s", err) } e.epollEvent = append(e.epollEvent, epollEvent) return nil } func (e *EventPoller) EpollStart() <-chan int { - - e.stopEventPollerChan = make(chan struct{}) - e.updateEventPollerChan = make(chan int) e.wg.Add(1) go e.eventsPoller() - - return e.updateEventPollerChan + return e.fdEventPollerChan } +func (e *EventPoller) getEventFDs(totalEvents int) { + for _, event := range e.epollEvent[:totalEvents] { + select { + case e.fdEventPollerChan <- int(event.Fd): + + case <-e.stopEventPollerChan: + return + } + } +} func (e *EventPoller) eventsPoller() { defer e.wg.Done() for { @@ -69,20 +77,12 @@ func (e *EventPoller) eventsPoller() { default: break } - numEvents := e.poll(e.epollEvent[:e.bufferCnt]) - for _, event := range e.epollEvent[:numEvents] { - select { - case e.updateEventPollerChan <- int(event.Fd): - - case <-e.stopEventPollerChan: - return - } - } + totalEvents := e.poll(e.epollEvent[:e.bufferCnt]) + e.getEventFDs(totalEvents) } } func (e *EventPoller) poll(events []unix.EpollEvent) int { - timeoutMs := 150 n, err := unix.EpollWait(e.epollFd, events, timeoutMs) if err != nil { diff --git a/pkg/tc/tc.go b/pkg/tc/tc.go index f71320e..6380db2 100644 --- a/pkg/tc/tc.go +++ b/pkg/tc/tc.go @@ -37,7 +37,6 @@ type BpfTc interface { TCEgressAttach(interfaceName string, progFD int, funcName string) error TCEgressDetach(interfaceName string) error CleanupQdiscs(ingressCleanup bool, egressCleanup bool) error - mismatchedInterfacePrefix(interfaceName string) error } var _ BpfTc = &bpfTc{} @@ -76,9 +75,9 @@ func enableQdisc(link netlink.Link) bool { } -func (m *bpfTc) mismatchedInterfacePrefix(interfaceName string) error { - if !strings.HasPrefix(interfaceName, m.InterfacePrefix) { - log.Errorf("expected prefix - %s but got %s", m.InterfacePrefix, interfaceName) +func mismatchedInterfacePrefix(interfaceName string, interfacePrefix string) error { + if !strings.HasPrefix(interfaceName, interfacePrefix) { + log.Errorf("expected prefix - %s but got %s", interfacePrefix, interfaceName) return errors.New("Mismatched initialized prefix name and passed interface name") } return nil @@ -86,7 +85,7 @@ func (m *bpfTc) mismatchedInterfacePrefix(interfaceName string) error { func (m *bpfTc) TCIngressAttach(interfaceName string, progFD int, funcName string) error { - if err := m.mismatchedInterfacePrefix(interfaceName); err != nil { + if err := mismatchedInterfacePrefix(interfaceName, m.InterfacePrefix); err != nil { return err } @@ -138,7 +137,7 @@ func (m *bpfTc) TCIngressAttach(interfaceName string, progFD int, funcName strin func (m *bpfTc) TCIngressDetach(interfaceName string) error { - if err := m.mismatchedInterfacePrefix(interfaceName); err != nil { + if err := mismatchedInterfacePrefix(interfaceName, m.InterfacePrefix); err != nil { return err } @@ -174,7 +173,7 @@ func (m *bpfTc) TCIngressDetach(interfaceName string) error { func (m *bpfTc) TCEgressAttach(interfaceName string, progFD int, funcName string) error { - if err := m.mismatchedInterfacePrefix(interfaceName); err != nil { + if err := mismatchedInterfacePrefix(interfaceName, m.InterfacePrefix); err != nil { return err } @@ -226,7 +225,7 @@ func (m *bpfTc) TCEgressAttach(interfaceName string, progFD int, funcName string func (m *bpfTc) TCEgressDetach(interfaceName string) error { - if err := m.mismatchedInterfacePrefix(interfaceName); err != nil { + if err := mismatchedInterfacePrefix(interfaceName, m.InterfacePrefix); err != nil { return err } diff --git a/pkg/tc/tc_test.go b/pkg/tc/tc_test.go index fec7333..68bd463 100644 --- a/pkg/tc/tc_test.go +++ b/pkg/tc/tc_test.go @@ -120,8 +120,7 @@ func TestMismatchedPrefixName(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - testTcClient := New("eni") - err := testTcClient.mismatchedInterfacePrefix(tt.interfaceName) + err := mismatchedInterfacePrefix(tt.interfaceName, "eni") if tt.wantErr != nil { assert.EqualError(t, err, tt.wantErr.Error()) } else { diff --git a/pkg/xdp/generate_mocks.go b/pkg/xdp/generate_mocks.go new file mode 100644 index 0000000..ddc9322 --- /dev/null +++ b/pkg/xdp/generate_mocks.go @@ -0,0 +1,15 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"). You may +// not use this file except in compliance with the License. A copy of the +// License is located at +// +// http://aws.amazon.com/apache2.0/ +// +// or in the "license" file accompanying this file. This file is distributed +// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +// express or implied. See the License for the specific language governing +// permissions and limitations under the License. +package xdp + +//go:generate go run github.com/golang/mock/mockgen -destination mocks/xdp_mocks.go . BpfXdp diff --git a/pkg/xdp/mocks/xdp_mocks.go b/pkg/xdp/mocks/xdp_mocks.go new file mode 100644 index 0000000..832f2fc --- /dev/null +++ b/pkg/xdp/mocks/xdp_mocks.go @@ -0,0 +1,62 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/aws/aws-ebpf-sdk-go/pkg/xdp (interfaces: BpfXdp) + +// Package mock_xdp is a generated GoMock package. +package mock_xdp + +import ( + reflect "reflect" + + gomock "github.com/golang/mock/gomock" +) + +// MockBpfXdp is a mock of BpfXdp interface. +type MockBpfXdp struct { + ctrl *gomock.Controller + recorder *MockBpfXdpMockRecorder +} + +// MockBpfXdpMockRecorder is the mock recorder for MockBpfXdp. +type MockBpfXdpMockRecorder struct { + mock *MockBpfXdp +} + +// NewMockBpfXdp creates a new mock instance. +func NewMockBpfXdp(ctrl *gomock.Controller) *MockBpfXdp { + mock := &MockBpfXdp{ctrl: ctrl} + mock.recorder = &MockBpfXdpMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockBpfXdp) EXPECT() *MockBpfXdpMockRecorder { + return m.recorder +} + +// XDPAttach mocks base method. +func (m *MockBpfXdp) XDPAttach(arg0 int) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "XDPAttach", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// XDPAttach indicates an expected call of XDPAttach. +func (mr *MockBpfXdpMockRecorder) XDPAttach(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "XDPAttach", reflect.TypeOf((*MockBpfXdp)(nil).XDPAttach), arg0) +} + +// XDPDetach mocks base method. +func (m *MockBpfXdp) XDPDetach() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "XDPDetach") + ret0, _ := ret[0].(error) + return ret0 +} + +// XDPDetach indicates an expected call of XDPDetach. +func (mr *MockBpfXdpMockRecorder) XDPDetach() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "XDPDetach", reflect.TypeOf((*MockBpfXdp)(nil).XDPDetach)) +} diff --git a/pkg/xdp/xdp.go b/pkg/xdp/xdp.go index 1d4274b..b0a9c78 100644 --- a/pkg/xdp/xdp.go +++ b/pkg/xdp/xdp.go @@ -22,30 +22,48 @@ import ( var log = logger.Get() -func XDPAttach(interfaceName string, progFD int) error { +type BpfXdp interface { + XDPAttach(progFD int) error + XDPDetach() error +} + +var _ BpfXdp = &bpfXdp{} + +type bpfXdp struct { + interfaceName string +} + +func New(ifName string) BpfXdp { + return &bpfXdp{ + interfaceName: ifName, + } + +} + +func (b *bpfXdp) XDPAttach(progFD int) error { - link, err := netlink.LinkByName(interfaceName) + link, err := netlink.LinkByName(b.interfaceName) if err != nil { - log.Errorf("failed to obtain link info for %s : %v", interfaceName, err) + log.Errorf("failed to obtain link info for %s : %v", b.interfaceName, err) return err } - log.Infof("Attaching xdp prog %d to interface %s", progFD, interfaceName) + log.Infof("Attaching xdp prog %d to interface %s", progFD, b.interfaceName) if err := netlink.LinkSetXdpFdWithFlags(link, progFD, constdef.XDP_ATTACH_MODE_SKB); err != nil { log.Errorf("failed to setup xdp: %v", err) return err } - log.Infof("Attached XDP to interface %s", interfaceName) + log.Infof("Attached XDP to interface %s", b.interfaceName) return nil } -func XDPDetach(interfaceName string) error { +func (b *bpfXdp) XDPDetach() error { - link, err := netlink.LinkByName(interfaceName) + link, err := netlink.LinkByName(b.interfaceName) if err != nil { - log.Errorf("failed to obtain link info for %s : %v", interfaceName, err) + log.Errorf("failed to obtain link info for %s : %v", b.interfaceName, err) return err } diff --git a/pkg/xdp/xdp_test.go b/pkg/xdp/xdp_test.go new file mode 100644 index 0000000..e51bea0 --- /dev/null +++ b/pkg/xdp/xdp_test.go @@ -0,0 +1,220 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"). +// You may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +//limitations under the License. + +package xdp + +import ( + "errors" + "os" + "testing" + + constdef "github.com/aws/aws-ebpf-sdk-go/pkg/constants" + "github.com/aws/aws-ebpf-sdk-go/pkg/elfparser" + mock_ebpf_maps "github.com/aws/aws-ebpf-sdk-go/pkg/maps/mocks" + mock_ebpf_progs "github.com/aws/aws-ebpf-sdk-go/pkg/progs/mocks" + "github.com/aws/aws-ebpf-sdk-go/pkg/utils" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" + "github.com/vishvananda/netlink" +) + +const ( + DUMMY_PROG_PREFIX = "test" + DUMMY_PROG_NAME = "xdp_test_prog" +) + +type testMocks struct { + path string + ctrl *gomock.Controller + ebpf_progs *mock_ebpf_progs.MockBpfProgAPIs + ebpf_maps *mock_ebpf_maps.MockBpfMapAPIs + xdpClient BpfXdp +} + +func setup(t *testing.T, testPath string, interfaceName string) *testMocks { + ctrl := gomock.NewController(t) + return &testMocks{ + path: testPath, + ctrl: ctrl, + ebpf_progs: mock_ebpf_progs.NewMockBpfProgAPIs(ctrl), + ebpf_maps: mock_ebpf_maps.NewMockBpfMapAPIs(ctrl), + xdpClient: New(interfaceName), + } +} + +func setupTest(interfaceNames []string, t *testing.T) { + utils.Mount_bpf_fs() + for _, interfaceName := range interfaceNames { + linkAttr := netlink.LinkAttrs{Name: interfaceName} + linkIFB := netlink.Ifb{} + linkIFB.LinkAttrs = linkAttr + if err := netlink.LinkAdd(&linkIFB); err != nil { + assert.NoError(t, err) + } + } +} + +func teardownTest(interfaceNames []string, t *testing.T, ignoreDelErr bool) { + utils.Unmount_bpf_fs() + //Cleanup link + for _, interfaceName := range interfaceNames { + linkAttr := netlink.LinkAttrs{Name: interfaceName} + linkIFB := netlink.Ifb{} + linkIFB.LinkAttrs = linkAttr + if err := netlink.LinkDel(&linkIFB); err != nil && !ignoreDelErr { + assert.NoError(t, err) + } + } +} + +func deleteLinks(interfaceNames []string, t *testing.T) { + //Cleanup link + for _, interfaceName := range interfaceNames { + linkAttr := netlink.LinkAttrs{Name: interfaceName} + linkIFB := netlink.Ifb{} + linkIFB.LinkAttrs = linkAttr + if err := netlink.LinkDel(&linkIFB); err != nil { + assert.NoError(t, err) + } + } +} + +func TestTCXdpAttachDetach(t *testing.T) { + if os.Getuid() != 0 { + t.Skip("Test requires root privileges.") + } + + interfaceName := "foo1" + + m := setup(t, "../../test-data/xdp.bpf.elf", interfaceName) + defer m.ctrl.Finish() + + var interfaceNames []string + interfaceNames = append(interfaceNames, interfaceName) + setupTest(interfaceNames, t) + defer teardownTest(interfaceNames, t, false) + + m.ebpf_maps.EXPECT().CreateBPFMap(gomock.Any()).AnyTimes() + m.ebpf_progs.EXPECT().LoadProg(gomock.Any()).AnyTimes() + m.ebpf_maps.EXPECT().PinMap(gomock.Any(), gomock.Any()).AnyTimes() + m.ebpf_maps.EXPECT().GetMapFromPinPath(gomock.Any()).AnyTimes() + m.ebpf_progs.EXPECT().GetProgFromPinPath(gomock.Any()).AnyTimes() + m.ebpf_progs.EXPECT().GetBPFProgAssociatedMapsIDs(gomock.Any()).AnyTimes() + + bpfSDKclient := elfparser.New() + progInfo, _, err := bpfSDKclient.LoadBpfFile(m.path, DUMMY_PROG_PREFIX) + if err != nil { + assert.NoError(t, err) + } + pinPath := constdef.PROG_BPF_FS + DUMMY_PROG_PREFIX + "_" + DUMMY_PROG_NAME + + progFD := progInfo[pinPath].Program.ProgFD + if err := m.xdpClient.XDPAttach(progFD); err != nil { + assert.NoError(t, err) + } + + if err := m.xdpClient.XDPDetach(); err != nil { + assert.NoError(t, err) + } +} + +func TestNetLinkAPIs(t *testing.T) { + + netLinktests := []struct { + name string + interfaceName string + overrideName bool + overrideProg bool + skipAttach bool + want []int + wantErr error + }{ + { + name: "Failed Link By Name", + interfaceName: "foo2", + want: nil, + overrideName: true, + wantErr: errors.New("Link not found"), + }, + { + name: "Invalid Program", + interfaceName: "foo3", + want: nil, + overrideProg: true, + wantErr: errors.New("invalid argument"), + }, + { + name: "Detach without attach Program", + interfaceName: "foo4", + want: nil, + skipAttach: true, + wantErr: nil, + }, + } + + for _, tt := range netLinktests { + t.Run(tt.name, func(t *testing.T) { + m := setup(t, "../../test-data/xdp.bpf.elf", tt.interfaceName) + defer m.ctrl.Finish() + + var interfaceNames []string + interfaceNames = append(interfaceNames, tt.interfaceName) + + setupTest(interfaceNames, t) + defer teardownTest(interfaceNames, t, tt.overrideName) + + m.ebpf_maps.EXPECT().CreateBPFMap(gomock.Any()).AnyTimes() + m.ebpf_progs.EXPECT().LoadProg(gomock.Any()).AnyTimes() + m.ebpf_maps.EXPECT().PinMap(gomock.Any(), gomock.Any()).AnyTimes() + m.ebpf_maps.EXPECT().GetMapFromPinPath(gomock.Any()).AnyTimes() + m.ebpf_progs.EXPECT().GetProgFromPinPath(gomock.Any()).AnyTimes() + m.ebpf_progs.EXPECT().GetBPFProgAssociatedMapsIDs(gomock.Any()).AnyTimes() + + bpfSDKclient := elfparser.New() + progInfo, _, err := bpfSDKclient.LoadBpfFile(m.path, DUMMY_PROG_PREFIX) + if err != nil { + assert.NoError(t, err) + } + + if tt.overrideName { + deleteLinks(interfaceNames, t) + } + + pinPath := constdef.PROG_BPF_FS + DUMMY_PROG_PREFIX + "_" + DUMMY_PROG_NAME + + progFD := progInfo[pinPath].Program.ProgFD + + if tt.overrideProg { + progFD = 0 + } + if !tt.skipAttach { + err = m.xdpClient.XDPAttach(progFD) + if tt.wantErr != nil { + assert.EqualError(t, err, tt.wantErr.Error()) + } else { + assert.NoError(t, err) + } + } + + if tt.skipAttach { + err = m.xdpClient.XDPDetach() + if tt.wantErr != nil { + assert.EqualError(t, err, tt.wantErr.Error()) + } else { + assert.NoError(t, err) + } + } + }) + } +} diff --git a/test-data/ring_buffer.bpf.c b/test-data/ring_buffer.bpf.c new file mode 100644 index 0000000..9c5e721 --- /dev/null +++ b/test-data/ring_buffer.bpf.c @@ -0,0 +1,32 @@ +#include "vmlinux.h" +#include +#include +#include + +#define BPF_MAP_TYPE_RINGBUF 27 +#define PIN_GLOBAL_NS 2 + +struct bpf_map_def_pvt { + __u32 type; + __u32 key_size; + __u32 value_size; + __u32 max_entries; + __u32 map_flags; + __u32 pinning; + __u32 inner_map_fd; +}; + +struct bpf_map_def_pvt SEC("maps") test_events = { + .type = BPF_MAP_TYPE_RINGBUF, + .max_entries = 256 * 1024, + .pinning = PIN_GLOBAL_NS, +}; + +SEC("kprobe/__nf_conntrack_hash_insert") +int conn_insert(struct pt_regs *ctx) { + __u32 evt_test = 20; + bpf_ringbuf_output(&test_events, &evt_test, sizeof(evt_test), 2); + return 0; +} + +char _license[] SEC("license") = "GPL"; \ No newline at end of file diff --git a/test-data/xdp.bpf.c b/test-data/xdp.bpf.c new file mode 100644 index 0000000..aba377f --- /dev/null +++ b/test-data/xdp.bpf.c @@ -0,0 +1,11 @@ +#include "vmlinux.h" +#include +#include +#include + +SEC("xdp") +int xdp_test_prog(struct xdp_md *ctx) +{ + return XDP_DROP; +} +char _license[] SEC("license") = "GPL"; \ No newline at end of file From 1886b0472a7a2cbfe22ae118d99ebefc63979873 Mon Sep 17 00:00:00 2001 From: Jayanth Varavani <1111446+jayanthvn@users.noreply.github.com> Date: Sat, 26 Aug 2023 22:36:00 +0000 Subject: [PATCH 09/29] Third party attribution doc --- THIRD-PARTY | 4715 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 4715 insertions(+) create mode 100644 THIRD-PARTY diff --git a/THIRD-PARTY b/THIRD-PARTY new file mode 100644 index 0000000..530ce9b --- /dev/null +++ b/THIRD-PARTY @@ -0,0 +1,4715 @@ + +## github.com/aws/aws-ebpf-sdk-go/pkg ([Apache-2.0](https://github.com/aws/aws-ebpf-sdk-go/blob/HEAD/LICENSE)) + +``` + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. +``` +## go.uber.org/multierr ([MIT](https://github.com/uber-go/multierr/blob/v1.10.0/LICENSE.txt)) + +```Copyright (c) 2017-2021 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +``` +## go.uber.org/zap ([MIT](https://github.com/uber-go/zap/blob/v1.25.0/LICENSE.txt)) + +```Copyright (c) 2016-2017 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +``` +## gopkg.in/natefinch/lumberjack.v2 ([MIT](https://github.com/natefinch/lumberjack/blob/v2.2.1/LICENSE)) + +```The MIT License (MIT) + +Copyright (c) 2014 Nate Finch + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.``` + +## github.com/aws/aws-ebpf-sdk-go/pkg/constants ([Apache-2.0](https://github.com/aws/aws-ebpf-sdk-go/blob/HEAD/LICENSE)) + +``` + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. +``` + +## github.com/aws/aws-ebpf-sdk-go/pkg ([Apache-2.0](https://github.com/aws/aws-ebpf-sdk-go/blob/HEAD/LICENSE)) + +``` + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. +``` +## github.com/vishvananda/netlink ([Apache-2.0](https://github.com/vishvananda/netlink/blob/v1.1.0/LICENSE)) + +``` + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright 2014 Vishvananda Ishaya. + Copyright 2014 Docker, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +``` +## github.com/vishvananda/netns ([Apache-2.0](https://github.com/vishvananda/netns/blob/0a2b9b5464df/LICENSE)) + +``` + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright 2014 Vishvananda Ishaya. + Copyright 2014 Docker, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +``` +## go.uber.org/multierr ([MIT](https://github.com/uber-go/multierr/blob/v1.10.0/LICENSE.txt)) + +```Copyright (c) 2017-2021 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +``` +## go.uber.org/zap ([MIT](https://github.com/uber-go/zap/blob/v1.25.0/LICENSE.txt)) + +```Copyright (c) 2016-2017 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +``` +## golang.org/x/sys/unix ([BSD-3-Clause](https://cs.opensource.google/go/x/sys/+/v0.6.0:LICENSE)) + +```Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +``` +## gopkg.in/natefinch/lumberjack.v2 ([MIT](https://github.com/natefinch/lumberjack/blob/v2.2.1/LICENSE)) + +```The MIT License (MIT) + +Copyright (c) 2014 Nate Finch + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.``` + +## github.com/aws/aws-ebpf-sdk-go/pkg ([Apache-2.0](https://github.com/aws/aws-ebpf-sdk-go/blob/HEAD/LICENSE)) + +``` + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. +``` +## go.uber.org/multierr ([MIT](https://github.com/uber-go/multierr/blob/v1.10.0/LICENSE.txt)) + +```Copyright (c) 2017-2021 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +``` +## go.uber.org/zap ([MIT](https://github.com/uber-go/zap/blob/v1.25.0/LICENSE.txt)) + +```Copyright (c) 2016-2017 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +``` +## golang.org/x/sys/unix ([BSD-3-Clause](https://cs.opensource.google/go/x/sys/+/v0.6.0:LICENSE)) + +```Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +``` +## gopkg.in/natefinch/lumberjack.v2 ([MIT](https://github.com/natefinch/lumberjack/blob/v2.2.1/LICENSE)) + +```The MIT License (MIT) + +Copyright (c) 2014 Nate Finch + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.``` + +## github.com/aws/aws-ebpf-sdk-go/pkg ([Apache-2.0](https://github.com/aws/aws-ebpf-sdk-go/blob/HEAD/LICENSE)) + +``` + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. +``` +## go.uber.org/multierr ([MIT](https://github.com/uber-go/multierr/blob/v1.10.0/LICENSE.txt)) + +```Copyright (c) 2017-2021 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +``` +## go.uber.org/zap ([MIT](https://github.com/uber-go/zap/blob/v1.25.0/LICENSE.txt)) + +```Copyright (c) 2016-2017 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +``` +## golang.org/x/sys/unix ([BSD-3-Clause](https://cs.opensource.google/go/x/sys/+/v0.6.0:LICENSE)) + +```Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +``` +## gopkg.in/natefinch/lumberjack.v2 ([MIT](https://github.com/natefinch/lumberjack/blob/v2.2.1/LICENSE)) + +```The MIT License (MIT) + +Copyright (c) 2014 Nate Finch + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.``` + +## github.com/aws/aws-ebpf-sdk-go/pkg/logger ([Apache-2.0](https://github.com/aws/aws-ebpf-sdk-go/blob/HEAD/LICENSE)) + +``` + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. +``` +## go.uber.org/multierr ([MIT](https://github.com/uber-go/multierr/blob/v1.10.0/LICENSE.txt)) + +```Copyright (c) 2017-2021 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +``` +## go.uber.org/zap ([MIT](https://github.com/uber-go/zap/blob/v1.25.0/LICENSE.txt)) + +```Copyright (c) 2016-2017 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +``` +## gopkg.in/natefinch/lumberjack.v2 ([MIT](https://github.com/natefinch/lumberjack/blob/v2.2.1/LICENSE)) + +```The MIT License (MIT) + +Copyright (c) 2014 Nate Finch + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.``` + +## github.com/aws/aws-ebpf-sdk-go/pkg ([Apache-2.0](https://github.com/aws/aws-ebpf-sdk-go/blob/HEAD/LICENSE)) + +``` + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. +``` +## go.uber.org/multierr ([MIT](https://github.com/uber-go/multierr/blob/v1.10.0/LICENSE.txt)) + +```Copyright (c) 2017-2021 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +``` +## go.uber.org/zap ([MIT](https://github.com/uber-go/zap/blob/v1.25.0/LICENSE.txt)) + +```Copyright (c) 2016-2017 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +``` +## golang.org/x/sys/unix ([BSD-3-Clause](https://cs.opensource.google/go/x/sys/+/v0.6.0:LICENSE)) + +```Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +``` +## gopkg.in/natefinch/lumberjack.v2 ([MIT](https://github.com/natefinch/lumberjack/blob/v2.2.1/LICENSE)) + +```The MIT License (MIT) + +Copyright (c) 2014 Nate Finch + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.``` + +## github.com/aws/aws-ebpf-sdk-go/pkg ([Apache-2.0](https://github.com/aws/aws-ebpf-sdk-go/blob/HEAD/LICENSE)) + +``` + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. +``` +## github.com/vishvananda/netlink ([Apache-2.0](https://github.com/vishvananda/netlink/blob/v1.1.0/LICENSE)) + +``` + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright 2014 Vishvananda Ishaya. + Copyright 2014 Docker, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +``` +## github.com/vishvananda/netns ([Apache-2.0](https://github.com/vishvananda/netns/blob/0a2b9b5464df/LICENSE)) + +``` + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright 2014 Vishvananda Ishaya. + Copyright 2014 Docker, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +``` +## go.uber.org/multierr ([MIT](https://github.com/uber-go/multierr/blob/v1.10.0/LICENSE.txt)) + +```Copyright (c) 2017-2021 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +``` +## go.uber.org/zap ([MIT](https://github.com/uber-go/zap/blob/v1.25.0/LICENSE.txt)) + +```Copyright (c) 2016-2017 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +``` +## golang.org/x/sys/unix ([BSD-3-Clause](https://cs.opensource.google/go/x/sys/+/v0.6.0:LICENSE)) + +```Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +``` +## gopkg.in/natefinch/lumberjack.v2 ([MIT](https://github.com/natefinch/lumberjack/blob/v2.2.1/LICENSE)) + +```The MIT License (MIT) + +Copyright (c) 2014 Nate Finch + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.``` + +## github.com/aws/aws-ebpf-sdk-go/pkg ([Apache-2.0](https://github.com/aws/aws-ebpf-sdk-go/blob/HEAD/LICENSE)) + +``` + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. +``` +## github.com/vishvananda/netlink ([Apache-2.0](https://github.com/vishvananda/netlink/blob/v1.1.0/LICENSE)) + +``` + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright 2014 Vishvananda Ishaya. + Copyright 2014 Docker, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +``` +## github.com/vishvananda/netns ([Apache-2.0](https://github.com/vishvananda/netns/blob/0a2b9b5464df/LICENSE)) + +``` + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright 2014 Vishvananda Ishaya. + Copyright 2014 Docker, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +``` +## go.uber.org/multierr ([MIT](https://github.com/uber-go/multierr/blob/v1.10.0/LICENSE.txt)) + +```Copyright (c) 2017-2021 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +``` +## go.uber.org/zap ([MIT](https://github.com/uber-go/zap/blob/v1.25.0/LICENSE.txt)) + +```Copyright (c) 2016-2017 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +``` +## golang.org/x/sys/unix ([BSD-3-Clause](https://cs.opensource.google/go/x/sys/+/v0.6.0:LICENSE)) + +```Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +``` +## gopkg.in/natefinch/lumberjack.v2 ([MIT](https://github.com/natefinch/lumberjack/blob/v2.2.1/LICENSE)) + +```The MIT License (MIT) + +Copyright (c) 2014 Nate Finch + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.``` + +## github.com/aws/aws-ebpf-sdk-go/pkg ([Apache-2.0](https://github.com/aws/aws-ebpf-sdk-go/blob/HEAD/LICENSE)) + +``` + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. +``` +## go.uber.org/multierr ([MIT](https://github.com/uber-go/multierr/blob/v1.10.0/LICENSE.txt)) + +```Copyright (c) 2017-2021 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +``` +## go.uber.org/zap ([MIT](https://github.com/uber-go/zap/blob/v1.25.0/LICENSE.txt)) + +```Copyright (c) 2016-2017 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +``` +## golang.org/x/sys/unix ([BSD-3-Clause](https://cs.opensource.google/go/x/sys/+/v0.6.0:LICENSE)) + +```Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +``` +## gopkg.in/natefinch/lumberjack.v2 ([MIT](https://github.com/natefinch/lumberjack/blob/v2.2.1/LICENSE)) + +```The MIT License (MIT) + +Copyright (c) 2014 Nate Finch + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.``` + +## github.com/aws/aws-ebpf-sdk-go/pkg ([Apache-2.0](https://github.com/aws/aws-ebpf-sdk-go/blob/HEAD/LICENSE)) + +``` + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. +``` +## go.uber.org/multierr ([MIT](https://github.com/uber-go/multierr/blob/v1.10.0/LICENSE.txt)) + +```Copyright (c) 2017-2021 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +``` +## go.uber.org/zap ([MIT](https://github.com/uber-go/zap/blob/v1.25.0/LICENSE.txt)) + +```Copyright (c) 2016-2017 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +``` +## golang.org/x/sys/unix ([BSD-3-Clause](https://cs.opensource.google/go/x/sys/+/v0.6.0:LICENSE)) + +```Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +``` +## gopkg.in/natefinch/lumberjack.v2 ([MIT](https://github.com/natefinch/lumberjack/blob/v2.2.1/LICENSE)) + +```The MIT License (MIT) + +Copyright (c) 2014 Nate Finch + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.``` + +## github.com/aws/aws-ebpf-sdk-go/pkg ([Apache-2.0](https://github.com/aws/aws-ebpf-sdk-go/blob/HEAD/LICENSE)) + +``` + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. +``` +## github.com/vishvananda/netlink ([Apache-2.0](https://github.com/vishvananda/netlink/blob/v1.1.0/LICENSE)) + +``` + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright 2014 Vishvananda Ishaya. + Copyright 2014 Docker, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +``` +## github.com/vishvananda/netns ([Apache-2.0](https://github.com/vishvananda/netns/blob/0a2b9b5464df/LICENSE)) + +``` + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright 2014 Vishvananda Ishaya. + Copyright 2014 Docker, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +``` +## go.uber.org/multierr ([MIT](https://github.com/uber-go/multierr/blob/v1.10.0/LICENSE.txt)) + +```Copyright (c) 2017-2021 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +``` +## go.uber.org/zap ([MIT](https://github.com/uber-go/zap/blob/v1.25.0/LICENSE.txt)) + +```Copyright (c) 2016-2017 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +``` +## golang.org/x/sys/unix ([BSD-3-Clause](https://cs.opensource.google/go/x/sys/+/v0.6.0:LICENSE)) + +```Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +``` +## gopkg.in/natefinch/lumberjack.v2 ([MIT](https://github.com/natefinch/lumberjack/blob/v2.2.1/LICENSE)) + +```The MIT License (MIT) + +Copyright (c) 2014 Nate Finch + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.``` From 136330d9523f521cf15d2de08b5c62a3cc0be1a9 Mon Sep 17 00:00:00 2001 From: Jayanth Varavani <1111446+jayanthvn@users.noreply.github.com> Date: Mon, 28 Aug 2023 12:34:51 -0700 Subject: [PATCH 10/29] readme-v1 (#30) --- README.md | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 112 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 847260c..d6b03f9 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,123 @@ -## My Project +# aws-ebpf-sdk-go -TODO: Fill this README out! +Golang based SDK for kernel eBPF operations i.e, load/attach/detach eBPF programs and create/delete/update maps. SDK relies on Unix bpf() system calls. -Be sure to: +SDK currently supports below eBPF program types - -* Change the title in this README -* Edit your repository description on GitHub +1. Traffic Classifiers +2. XDP +3. Kprobes/Kretprobes +4. Tracepoint probes + +Ring buffer support is available and that would need kernel 5.10+. Map in Map support and perf buffer support is not yet available. + +Contributions welcome! + +Note: This is the first version of SDK and interface is subject to change so kindly review the release notes before upgrading. + +# Getting started + +## How to build SDK? + +Run `make buid-linux` - this will build the sdk binary. + +## How to build elf file? + +``` +clang -I../../.. -O2 -target bpf -c -o +``` + +## How to use the SDK? + +**Note:** SDK expects the BPF File System (/sys/fs/bpf) to be mounted. + +In your application, + +1. Get the latest SDK - + +``` +GOPROXY=direct go get github.com/aws/aws-ebpf-sdk-go +``` + +2. Import the elfparser - + +``` +goebpfelfparser "github.com/aws/aws-ebpf-sdk-go/pkg/elfparser" +``` + +3. Load the elf - + +``` +goebpfelfparser.LoadBpfFile(, ) +``` + +On a successful load, SDK returns - + +1. loaded programs (includes associated maps) + +``` +This is indexed by the pinpath - + +type BpfData struct { + Program ebpf_progs.BpfProgram // Return the program + Maps map[string]ebpf_maps.BpfMap // List of associated maps +} +``` + +2. All maps in the elf file +``` +This is indexed by the map name - + +type BpfMap struct { + MapFD uint32 + MapID uint32 + MapMetaData CreateEBPFMapInput +} +``` + +Application can specify custom pinpath while loading the elf file. + +Maps and Programs pinpath location is not customizable with the current version of SDK and will be installed under the below locations by default - + +Program PinPath - "/sys/fs/bpf/globals/aws/programs/" + +Map PinPath - "/sys/fs/bpf/globals/aws/maps/" + +Map defintion should follow the below definition else the SDK will fail to create the map. + +``` +struct bpf_map_def_pvt { + __u32 type; + __u32 key_size; + __u32 value_size; + __u32 max_entries; + __u32 map_flags; + __u32 pinning; + __u32 inner_map_fd; +}; +``` +## How to run unit-test + +Run `sudo make unit-test` + +Note: you would need to run this on you linux system + +## How to run functional tests + +Go to - + +``` +cd test/ +make run-test +``` ## Security See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information. +If you think you’ve found a potential security issue, please do not post it in the Issues. Instead, please follow the +instructions [here](https://aws.amazon.com/security/vulnerability-reporting/) or [email AWS security directly](mailto:aws-security@amazon.com). + ## License This project is licensed under the Apache-2.0 License. From fe6b55b97389bcd03d6b9bdaffca4a95269a019a Mon Sep 17 00:00:00 2001 From: Jayanth Varavani <1111446+jayanthvn@users.noreply.github.com> Date: Mon, 28 Aug 2023 14:48:09 -0700 Subject: [PATCH 11/29] Update README.md (#33) --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index d6b03f9..52e9658 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,11 @@ struct bpf_map_def_pvt { __u32 inner_map_fd; }; ``` + +## How to debug SDK issues? + +SDK logs are located here `/var/log/aws-routed-eni/ebpf-sdk.log`. + ## How to run unit-test Run `sudo make unit-test` From 1de786ecbabb57a8441aeef3286db884ab010a60 Mon Sep 17 00:00:00 2001 From: Jayanth Varavani <1111446+jayanthvn@users.noreply.github.com> Date: Mon, 28 Aug 2023 14:51:07 -0700 Subject: [PATCH 12/29] Update README.md --- README.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 52e9658..b914a78 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,19 @@ Golang based SDK for kernel eBPF operations i.e, load/attach/detach eBPF programs and create/delete/update maps. SDK relies on Unix bpf() system calls. -SDK currently supports below eBPF program types - +SDK currently supports - -1. Traffic Classifiers -2. XDP -3. Kprobes/Kretprobes -4. Tracepoint probes +1. eBPF program types - + a. Traffic Classifiers + b. XDP + c. Kprobes/Kretprobes + d. Tracepoint probes +2. Ring buffer (would need kernel 5.10+) -Ring buffer support is available and that would need kernel 5.10+. Map in Map support and perf buffer support is not yet available. +SDK currently do not support - + +1. Map in Map +2. Perf buffer Contributions welcome! From 8938dadde8df16a30c6b1ed794cc68e34d9866cc Mon Sep 17 00:00:00 2001 From: Alex Jones Date: Tue, 29 Aug 2023 21:53:05 +0100 Subject: [PATCH 13/29] chore: spelling in README (#36) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b914a78..38c05da 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Note: This is the first version of SDK and interface is subject to change so kin ## How to build SDK? -Run `make buid-linux` - this will build the sdk binary. +Run `make build-linux` - this will build the sdk binary. ## How to build elf file? From cde5984d65fb75f4128d636a797701167e4674fb Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Wed, 30 Aug 2023 10:27:25 -0400 Subject: [PATCH 14/29] Add github action for functional tests --- .github/workflows/pr-tests.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/pr-tests.yaml b/.github/workflows/pr-tests.yaml index 652d183..c00f722 100644 --- a/.github/workflows/pr-tests.yaml +++ b/.github/workflows/pr-tests.yaml @@ -36,3 +36,20 @@ jobs: run: sudo make unit-test - name: Upload code coverage uses: codecov/codecov-action@v3 + functional-test: + name: Functional test + runs-on: ubuntu-latest + steps: + - name: Checkout latest commit in the PR + uses: actions/checkout@v3 + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: "1.20" + - name: Set up BPF + run: | + sudo apt-get install libbpf-dev + - name: Build + run: make build-linux + - name: Functional test + run: cd test && sudo make run-test \ No newline at end of file From a0b87792beac0a89f1e3980a2abe28b8be360680 Mon Sep 17 00:00:00 2001 From: Jayanth Varavani <1111446+jayanthvn@users.noreply.github.com> Date: Wed, 30 Aug 2023 07:27:57 -0700 Subject: [PATCH 15/29] Merge issue with func tests (#38) --- README.md | 2 +- test/go.mod | 11 ++++++----- test/go.sum | 22 +++++++++++----------- test/main.go | 22 ++++++++++++++-------- 4 files changed, 32 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 38c05da..51f20a8 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ Go to - ``` cd test/ -make run-test +sudo make run-test ``` ## Security diff --git a/test/go.mod b/test/go.mod index 93dec34..041da3f 100644 --- a/test/go.mod +++ b/test/go.mod @@ -2,17 +2,18 @@ module github.com/jayanthvn/pure-gobpf/test go 1.19 -require github.com/aws/aws-ebpf-sdk-go v0.0.0-20230616053809-009e64b9692e +require ( + github.com/aws/aws-ebpf-sdk-go v0.0.0-20230616053809-009e64b9692e + github.com/fatih/color v1.15.0 +) require ( - github.com/fatih/color v1.15.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.17 // indirect github.com/vishvananda/netlink v1.1.0 // indirect github.com/vishvananda/netns v0.0.4 // indirect - go.uber.org/atomic v1.7.0 // indirect - go.uber.org/multierr v1.6.0 // indirect - go.uber.org/zap v1.24.0 // indirect + go.uber.org/multierr v1.10.0 // indirect + go.uber.org/zap v1.25.0 // indirect golang.org/x/sys v0.6.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect ) diff --git a/test/go.sum b/test/go.sum index db3d7ef..2665cf2 100644 --- a/test/go.sum +++ b/test/go.sum @@ -1,29 +1,29 @@ -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= +github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/vishvananda/netlink v1.1.0 h1:1iyaYNBLmP6L0220aDnYQpo1QEV4t4hJ+xEEhhJH8j0= github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU= github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8= github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= -go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= -go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= -go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= -go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= +go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= +go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= +go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= +go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk= golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/test/main.go b/test/main.go index aefb4df..238b4c9 100644 --- a/test/main.go +++ b/test/main.go @@ -97,7 +97,8 @@ func main() { } func TestLoadProg() error { - progInfo, _, err := goelf.LoadBpfFile("c/test.bpf.elf", "test") + gosdkClient := goelf.New() + progInfo, _, err := gosdkClient.LoadBpfFile("c/test.bpf.elf", "test") if err != nil { fmt.Println("Load BPF failed", "err:", err) return err @@ -110,7 +111,8 @@ func TestLoadProg() error { } func TestLoadMapWithNoProg() error { - _, loadedMap, err := goelf.LoadBpfFile("c/test-map.bpf.elf", "test") + gosdkClient := goelf.New() + _, loadedMap, err := gosdkClient.LoadBpfFile("c/test-map.bpf.elf", "test") if err != nil { fmt.Println("Load BPF failed", "err:", err) return err @@ -124,7 +126,8 @@ func TestLoadMapWithNoProg() error { } func TestMapOperations() error { - _, loadedMap, err := goelf.LoadBpfFile("c/test-map.bpf.elf", "operations") + gosdkClient := goelf.New() + _, loadedMap, err := gosdkClient.LoadBpfFile("c/test-map.bpf.elf", "operations") if err != nil { fmt.Println("Load BPF failed", "err:", err) return err @@ -260,7 +263,8 @@ func TestMapOperations() error { } func TestLoadTCfilter() error { - progInfo, _, err := goelf.LoadBpfFile("c/test.bpf.elf", "test") + gosdkClient := goelf.New() + progInfo, _, err := gosdkClient.LoadBpfFile("c/test.bpf.elf", "test") if err != nil { fmt.Println("Load BPF failed", "err:", err) return err @@ -273,23 +277,25 @@ func TestLoadTCfilter() error { tcProg := progInfo["/sys/fs/bpf/globals/aws/programs/test_handle_ingress"].Program progFD := tcProg.ProgFD + gosdkTcClient := ebpf_tc.New("lo") + fmt.Println("Try Attach ingress probe") - err = ebpf_tc.TCIngressAttach("lo", int(progFD), "ingress_test") + err = gosdkTcClient.TCIngressAttach("lo", int(progFD), "ingress_test") if err != nil { fmt.Println("Failed attaching ingress probe") } fmt.Println("Try Attach egress probe") - err = ebpf_tc.TCEgressAttach("lo", int(progFD), "egress_test") + err = gosdkTcClient.TCEgressAttach("lo", int(progFD), "egress_test") if err != nil { fmt.Println("Failed attaching ingress probe") } fmt.Println("Try Detach ingress probe") - err = ebpf_tc.TCIngressDetach("lo") + err = gosdkTcClient.TCIngressDetach("lo") if err != nil { fmt.Println("Failed attaching ingress probe") } fmt.Println("Try Detach egress probe") - err = ebpf_tc.TCEgressDetach("lo") + err = gosdkTcClient.TCEgressDetach("lo") if err != nil { fmt.Println("Failed attaching ingress probe") } From 99a3782a099dd8b2d4e2e165ec60fe26983eb0f0 Mon Sep 17 00:00:00 2001 From: Eishun Kondoh Date: Wed, 6 Sep 2023 05:47:52 +0900 Subject: [PATCH 16/29] test-data: Fix to use __builtin_memset() instead of memset() (#40) In BPF programs, when using functions like `memset()` and `memcpy()`, you should use LLVM built-in functions like `__builtin_memset()`. Signed-off-by: shun159 --- test-data/recoverydata.bpf.c | 2 +- test-data/tc.ingress.bpf.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test-data/recoverydata.bpf.c b/test-data/recoverydata.bpf.c index dcc289b..7362700 100644 --- a/test-data/recoverydata.bpf.c +++ b/test-data/recoverydata.bpf.c @@ -81,7 +81,7 @@ int conn_del(struct pt_regs *ctx) { struct nf_conn new_ct = {}; bpf_probe_read(&new_ct, sizeof(new_ct), ct); struct conntrack_key flow_key = {}; - memset(&flow_key, 0, sizeof(flow_key)); + __builtin_memset(&flow_key, 0, sizeof(flow_key)); struct nf_conntrack_tuple_hash tuplehash[IP_CT_DIR_MAX]; bpf_probe_read(&tuplehash, sizeof(tuplehash), &new_ct.tuplehash); diff --git a/test-data/tc.ingress.bpf.c b/test-data/tc.ingress.bpf.c index 4f1f10b..e96874e 100644 --- a/test-data/tc.ingress.bpf.c +++ b/test-data/tc.ingress.bpf.c @@ -97,7 +97,7 @@ int conn_del(struct pt_regs *ctx) { struct nf_conn new_ct = {}; bpf_probe_read(&new_ct, sizeof(new_ct), ct); struct conntrack_key flow_key = {}; - memset(&flow_key, 0, sizeof(flow_key)); + __builtin_memset(&flow_key, 0, sizeof(flow_key)); struct nf_conntrack_tuple_hash tuplehash[IP_CT_DIR_MAX]; bpf_probe_read(&tuplehash, sizeof(tuplehash), &new_ct.tuplehash); From 3f5271fdef96ec66a3280155dac9756ea54ec02e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Sep 2023 14:12:13 -0700 Subject: [PATCH 17/29] Bump golang.org/x/sys from 0.6.0 to 0.12.0 (#41) Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.6.0 to 0.12.0. - [Commits](https://github.com/golang/sys/compare/v0.6.0...v0.12.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 5 +---- go.sum | 8 ++------ 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index 9ea4132..1b314f0 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/stretchr/testify v1.8.4 github.com/vishvananda/netlink v1.1.0 go.uber.org/zap v1.25.0 - golang.org/x/sys v0.6.0 + golang.org/x/sys v0.12.0 gopkg.in/natefinch/lumberjack.v2 v2.2.1 ) @@ -16,8 +16,5 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df // indirect go.uber.org/multierr v1.10.0 // indirect - golang.org/x/mod v0.4.2 // indirect - golang.org/x/tools v0.1.1 // indirect - golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 89bf75d..a3840bc 100644 --- a/go.sum +++ b/go.sum @@ -5,7 +5,6 @@ github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/vishvananda/netlink v1.1.0 h1:1iyaYNBLmP6L0220aDnYQpo1QEV4t4hJ+xEEhhJH8j0= @@ -20,7 +19,6 @@ go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -33,18 +31,16 @@ golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.1 h1:wGiQel/hW0NnEkJUk8lbzkX2gFJU6PFxf1v5OlCfuOs= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From 7c74cf112e9c8d57b975da6977cdb6abc21df8a7 Mon Sep 17 00:00:00 2001 From: Jayanth Varavani <1111446+jayanthvn@users.noreply.github.com> Date: Wed, 6 Sep 2023 12:56:30 -0700 Subject: [PATCH 18/29] Fixup poller for events race condition (#43) * Fixup poller for events race condition * Testing package go tidy --- pkg/events/events.go | 68 ++++++++++++++++++++++------------------ pkg/events/poll/epoll.go | 1 + test/go.mod | 2 +- test/go.sum | 4 +-- 4 files changed, 41 insertions(+), 34 deletions(-) diff --git a/pkg/events/events.go b/pkg/events/events.go index ba04ab6..0190c4c 100644 --- a/pkg/events/events.go +++ b/pkg/events/events.go @@ -38,8 +38,9 @@ var _ Events = &events{} func New() Events { return &events{ - PageSize: os.Getpagesize(), - RingCnt: 0, + PageSize: os.Getpagesize(), + RingCnt: 0, + EventFdCnt: 0, } } @@ -48,6 +49,7 @@ type events struct { RingBuffers []*RingBuffer PageSize int RingCnt int + EventFdCnt int eventsStopChannel chan struct{} wg sync.WaitGroup eventsDataChannel chan []byte @@ -138,13 +140,14 @@ func (ev *events) setupRingBuffer(mapFD int, maxEntries uint32) (chan []byte, er ringbuffer.Data = unsafe.Pointer(uintptr(unsafe.Pointer(&producer[0])) + uintptr(ev.PageSize)) ev.RingBuffers = append(ev.RingBuffers, ringbuffer) - ev.RingCnt++ - err = ev.epoller.AddEpollCtl(mapFD, ev.RingCnt) + err = ev.epoller.AddEpollCtl(mapFD, ev.EventFdCnt) if err != nil { unix.Munmap(producer) return nil, fmt.Errorf("failed to Epoll event: %s", err) } + ev.RingCnt++ + ev.EventFdCnt++ //Start channels read ev.eventsStopChannel = make(chan struct{}) @@ -197,40 +200,43 @@ func (ev *events) reconcileEventsDataChannel() { <-ev.eventsStopChannel } -// Similar to libbpf poll ring +// Similar to libbpf poll and process ring +// Ref: https://github.com/torvalds/linux/blob/744a759492b5c57ff24a6e8aabe47b17ad8ee964/tools/lib/bpf/ringbuf.c#L227 func (ev *events) readRingBuffer(eventRing *RingBuffer) { - readDone := true consPosition := eventRing.getConsumerPosition() - for !readDone { - readDone = ev.parseBuffer(consPosition, eventRing) - } + ev.parseBuffer(consPosition, eventRing) } -func (ev *events) parseBuffer(consumerPosition uint64, eventRing *RingBuffer) bool { - readDone := true - producerPosition := eventRing.getProducerPosition() - for consumerPosition < producerPosition { - - // Get the header - Data points to the DataPage which will be offset by consumerPosition - ringdata := eventRing.ParseRingData(consumerPosition) - - // Check if busy then skip, Might not be committed yet - // There are 2 steps -> reserve and then commit/discard - if ringdata.BusyRecord { - readDone = true - break - } +func (ev *events) parseBuffer(consumerPosition uint64, eventRing *RingBuffer) { + var readDone bool + for { + readDone = true + producerPosition := eventRing.getProducerPosition() + for consumerPosition < producerPosition { + + // Get the header - Data points to the DataPage which will be offset by consumerPosition + ringdata := eventRing.ParseRingData(consumerPosition) + + // Check if busy then skip, Might not be committed yet + // There are 2 steps -> reserve and then commit/discard + if ringdata.BusyRecord { + readDone = true + break + } - readDone = false + readDone = false - // Update the position to the next record irrespective of discard or commit of data - consumerPosition += uint64(ringdata.RecordLen) + // Update the position to the next record irrespective of discard or commit of data + consumerPosition += uint64(ringdata.RecordLen) - //Pick the data only if committed - if !ringdata.DiscardRecord { - ev.eventsDataChannel <- ringdata.parseSample() + //Pick the data only if committed + if !ringdata.DiscardRecord { + ev.eventsDataChannel <- ringdata.parseSample() + } + eventRing.setConsumerPosition(consumerPosition) + } + if readDone { + break } - eventRing.setConsumerPosition(consumerPosition) } - return readDone } diff --git a/pkg/events/poll/epoll.go b/pkg/events/poll/epoll.go index a0ce64d..8cb7288 100644 --- a/pkg/events/poll/epoll.go +++ b/pkg/events/poll/epoll.go @@ -49,6 +49,7 @@ func (e *EventPoller) AddEpollCtl(mapFD, eventFD int) error { return fmt.Errorf("failed to Epoll event: %s", err) } e.epollEvent = append(e.epollEvent, epollEvent) + e.bufferCnt++ return nil } diff --git a/test/go.mod b/test/go.mod index 041da3f..aa91a81 100644 --- a/test/go.mod +++ b/test/go.mod @@ -14,7 +14,7 @@ require ( github.com/vishvananda/netns v0.0.4 // indirect go.uber.org/multierr v1.10.0 // indirect go.uber.org/zap v1.25.0 // indirect - golang.org/x/sys v0.6.0 // indirect + golang.org/x/sys v0.12.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect ) diff --git a/test/go.sum b/test/go.sum index 2665cf2..2eed2e2 100644 --- a/test/go.sum +++ b/test/go.sum @@ -22,8 +22,8 @@ go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk= golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= From 8103f70b612f5548c7752b1b3d58228390b22ffc Mon Sep 17 00:00:00 2001 From: Eishun Kondoh Date: Thu, 7 Sep 2023 10:47:15 +0900 Subject: [PATCH 19/29] makefile: fix to remove unused option from build-bpf target (#42) * makefile: fix to remove unused option from build-bpf target Signed-off-by: shun159 * makefile: refactor using pattern rule Signed-off-by: shun159 --------- Signed-off-by: shun159 --- Makefile | 48 +++++++++++++++++++----------------------------- 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index 9a96937..fd046bd 100644 --- a/Makefile +++ b/Makefile @@ -32,34 +32,20 @@ vet: ## Run go vet on source code. # Build BPF CLANG := clang CLANG_INCLUDE := -I../../.. -EBPF_SOURCE := test-data/tc.ingress.bpf.c -EBPF_BINARY := test-data/tc.ingress.bpf.elf -EBPF_TEST_SOURCE := test-data/tc.bpf.c -EBPF_TEST_BINARY := test-data/tc.bpf.elf -EBPF_TEST_MAP_SOURCE := test-data/test.map.bpf.c -EBPF_TEST_MAP_BINARY := test-data/test.map.bpf.elf -EBPF_TEST_LIC_SOURCE := test-data/test_license.bpf.c -EBPF_TEST_LIC_BINARY := test-data/test_license.bpf.elf -EBPF_TEST_INV_MAP_SOURCE := test-data/invalid_map.bpf.c -EBPF_TEST_INV_MAP_BINARY := test-data/invalid_map.bpf.elf -EBPF_TEST_RECOVERY_SOURCE := test-data/recoverydata.bpf.c -EBPF_TEST_RECOVERY_BINARY := test-data/recoverydata.bpf.elf -EBPF_TEST_KPROBE_SOURCE := test-data/test-kprobe.bpf.c -EBPF_TEST_KPROBE_BINARY := test-data/test-kprobe.bpf.elf -EBPF_TEST_XDP_SOURCE := test-data/xdp.bpf.c -EBPF_TEST_XDP_BINARY := test-data/xdp.bpf.elf -EBPF_TEST_RINGBUFFER_SOURCE := test-data/ring_buffer.bpf.c -EBPF_TEST_RINGBUFFER_BINARY := test-data/ring_buffer.bpf.elf -build-bpf: ## Build BPF - $(CLANG) $(CLANG_INCLUDE) -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -march=bpf -D__TARGET_ARCH_$(ARCH) -c $(EBPF_SOURCE) -o $(EBPF_BINARY) - $(CLANG) $(CLANG_INCLUDE) -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -march=bpf -D__TARGET_ARCH_$(ARCH) -c $(EBPF_TEST_SOURCE) -o $(EBPF_TEST_BINARY) - $(CLANG) $(CLANG_INCLUDE) -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -march=bpf -D__TARGET_ARCH_$(ARCH) -c $(EBPF_TEST_MAP_SOURCE) -o $(EBPF_TEST_MAP_BINARY) - $(CLANG) $(CLANG_INCLUDE) -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -march=bpf -D__TARGET_ARCH_$(ARCH) -c $(EBPF_TEST_LIC_SOURCE) -o $(EBPF_TEST_LIC_BINARY) - $(CLANG) $(CLANG_INCLUDE) -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -march=bpf -D__TARGET_ARCH_$(ARCH) -c $(EBPF_TEST_INV_MAP_SOURCE) -o $(EBPF_TEST_INV_MAP_BINARY) - $(CLANG) $(CLANG_INCLUDE) -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -march=bpf -D__TARGET_ARCH_$(ARCH) -c $(EBPF_TEST_RECOVERY_SOURCE) -o $(EBPF_TEST_RECOVERY_BINARY) - $(CLANG) $(CLANG_INCLUDE) -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -march=bpf -D__TARGET_ARCH_$(ARCH) -c $(EBPF_TEST_KPROBE_SOURCE) -o $(EBPF_TEST_KPROBE_BINARY) - $(CLANG) $(CLANG_INCLUDE) -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -march=bpf -D__TARGET_ARCH_$(ARCH) -c $(EBPF_TEST_XDP_SOURCE) -o $(EBPF_TEST_XDP_BINARY) - $(CLANG) $(CLANG_INCLUDE) -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -march=bpf -D__TARGET_ARCH_$(ARCH) -c $(EBPF_TEST_RINGBUFFER_SOURCE) -o $(EBPF_TEST_RINGBUFFER_BINARY) +BPF_CFLAGS := -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -D__TARGET_ARCH_$(ARCH) +TARGETS := \ + test-data/tc.ingress \ + test-data/tc \ + test-data/test.map \ + test-data/test_license \ + test-data/invalid_map \ + test-data/recoverydata \ + test-data/test-kprobe \ + test-data/xdp \ + test-data/ring_buffer + +%.bpf.elf: %.bpf.c + $(CLANG) $(CLANG_INCLUDE) $(BPF_CFLAGS) -c $< -o $@ vmlinuxh: bpftool btf dump file /sys/kernel/btf/vmlinux format c > $(abspath ./test-data/vmlinux.h) @@ -67,7 +53,11 @@ vmlinuxh: ##@ Run Unit Tests # Run unit tests unit-test: vmlinuxh -unit-test: build-bpf +unit-test: $(addsuffix .bpf.elf,$(TARGETS)) unit-test: export AWS_EBPF_SDK_LOG_FILE=stdout unit-test: ## Run unit tests go test -v -coverprofile=coverage.txt -covermode=atomic ./pkg/... + +.PHONY: clean +clean: + -@rm -f test-data/*.elf From 07b0ce04e3e3ac6caf9c8f39badc6d1adf04e654 Mon Sep 17 00:00:00 2001 From: Eishun Kondoh Date: Fri, 15 Sep 2023 03:18:23 +0900 Subject: [PATCH 20/29] test-data: fix to solve compile warning for test-data (#45) * test-data: fix to solve compile warning for test-data use `void`instead of the `struct sched_process_fork_t` to solve compile warnings for resolvedata and tc.ingress ```shellsesson $ doas make test-data/recoverydata.bpf.elf clang -I../../.. -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -D__TARGET_ARCH_x86 -c test-data/recoverydata.bpf.c -o test-data/recoverydata.bpf.elf test-data/recoverydata.bpf.c:101:31: warning: declaration of 'struct sched_process_fork_t' will not be visible outside of this function [-Wvisibility] int sched_process_fork(struct sched_process_fork_t *ctx) { ^ 1 warning generated. ``` Signed-off-by: shun159 * makefile: Refactor the vmlinux and unit-test targets 1. Check the existence of the /sys/kernel/btf/vmlinux file before generating the header file using bpftool. 2. Improve the idempotency of the vmlinux target. 3. Add the `LOGFILE_PATH` variable to allow specifying a different path for the `AWS_EBPF_SDK_LOG_FILE`. Signed-off-by: shun159 --------- Signed-off-by: shun159 --- Makefile | 43 +++++++++++++++++++++++------------- test-data/recoverydata.bpf.c | 2 +- test-data/tc.ingress.bpf.c | 2 +- 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index fd046bd..eb2b0c7 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,12 @@ export GOPROXY = direct +CURDIR := $(abspath .) +TESTDATADIR := $(CURDIR)/test-data +BPFTOOL := bpftool +CLANG := clang +LOGFILE_PATH ?= stdout + UNAME_ARCH = $(shell uname -m) ARCH = $(lastword $(subst :, ,$(filter $(UNAME_ARCH):%,x86_64:x86 aarch64:arm64))) @@ -29,35 +35,42 @@ check-format: format vet: ## Run go vet on source code. go vet $(ALLPKGS) + # Build BPF -CLANG := clang CLANG_INCLUDE := -I../../.. BPF_CFLAGS := -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -D__TARGET_ARCH_$(ARCH) TARGETS := \ - test-data/tc.ingress \ - test-data/tc \ - test-data/test.map \ - test-data/test_license \ - test-data/invalid_map \ - test-data/recoverydata \ - test-data/test-kprobe \ - test-data/xdp \ - test-data/ring_buffer + $(TESTDATADIR)/tc.ingress \ + $(TESTDATADIR)/tc \ + $(TESTDATADIR)/test.map \ + $(TESTDATADIR)/test_license \ + $(TESTDATADIR)/invalid_map \ + $(TESTDATADIR)/recoverydata \ + $(TESTDATADIR)/test-kprobe \ + $(TESTDATADIR)/xdp \ + $(TESTDATADIR)/ring_buffer %.bpf.elf: %.bpf.c $(CLANG) $(CLANG_INCLUDE) $(BPF_CFLAGS) -c $< -o $@ -vmlinuxh: - bpftool btf dump file /sys/kernel/btf/vmlinux format c > $(abspath ./test-data/vmlinux.h) +## check if the vmlinux exists in /sys/kernel/btf directory +VMLINUX_BTF ?= $(wildcard /sys/kernel/btf/vmlinux) +ifeq ($(VMLINUX_BTF),) +$(error Cannot find a vmlinux) +endif + +$(TESTDATADIR)/vmlinux.h: + $(BPFTOOL) btf dump file $(VMLINUX_BTF) format c > $@ ##@ Run Unit Tests # Run unit tests -unit-test: vmlinuxh +unit-test: $(TESTDATADIR)/vmlinux.h unit-test: $(addsuffix .bpf.elf,$(TARGETS)) -unit-test: export AWS_EBPF_SDK_LOG_FILE=stdout +unit-test: export AWS_EBPF_SDK_LOG_FILE=$(LOGFILE_PATH) unit-test: ## Run unit tests go test -v -coverprofile=coverage.txt -covermode=atomic ./pkg/... .PHONY: clean clean: - -@rm -f test-data/*.elf + -@rm -f $(TESTDATADIR)/vmlinux.h + -@rm -f $(TESTDATADIR)/*.elf diff --git a/test-data/recoverydata.bpf.c b/test-data/recoverydata.bpf.c index 7362700..afb336c 100644 --- a/test-data/recoverydata.bpf.c +++ b/test-data/recoverydata.bpf.c @@ -96,7 +96,7 @@ int conn_del(struct pt_regs *ctx) { } SEC("tracepoint/sched/sched_process_fork") -int sched_process_fork(struct sched_process_fork_t *ctx) { +int sched_process_fork(void *ctx) { return 0; } diff --git a/test-data/tc.ingress.bpf.c b/test-data/tc.ingress.bpf.c index e96874e..907f7bb 100644 --- a/test-data/tc.ingress.bpf.c +++ b/test-data/tc.ingress.bpf.c @@ -119,7 +119,7 @@ int conn_del(struct pt_regs *ctx) { } SEC("tracepoint/sched/sched_process_fork") -int sched_process_fork(struct sched_process_fork_t *ctx) { +int sched_process_fork(void *ctx) { return 0; } From 91484553c7b7187d45026c2780c735e076840538 Mon Sep 17 00:00:00 2001 From: Eishun Kondoh Date: Mon, 18 Sep 2023 08:38:54 +0900 Subject: [PATCH 21/29] kprobe: Add defer statements for resource cleanup in KprobeAttach()/KretprobeAttach (#46) Ensure that file handle is properly closed using `defer` statements. Signed-off-by: shun159 --- pkg/kprobe/kprobe.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/kprobe/kprobe.go b/pkg/kprobe/kprobe.go index da32b68..25273dc 100644 --- a/pkg/kprobe/kprobe.go +++ b/pkg/kprobe/kprobe.go @@ -87,6 +87,7 @@ func (k *bpfKprobe) KprobeAttach() error { log.Errorf("error opening kprobe_events file: %v", err) return err } + defer file.Close() eventString := fmt.Sprintf("p:kprobes/%s %s", k.eventName, k.funcName) _, err = file.WriteString(eventString) @@ -173,6 +174,7 @@ func (k *bpfKprobe) KretprobeAttach() error { log.Errorf("error opening kprobe_events file: %v", err) return err } + defer file.Close() eventString := fmt.Sprintf("r4096:kretprobes/%s %s", k.eventName, k.funcName) _, err = file.WriteString(eventString) From f141814508d0f1e22f8d90230680e09cac5e995c Mon Sep 17 00:00:00 2001 From: Jayanth Varavani <1111446+jayanthvn@users.noreply.github.com> Date: Thu, 12 Oct 2023 19:43:05 -0700 Subject: [PATCH 22/29] Add v6 test and inc log level (#53) --- pkg/progs/loader.go | 14 ++++- test/c/test-v6.bpf.c | 142 +++++++++++++++++++++++++++++++++++++++++++ test/c/test.bpf.c | 14 ++++- test/main.go | 15 +++++ 4 files changed, 182 insertions(+), 3 deletions(-) create mode 100644 test/c/test-v6.bpf.c diff --git a/pkg/progs/loader.go b/pkg/progs/loader.go index 1c71ed6..b5eaf74 100644 --- a/pkg/progs/loader.go +++ b/pkg/progs/loader.go @@ -19,6 +19,7 @@ import ( "os" "path/filepath" "runtime" + "strings" "syscall" "unsafe" @@ -184,6 +185,12 @@ func (m *BpfProgram) UnPinProg(pinPath string) error { return unix.Close(int(m.ProgFD)) } +func parseLogs(log []byte) []string { + logStr := string(log) + logs := strings.Split(logStr, "\n") + return logs +} + func (m *BpfProgram) LoadProg(progMetaData CreateEBPFProgInput) (int, error) { var prog_type uint32 @@ -209,7 +216,7 @@ func (m *BpfProgram) LoadProg(progMetaData CreateEBPFProgInput) (int, error) { ProgType: prog_type, LogBuf: uintptr(unsafe.Pointer(&logBuf[0])), LogSize: uint32(cap(logBuf) - 1), - LogLevel: 1, + LogLevel: 4, } program.Insns = uintptr(unsafe.Pointer(&progMetaData.ProgData[0])) @@ -227,7 +234,10 @@ func (m *BpfProgram) LoadProg(progMetaData CreateEBPFProgInput) (int, error) { log.Infof("Load prog done with fd : %d", int(fd)) if errno != 0 { - log.Errorf(string(logBuf)) + logArray := parseLogs(logBuf) + for _, str := range logArray { + fmt.Println(str) + } return -1, errno } diff --git a/test/c/test-v6.bpf.c b/test/c/test-v6.bpf.c new file mode 100644 index 0000000..6617760 --- /dev/null +++ b/test/c/test-v6.bpf.c @@ -0,0 +1,142 @@ +#include "vmlinux.h" +#include +#include +#include + +#define BPF_F_NO_PREALLOC 1 +#define ETH_HLEN 14 +#define BPF_MAP_ID_INGRESS_MAP 2 +#define MAX_RULES 256 +#define MIN_RULES 128 +#define PIN_GLOBAL_NS 2 +#define RESERVED_IP_PROTOCOL 255 +#define ANY_IP_PROTOCOL 254 +#define ANY_PORT 0 + +struct bpf_map_def_pvt { + __u32 type; + __u32 key_size; + __u32 value_size; + __u32 max_entries; + __u32 map_flags; + __u32 pinning; + __u32 inner_map_fd; +}; + +struct keystruct +{ + __u32 prefix_len; + __u8 ip[16]; +}; + +struct lpm_trie_key { + __u32 prefixlen; + __u8 ip[16]; +}; + +struct lpm_trie_val { + __u32 protocol; + __u32 start_port; + __u32 end_port; +}; + +struct bpf_map_def_pvt SEC("maps") ingress_map = { + .type = BPF_MAP_TYPE_LPM_TRIE, + .key_size =sizeof(struct lpm_trie_key), + .value_size = sizeof(struct lpm_trie_val[30]), + .max_entries = 65536, + .map_flags = BPF_F_NO_PREALLOC, + .pinning = PIN_GLOBAL_NS, +}; + + +SEC("tc_cls") +int handle_ingress(struct __sk_buff *skb) +{ + struct keystruct trie_key; + struct lpm_trie_val *trie_val; + __u16 l4_src_port = 0; + __u16 l4_dst_port = 0; + void *data_end = (void *)(long)skb->data_end; + void *data = (void *)(long)skb->data; + + + struct ethhdr *ether = data; + if (data + sizeof(*ether) > data_end) { + return BPF_OK; + } + + if (ether->h_proto == 0xdd86) { // htons(ETH_P_IPV6) -> 0x086ddU + data += sizeof(*ether); + struct ipv6hdr *ip = data; + struct tcphdr *l4_tcp_hdr = data + sizeof(struct ipv6hdr); + struct udphdr *l4_udp_hdr = data + sizeof(struct ipv6hdr); + struct sctphdr *l4_sctp_hdr = data + sizeof(struct ipv6hdr); + + if (data + sizeof(*ip) > data_end) { + return BPF_OK; + } + + if (ip->version != 6) { + return BPF_OK; + } + + //ICMPv6 - Neighbor Discovery Packets + if (ip->nexthdr == 58) { + return BPF_OK; + } + + switch (ip->nexthdr) { + case IPPROTO_TCP: + if (data + sizeof(*ip) + sizeof(*l4_tcp_hdr) > data_end) { + return BPF_OK; + } + l4_src_port = (((((unsigned short)(l4_tcp_hdr->source) & 0xFF)) << 8) | (((unsigned short)(l4_tcp_hdr->source) & 0xFF00) >> 8)); + l4_dst_port = (((((unsigned short)(l4_tcp_hdr->dest) & 0xFF)) << 8) | (((unsigned short)(l4_tcp_hdr->dest) & 0xFF00) >> 8)); + break; + case IPPROTO_UDP: + if (data + sizeof(*ip) + sizeof(*l4_udp_hdr) > data_end) { + return BPF_OK; + } + l4_src_port = (((((unsigned short)(l4_udp_hdr->source) & 0xFF)) << 8) | (((unsigned short)(l4_udp_hdr->source) & 0xFF00) >> 8)); + l4_dst_port = (((((unsigned short)(l4_udp_hdr->dest) & 0xFF)) << 8) | (((unsigned short)(l4_udp_hdr->dest) & 0xFF00) >> 8)); + break; + case IPPROTO_SCTP: + if (data + sizeof(*ip) + sizeof(*l4_sctp_hdr) > data_end) { + return BPF_OK; + } + l4_src_port = (((((unsigned short)(l4_sctp_hdr->source) & 0xFF)) << 8) | (((unsigned short)(l4_sctp_hdr->source) & 0xFF00) >> 8)); + l4_dst_port = (((((unsigned short)(l4_sctp_hdr->dest) & 0xFF)) << 8) | (((unsigned short)(l4_sctp_hdr->dest) & 0xFF00) >> 8)); + break; + } + + trie_key.prefix_len = 128; + //Fill the IP Key to be used for lookup + for (int i=0; i<16; i++){ + trie_key.ip[i] = ip->saddr.in6_u.u6_addr8[i]; + } + + //Check if it's in the allowed list + trie_val = bpf_map_lookup_elem(&ingress_map, &trie_key); + if (trie_val == NULL) { + return BPF_DROP; + } + + for (int i=0; i<30; i++, trie_val++){ + if (trie_val->protocol == RESERVED_IP_PROTOCOL) { + return BPF_DROP; + } + + if ((trie_val->protocol == ANY_IP_PROTOCOL) || (trie_val->protocol == ip->nexthdr && + ((trie_val->start_port == ANY_PORT) || (l4_dst_port == trie_val->start_port) || + (l4_dst_port > trie_val->start_port && l4_dst_port <= trie_val->end_port)))) { + return BPF_OK; + } + } + return BPF_DROP; + } + return BPF_OK; + +} + +char _license[] SEC("license") = "GPL"; diff --git a/test/c/test.bpf.c b/test/c/test.bpf.c index 5508f49..f39878f 100644 --- a/test/c/test.bpf.c +++ b/test/c/test.bpf.c @@ -43,7 +43,7 @@ struct lpm_trie_val { struct bpf_map_def_pvt SEC("maps") ingress_map = { .type = BPF_MAP_TYPE_LPM_TRIE, .key_size =sizeof(struct lpm_trie_key), - .value_size = sizeof(struct lpm_trie_val[8]), + .value_size = sizeof(struct lpm_trie_val[30]), .max_entries = 65536, .map_flags = BPF_F_NO_PREALLOC, .pinning = PIN_GLOBAL_NS, @@ -114,6 +114,18 @@ int handle_ingress(struct __sk_buff *skb) return BPF_DROP; } + for (int i=0; i<30; i++, trie_val++){ + if (trie_val->protocol == RESERVED_IP_PROTOCOL) { + return BPF_DROP; + } + + if ((trie_val->protocol == ANY_IP_PROTOCOL) || (trie_val->protocol == ip->protocol && + ((trie_val->start_port == ANY_PORT) || (l4_dst_port == trie_val->start_port) || + (l4_dst_port > trie_val->start_port && l4_dst_port <= trie_val->end_port)))) { + return BPF_OK; + } + } + return BPF_OK; } diff --git a/test/main.go b/test/main.go index 238b4c9..4ef04d9 100644 --- a/test/main.go +++ b/test/main.go @@ -55,6 +55,7 @@ func main() { mount_bpf_fs() testFunctions := []testFunc{ {Name: "Test loading Program", Func: TestLoadProg}, + {Name: "Test loading V6 Program", Func: TestLoadv6Prog}, {Name: "Test loading TC filter", Func: TestLoadTCfilter}, {Name: "Test loading Maps without Program", Func: TestLoadMapWithNoProg}, {Name: "Test loading Map operations", Func: TestMapOperations}, @@ -110,6 +111,20 @@ func TestLoadProg() error { return nil } +func TestLoadv6Prog() error { + gosdkClient := goelf.New() + progInfo, _, err := gosdkClient.LoadBpfFile("c/test-v6.bpf.elf", "test") + if err != nil { + fmt.Println("Load BPF failed", "err:", err) + return err + } + + for pinPath, _ := range progInfo { + fmt.Println("Prog Info: ", "Pin Path: ", pinPath) + } + return nil +} + func TestLoadMapWithNoProg() error { gosdkClient := goelf.New() _, loadedMap, err := gosdkClient.LoadBpfFile("c/test-map.bpf.elf", "test") From 70a86151f53854628ac7fef1aadd0737c967c2dc Mon Sep 17 00:00:00 2001 From: Jayanth Varavani <1111446+jayanthvn@users.noreply.github.com> Date: Tue, 17 Oct 2023 08:58:13 -0700 Subject: [PATCH 23/29] Fix verifier log buffer size (#54) --- pkg/progs/loader.go | 4 ++-- pkg/utils/utils.go | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/progs/loader.go b/pkg/progs/loader.go index b5eaf74..5b9e96c 100644 --- a/pkg/progs/loader.go +++ b/pkg/progs/loader.go @@ -211,12 +211,12 @@ func (m *BpfProgram) LoadProg(progMetaData CreateEBPFProgInput) (int, error) { prog_type = uint32(netlink.BPF_PROG_TYPE_UNSPEC) } - logBuf := make([]byte, 65535) + logBuf := make([]byte, utils.GetLogBufferSize()) program := netlink.BPFAttr{ ProgType: prog_type, LogBuf: uintptr(unsafe.Pointer(&logBuf[0])), LogSize: uint32(cap(logBuf) - 1), - LogLevel: 4, + LogLevel: 1, } program.Insns = uintptr(unsafe.Pointer(&progMetaData.ProgData[0])) diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index f58a3df..5d101e7 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -17,6 +17,7 @@ package utils import ( "encoding/binary" "fmt" + "math" "os" "runtime" "syscall" @@ -194,3 +195,7 @@ func Unmount_bpf_fs() error { } return err } + +func GetLogBufferSize() int { + return math.MaxUint32 >> 8 +} From d0cca9923684275537f00679308a47c510567bd7 Mon Sep 17 00:00:00 2001 From: Jayanth Varavani <1111446+jayanthvn@users.noreply.github.com> Date: Tue, 7 Nov 2023 23:11:57 +0000 Subject: [PATCH 24/29] Use defer close --- pkg/maps/loader.go | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/pkg/maps/loader.go b/pkg/maps/loader.go index ed9fa9c..e24bced 100644 --- a/pkg/maps/loader.go +++ b/pkg/maps/loader.go @@ -287,6 +287,7 @@ func (m *BpfMap) CreateUpdateMapEntry(key, value uintptr, updateFlags uint64) er log.Errorf("unable to GetMapFDfromID and ret %d and err %s", int(mapFD), err) return fmt.Errorf("unable to get FD: %s", err) } + defer unix.Close(mapFD) attr := utils.BpfMapAttr{ MapFD: uint32(mapFD), @@ -309,7 +310,6 @@ func (m *BpfMap) CreateUpdateMapEntry(key, value uintptr, updateFlags uint64) er } log.Infof("Create/Update map entry done with fd : %d and err %s", int(ret), errno) - unix.Close(mapFD) return nil } @@ -320,6 +320,8 @@ func (m *BpfMap) DeleteMapEntry(key uintptr) error { log.Errorf("unable to GetMapFDfromID and ID %d and err %s", int(m.MapID), err) return fmt.Errorf("unable to get FD: %s", err) } + defer unix.Close(mapFD) + attr := utils.BpfMapAttr{ MapFD: uint32(mapFD), Key: uint64(key), @@ -336,7 +338,6 @@ func (m *BpfMap) DeleteMapEntry(key uintptr) error { } log.Infof("Delete map entry done with fd : %d and err %s", int(ret), errno) - unix.Close(mapFD) return nil } @@ -352,6 +353,8 @@ func (m *BpfMap) GetNextMapEntry(key, nextKey uintptr) error { log.Errorf("unable to GetMapFDfromID and ret %d and err %s", int(mapFD), err) return fmt.Errorf("unable to get FD: %s", err) } + defer unix.Close(mapFD) + attr := utils.BpfMapAttr{ MapFD: uint32(mapFD), Key: uint64(key), @@ -365,17 +368,14 @@ func (m *BpfMap) GetNextMapEntry(key, nextKey uintptr) error { ) if errors.Is(errno, unix.ENOENT) { log.Errorf("last entry read done") - unix.Close(mapFD) return errno } if errno != 0 { log.Errorf("unable to get next map entry and ret %d and err %s", int(ret), errno) - unix.Close(mapFD) return fmt.Errorf("unable to get next map entry: %s", errno) } log.Infof("Got next map entry with fd : %d and err %s", int(ret), errno) - unix.Close(mapFD) return nil } @@ -418,6 +418,8 @@ func (m *BpfMap) GetMapEntry(key, value uintptr) error { log.Errorf("unable to GetMapFDfromID and ret %d and err %s", int(mapFD), err) return fmt.Errorf("unable to get FD: %s", err) } + defer unix.Close(mapFD) + attr := utils.BpfMapAttr{ MapFD: uint32(mapFD), Key: uint64(key), @@ -431,12 +433,10 @@ func (m *BpfMap) GetMapEntry(key, value uintptr) error { ) if errno != 0 { log.Errorf("unable to get map entry and ret %d and err %s", int(ret), errno) - unix.Close(mapFD) return fmt.Errorf("unable to get next map entry: %s", errno) } log.Infof("Got map entry with fd : %d and err %s", int(ret), errno) - unix.Close(mapFD) return nil } @@ -578,6 +578,7 @@ func BpfGetAllMapInfo() ([]BpfMapInfo, error) { bpfMapInfo, err := GetBPFmapInfo(mapfd) if err != nil { log.Errorf("failed to get map Info for FD", mapfd) + unix.Close(mapfd) return nil, err } unix.Close(mapfd) @@ -643,6 +644,8 @@ func GetNextMapEntryByID(key, nextKey uintptr, mapID int) error { log.Errorf("unable to GetMapFDfromID and ret %d and err %s", int(mapFD), err) return fmt.Errorf("unable to get FD: %s", err) } + + defer unix.Close(mapFD) attr := utils.BpfMapAttr{ MapFD: uint32(mapFD), Key: uint64(key), @@ -655,17 +658,14 @@ func GetNextMapEntryByID(key, nextKey uintptr, mapID int) error { unsafe.Sizeof(attr), ) if errors.Is(errno, unix.ENOENT) { - unix.Close(mapFD) return errno } if errno != 0 { log.Errorf("unable to get next map entry and ret %d and err %s", int(ret), errno) - unix.Close(mapFD) return fmt.Errorf("unable to get next map entry: %s", errno) } log.Infof("Got next map entry with fd : %d and err %s", int(ret), errno) - unix.Close(mapFD) return nil } @@ -676,6 +676,7 @@ func GetMapEntryByID(key, value uintptr, mapID int) error { log.Errorf("unable to GetMapFDfromID and ret %d and err %s", int(mapFD), err) return fmt.Errorf("unable to get FD: %s", err) } + defer unix.Close(mapFD) attr := utils.BpfMapAttr{ MapFD: uint32(mapFD), @@ -691,11 +692,9 @@ func GetMapEntryByID(key, value uintptr, mapID int) error { if errno != 0 { log.Errorf("unable to get map entry and ret %d and err %s", int(ret), errno) - unix.Close(mapFD) return fmt.Errorf("unable to get next map entry: %s", errno) } log.Infof("Got map entry with ret : %d and err %s", int(ret), errno) - unix.Close(mapFD) return nil } From 85c3cb5f38b71f8c4b756c87f05ad2a598f2d387 Mon Sep 17 00:00:00 2001 From: Jayanth Varavani <1111446+jayanthvn@users.noreply.github.com> Date: Wed, 8 Nov 2023 19:10:48 +0000 Subject: [PATCH 25/29] Minor cleanup --- pkg/maps/loader.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/maps/loader.go b/pkg/maps/loader.go index e24bced..d5987bc 100644 --- a/pkg/maps/loader.go +++ b/pkg/maps/loader.go @@ -493,7 +493,7 @@ func (m *BpfMap) BulkRefreshMapEntries(newMapContents map[string]uintptr) error // 4. Delete stale Keys log.Infof("Check for stale entries and got %d entries from BPF map", len(retrievedMapKeyList)) for _, key := range retrievedMapKeyList { - log.Infof("Checking if key %s is deltable", key) + log.Infof("Checking if key %s is deletable", key) if _, ok := newMapContents[key]; !ok { log.Infof("This can be deleted, not needed anymore...") deletableKeyByte := []byte(key) From e650b3425005f4b471fb2df9c9c8f496b545a072 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 8 Nov 2023 12:12:30 -0800 Subject: [PATCH 26/29] Bump go.uber.org/zap from 1.25.0 to 1.26.0 (#52) Bumps [go.uber.org/zap](https://github.com/uber-go/zap) from 1.25.0 to 1.26.0. - [Release notes](https://github.com/uber-go/zap/releases) - [Changelog](https://github.com/uber-go/zap/blob/master/CHANGELOG.md) - [Commits](https://github.com/uber-go/zap/compare/v1.25.0...v1.26.0) --- updated-dependencies: - dependency-name: go.uber.org/zap dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 1b314f0..5dab525 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/golang/mock v1.6.0 github.com/stretchr/testify v1.8.4 github.com/vishvananda/netlink v1.1.0 - go.uber.org/zap v1.25.0 + go.uber.org/zap v1.26.0 golang.org/x/sys v0.12.0 gopkg.in/natefinch/lumberjack.v2 v2.2.1 ) diff --git a/go.sum b/go.sum index a3840bc..6f8879a 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,3 @@ -github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= @@ -15,8 +14,8 @@ github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1 go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= -go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk= +go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= +go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= From 0d8c15e40b275fdfda451689e83e6a9f38bc13f1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 8 Nov 2023 12:15:34 -0800 Subject: [PATCH 27/29] Bump golang.org/x/sys from 0.12.0 to 0.14.0 (#59) Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.12.0 to 0.14.0. - [Commits](https://github.com/golang/sys/compare/v0.12.0...v0.14.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 5dab525..b0a6c9e 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/stretchr/testify v1.8.4 github.com/vishvananda/netlink v1.1.0 go.uber.org/zap v1.26.0 - golang.org/x/sys v0.12.0 + golang.org/x/sys v0.14.0 gopkg.in/natefinch/lumberjack.v2 v2.2.1 ) diff --git a/go.sum b/go.sum index 6f8879a..e0970ab 100644 --- a/go.sum +++ b/go.sum @@ -30,8 +30,8 @@ golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= -golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= +golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= From 7c59e83cc7cd11dc8da9b969c8a052e1199f3faf Mon Sep 17 00:00:00 2001 From: Jayanth Varavani <1111446+jayanthvn@users.noreply.github.com> Date: Wed, 8 Nov 2023 12:45:24 -0800 Subject: [PATCH 28/29] Update pr-tests.yaml (#62) --- .github/workflows/pr-tests.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr-tests.yaml b/.github/workflows/pr-tests.yaml index c00f722..2c67fde 100644 --- a/.github/workflows/pr-tests.yaml +++ b/.github/workflows/pr-tests.yaml @@ -4,6 +4,7 @@ on: pull_request: branches: - "main" + - "release*" permissions: contents: read @@ -52,4 +53,4 @@ jobs: - name: Build run: make build-linux - name: Functional test - run: cd test && sudo make run-test \ No newline at end of file + run: cd test && sudo make run-test From ca15eba58c465dce290c92bebf10d874c3d3f803 Mon Sep 17 00:00:00 2001 From: Jayanth Varavani <1111446+jayanthvn@users.noreply.github.com> Date: Thu, 9 Nov 2023 15:33:38 +0000 Subject: [PATCH 29/29] Update gomod --- test/go.mod | 4 ++-- test/go.sum | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/test/go.mod b/test/go.mod index aa91a81..29889e0 100644 --- a/test/go.mod +++ b/test/go.mod @@ -13,8 +13,8 @@ require ( github.com/vishvananda/netlink v1.1.0 // indirect github.com/vishvananda/netns v0.0.4 // indirect go.uber.org/multierr v1.10.0 // indirect - go.uber.org/zap v1.25.0 // indirect - golang.org/x/sys v0.12.0 // indirect + go.uber.org/zap v1.26.0 // indirect + golang.org/x/sys v0.14.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect ) diff --git a/test/go.sum b/test/go.sum index 2eed2e2..84cec8e 100644 --- a/test/go.sum +++ b/test/go.sum @@ -1,4 +1,3 @@ -github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= @@ -18,12 +17,12 @@ github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZla go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= -go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk= +go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= +go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= -golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= +golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=