diff --git a/core/device/tun/tun_netstack.go b/core/device/tun/tun_netstack.go index aa7d5306..a451ae1b 100644 --- a/core/device/tun/tun_netstack.go +++ b/core/device/tun/tun_netstack.go @@ -55,12 +55,15 @@ func Open(name string, mtu uint32) (device.Device, error) { EthernetHeader: false, // SYS_READV support only for TUN fd. PacketDispatchMode: fdbased.Readv, - // TODO: set this field to zero in the future. - // it's a only temporary hack to avoid `socket operation - // on non-socket` error caused by SYS_SENDMMSG syscall. + // TAP/TUN fd's are not sockets and using the WritePackets calls results + // in errors as it always defaults to using SendMMsg which is not supported + // for tap/tun device fds. // - // Ref: https://github.com/google/gvisor/issues/7125 - MaxSyscallHeaderBytes: 0x40, + // This CL changes WritePackets to gracefully degrade to using writev instead + // of sendmmsg if the underlying fd is not a socket. + // + // Fixed: https://github.com/google/gvisor/commit/f33d034fecd7723a1e560ccc62aeeba328454fd0 + MaxSyscallHeaderBytes: 0x00, }) if err != nil { return nil, fmt.Errorf("create endpoint: %w", err) diff --git a/go.mod b/go.mod index 7d27b4eb..7f4ec051 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11 golang.zx2c4.com/wireguard v0.0.0-20220202223031-3b95c81cc178 gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b - gvisor.dev/gvisor v0.0.0-20220205064904-d09fa42eaa20 + gvisor.dev/gvisor v0.0.0-20220208035940-56a131734b85 ) require ( diff --git a/go.sum b/go.sum index adea0a12..df41fba3 100644 --- a/go.sum +++ b/go.sum @@ -60,5 +60,5 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gvisor.dev/gvisor v0.0.0-20220205064904-d09fa42eaa20 h1:Aih4gc0gDmeT48uWlEuR7kl8AjqHR6buUV2kfjPzC0Y= -gvisor.dev/gvisor v0.0.0-20220205064904-d09fa42eaa20/go.mod h1:V4WNP2Uwtx69eOhvLDSQ734EaTJTaBI3P8KgRAlROsg= +gvisor.dev/gvisor v0.0.0-20220208035940-56a131734b85 h1:BELDz7P8Bn3BMDa9NYMDGATVO+F1fd/Pvr3Z2oisCvI= +gvisor.dev/gvisor v0.0.0-20220208035940-56a131734b85/go.mod h1:V4WNP2Uwtx69eOhvLDSQ734EaTJTaBI3P8KgRAlROsg=