From 891d964bd44924812496725914474326aff9d306 Mon Sep 17 00:00:00 2001 From: Jordan Whited Date: Wed, 18 Oct 2023 18:50:40 -0700 Subject: [PATCH] wgengine/magicsock: simplify tryEnableUDPOffload() (#9872) Don't assume Linux lacks UDP_GRO support if it lacks UDP_SEGMENT support. This mirrors a similar change in wireguard/wireguard-go@177caa7 for consistency sake. We haven't found any issues here, just being overly paranoid. Updates #cleanup Signed-off-by: Jordan Whited --- wgengine/magicsock/magicsock_linux.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/wgengine/magicsock/magicsock_linux.go b/wgengine/magicsock/magicsock_linux.go index 1f7f5528d..c484f77c0 100644 --- a/wgengine/magicsock/magicsock_linux.go +++ b/wgengine/magicsock/magicsock_linux.go @@ -328,11 +328,7 @@ func tryEnableUDPOffload(pconn nettype.PacketConn) (hasTX bool, hasRX bool) { } err = rc.Control(func(fd uintptr) { _, errSyscall := syscall.GetsockoptInt(int(fd), unix.IPPROTO_UDP, unix.UDP_SEGMENT) - if errSyscall != nil { - // no point in checking RX, TX support was added first. - return - } - hasTX = true + hasTX = errSyscall == nil errSyscall = syscall.SetsockoptInt(int(fd), unix.IPPROTO_UDP, unix.UDP_GRO, 1) hasRX = errSyscall == nil })