Skip to content

Commit

Permalink
main: use rlimit.RemoveMemlock()
Browse files Browse the repository at this point in the history
cilium/ebpf provides a helper which removes the memlock limit if
necessary. Use it instead of unconditionally bumping RLIMIT_MEMLOCK.
  • Loading branch information
lmb authored and tklauser committed Jun 28, 2023
1 parent 2b720fb commit 0578811
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 4 deletions.
6 changes: 2 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/cilium/ebpf"
"github.com/cilium/ebpf/btf"
"github.com/cilium/ebpf/link"
"github.com/cilium/ebpf/rlimit"
flag "github.com/spf13/pflag"
"golang.org/x/sys/unix"

Expand All @@ -40,10 +41,7 @@ func main() {
}); err != nil {
log.Fatalf("failed to set temporary rlimit: %s", err)
}
if err := unix.Setrlimit(unix.RLIMIT_MEMLOCK, &unix.Rlimit{
Cur: unix.RLIM_INFINITY,
Max: unix.RLIM_INFINITY,
}); err != nil {
if err := rlimit.RemoveMemlock(); err != nil {
log.Fatalf("Failed to set temporary rlimit: %s", err)
}

Expand Down
123 changes: 123 additions & 0 deletions vendor/github.com/cilium/ebpf/rlimit/rlimit.go

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

1 change: 1 addition & 0 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ github.com/cilium/ebpf/internal
github.com/cilium/ebpf/internal/sys
github.com/cilium/ebpf/internal/unix
github.com/cilium/ebpf/link
github.com/cilium/ebpf/rlimit
# github.com/fatih/color v1.14.1
## explicit; go 1.17
github.com/fatih/color
Expand Down

0 comments on commit 0578811

Please sign in to comment.