conn: disable sticky sockets on Android
We can't have the netlink listener socket, so it's not possible to support it. Plus, android networking stack complexity makes it a bit tricky anyway, so best to leave it disabled. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
cc20c08c96
commit
3a9e75374f
@ -7,6 +7,7 @@ package conn
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"runtime"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
@ -36,14 +37,18 @@ func init() {
|
|||||||
var err error
|
var err error
|
||||||
switch network {
|
switch network {
|
||||||
case "udp4":
|
case "udp4":
|
||||||
c.Control(func(fd uintptr) {
|
if runtime.GOOS != "android" {
|
||||||
err = unix.SetsockoptInt(int(fd), unix.IPPROTO_IP, unix.IP_PKTINFO, 1)
|
c.Control(func(fd uintptr) {
|
||||||
})
|
err = unix.SetsockoptInt(int(fd), unix.IPPROTO_IP, unix.IP_PKTINFO, 1)
|
||||||
|
})
|
||||||
|
}
|
||||||
case "udp6":
|
case "udp6":
|
||||||
c.Control(func(fd uintptr) {
|
c.Control(func(fd uintptr) {
|
||||||
err = unix.SetsockoptInt(int(fd), unix.IPPROTO_IPV6, unix.IPV6_RECVPKTINFO, 1)
|
if runtime.GOOS != "android" {
|
||||||
if err != nil {
|
err = unix.SetsockoptInt(int(fd), unix.IPPROTO_IPV6, unix.IPV6_RECVPKTINFO, 1)
|
||||||
return
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
err = unix.SetsockoptInt(int(fd), unix.IPPROTO_IPV6, unix.IPV6_V6ONLY, 1)
|
err = unix.SetsockoptInt(int(fd), unix.IPPROTO_IPV6, unix.IPV6_V6ONLY, 1)
|
||||||
})
|
})
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//go:build !linux
|
//go:build !linux || android
|
||||||
|
|
||||||
/* SPDX-License-Identifier: MIT
|
/* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@ -23,3 +23,5 @@ func setSrcControl(control *[]byte, ep *StdNetEndpoint) {
|
|||||||
// srcControlSize returns the recommended buffer size for pooling sticky control
|
// srcControlSize returns the recommended buffer size for pooling sticky control
|
||||||
// data.
|
// data.
|
||||||
const srcControlSize = 0
|
const srcControlSize = 0
|
||||||
|
|
||||||
|
const StdNetSupportsStickySockets = false
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//go:build linux && !android
|
||||||
|
|
||||||
/* SPDX-License-Identifier: MIT
|
/* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved.
|
* 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)
|
var srcControlSize = unix.CmsgSpace(unix.SizeofInet6Pktinfo)
|
||||||
|
|
||||||
|
const StdNetSupportsStickySockets = true
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//go:build linux
|
//go:build linux && !android
|
||||||
|
|
||||||
/* SPDX-License-Identifier: MIT
|
/* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
|
@ -25,6 +25,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (device *Device) startRouteListener(bind conn.Bind) (*rwcancel.RWCancel, error) {
|
func (device *Device) startRouteListener(bind conn.Bind) (*rwcancel.RWCancel, error) {
|
||||||
|
if !conn.StdNetSupportsStickySockets {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
if _, ok := bind.(*conn.StdNetBind); !ok {
|
if _, ok := bind.(*conn.StdNetBind); !ok {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user