forked from quic-go/quic-go
add QUIC_GO_DISABLE_GSO env to disable GSO
This commit is contained in:
@@ -7,12 +7,22 @@ import (
|
||||
"errors"
|
||||
"net/netip"
|
||||
"os"
|
||||
"strconv"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
var gsoDisabled bool
|
||||
|
||||
func init() {
|
||||
disabled, err := strconv.ParseBool(os.Getenv("QUIC_GO_DISABLE_GSO"))
|
||||
if err == nil {
|
||||
gsoDisabled = disabled
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
msgTypeIPTOS = unix.IP_TOS
|
||||
ipv4PKTINFO = unix.IP_PKTINFO
|
||||
@@ -55,6 +65,9 @@ func parseIPv4PktInfo(body []byte) (ip netip.Addr, ifIndex uint32, ok bool) {
|
||||
// isGSOSupported tests if the kernel supports GSO.
|
||||
// Sending with GSO might still fail later on, if the interface doesn't support it (see isGSOError).
|
||||
func isGSOSupported(conn syscall.RawConn) bool {
|
||||
if gsoDisabled {
|
||||
return false
|
||||
}
|
||||
var serr error
|
||||
if err := conn.Control(func(fd uintptr) {
|
||||
_, serr = unix.GetsockoptInt(int(fd), unix.IPPROTO_UDP, unix.UDP_SEGMENT)
|
||||
|
||||
Reference in New Issue
Block a user