-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update cilium/ebpf to v0.16.0 fix RunValidator return error. Signed-off-by: cfc4n <cfc4n.cs@gmail.com>
- Loading branch information
Showing
8 changed files
with
154 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,27 @@ | ||
module github.com/gojue/ebpfmanager | ||
|
||
go 1.21 | ||
go 1.22.10 | ||
|
||
require ( | ||
github.com/avast/retry-go v3.0.0+incompatible | ||
github.com/cilium/ebpf v0.12.3 | ||
github.com/cilium/ebpf v0.16.0 | ||
github.com/florianl/go-tc v0.4.0 | ||
github.com/hashicorp/go-multierror v1.1.1 | ||
github.com/shuLhan/go-bindata v4.0.0+incompatible | ||
github.com/sirupsen/logrus v1.8.1 | ||
github.com/vishvananda/netlink v1.1.0 | ||
golang.org/x/sys v0.14.1-0.20231108175955-e4099bfacb8c | ||
golang.org/x/sys v0.20.0 | ||
) | ||
|
||
require ( | ||
github.com/google/go-cmp v0.5.9 // indirect | ||
github.com/google/go-cmp v0.6.0 // indirect | ||
github.com/hashicorp/errwrap v1.0.0 // indirect | ||
github.com/josharian/native v0.0.0-20200817173448-b6b71def0850 // indirect | ||
github.com/mdlayher/netlink v1.4.1 // indirect | ||
github.com/mdlayher/socket v0.0.0-20210307095302-262dc9984e00 // indirect | ||
github.com/josharian/native v1.1.0 // indirect | ||
github.com/mdlayher/netlink v1.7.2 // indirect | ||
github.com/mdlayher/socket v0.4.1 // indirect | ||
github.com/stretchr/testify v1.3.0 // indirect | ||
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df // indirect | ||
golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2 // indirect | ||
golang.org/x/net v0.0.0-20210610124326-52da8fb2a613 // indirect | ||
golang.org/x/net v0.23.0 // indirect | ||
golang.org/x/sync v0.1.0 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package manager | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"sync" | ||
"syscall" | ||
|
||
"golang.org/x/sys/unix" | ||
) | ||
|
||
const ( | ||
traceFSRoot = "/sys/kernel/tracing" | ||
debugFSRoot = "/sys/kernel/debug/tracing" | ||
) | ||
|
||
var ( | ||
tracingRoot = struct { | ||
once sync.Once | ||
path string | ||
err error | ||
}{} | ||
) | ||
|
||
func getTracefsRoot() (string, error) { | ||
tracingRoot.once.Do(func() { | ||
var statfs unix.Statfs_t | ||
var traceError error | ||
if traceError = unix.Statfs(traceFSRoot, &statfs); traceError == nil { | ||
if statfs.Type == unix.TRACEFS_MAGIC { | ||
tracingRoot.path = traceFSRoot | ||
return | ||
} | ||
traceError = fmt.Errorf("%s is not mounted with tracefs filesystem type", traceFSRoot) | ||
} | ||
var debugError error | ||
if debugError = unix.Statfs(debugFSRoot, &statfs); debugError == nil { | ||
if statfs.Type == unix.TRACEFS_MAGIC || statfs.Type == unix.DEBUGFS_MAGIC { | ||
tracingRoot.path = debugFSRoot | ||
return | ||
} | ||
debugError = fmt.Errorf("%s is not mounted with tracefs or debugfs filesystem type", debugFSRoot) | ||
} | ||
|
||
bestError := fmt.Errorf("tracefs: %s", traceError) | ||
// only fallback to debugfs error if tracefs doesn't exist at all and debugfs does | ||
if errors.Is(traceError, syscall.ENOENT) && !errors.Is(debugError, syscall.ENOENT) { | ||
bestError = fmt.Errorf("debugfs: %s", debugError) | ||
} | ||
tracingRoot.err = fmt.Errorf("tracefs or debugfs is not available: %s", bestError) | ||
}) | ||
return tracingRoot.path, tracingRoot.err | ||
} | ||
|
||
// Root returns the tracing root path in use, `/sys/kernel/tracing` (tracefs) or `/sys/kernel/debug/tracing` (debugfs) | ||
func TracefsRoot() (string, error) { | ||
return getTracefsRoot() | ||
} | ||
|
||
// ReadFile reads the relative path provided, using the detected root of tracefs or debugfs | ||
func TracefsReadFile(relname string) ([]byte, error) { | ||
root, err := getTracefsRoot() | ||
if err != nil { | ||
return nil, err | ||
} | ||
return os.ReadFile(filepath.Join(root, relname)) | ||
} | ||
|
||
// Open opens the relative path provided (similar to os.Open), using the detected root of tracefs or debugfs | ||
func TracefsOpen(relname string) (*os.File, error) { | ||
return TracefsOpenFile(relname, os.O_RDONLY, 0) | ||
} | ||
|
||
// OpenFile opens the relative path provided (similar to os.OpenFile), using the detected root of tracefs or debugfs | ||
func TracefsOpenFile(relname string, flag int, perm os.FileMode) (*os.File, error) { | ||
root, err := getTracefsRoot() | ||
if err != nil { | ||
return nil, err | ||
} | ||
return os.OpenFile(filepath.Join(root, relname), flag, perm) | ||
} |
Oops, something went wrong.