diff --git a/sys_conn_helper_linux.go b/sys_conn_helper_linux.go index 5a177c29..5bda2286 100644 --- a/sys_conn_helper_linux.go +++ b/sys_conn_helper_linux.go @@ -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)