diff --git a/cmd/tailscaled/depaware.txt b/cmd/tailscaled/depaware.txt index 9677687e5..052893f58 100644 --- a/cmd/tailscaled/depaware.txt +++ b/cmd/tailscaled/depaware.txt @@ -129,7 +129,8 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de 💣 golang.zx2c4.com/wireguard/tun from golang.zx2c4.com/wireguard/device+ W 💣 golang.zx2c4.com/wireguard/windows/tunnel/winipcfg from tailscale.com/cmd/tailscaled+ gvisor.dev/gvisor/pkg/atomicbitops from gvisor.dev/gvisor/pkg/tcpip+ - 💣 gvisor.dev/gvisor/pkg/buffer from gvisor.dev/gvisor/pkg/tcpip/stack + gvisor.dev/gvisor/pkg/bits from gvisor.dev/gvisor/pkg/bufferv2 + 💣 gvisor.dev/gvisor/pkg/bufferv2 from gvisor.dev/gvisor/pkg/tcpip+ gvisor.dev/gvisor/pkg/context from gvisor.dev/gvisor/pkg/refs+ 💣 gvisor.dev/gvisor/pkg/gohacks from gvisor.dev/gvisor/pkg/state/wire+ gvisor.dev/gvisor/pkg/linewriter from gvisor.dev/gvisor/pkg/log @@ -143,7 +144,6 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de 💣 gvisor.dev/gvisor/pkg/sync from gvisor.dev/gvisor/pkg/linewriter+ gvisor.dev/gvisor/pkg/tcpip from gvisor.dev/gvisor/pkg/tcpip/header+ gvisor.dev/gvisor/pkg/tcpip/adapters/gonet from tailscale.com/wgengine/netstack - 💣 gvisor.dev/gvisor/pkg/tcpip/buffer from gvisor.dev/gvisor/pkg/tcpip/header+ gvisor.dev/gvisor/pkg/tcpip/hash/jenkins from gvisor.dev/gvisor/pkg/tcpip/stack+ gvisor.dev/gvisor/pkg/tcpip/header from gvisor.dev/gvisor/pkg/tcpip/header/parse+ gvisor.dev/gvisor/pkg/tcpip/header/parse from gvisor.dev/gvisor/pkg/tcpip/network/ipv4+ @@ -152,6 +152,7 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de gvisor.dev/gvisor/pkg/tcpip/network/hash from gvisor.dev/gvisor/pkg/tcpip/network/ipv4+ gvisor.dev/gvisor/pkg/tcpip/network/internal/fragmentation from gvisor.dev/gvisor/pkg/tcpip/network/ipv4+ gvisor.dev/gvisor/pkg/tcpip/network/internal/ip from gvisor.dev/gvisor/pkg/tcpip/network/ipv4+ + gvisor.dev/gvisor/pkg/tcpip/network/internal/multicast from gvisor.dev/gvisor/pkg/tcpip/network/ipv4+ gvisor.dev/gvisor/pkg/tcpip/network/ipv4 from tailscale.com/net/tstun+ gvisor.dev/gvisor/pkg/tcpip/network/ipv6 from tailscale.com/wgengine/netstack gvisor.dev/gvisor/pkg/tcpip/ports from gvisor.dev/gvisor/pkg/tcpip/stack+ diff --git a/go.mod b/go.mod index dc707b329..4caed6c66 100644 --- a/go.mod +++ b/go.mod @@ -19,12 +19,14 @@ require ( github.com/dave/jennifer v1.4.1 github.com/evanw/esbuild v0.14.39 github.com/frankban/quicktest v1.14.0 + github.com/fxamacker/cbor/v2 v2.4.0 github.com/go-ole/go-ole v1.2.6 github.com/godbus/dbus/v5 v5.0.6 github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da github.com/google/go-cmp v0.5.8 github.com/google/uuid v1.3.0 github.com/goreleaser/nfpm v1.10.3 + github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 github.com/iancoleman/strcase v0.2.0 github.com/insomniacslk/dhcp v0.0.0-20211209223715-7d93572ebe8e github.com/jsimonetti/rtnetlink v1.1.2-0.20220408201609-d380b505068b @@ -61,7 +63,7 @@ require ( golang.org/x/tools v0.1.11 golang.zx2c4.com/wireguard v0.0.0-20220703234212-c31a7b1ab478 golang.zx2c4.com/wireguard/windows v0.4.10 - gvisor.dev/gvisor v0.0.0-20220407223209-21871174d445 + gvisor.dev/gvisor v0.0.0-20220721202624-0b2c11c2773c honnef.co/go/tools v0.4.0-0.dev.0.20220404092545-59d7a2877f83 inet.af/netaddr v0.0.0-20220617031823-097006376321 inet.af/peercred v0.0.0-20210906144145-0893ea02156a @@ -124,7 +126,6 @@ require ( github.com/fatih/color v1.13.0 // indirect github.com/fatih/structtag v1.2.0 // indirect github.com/fsnotify/fsnotify v1.5.1 // indirect - github.com/fxamacker/cbor/v2 v2.4.0 // indirect github.com/fzipp/gocyclo v0.3.1 // indirect github.com/gliderlabs/ssh v0.3.3 // indirect github.com/go-critic/go-critic v0.6.1 // indirect @@ -166,7 +167,6 @@ require ( github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/hcl v1.0.0 // indirect - github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 // indirect github.com/huandu/xstrings v1.3.2 // indirect github.com/imdario/mergo v0.3.12 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect diff --git a/go.sum b/go.sum index d77d628ca..09aea7b23 100644 --- a/go.sum +++ b/go.sum @@ -1110,8 +1110,6 @@ github.com/tailscale/golang-x-crypto v0.0.0-20220428210705-0b941c09a5e1 h1:vsFV6 github.com/tailscale/golang-x-crypto v0.0.0-20220428210705-0b941c09a5e1/go.mod h1:95n9fbUCixVSI4QXLEvdKJjnYK2eUlkTx9+QwLPXFKU= github.com/tailscale/goupnp v1.0.1-0.20210804011211-c64d0f06ea05 h1:4chzWmimtJPxRs2O36yuGRW3f9SYV+bMTTvMBI0EKio= github.com/tailscale/goupnp v1.0.1-0.20210804011211-c64d0f06ea05/go.mod h1:PdCqy9JzfWMJf1H5UJW2ip33/d4YkoKN0r67yKH1mG8= -github.com/tailscale/hujson v0.0.0-20220506202205-92b4b88a9e17 h1:QaQrUggZ7U2lE3HhoPx6bDK7fO385FR7pHRYSPEv70Q= -github.com/tailscale/hujson v0.0.0-20220506202205-92b4b88a9e17/go.mod h1:DFSS3NAGHthKo1gTlmEcSBiZrRJXi28rLNd/1udP1c8= github.com/tailscale/hujson v0.0.0-20220630195928-54599719472f h1:n4r/sJ92cBSBHK8n9lR1XLFr0OiTVeGfN5TR+9LaN7E= github.com/tailscale/hujson v0.0.0-20220630195928-54599719472f/go.mod h1:DFSS3NAGHthKo1gTlmEcSBiZrRJXi28rLNd/1udP1c8= github.com/tailscale/mkctr v0.0.0-20220601142259-c0b937af2e89 h1:7xU7AFQE83h0wz/dIMvD0t77g0FxFfZIQjghDQxyG2U= @@ -1859,8 +1857,8 @@ gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C 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= gotest.tools/v3 v3.0.3 h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0= -gvisor.dev/gvisor v0.0.0-20220407223209-21871174d445 h1:pLNQCtMzh4O6rdhoUeWHuutt4yMft+B9Cgw/bezWchE= -gvisor.dev/gvisor v0.0.0-20220407223209-21871174d445/go.mod h1:tWwEcFvJavs154OdjFCw78axNrsDlz4Zh8jvPqwcpGI= +gvisor.dev/gvisor v0.0.0-20220721202624-0b2c11c2773c h1:frrINYSQqhraHqy23/dWqdNt7mRlsGJJBwGHvI3Q+/c= +gvisor.dev/gvisor v0.0.0-20220721202624-0b2c11c2773c/go.mod h1:TIvkJD0sxe8pIob3p6T8IzxXunlp6yfgktvTNp+DGNM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/net/tstun/tap_linux.go b/net/tstun/tap_linux.go index ea16f0ffc..153cf5cda 100644 --- a/net/tstun/tap_linux.go +++ b/net/tstun/tap_linux.go @@ -14,7 +14,6 @@ "golang.org/x/sys/unix" "golang.zx2c4.com/wireguard/tun" "gvisor.dev/gvisor/pkg/tcpip" - "gvisor.dev/gvisor/pkg/tcpip/buffer" "gvisor.dev/gvisor/pkg/tcpip/header" "gvisor.dev/gvisor/pkg/tcpip/network/ipv4" "gvisor.dev/gvisor/pkg/tcpip/transport/udp" @@ -290,7 +289,7 @@ func (t *Wrapper) handleDHCPRequest(ethBuf []byte) bool { } func packLayer2UDP(payload []byte, srcMAC, dstMAC net.HardwareAddr, src, dst netaddr.IPPort) []byte { - buf := buffer.NewView(header.EthernetMinimumSize + header.UDPMinimumSize + header.IPv4MinimumSize + len(payload)) + buf := make([]byte, header.EthernetMinimumSize+header.UDPMinimumSize+header.IPv4MinimumSize+len(payload)) payloadStart := len(buf) - len(payload) copy(buf[payloadStart:], payload) srcB := src.IP().As4() diff --git a/net/tstun/wrap.go b/net/tstun/wrap.go index 61d529f85..1c50eccda 100644 --- a/net/tstun/wrap.go +++ b/net/tstun/wrap.go @@ -524,9 +524,10 @@ func (t *Wrapper) Read(buf []byte, offset int) (int, error) { var n int if res.packet != nil { - n = copy(buf[offset:], res.packet.NetworkHeader().View()) - n += copy(buf[offset+n:], res.packet.TransportHeader().View()) - n += copy(buf[offset+n:], res.packet.Data().AsRange().AsView()) + + n = copy(buf[offset:], res.packet.NetworkHeader().Slice()) + n += copy(buf[offset+n:], res.packet.TransportHeader().Slice()) + n += copy(buf[offset+n:], res.packet.Data().AsRange().ToSlice()) res.packet.DecRef() } else { @@ -715,9 +716,9 @@ func (t *Wrapper) SetFilter(filt *filter.Filter) { func (t *Wrapper) InjectInboundPacketBuffer(pkt *stack.PacketBuffer) error { buf := make([]byte, PacketStartOffset+pkt.Size()) - n := copy(buf[PacketStartOffset:], pkt.NetworkHeader().View()) - n += copy(buf[PacketStartOffset+n:], pkt.TransportHeader().View()) - n += copy(buf[PacketStartOffset+n:], pkt.Data().AsRange().AsView()) + n := copy(buf[PacketStartOffset:], pkt.NetworkHeader().Slice()) + n += copy(buf[PacketStartOffset+n:], pkt.TransportHeader().Slice()) + n += copy(buf[PacketStartOffset+n:], pkt.Data().AsRange().ToSlice()) if n != pkt.Size() { panic("unexpected packet size after copy") } diff --git a/tstest/archtest/archtest_test.go b/tstest/archtest/archtest_test.go index a758536b3..da5e0c5af 100644 --- a/tstest/archtest/archtest_test.go +++ b/tstest/archtest/archtest_test.go @@ -14,9 +14,9 @@ // tests netstack's AlignedAtomicInt64. func TestAlignedAtomicInt64(t *testing.T) { type T struct { - A atomicbitops.AlignedAtomicInt64 + A atomicbitops.Int64 x int32 - B atomicbitops.AlignedAtomicInt64 + B atomicbitops.Int64 } t.Logf("I am %v/%v\n", runtime.GOOS, runtime.GOARCH) diff --git a/wgengine/netstack/netstack.go b/wgengine/netstack/netstack.go index 201b8a9dd..4b9882258 100644 --- a/wgengine/netstack/netstack.go +++ b/wgengine/netstack/netstack.go @@ -21,10 +21,10 @@ "sync/atomic" "time" + "gvisor.dev/gvisor/pkg/bufferv2" "gvisor.dev/gvisor/pkg/refs" "gvisor.dev/gvisor/pkg/tcpip" "gvisor.dev/gvisor/pkg/tcpip/adapters/gonet" - "gvisor.dev/gvisor/pkg/tcpip/buffer" "gvisor.dev/gvisor/pkg/tcpip/header" "gvisor.dev/gvisor/pkg/tcpip/link/channel" "gvisor.dev/gvisor/pkg/tcpip/network/ipv4" @@ -402,9 +402,9 @@ func (ns *Impl) handleLocalPackets(p *packet.Parsed, t *tstun.Wrapper) filter.Re if debugPackets { ns.logf("[v2] service packet in (from %v): % x", p.Src, p.Buffer()) } - vv := buffer.View(append([]byte(nil), p.Buffer()...)).ToVectorisedView() + packetBuf := stack.NewPacketBuffer(stack.PacketBufferOptions{ - Data: vv, + Payload: bufferv2.MakeWithData(append([]byte(nil), p.Buffer()...)), }) ns.linkEP.InjectInbound(pn, packetBuf) packetBuf.DecRef() @@ -477,7 +477,7 @@ func (ns *Impl) inject() { // TODO(tom): Figure out if its safe to modify packet.Parsed to fill in // the IP src/dest even if its missing the rest of the pkt. // That way we dont have to do this twitchy-af byte-yeeting. - if b := pkt.NetworkHeader().View(); len(b) >= 20 { // min ipv4 header + if b := pkt.NetworkHeader().Slice(); len(b) >= 20 { // min ipv4 header switch b[0] >> 4 { // ip proto field case 4: if srcIP := netaddr.IPv4(b[12], b[13], b[14], b[15]); magicDNSIP == srcIP { @@ -687,9 +687,8 @@ func (ns *Impl) injectInbound(p *packet.Parsed, t *tstun.Wrapper) filter.Respons if debugPackets { ns.logf("[v2] packet in (from %v): % x", p.Src, p.Buffer()) } - vv := buffer.View(append([]byte(nil), p.Buffer()...)).ToVectorisedView() packetBuf := stack.NewPacketBuffer(stack.PacketBufferOptions{ - Data: vv, + Payload: bufferv2.MakeWithData(append([]byte(nil), p.Buffer()...)), }) ns.linkEP.InjectInbound(pn, packetBuf) packetBuf.DecRef()