]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
conn: simplify supportsUDPOffload
authorJason A. Donenfeld <Jason@zx2c4.com>
Wed, 18 Oct 2023 19:02:52 +0000 (21:02 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Wed, 18 Oct 2023 19:02:52 +0000 (21:02 +0200)
This allows a kernel to support UDP_GRO while not supporting
UDP_SEGMENT.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
conn/features_linux.go

index e1fb57fa46ad38609ec48202b93c3d3d675d1051..8959d935829a6a7fab08f1bee2eba949f2af779b 100644 (file)
@@ -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