Skip to content

Commit 2da8bb3

Browse files
committed
conn: disable GRO/GSO on Android
We're already getting weird reports about performance drops. Android kernels are known to be wild, so let's not play games. Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent 264889f commit 2da8bb3

File tree

6 files changed

+11
-10
lines changed

6 files changed

+11
-10
lines changed

conn/bind_std.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ again:
175175
var fns []ReceiveFunc
176176
if v4conn != nil {
177177
s.ipv4TxOffload, s.ipv4RxOffload = supportsUDPOffload(v4conn)
178-
if runtime.GOOS == "linux" || runtime.GOOS == "android" {
178+
if runtime.GOOS == "linux" {
179179
v4pc = ipv4.NewPacketConn(v4conn)
180180
s.ipv4PC = v4pc
181181
}
@@ -184,7 +184,7 @@ again:
184184
}
185185
if v6conn != nil {
186186
s.ipv6TxOffload, s.ipv6RxOffload = supportsUDPOffload(v6conn)
187-
if runtime.GOOS == "linux" || runtime.GOOS == "android" {
187+
if runtime.GOOS == "linux" {
188188
v6pc = ipv6.NewPacketConn(v6conn)
189189
s.ipv6PC = v6pc
190190
}
@@ -238,7 +238,7 @@ func (s *StdNetBind) receiveIP(
238238
}
239239
defer s.putMessages(msgs)
240240
var numMsgs int
241-
if runtime.GOOS == "linux" || runtime.GOOS == "android" {
241+
if runtime.GOOS == "linux" {
242242
if rxOffload {
243243
readAt := len(*msgs) - (IdealBatchSize / udpSegmentMaxDatagrams)
244244
numMsgs, err = br.ReadBatch((*msgs)[readAt:], 0)
@@ -292,7 +292,7 @@ func (s *StdNetBind) makeReceiveIPv6(pc *ipv6.PacketConn, conn *net.UDPConn, rxO
292292
// TODO: When all Binds handle IdealBatchSize, remove this dynamic function and
293293
// rename the IdealBatchSize constant to BatchSize.
294294
func (s *StdNetBind) BatchSize() int {
295-
if runtime.GOOS == "linux" || runtime.GOOS == "android" {
295+
if runtime.GOOS == "linux" {
296296
return IdealBatchSize
297297
}
298298
return 1
@@ -415,7 +415,7 @@ func (s *StdNetBind) send(conn *net.UDPConn, pc batchWriter, msgs []ipv6.Message
415415
err error
416416
start int
417417
)
418-
if runtime.GOOS == "linux" || runtime.GOOS == "android" {
418+
if runtime.GOOS == "linux" {
419419
for {
420420
n, err = pc.WriteBatch(msgs[start:], 0)
421421
if err != nil || n == len(msgs[start:]) {

conn/features_default.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
//go:build !linux
2-
// +build !linux
1+
//go:build !linux || android
32

43
/* SPDX-License-Identifier: MIT
54
*

conn/features_linux.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build linux && !android
2+
13
/* SPDX-License-Identifier: MIT
24
*
35
* Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved.

conn/gso_default.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build !linux
1+
//go:build !linux || android
22

33
/* SPDX-License-Identifier: MIT
44
*

conn/gso_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build linux
1+
//go:build linux && !android
22

33
/* SPDX-License-Identifier: MIT
44
*

device/queueconstants_android.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ const (
1414
QueueOutboundSize = 1024
1515
QueueInboundSize = 1024
1616
QueueHandshakeSize = 1024
17-
MaxSegmentSize = (1 << 16) - 1 // largest possible UDP datagram
17+
MaxSegmentSize = 2200
1818
PreallocatedBuffersPerPool = 4096
1919
)

0 commit comments

Comments
 (0)