Skip to content

Commit

Permalink
update github.com/cilium/ebpf
Browse files Browse the repository at this point in the history
Manually update the dependency and remove usage of the deprecated
LogSize field.

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
  • Loading branch information
lmb authored and kkourt committed Jul 23, 2024
1 parent 6680baa commit 2b40f93
Show file tree
Hide file tree
Showing 15 changed files with 190 additions and 146 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ toolchain go1.22.3
require (
github.com/bombsimon/logrusr/v4 v4.1.0
github.com/cilium/cilium v1.15.7
github.com/cilium/ebpf v0.15.1-0.20240703142256-12aca1027ee8
github.com/cilium/ebpf v0.15.1-0.20240723115216-b689d288f907
github.com/cilium/little-vm-helper v0.0.19
github.com/cilium/lumberjack/v2 v2.3.0
github.com/cilium/tetragon/api v0.0.0-00010101000000-000000000000
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ github.com/cilium/cilium v1.15.7 h1:7LwGfAW/fR/VFcm6zlESjE2Ut5vJWe+kdWq3RNJrNRc=
github.com/cilium/cilium v1.15.7/go.mod h1:6Ml8eeyWjMJKDeadutWhn5NibMps0H+yLOgfKBoHTUs=
github.com/cilium/controller-tools v0.8.0-1 h1:D5xhwSUZZceaKAacHOyfcpUMgLbs2TGeJEijNHlAQlc=
github.com/cilium/controller-tools v0.8.0-1/go.mod h1:qE2DXhVOiEq5ijmINcFbqi9GZrrUjzB1TuJU0xa6eoY=
github.com/cilium/ebpf v0.15.1-0.20240703142256-12aca1027ee8 h1:+AMtTVJtVC6OGInoYSGtTW9YTblQBi/sysXD4rtc3to=
github.com/cilium/ebpf v0.15.1-0.20240703142256-12aca1027ee8/go.mod h1:L7u2Blt2jMM/vLAVgjxluxtBKlz3/GWjB0dMOEngfwE=
github.com/cilium/ebpf v0.15.1-0.20240723115216-b689d288f907 h1:BOjEZLrpgON0BnbxBdY2NkKMIe6Km8IFP/XSTmKBk/E=
github.com/cilium/ebpf v0.15.1-0.20240723115216-b689d288f907/go.mod h1:L7u2Blt2jMM/vLAVgjxluxtBKlz3/GWjB0dMOEngfwE=
github.com/cilium/little-vm-helper v0.0.19 h1:eJeJM/03MGLrLUXXTBDZo2JoX5cIbm5+9iWjoHgpy/M=
github.com/cilium/little-vm-helper v0.0.19/go.mod h1:X3HGJKJ3/8vqP06VyajvD0nNDLYnGv96W8jWx4m3I7g=
github.com/cilium/lumberjack/v2 v2.3.0 h1:IhVJMvPpqDYmQzC0KDhAoy7KlaRsyOsZnT97Nsa3u0o=
Expand Down
57 changes: 18 additions & 39 deletions pkg/sensors/program/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ import (
"github.com/cilium/tetragon/pkg/logger"
"github.com/cilium/tetragon/pkg/option"
"github.com/cilium/tetragon/pkg/sensors/unloader"
"golang.org/x/sys/unix"
)

var (
verifierLogBufferSize = 10 * 1024 * 1024 // 10MB
)

// AttachFunc is the type for the various attachment functions. The function is
Expand Down Expand Up @@ -890,44 +885,28 @@ func doLoadProgram(
opts.MapReplacements = pinnedMaps

coll, err := ebpf.NewCollectionWithOptions(spec, opts)
if err != nil && load.KernelTypes != nil {
opts.Programs.KernelTypes = load.KernelTypes
coll, err = ebpf.NewCollectionWithOptions(spec, opts)
}
if err != nil {
// Retry again with logging to capture the verifier log. We don't log by default
// as that makes the loading very slow.
opts.Programs.LogLevel = 1
opts.Programs.LogSize = verifierLogBufferSize
if load.KernelTypes != nil {
opts.Programs.KernelTypes = load.KernelTypes
}
// If we hit ENOSPC that means that our log size is not big enough,
// so keep trying again with log size * 2 until we succeed or the kernel
// complains.
for {
coll, err = ebpf.NewCollectionWithOptions(spec, opts)
if errors.Is(err, unix.ENOSPC) {
opts.Programs.LogSize = opts.Programs.LogSize * 2
continue
}
break
}
if err != nil {
// Log the error directly using the logger so that the verifier log
// gets properly pretty-printed.
if verbose != 0 {
logger.GetLogger().Infof("Opening collection failed, dumping verifier log.")
var ve *ebpf.VerifierError
if errors.As(err, &ve) {
// Print a truncated version if we have verbose=1, otherwise dump the
// full log.
if verbose < 2 {
fmt.Println(slimVerifierError(fmt.Sprintf("%+v", ve)))
} else {
fmt.Printf("%+v\n", ve)
}
// Log the error directly using the logger so that the verifier log
// gets properly pretty-printed.
if verbose != 0 {
logger.GetLogger().Infof("Opening collection failed, dumping verifier log.")
var ve *ebpf.VerifierError
if errors.As(err, &ve) {
// Print a truncated version if we have verbose=1, otherwise dump the
// full log.
if verbose < 2 {
fmt.Println(slimVerifierError(fmt.Sprintf("%+v", ve)))
} else {
fmt.Printf("%+v\n", ve)
}
}

return nil, fmt.Errorf("opening collection '%s' failed: %w", load.Name, err)
}

return nil, fmt.Errorf("opening collection '%s' failed: %w", load.Name, err)
}
defer coll.Close()

Expand Down
2 changes: 2 additions & 0 deletions vendor/github.com/cilium/ebpf/CODEOWNERS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 15 additions & 7 deletions vendor/github.com/cilium/ebpf/btf/btf.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 44 additions & 14 deletions vendor/github.com/cilium/ebpf/btf/handle.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions vendor/github.com/cilium/ebpf/btf/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/cilium/ebpf/collection.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions vendor/github.com/cilium/ebpf/info.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 6 additions & 23 deletions vendor/github.com/cilium/ebpf/internal/errors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion vendor/github.com/cilium/ebpf/link/xdp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2b40f93

Please sign in to comment.