mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
have gVisor use renamed buffer package
PiperOrigin-RevId: 537209194
This commit is contained in:
committed by
gVisor bot
parent
64d1e9c09b
commit
89d6bf18c8
@@ -10,7 +10,7 @@ go_library(
|
||||
visibility = ["//pkg/sentry:internal"],
|
||||
deps = [
|
||||
"//pkg/abi/linux",
|
||||
"//pkg/bufferv2",
|
||||
"//pkg/buffer",
|
||||
"//pkg/context",
|
||||
"//pkg/errors/linuxerr",
|
||||
"//pkg/hostarch",
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
"gvisor.dev/gvisor/pkg/abi/linux"
|
||||
"gvisor.dev/gvisor/pkg/bufferv2"
|
||||
"gvisor.dev/gvisor/pkg/buffer"
|
||||
"gvisor.dev/gvisor/pkg/context"
|
||||
"gvisor.dev/gvisor/pkg/errors/linuxerr"
|
||||
"gvisor.dev/gvisor/pkg/hostarch"
|
||||
@@ -156,7 +156,7 @@ func (fd *tunFD) Write(ctx context.Context, src usermem.IOSequence, opts vfs.Wri
|
||||
if int64(mtu) < src.NumBytes() {
|
||||
return 0, unix.EMSGSIZE
|
||||
}
|
||||
data := bufferv2.NewView(int(src.NumBytes()))
|
||||
data := buffer.NewView(int(src.NumBytes()))
|
||||
defer data.Release()
|
||||
if _, err := io.CopyN(data, src.Reader(ctx), src.NumBytes()); err != nil {
|
||||
return 0, err
|
||||
|
||||
@@ -89,7 +89,7 @@ go_library(
|
||||
deps = [
|
||||
"//pkg/abi/linux",
|
||||
"//pkg/atomicbitops",
|
||||
"//pkg/bufferv2",
|
||||
"//pkg/buffer",
|
||||
"//pkg/context",
|
||||
"//pkg/errors/linuxerr",
|
||||
"//pkg/fdnotifier",
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ go_library(
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg/atomicbitops",
|
||||
"//pkg/bufferv2",
|
||||
"//pkg/buffer",
|
||||
"//pkg/sync",
|
||||
"//pkg/waiter",
|
||||
],
|
||||
|
||||
@@ -11,7 +11,7 @@ go_library(
|
||||
srcs = ["checker.go"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg/bufferv2",
|
||||
"//pkg/buffer",
|
||||
"//pkg/tcpip",
|
||||
"//pkg/tcpip/checksum",
|
||||
"//pkg/tcpip/header",
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"gvisor.dev/gvisor/pkg/bufferv2"
|
||||
"gvisor.dev/gvisor/pkg/buffer"
|
||||
"gvisor.dev/gvisor/pkg/tcpip"
|
||||
"gvisor.dev/gvisor/pkg/tcpip/checksum"
|
||||
"gvisor.dev/gvisor/pkg/tcpip/header"
|
||||
@@ -45,7 +45,7 @@ type ControlMessagesChecker func(*testing.T, tcpip.ReceivableControlMessages)
|
||||
// would call:
|
||||
//
|
||||
// checker.IPv4(t, v, checker.SrcAddr(x), checker.DstAddr(y))
|
||||
func IPv4(t *testing.T, v *bufferv2.View, checkers ...NetworkChecker) {
|
||||
func IPv4(t *testing.T, v *buffer.View, checkers ...NetworkChecker) {
|
||||
t.Helper()
|
||||
|
||||
ipv4 := header.IPv4(v.AsSlice())
|
||||
@@ -68,7 +68,7 @@ func IPv4(t *testing.T, v *bufferv2.View, checkers ...NetworkChecker) {
|
||||
|
||||
// IPv6 checks the validity and properties of the given IPv6 packet. The usage
|
||||
// is similar to IPv4.
|
||||
func IPv6(t *testing.T, v *bufferv2.View, checkers ...NetworkChecker) {
|
||||
func IPv6(t *testing.T, v *buffer.View, checkers ...NetworkChecker) {
|
||||
t.Helper()
|
||||
|
||||
ipv6 := header.IPv6(v.AsSlice())
|
||||
@@ -1703,7 +1703,7 @@ func IGMPv3Report(expectedRecords map[tcpip.Address]header.IGMPv3ReportRecordTyp
|
||||
type IPv6ExtHdrChecker func(*testing.T, header.IPv6PayloadHeader)
|
||||
|
||||
// IPv6WithExtHdr is like IPv6 but allows IPv6 packets with extension headers.
|
||||
func IPv6WithExtHdr(t *testing.T, v *bufferv2.View, checkers ...NetworkChecker) {
|
||||
func IPv6WithExtHdr(t *testing.T, v *buffer.View, checkers ...NetworkChecker) {
|
||||
t.Helper()
|
||||
|
||||
ipv6 := header.IPv6(v.AsSlice())
|
||||
@@ -1714,7 +1714,7 @@ func IPv6WithExtHdr(t *testing.T, v *bufferv2.View, checkers ...NetworkChecker)
|
||||
|
||||
payloadIterator := header.MakeIPv6PayloadIterator(
|
||||
header.IPv6ExtensionHeaderIdentifier(ipv6.NextHeader()),
|
||||
bufferv2.MakeWithData(ipv6.Payload()),
|
||||
buffer.MakeWithData(ipv6.Payload()),
|
||||
)
|
||||
defer payloadIterator.Release()
|
||||
|
||||
@@ -1764,7 +1764,7 @@ func IPv6ExtHdr(headers ...IPv6ExtHdrChecker) NetworkChecker {
|
||||
|
||||
payloadIterator := header.MakeIPv6PayloadIterator(
|
||||
header.IPv6ExtensionHeaderIdentifier(extHdrs.IPv6.NextHeader()),
|
||||
bufferv2.MakeWithData(extHdrs.IPv6.Payload()),
|
||||
buffer.MakeWithData(extHdrs.IPv6.Payload()),
|
||||
)
|
||||
defer payloadIterator.Release()
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ go_library(
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg/bufferv2",
|
||||
"//pkg/buffer",
|
||||
"//pkg/tcpip",
|
||||
"//pkg/tcpip/checksum",
|
||||
"//pkg/tcpip/seqnum",
|
||||
@@ -58,7 +58,7 @@ go_test(
|
||||
],
|
||||
deps = [
|
||||
":header",
|
||||
"//pkg/bufferv2",
|
||||
"//pkg/buffer",
|
||||
"//pkg/rand",
|
||||
"//pkg/tcpip",
|
||||
"//pkg/tcpip/checksum",
|
||||
@@ -79,7 +79,7 @@ go_test(
|
||||
],
|
||||
library = ":header",
|
||||
deps = [
|
||||
"//pkg/bufferv2",
|
||||
"//pkg/buffer",
|
||||
"//pkg/tcpip",
|
||||
"//pkg/tcpip/testutil",
|
||||
"@com_github_google_go_cmp//cmp:go_default_library",
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/bufferv2"
|
||||
"gvisor.dev/gvisor/pkg/buffer"
|
||||
"gvisor.dev/gvisor/pkg/tcpip"
|
||||
"gvisor.dev/gvisor/pkg/tcpip/checksum"
|
||||
"gvisor.dev/gvisor/pkg/tcpip/header"
|
||||
@@ -77,8 +77,8 @@ func TestICMPv4Checksum(t *testing.T) {
|
||||
if _, err := rnd.Read(buf); err != nil {
|
||||
t.Fatalf("rnd.Read failed: %v", err)
|
||||
}
|
||||
b := bufferv2.MakeWithData(buf[:5])
|
||||
b.Append(bufferv2.NewViewWithData(buf[5:]))
|
||||
b := buffer.MakeWithData(buf[:5])
|
||||
b.Append(buffer.NewViewWithData(buf[5:]))
|
||||
|
||||
want := checksum.Checksum(b.Flatten(), 0)
|
||||
want = ^checksum.Checksum(h, want)
|
||||
@@ -102,9 +102,9 @@ func TestICMPv6Checksum(t *testing.T) {
|
||||
if _, err := rnd.Read(buf); err != nil {
|
||||
t.Fatalf("rnd.Read failed: %v", err)
|
||||
}
|
||||
b := bufferv2.MakeWithData(buf[:7])
|
||||
b.Append(bufferv2.NewViewWithData(buf[7:10]))
|
||||
b.Append(bufferv2.NewViewWithData(buf[10:]))
|
||||
b := buffer.MakeWithData(buf[:7])
|
||||
b.Append(buffer.NewViewWithData(buf[7:10]))
|
||||
b.Append(buffer.NewViewWithData(buf[10:]))
|
||||
|
||||
dst := header.IPv6Loopback
|
||||
src := header.IPv6Loopback
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
"io"
|
||||
"math"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/bufferv2"
|
||||
"gvisor.dev/gvisor/pkg/buffer"
|
||||
"gvisor.dev/gvisor/pkg/tcpip"
|
||||
)
|
||||
|
||||
@@ -163,7 +163,7 @@ type IPv6PayloadHeader interface {
|
||||
// it's no longer needed.
|
||||
type IPv6RawPayloadHeader struct {
|
||||
Identifier IPv6ExtensionHeaderIdentifier
|
||||
Buf bufferv2.Buffer
|
||||
Buf buffer.Buffer
|
||||
}
|
||||
|
||||
// isIPv6PayloadHeader implements IPv6PayloadHeader.isIPv6PayloadHeader.
|
||||
@@ -176,7 +176,7 @@ func (i IPv6RawPayloadHeader) Release() {
|
||||
|
||||
// ipv6OptionsExtHdr is an IPv6 extension header that holds options.
|
||||
type ipv6OptionsExtHdr struct {
|
||||
buf *bufferv2.View
|
||||
buf *buffer.View
|
||||
}
|
||||
|
||||
// Release implements IPv6PayloadHeader.Release.
|
||||
@@ -203,7 +203,7 @@ func (i ipv6OptionsExtHdr) Iter() IPv6OptionsExtHdrOptionsIterator {
|
||||
// modify the backing payload so long as the IPv6OptionsExtHdrOptionsIterator
|
||||
// obtained before modification is no longer used.
|
||||
type IPv6OptionsExtHdrOptionsIterator struct {
|
||||
reader *bufferv2.View
|
||||
reader *buffer.View
|
||||
|
||||
// optionOffset is the number of bytes from the first byte of the
|
||||
// options field to the beginning of the current option.
|
||||
@@ -299,7 +299,7 @@ var ErrMalformedIPv6ExtHdrOption = errors.New("malformed IPv6 extension header o
|
||||
// header option that is unknown by the parsing utilities.
|
||||
type IPv6UnknownExtHdrOption struct {
|
||||
Identifier IPv6ExtHdrOptionIdentifier
|
||||
Data *bufferv2.View
|
||||
Data *buffer.View
|
||||
}
|
||||
|
||||
// UnknownAction implements IPv6OptionUnknownAction.UnknownAction.
|
||||
@@ -382,7 +382,7 @@ func (i *IPv6OptionsExtHdrOptionsIterator) Next() (IPv6ExtHdrOption, bool, error
|
||||
}
|
||||
return &IPv6RouterAlertOption{Value: IPv6RouterAlertValue(binary.BigEndian.Uint16(routerAlertValue[:]))}, false, nil
|
||||
default:
|
||||
bytes := bufferv2.NewView(int(length))
|
||||
bytes := buffer.NewView(int(length))
|
||||
if n, err := io.CopyN(bytes, i.reader, int64(length)); err != nil {
|
||||
if err == io.EOF {
|
||||
err = io.ErrUnexpectedEOF
|
||||
@@ -416,7 +416,7 @@ func (IPv6DestinationOptionsExtHdr) isIPv6PayloadHeader() {}
|
||||
// IPv6RoutingExtHdr is a buffer holding the Routing extension header specific
|
||||
// data as outlined in RFC 8200 section 4.4.
|
||||
type IPv6RoutingExtHdr struct {
|
||||
Buf *bufferv2.View
|
||||
Buf *buffer.View
|
||||
}
|
||||
|
||||
// isIPv6PayloadHeader implements IPv6PayloadHeader.isIPv6PayloadHeader.
|
||||
@@ -488,7 +488,7 @@ type IPv6PayloadIterator struct {
|
||||
// The identifier of the next header to parse.
|
||||
nextHdrIdentifier IPv6ExtensionHeaderIdentifier
|
||||
|
||||
payload bufferv2.Buffer
|
||||
payload buffer.Buffer
|
||||
|
||||
// Indicates to the iterator that it should return the remaining payload as a
|
||||
// raw payload on the next call to Next.
|
||||
@@ -521,7 +521,7 @@ func (i IPv6PayloadIterator) ParseOffset() uint32 {
|
||||
// MakeIPv6PayloadIterator returns an iterator over the IPv6 payload containing
|
||||
// extension headers, or a raw payload if the payload cannot be parsed. The
|
||||
// iterator takes ownership of the payload.
|
||||
func MakeIPv6PayloadIterator(nextHdrIdentifier IPv6ExtensionHeaderIdentifier, payload bufferv2.Buffer) IPv6PayloadIterator {
|
||||
func MakeIPv6PayloadIterator(nextHdrIdentifier IPv6ExtensionHeaderIdentifier, payload buffer.Buffer) IPv6PayloadIterator {
|
||||
return IPv6PayloadIterator{
|
||||
nextHdrIdentifier: nextHdrIdentifier,
|
||||
payload: payload,
|
||||
@@ -543,7 +543,7 @@ func (i *IPv6PayloadIterator) Release() {
|
||||
func (i *IPv6PayloadIterator) AsRawHeader(consume bool) IPv6RawPayloadHeader {
|
||||
identifier := i.nextHdrIdentifier
|
||||
|
||||
var buf bufferv2.Buffer
|
||||
var buf buffer.Buffer
|
||||
if consume {
|
||||
// Since we consume the iterator, we return the payload as is.
|
||||
buf = i.payload
|
||||
@@ -653,7 +653,7 @@ func (i *IPv6PayloadIterator) NextHeaderIdentifier() IPv6ExtensionHeaderIdentifi
|
||||
// If bytes is not nil, extension header specific data will be read into bytes
|
||||
// if it has enough capacity. If bytes is provided but does not have enough
|
||||
// capacity for the data, nextHeaderData will panic.
|
||||
func (i *IPv6PayloadIterator) nextHeaderData(fragmentHdr bool, bytes []byte) (IPv6ExtensionHeaderIdentifier, *bufferv2.View, error) {
|
||||
func (i *IPv6PayloadIterator) nextHeaderData(fragmentHdr bool, bytes []byte) (IPv6ExtensionHeaderIdentifier, *buffer.View, error) {
|
||||
// We ignore the number of bytes read because we know we will only ever read
|
||||
// at max 1 bytes since rune has a length of 1. If we read 0 bytes, the Read
|
||||
// would return io.EOF to indicate that io.Reader has reached the end of the
|
||||
@@ -700,7 +700,7 @@ func (i *IPv6PayloadIterator) nextHeaderData(fragmentHdr bool, bytes []byte) (IP
|
||||
}
|
||||
return IPv6ExtensionHeaderIdentifier(nextHdrIdentifier), nil, nil
|
||||
}
|
||||
v := bufferv2.NewView(bytesLen)
|
||||
v := buffer.NewView(bytesLen)
|
||||
if n, err := io.CopyN(v, &rdr, int64(bytesLen)); err != nil {
|
||||
if err == io.EOF {
|
||||
err = io.ErrUnexpectedEOF
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -23,7 +23,7 @@ go_test(
|
||||
srcs = ["ethernet_test.go"],
|
||||
deps = [
|
||||
":ethernet",
|
||||
"//pkg/bufferv2",
|
||||
"//pkg/buffer",
|
||||
"//pkg/refs",
|
||||
"//pkg/tcpip",
|
||||
"//pkg/tcpip/header",
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"gvisor.dev/gvisor/pkg/bufferv2"
|
||||
"gvisor.dev/gvisor/pkg/buffer"
|
||||
"gvisor.dev/gvisor/pkg/refs"
|
||||
"gvisor.dev/gvisor/pkg/tcpip"
|
||||
"gvisor.dev/gvisor/pkg/tcpip/header"
|
||||
@@ -102,7 +102,7 @@ func TestDeliverNetworkPacket(t *testing.T) {
|
||||
DstAddr: testCase.dstAddr,
|
||||
Type: networkProtocol,
|
||||
})
|
||||
p := stack.NewPacketBuffer(stack.PacketBufferOptions{Payload: bufferv2.MakeWithData(eth)})
|
||||
p := stack.NewPacketBuffer(stack.PacketBufferOptions{Payload: buffer.MakeWithData(eth)})
|
||||
defer p.DecRef()
|
||||
e.DeliverNetworkPacket(0, p)
|
||||
if got, want := len(networkDispatcher.networkPackets), 1; got != want {
|
||||
@@ -187,7 +187,7 @@ func TestWritePacketToRemoteAddHeader(t *testing.T) {
|
||||
t.Fatalf("s.CreateNIC(%d, _): %s", nicID, err)
|
||||
}
|
||||
|
||||
if err := s.WritePacketToRemote(nicID, remoteLinkAddr, netProto, bufferv2.Buffer{}); err != nil {
|
||||
if err := s.WritePacketToRemote(nicID, remoteLinkAddr, netProto, buffer.Buffer{}); err != nil {
|
||||
t.Fatalf("s.WritePacketToRemote(%d, %s, _): %s", nicID, remoteLinkAddr, err)
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ go_library(
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg/atomicbitops",
|
||||
"//pkg/bufferv2",
|
||||
"//pkg/buffer",
|
||||
"//pkg/sync",
|
||||
"//pkg/tcpip",
|
||||
"//pkg/tcpip/header",
|
||||
@@ -35,7 +35,7 @@ go_test(
|
||||
srcs = ["endpoint_test.go"],
|
||||
library = ":fdbased",
|
||||
deps = [
|
||||
"//pkg/bufferv2",
|
||||
"//pkg/buffer",
|
||||
"//pkg/refs",
|
||||
"//pkg/tcpip",
|
||||
"//pkg/tcpip/header",
|
||||
|
||||
@@ -45,7 +45,7 @@ import (
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
"gvisor.dev/gvisor/pkg/atomicbitops"
|
||||
"gvisor.dev/gvisor/pkg/bufferv2"
|
||||
"gvisor.dev/gvisor/pkg/buffer"
|
||||
"gvisor.dev/gvisor/pkg/sync"
|
||||
"gvisor.dev/gvisor/pkg/tcpip"
|
||||
"gvisor.dev/gvisor/pkg/tcpip/header"
|
||||
@@ -730,7 +730,7 @@ func (e *endpoint) WritePackets(pkts stack.PacketBufferList) (int, tcpip.Error)
|
||||
}
|
||||
|
||||
// InjectOutbound implements stack.InjectableEndpoint.InjectOutbound.
|
||||
func (e *endpoint) InjectOutbound(dest tcpip.Address, packet *bufferv2.View) tcpip.Error {
|
||||
func (e *endpoint) InjectOutbound(dest tcpip.Address, packet *buffer.View) tcpip.Error {
|
||||
return rawfile.NonBlockingWrite(e.fds[0].fd, packet.AsSlice())
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import (
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"golang.org/x/sys/unix"
|
||||
"gvisor.dev/gvisor/pkg/bufferv2"
|
||||
"gvisor.dev/gvisor/pkg/buffer"
|
||||
"gvisor.dev/gvisor/pkg/refs"
|
||||
"gvisor.dev/gvisor/pkg/tcpip"
|
||||
"gvisor.dev/gvisor/pkg/tcpip/header"
|
||||
@@ -195,7 +195,7 @@ func testWritePacket(t *testing.T, plen int, eth bool, gsoMaxSize uint32, hash u
|
||||
const netHdrLen = 100
|
||||
pkt := stack.NewPacketBuffer(stack.PacketBufferOptions{
|
||||
ReserveHeaderBytes: int(c.ep.MaxHeaderLength()) + netHdrLen,
|
||||
Payload: bufferv2.MakeWithData(payload),
|
||||
Payload: buffer.MakeWithData(payload),
|
||||
})
|
||||
defer pkt.DecRef()
|
||||
pkt.Hash = hash
|
||||
@@ -386,7 +386,7 @@ func TestDeliverPacket(t *testing.T) {
|
||||
|
||||
wantPkt := stack.NewPacketBuffer(stack.PacketBufferOptions{
|
||||
ReserveHeaderBytes: header.EthernetMinimumSize,
|
||||
Payload: bufferv2.MakeWithData(all),
|
||||
Payload: buffer.MakeWithData(all),
|
||||
})
|
||||
defer wantPkt.DecRef()
|
||||
if eth {
|
||||
@@ -503,7 +503,7 @@ func TestIovecBuffer(t *testing.T) {
|
||||
buf := b.pullBuffer(c.n)
|
||||
defer buf.Release()
|
||||
var lengths []int
|
||||
buf.Apply(func(v *bufferv2.View) {
|
||||
buf.Apply(func(v *buffer.View) {
|
||||
lengths = append(lengths, v.Size())
|
||||
})
|
||||
if !reflect.DeepEqual(lengths, c.wantLengths) {
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
"gvisor.dev/gvisor/pkg/bufferv2"
|
||||
"gvisor.dev/gvisor/pkg/buffer"
|
||||
"gvisor.dev/gvisor/pkg/tcpip"
|
||||
"gvisor.dev/gvisor/pkg/tcpip/header"
|
||||
"gvisor.dev/gvisor/pkg/tcpip/link/rawfile"
|
||||
@@ -134,7 +134,7 @@ type packetMMapDispatcher struct {
|
||||
|
||||
func (*packetMMapDispatcher) release() {}
|
||||
|
||||
func (d *packetMMapDispatcher) readMMappedPacket() (*bufferv2.View, bool, tcpip.Error) {
|
||||
func (d *packetMMapDispatcher) readMMappedPacket() (*buffer.View, bool, tcpip.Error) {
|
||||
hdr := tPacketHdr(d.ringBuffer[d.ringOffset*tpFrameSize:])
|
||||
for hdr.tpStatus()&tpStatusUser == 0 {
|
||||
stopped, errno := rawfile.BlockingPollUntilStopped(d.EFD, d.fd, unix.POLLIN|unix.POLLERR)
|
||||
@@ -158,7 +158,7 @@ func (d *packetMMapDispatcher) readMMappedPacket() (*bufferv2.View, bool, tcpip.
|
||||
}
|
||||
|
||||
// Copy out the packet from the mmapped frame to a locally owned buffer.
|
||||
pkt := bufferv2.NewView(int(hdr.tpSnapLen()))
|
||||
pkt := buffer.NewView(int(hdr.tpSnapLen()))
|
||||
pkt.Write(hdr.Payload())
|
||||
// Release packet to kernel.
|
||||
hdr.setTPStatus(tpStatusKernel)
|
||||
@@ -190,7 +190,7 @@ func (d *packetMMapDispatcher) dispatch() (bool, tcpip.Error) {
|
||||
}
|
||||
|
||||
pbuf := stack.NewPacketBuffer(stack.PacketBufferOptions{
|
||||
Payload: bufferv2.MakeWithView(pkt),
|
||||
Payload: buffer.MakeWithView(pkt),
|
||||
})
|
||||
defer pbuf.DecRef()
|
||||
if d.e.hdrSize > 0 {
|
||||
|
||||
@@ -19,7 +19,7 @@ package fdbased
|
||||
|
||||
import (
|
||||
"golang.org/x/sys/unix"
|
||||
"gvisor.dev/gvisor/pkg/bufferv2"
|
||||
"gvisor.dev/gvisor/pkg/buffer"
|
||||
"gvisor.dev/gvisor/pkg/tcpip"
|
||||
"gvisor.dev/gvisor/pkg/tcpip/header"
|
||||
"gvisor.dev/gvisor/pkg/tcpip/link/rawfile"
|
||||
@@ -34,7 +34,7 @@ type iovecBuffer struct {
|
||||
// buffer is the actual buffer that holds the packet contents. Some contents
|
||||
// are reused across calls to pullBuffer if number of requested bytes is
|
||||
// smaller than the number of bytes allocated in the buffer.
|
||||
views []*bufferv2.View
|
||||
views []*buffer.View
|
||||
|
||||
// iovecs are initialized with base pointers/len of the corresponding
|
||||
// entries in the views defined above, except when GSO is enabled
|
||||
@@ -58,7 +58,7 @@ type iovecBuffer struct {
|
||||
|
||||
func newIovecBuffer(sizes []int, skipsVnetHdr bool) *iovecBuffer {
|
||||
b := &iovecBuffer{
|
||||
views: make([]*bufferv2.View, len(sizes)),
|
||||
views: make([]*buffer.View, len(sizes)),
|
||||
sizes: sizes,
|
||||
skipsVnetHdr: skipsVnetHdr,
|
||||
}
|
||||
@@ -86,7 +86,7 @@ func (b *iovecBuffer) nextIovecs() []unix.Iovec {
|
||||
if b.views[i] != nil {
|
||||
break
|
||||
}
|
||||
v := bufferv2.NewViewSize(b.sizes[i])
|
||||
v := buffer.NewViewSize(b.sizes[i])
|
||||
b.views[i] = v
|
||||
b.iovecs[i+vnetHdrOff] = unix.Iovec{Base: v.BasePtr()}
|
||||
b.iovecs[i+vnetHdrOff].SetLen(v.Size())
|
||||
@@ -99,14 +99,14 @@ func (b *iovecBuffer) nextIovecs() []unix.Iovec {
|
||||
// that holds the storage, and updates pulledIndex to indicate which part
|
||||
// of b.buffer's storage must be reallocated during the next call to
|
||||
// nextIovecs.
|
||||
func (b *iovecBuffer) pullBuffer(n int) bufferv2.Buffer {
|
||||
var views []*bufferv2.View
|
||||
func (b *iovecBuffer) pullBuffer(n int) buffer.Buffer {
|
||||
var views []*buffer.View
|
||||
c := 0
|
||||
if b.skipsVnetHdr {
|
||||
c += virtioNetHdrSize
|
||||
if c >= n {
|
||||
// Nothing in the packet.
|
||||
return bufferv2.Buffer{}
|
||||
return buffer.Buffer{}
|
||||
}
|
||||
}
|
||||
// Remove the used views from the buffer.
|
||||
@@ -125,7 +125,7 @@ func (b *iovecBuffer) pullBuffer(n int) bufferv2.Buffer {
|
||||
// Exclude the size of the vnet header.
|
||||
n -= virtioNetHdrSize
|
||||
}
|
||||
pulled := bufferv2.Buffer{}
|
||||
pulled := buffer.Buffer{}
|
||||
for _, v := range views {
|
||||
pulled.Append(v)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ go_library(
|
||||
srcs = ["injectable.go"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg/bufferv2",
|
||||
"//pkg/buffer",
|
||||
"//pkg/tcpip",
|
||||
"//pkg/tcpip/header",
|
||||
"//pkg/tcpip/stack",
|
||||
@@ -23,7 +23,7 @@ go_test(
|
||||
srcs = ["injectable_test.go"],
|
||||
library = ":muxed",
|
||||
deps = [
|
||||
"//pkg/bufferv2",
|
||||
"//pkg/buffer",
|
||||
"//pkg/refs",
|
||||
"//pkg/tcpip",
|
||||
"//pkg/tcpip/link/fdbased",
|
||||
|
||||
@@ -18,7 +18,7 @@ package muxed
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/bufferv2"
|
||||
"gvisor.dev/gvisor/pkg/buffer"
|
||||
"gvisor.dev/gvisor/pkg/tcpip"
|
||||
"gvisor.dev/gvisor/pkg/tcpip/header"
|
||||
"gvisor.dev/gvisor/pkg/tcpip/stack"
|
||||
@@ -124,7 +124,7 @@ func (m *InjectableEndpoint) WritePackets(pkts stack.PacketBufferList) (int, tcp
|
||||
|
||||
// InjectOutbound writes outbound packets to the appropriate
|
||||
// LinkInjectableEndpoint based on the dest address.
|
||||
func (m *InjectableEndpoint) InjectOutbound(dest tcpip.Address, packet *bufferv2.View) tcpip.Error {
|
||||
func (m *InjectableEndpoint) InjectOutbound(dest tcpip.Address, packet *buffer.View) tcpip.Error {
|
||||
endpoint, ok := m.routes[dest]
|
||||
if !ok {
|
||||
return &tcpip.ErrHostUnreachable{}
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
"gvisor.dev/gvisor/pkg/bufferv2"
|
||||
"gvisor.dev/gvisor/pkg/buffer"
|
||||
"gvisor.dev/gvisor/pkg/refs"
|
||||
"gvisor.dev/gvisor/pkg/tcpip"
|
||||
"gvisor.dev/gvisor/pkg/tcpip/link/fdbased"
|
||||
@@ -32,7 +32,7 @@ import (
|
||||
func TestInjectableEndpointRawDispatch(t *testing.T) {
|
||||
endpoint, sock, dstIP := makeTestInjectableEndpoint(t)
|
||||
|
||||
v := bufferv2.NewViewWithData([]byte{0xFA})
|
||||
v := buffer.NewViewWithData([]byte{0xFA})
|
||||
defer v.Release()
|
||||
endpoint.InjectOutbound(dstIP, v)
|
||||
|
||||
@@ -51,7 +51,7 @@ func TestInjectableEndpointDispatch(t *testing.T) {
|
||||
|
||||
pkt := stack.NewPacketBuffer(stack.PacketBufferOptions{
|
||||
ReserveHeaderBytes: 1,
|
||||
Payload: bufferv2.MakeWithData([]byte{0xFB}),
|
||||
Payload: buffer.MakeWithData([]byte{0xFB}),
|
||||
})
|
||||
defer pkt.DecRef()
|
||||
pkt.TransportHeader().Push(1)[0] = 0xFA
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user