@@ -90,17 +90,25 @@ func supportsUDPOffload(conn *net.UDPConn) (txOffload, rxOffload bool) {
9090 log .W ("wg: gso: syscall conn nil" )
9191 return
9292 }
93+
94+ var opt int
95+ var errSyscallTx , errSyscallRx error
9396 err = rc .Control (func (fd uintptr ) {
94- _ , errSyscall := unix .GetsockoptInt (int (fd ), unix .IPPROTO_UDP , unix .UDP_SEGMENT )
95- txOffload = errSyscall == nil
96- opt , errSyscall := unix .GetsockoptInt (int (fd ), unix .IPPROTO_UDP , unix .UDP_GRO )
97- rxOffload = errSyscall == nil && opt == 1
97+ _ , errSyscallTx = unix .GetsockoptInt (int (fd ), unix .IPPROTO_UDP , unix .UDP_SEGMENT )
98+ opt , errSyscallRx = unix .GetsockoptInt (int (fd ), unix .IPPROTO_UDP , unix .UDP_GRO )
99+
98100 })
101+
99102 if err != nil {
100103 log .W ("wg: gso: no support; err: %v" , err )
101- return false , false
104+ return
102105 }
103- log .I ("wg: gso: txOffload: %v, rxOffload: %v" , txOffload , rxOffload )
106+
107+ txOffload = errSyscallTx == nil
108+ rxOffload = errSyscallRx == nil && opt == 1
109+
110+ log .I ("wg: gso: txOffload: %t (errTx: %v), rxOffload: %t (opt: %d; errRx: %v)" ,
111+ txOffload , rxOffload , errSyscallTx , opt , errSyscallRx )
104112 return txOffload , rxOffload
105113}
106114
0 commit comments