Skip to content

Commit 0586b9e

Browse files
Mahdi-zareinekohasekai
authored andcommitted
Ignore darwin IP_DONTFRAG error when not supported
1 parent f080206 commit 0586b9e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

common/control/frag_darwin.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package control
22

33
import (
4+
"errors"
45
"os"
56
"syscall"
67

@@ -18,12 +19,18 @@ func DisableUDPFragment() Func {
1819
if network == "udp" || network == "udp4" {
1920
err := unix.SetsockoptInt(int(fd), unix.IPPROTO_IP, unix.IP_DONTFRAG, 1)
2021
if err != nil {
22+
if errors.Is(err, unix.ENOPROTOOPT) || errors.Is(err, unix.EOPNOTSUPP) {
23+
return nil
24+
}
2125
return os.NewSyscallError("SETSOCKOPT IP_DONTFRAG", err)
2226
}
2327
}
2428
if network == "udp" || network == "udp6" {
2529
err := unix.SetsockoptInt(int(fd), unix.IPPROTO_IPV6, unix.IPV6_DONTFRAG, 1)
2630
if err != nil {
31+
if errors.Is(err, unix.ENOPROTOOPT) || errors.Is(err, unix.EOPNOTSUPP) {
32+
return nil
33+
}
2734
return os.NewSyscallError("SETSOCKOPT IPV6_DONTFRAG", err)
2835
}
2936
}

0 commit comments

Comments
 (0)