diff options
Diffstat (limited to 'pkg/tcpip/link')
-rw-r--r-- | pkg/tcpip/link/fdbased/endpoint.go | 4 | ||||
-rw-r--r-- | pkg/tcpip/link/fdbased/endpoint_test.go | 5 | ||||
-rw-r--r-- | pkg/tcpip/link/sharedmem/sharedmem.go | 2 | ||||
-rw-r--r-- | pkg/tcpip/link/sniffer/sniffer.go | 4 |
4 files changed, 8 insertions, 7 deletions
diff --git a/pkg/tcpip/link/fdbased/endpoint.go b/pkg/tcpip/link/fdbased/endpoint.go index 0b0d6c1e2..40a10eb9b 100644 --- a/pkg/tcpip/link/fdbased/endpoint.go +++ b/pkg/tcpip/link/fdbased/endpoint.go @@ -178,10 +178,10 @@ func (e *endpoint) WritePacket(r *stack.Route, hdr buffer.Prependable, payload b } if payload.Size() == 0 { - return rawfile.NonBlockingWrite(e.fd, hdr.UsedBytes()) + return rawfile.NonBlockingWrite(e.fd, hdr.View()) } - return rawfile.NonBlockingWrite2(e.fd, hdr.UsedBytes(), payload.ToView()) + return rawfile.NonBlockingWrite2(e.fd, hdr.View(), payload.ToView()) } func (e *endpoint) capViews(n int, buffers []int) int { diff --git a/pkg/tcpip/link/fdbased/endpoint_test.go b/pkg/tcpip/link/fdbased/endpoint_test.go index f7890e031..411ad7832 100644 --- a/pkg/tcpip/link/fdbased/endpoint_test.go +++ b/pkg/tcpip/link/fdbased/endpoint_test.go @@ -17,6 +17,7 @@ package fdbased import ( + "bytes" "fmt" "math/rand" "reflect" @@ -157,7 +158,7 @@ func TestWritePacket(t *testing.T) { for i := range payload { payload[i] = uint8(rand.Intn(256)) } - want := append(hdr.UsedBytes(), payload...) + want := append(hdr.View(), payload...) if err := c.ep.WritePacket(r, hdr, payload.ToVectorisedView(), proto); err != nil { t.Fatalf("WritePacket failed: %v", err) } @@ -188,7 +189,7 @@ func TestWritePacket(t *testing.T) { if len(b) != len(want) { t.Fatalf("Read returned %v bytes, want %v", len(b), len(want)) } - if !reflect.DeepEqual(b, want) { + if !bytes.Equal(b, want) { t.Fatalf("Read returned %x, want %x", b, want) } }) diff --git a/pkg/tcpip/link/sharedmem/sharedmem.go b/pkg/tcpip/link/sharedmem/sharedmem.go index 887612957..5157f71e8 100644 --- a/pkg/tcpip/link/sharedmem/sharedmem.go +++ b/pkg/tcpip/link/sharedmem/sharedmem.go @@ -196,7 +196,7 @@ func (e *endpoint) WritePacket(r *stack.Route, hdr buffer.Prependable, payload b v := payload.ToView() // Transmit the packet. e.mu.Lock() - ok := e.tx.transmit(hdr.UsedBytes(), v) + ok := e.tx.transmit(hdr.View(), v) e.mu.Unlock() if !ok { diff --git a/pkg/tcpip/link/sniffer/sniffer.go b/pkg/tcpip/link/sniffer/sniffer.go index e6ce3ee13..bfb79fd57 100644 --- a/pkg/tcpip/link/sniffer/sniffer.go +++ b/pkg/tcpip/link/sniffer/sniffer.go @@ -190,10 +190,10 @@ func (e *endpoint) LinkAddress() tcpip.LinkAddress { // the request to the lower endpoint. func (e *endpoint) WritePacket(r *stack.Route, hdr buffer.Prependable, payload buffer.VectorisedView, protocol tcpip.NetworkProtocolNumber) *tcpip.Error { if atomic.LoadUint32(&LogPackets) == 1 && e.file == nil { - logPacket("send", protocol, hdr.UsedBytes()) + logPacket("send", protocol, hdr.View()) } if e.file != nil && atomic.LoadUint32(&LogPacketsToFile) == 1 { - hdrBuf := hdr.UsedBytes() + hdrBuf := hdr.View() length := len(hdrBuf) + payload.Size() if length > int(e.maxPCAPLen) { length = int(e.maxPCAPLen) |