diff options
-rw-r--r-- | conn/controlfns_linux.go | 17 | ||||
-rw-r--r-- | conn/sticky_default.go | 4 | ||||
-rw-r--r-- | conn/sticky_linux.go | 4 | ||||
-rw-r--r-- | conn/sticky_linux_test.go | 2 | ||||
-rw-r--r-- | device/sticky_linux.go | 3 |
5 files changed, 22 insertions, 8 deletions
diff --git a/conn/controlfns_linux.go b/conn/controlfns_linux.go index aff6245..a2396fe 100644 --- a/conn/controlfns_linux.go +++ b/conn/controlfns_linux.go @@ -7,6 +7,7 @@ package conn import ( "fmt" + "runtime" "syscall" "golang.org/x/sys/unix" @@ -36,14 +37,18 @@ func init() { var err error switch network { case "udp4": - c.Control(func(fd uintptr) { - err = unix.SetsockoptInt(int(fd), unix.IPPROTO_IP, unix.IP_PKTINFO, 1) - }) + if runtime.GOOS != "android" { + c.Control(func(fd uintptr) { + err = unix.SetsockoptInt(int(fd), unix.IPPROTO_IP, unix.IP_PKTINFO, 1) + }) + } case "udp6": c.Control(func(fd uintptr) { - err = unix.SetsockoptInt(int(fd), unix.IPPROTO_IPV6, unix.IPV6_RECVPKTINFO, 1) - if err != nil { - return + if runtime.GOOS != "android" { + err = unix.SetsockoptInt(int(fd), unix.IPPROTO_IPV6, unix.IPV6_RECVPKTINFO, 1) + if err != nil { + return + } } err = unix.SetsockoptInt(int(fd), unix.IPPROTO_IPV6, unix.IPV6_V6ONLY, 1) }) diff --git a/conn/sticky_default.go b/conn/sticky_default.go index 8c0adf5..05f00ea 100644 --- a/conn/sticky_default.go +++ b/conn/sticky_default.go @@ -1,4 +1,4 @@ -//go:build !linux +//go:build !linux || android /* SPDX-License-Identifier: MIT * @@ -23,3 +23,5 @@ func setSrcControl(control *[]byte, ep *StdNetEndpoint) { // srcControlSize returns the recommended buffer size for pooling sticky control // data. const srcControlSize = 0 + +const StdNetSupportsStickySockets = false diff --git a/conn/sticky_linux.go b/conn/sticky_linux.go index 278eb19..274fa38 100644 --- a/conn/sticky_linux.go +++ b/conn/sticky_linux.go @@ -1,3 +1,5 @@ +//go:build linux && !android + /* SPDX-License-Identifier: MIT * * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. @@ -111,3 +113,5 @@ func setSrcControl(control *[]byte, ep *StdNetEndpoint) { } var srcControlSize = unix.CmsgSpace(unix.SizeofInet6Pktinfo) + +const StdNetSupportsStickySockets = true diff --git a/conn/sticky_linux_test.go b/conn/sticky_linux_test.go index 3213e77..0219ac3 100644 --- a/conn/sticky_linux_test.go +++ b/conn/sticky_linux_test.go @@ -1,4 +1,4 @@ -//go:build linux +//go:build linux && !android /* SPDX-License-Identifier: MIT * diff --git a/device/sticky_linux.go b/device/sticky_linux.go index 3ce0769..f9230f8 100644 --- a/device/sticky_linux.go +++ b/device/sticky_linux.go @@ -25,6 +25,9 @@ import ( ) func (device *Device) startRouteListener(bind conn.Bind) (*rwcancel.RWCancel, error) { + if !conn.StdNetSupportsStickySockets { + return nil, nil + } if _, ok := bind.(*conn.StdNetBind); !ok { return nil, nil } |