Skip to content

Commit

Permalink
Fix Android UDP GRO check
Browse files Browse the repository at this point in the history
  • Loading branch information
albexk authored and pokamest committed Feb 12, 2024
1 parent 59101fd commit 032e33f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
8 changes: 0 additions & 8 deletions conn/controlfns_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,5 @@ func init() {
}
return err
},

// Attempt to enable UDP_GRO
func(network, address string, c syscall.RawConn) error {
c.Control(func(fd uintptr) {
_ = unix.SetsockoptInt(int(fd), unix.IPPROTO_UDP, unix.UDP_GRO, 1)
})
return nil
},
)
}
6 changes: 4 additions & 2 deletions conn/features_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ 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)
txOffload = errSyscall == nil
opt, errSyscall := unix.GetsockoptInt(int(fd), unix.IPPROTO_UDP, unix.UDP_GRO)
rxOffload = errSyscall == nil && opt == 1
// getsockopt(IPPROTO_UDP, UDP_GRO) is not supported in android
// use setsockopt workaround
errSyscall = unix.SetsockoptInt(int(fd), unix.IPPROTO_UDP, unix.UDP_GRO, 1)
rxOffload = errSyscall == nil
})
if err != nil {
return false, false
Expand Down

0 comments on commit 032e33f

Please sign in to comment.