Skip to content

Commit f1332ce

Browse files
committed
tunnel-icmp: suggest running as root on "operation not permitted" error
1 parent 0eed5aa commit f1332ce

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

simulator/tunnel-icmp.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ package simulator
22

33
import (
44
"context"
5+
"errors"
6+
"fmt"
57
"math/rand"
68
"net"
79
"os"
10+
"syscall"
811

912
"golang.org/x/net/icmp"
1013
"golang.org/x/net/ipv4"
@@ -26,6 +29,11 @@ func NewICMPtunnel() *ICMPtunnel {
2629
func (s *ICMPtunnel) Init(bind net.IP) error {
2730
c, err := icmp.ListenPacket("ip4:icmp", bind.String())
2831
if err != nil {
32+
// check if it's syscall error 1: "operation not permitted"
33+
var errno syscall.Errno
34+
if errors.As(err, &errno); errno == 1 {
35+
err = fmt.Errorf("%w (make sure you have sufficient network privileges or try to run as root)", err)
36+
}
2937
return err
3038
}
3139
s.c = c

0 commit comments

Comments
 (0)