summaryrefslogtreecommitdiffhomepage
path: root/conn/features_linux.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2023-10-18 21:02:52 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2023-10-18 21:02:52 +0200
commit177caa7e4419d1b95bbf0423f6be6230c7101504 (patch)
treeadd58988d7b424c14a4011a82aa7008883487cc8 /conn/features_linux.go
parent42ec952eadc297efadc70b9911d5a59bcd2db4a6 (diff)
conn: simplify supportsUDPOffload
This allows a kernel to support UDP_GRO while not supporting UDP_SEGMENT. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'conn/features_linux.go')
-rw-r--r--conn/features_linux.go10
1 files changed, 2 insertions, 8 deletions
diff --git a/conn/features_linux.go b/conn/features_linux.go
index e1fb57f..8959d93 100644
--- a/conn/features_linux.go
+++ b/conn/features_linux.go
@@ -18,15 +18,9 @@ func supportsUDPOffload(conn *net.UDPConn) (txOffload, rxOffload bool) {
}
err = rc.Control(func(fd uintptr) {
_, errSyscall := unix.GetsockoptInt(int(fd), unix.IPPROTO_UDP, unix.UDP_SEGMENT)
- if errSyscall != nil {
- return
- }
- txOffload = true
+ txOffload = errSyscall == nil
opt, errSyscall := unix.GetsockoptInt(int(fd), unix.IPPROTO_UDP, unix.UDP_GRO)
- if errSyscall != nil {
- return
- }
- rxOffload = opt == 1
+ rxOffload = errSyscall == nil && opt == 1
})
if err != nil {
return false, false