Skip to content

Commit

Permalink
bump rlimit so the eBPF map and program can be loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Ojea authored and aojea committed Jul 16, 2021
1 parent 660e79b commit fff3e52
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ netcat version using raw sockets to avoid iptables and/or other OS filtering mec
## Requirements

It only works on Linux with a Kernel version > 5.2
It requires CAP_NET_RAW privileges
It requires CAP_NET_RAW and CAP_SYS_RESOURCE capabilities
... or just run it with `sudo` ;)

## Install

Expand Down
8 changes: 8 additions & 0 deletions nk.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ func main() {
os.Exit(1)
}

// Increase rlimit so the eBPF map and program can be loaded.
if err := unix.Setrlimit(unix.RLIMIT_MEMLOCK, &unix.Rlimit{
Cur: unix.RLIM_INFINITY,
Max: unix.RLIM_INFINITY,
}); err != nil {
log.Fatalf("setting temporary rlimit: %s", err)
}

if !flagListen {
err = connect(ctx, args)
if err != nil {
Expand Down

0 comments on commit fff3e52

Please sign in to comment.