mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Only carry GSO options in the packet buffer
With this change, GSO options no longer needs to be passed around as a function argument in the write path. This change is done in preparation for a later change that defers segmentation, and may change GSO options for a packet as it flows down the stack. Updates #170. PiperOrigin-RevId: 369774872
This commit is contained in:
committed by
gVisor bot
parent
6f9db949d8
commit
47bc115158
@@ -658,7 +658,7 @@ func (jt *JumpTarget) id() targetID {
|
||||
}
|
||||
|
||||
// Action implements stack.Target.Action.
|
||||
func (jt *JumpTarget) Action(*stack.PacketBuffer, *stack.ConnTrack, stack.Hook, *stack.GSO, *stack.Route, tcpip.Address) (stack.RuleVerdict, int) {
|
||||
func (jt *JumpTarget) Action(*stack.PacketBuffer, *stack.ConnTrack, stack.Hook, *stack.Route, tcpip.Address) (stack.RuleVerdict, int) {
|
||||
return stack.RuleJump, jt.RuleNum
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ import (
|
||||
type PacketInfo struct {
|
||||
Pkt *stack.PacketBuffer
|
||||
Proto tcpip.NetworkProtocolNumber
|
||||
GSO *stack.GSO
|
||||
Route stack.RouteInfo
|
||||
}
|
||||
|
||||
@@ -229,11 +228,10 @@ func (e *Endpoint) LinkAddress() tcpip.LinkAddress {
|
||||
}
|
||||
|
||||
// WritePacket stores outbound packets into the channel.
|
||||
func (e *Endpoint) WritePacket(r stack.RouteInfo, gso *stack.GSO, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) tcpip.Error {
|
||||
func (e *Endpoint) WritePacket(r stack.RouteInfo, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) tcpip.Error {
|
||||
p := PacketInfo{
|
||||
Pkt: pkt,
|
||||
Proto: protocol,
|
||||
GSO: gso,
|
||||
Route: r,
|
||||
}
|
||||
|
||||
@@ -243,13 +241,12 @@ func (e *Endpoint) WritePacket(r stack.RouteInfo, gso *stack.GSO, protocol tcpip
|
||||
}
|
||||
|
||||
// WritePackets stores outbound packets into the channel.
|
||||
func (e *Endpoint) WritePackets(r stack.RouteInfo, gso *stack.GSO, pkts stack.PacketBufferList, protocol tcpip.NetworkProtocolNumber) (int, tcpip.Error) {
|
||||
func (e *Endpoint) WritePackets(r stack.RouteInfo, pkts stack.PacketBufferList, protocol tcpip.NetworkProtocolNumber) (int, tcpip.Error) {
|
||||
n := 0
|
||||
for pkt := pkts.Front(); pkt != nil; pkt = pkt.Next() {
|
||||
p := PacketInfo{
|
||||
Pkt: pkt,
|
||||
Proto: protocol,
|
||||
GSO: gso,
|
||||
Route: r,
|
||||
}
|
||||
|
||||
|
||||
@@ -61,20 +61,20 @@ func (e *Endpoint) Capabilities() stack.LinkEndpointCapabilities {
|
||||
}
|
||||
|
||||
// WritePacket implements stack.LinkEndpoint.
|
||||
func (e *Endpoint) WritePacket(r stack.RouteInfo, gso *stack.GSO, proto tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) tcpip.Error {
|
||||
func (e *Endpoint) WritePacket(r stack.RouteInfo, proto tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) tcpip.Error {
|
||||
e.AddHeader(e.Endpoint.LinkAddress(), r.RemoteLinkAddress, proto, pkt)
|
||||
return e.Endpoint.WritePacket(r, gso, proto, pkt)
|
||||
return e.Endpoint.WritePacket(r, proto, pkt)
|
||||
}
|
||||
|
||||
// WritePackets implements stack.LinkEndpoint.
|
||||
func (e *Endpoint) WritePackets(r stack.RouteInfo, gso *stack.GSO, pkts stack.PacketBufferList, proto tcpip.NetworkProtocolNumber) (int, tcpip.Error) {
|
||||
func (e *Endpoint) WritePackets(r stack.RouteInfo, pkts stack.PacketBufferList, proto tcpip.NetworkProtocolNumber) (int, tcpip.Error) {
|
||||
linkAddr := e.Endpoint.LinkAddress()
|
||||
|
||||
for pkt := pkts.Front(); pkt != nil; pkt = pkt.Next() {
|
||||
e.AddHeader(linkAddr, r.RemoteLinkAddress, proto, pkt)
|
||||
}
|
||||
|
||||
return e.Endpoint.WritePackets(r, gso, pkts, proto)
|
||||
return e.Endpoint.WritePackets(r, pkts, proto)
|
||||
}
|
||||
|
||||
// MaxHeaderLength implements stack.LinkEndpoint.
|
||||
|
||||
@@ -433,7 +433,7 @@ func (e *endpoint) AddHeader(local, remote tcpip.LinkAddress, protocol tcpip.Net
|
||||
|
||||
// WritePacket writes outbound packets to the file descriptor. If it is not
|
||||
// currently writable, the packet is dropped.
|
||||
func (e *endpoint) WritePacket(r stack.RouteInfo, gso *stack.GSO, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) tcpip.Error {
|
||||
func (e *endpoint) WritePacket(r stack.RouteInfo, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) tcpip.Error {
|
||||
if e.hdrSize > 0 {
|
||||
e.AddHeader(r.LocalLinkAddress, r.RemoteLinkAddress, protocol, pkt)
|
||||
}
|
||||
@@ -443,23 +443,23 @@ func (e *endpoint) WritePacket(r stack.RouteInfo, gso *stack.GSO, protocol tcpip
|
||||
fd := e.fds[pkt.Hash%uint32(len(e.fds))]
|
||||
if e.Capabilities()&stack.CapabilityHardwareGSO != 0 {
|
||||
vnetHdr := virtioNetHdr{}
|
||||
if gso != nil {
|
||||
if pkt.GSOOptions.Type != stack.GSONone {
|
||||
vnetHdr.hdrLen = uint16(pkt.HeaderSize())
|
||||
if gso.NeedsCsum {
|
||||
if pkt.GSOOptions.NeedsCsum {
|
||||
vnetHdr.flags = _VIRTIO_NET_HDR_F_NEEDS_CSUM
|
||||
vnetHdr.csumStart = header.EthernetMinimumSize + gso.L3HdrLen
|
||||
vnetHdr.csumOffset = gso.CsumOffset
|
||||
vnetHdr.csumStart = header.EthernetMinimumSize + pkt.GSOOptions.L3HdrLen
|
||||
vnetHdr.csumOffset = pkt.GSOOptions.CsumOffset
|
||||
}
|
||||
if gso.Type != stack.GSONone && uint16(pkt.Data().Size()) > gso.MSS {
|
||||
switch gso.Type {
|
||||
if pkt.GSOOptions.Type != stack.GSONone && uint16(pkt.Data().Size()) > pkt.GSOOptions.MSS {
|
||||
switch pkt.GSOOptions.Type {
|
||||
case stack.GSOTCPv4:
|
||||
vnetHdr.gsoType = _VIRTIO_NET_HDR_GSO_TCPV4
|
||||
case stack.GSOTCPv6:
|
||||
vnetHdr.gsoType = _VIRTIO_NET_HDR_GSO_TCPV6
|
||||
default:
|
||||
panic(fmt.Sprintf("Unknown gso type: %v", gso.Type))
|
||||
panic(fmt.Sprintf("Unknown gso type: %v", pkt.GSOOptions.Type))
|
||||
}
|
||||
vnetHdr.gsoSize = gso.MSS
|
||||
vnetHdr.gsoSize = pkt.GSOOptions.MSS
|
||||
}
|
||||
}
|
||||
|
||||
@@ -484,7 +484,7 @@ func (e *endpoint) sendBatch(batchFD int, batch []*stack.PacketBuffer) (int, tcp
|
||||
var vnetHdrBuf []byte
|
||||
if e.Capabilities()&stack.CapabilityHardwareGSO != 0 {
|
||||
vnetHdr := virtioNetHdr{}
|
||||
if pkt.GSOOptions != nil {
|
||||
if pkt.GSOOptions.Type != stack.GSONone {
|
||||
vnetHdr.hdrLen = uint16(pkt.HeaderSize())
|
||||
if pkt.GSOOptions.NeedsCsum {
|
||||
vnetHdr.flags = _VIRTIO_NET_HDR_F_NEEDS_CSUM
|
||||
@@ -540,7 +540,7 @@ func (e *endpoint) sendBatch(batchFD int, batch []*stack.PacketBuffer) (int, tcp
|
||||
// - pkt.EgressRoute
|
||||
// - pkt.GSOOptions
|
||||
// - pkt.NetworkProtocolNumber
|
||||
func (e *endpoint) WritePackets(_ stack.RouteInfo, _ *stack.GSO, pkts stack.PacketBufferList, _ tcpip.NetworkProtocolNumber) (int, tcpip.Error) {
|
||||
func (e *endpoint) WritePackets(_ stack.RouteInfo, pkts stack.PacketBufferList, _ tcpip.NetworkProtocolNumber) (int, tcpip.Error) {
|
||||
// Preallocate to avoid repeated reallocation as we append to batch.
|
||||
// batchSz is 47 because when SWGSO is in use then a single 65KB TCP
|
||||
// segment can get split into 46 segments of 1420 bytes and a single 216
|
||||
|
||||
@@ -207,18 +207,17 @@ func testWritePacket(t *testing.T, plen int, eth bool, gsoMaxSize uint32, hash u
|
||||
|
||||
// Write.
|
||||
want := append(append(buffer.View(nil), b...), payload...)
|
||||
var gso *stack.GSO
|
||||
const l3HdrLen = header.IPv6MinimumSize
|
||||
if gsoMaxSize != 0 {
|
||||
gso = &stack.GSO{
|
||||
pkt.GSOOptions = stack.GSO{
|
||||
Type: stack.GSOTCPv6,
|
||||
NeedsCsum: true,
|
||||
CsumOffset: csumOffset,
|
||||
MSS: gsoMSS,
|
||||
MaxSize: gsoMaxSize,
|
||||
L3HdrLen: header.IPv4MaximumHeaderSize,
|
||||
L3HdrLen: l3HdrLen,
|
||||
}
|
||||
}
|
||||
if err := c.ep.WritePacket(r, gso, proto, pkt); err != nil {
|
||||
if err := c.ep.WritePacket(r, proto, pkt); err != nil {
|
||||
t.Fatalf("WritePacket failed: %v", err)
|
||||
}
|
||||
|
||||
@@ -235,7 +234,7 @@ func testWritePacket(t *testing.T, plen int, eth bool, gsoMaxSize uint32, hash u
|
||||
if vnetHdr.flags&_VIRTIO_NET_HDR_F_NEEDS_CSUM == 0 {
|
||||
t.Fatalf("virtioNetHdr.flags %v doesn't contain %v", vnetHdr.flags, _VIRTIO_NET_HDR_F_NEEDS_CSUM)
|
||||
}
|
||||
csumStart := header.EthernetMinimumSize + gso.L3HdrLen
|
||||
const csumStart = header.EthernetMinimumSize + l3HdrLen
|
||||
if vnetHdr.csumStart != csumStart {
|
||||
t.Fatalf("vnetHdr.csumStart = %v, want %v", vnetHdr.csumStart, csumStart)
|
||||
}
|
||||
@@ -243,7 +242,7 @@ func testWritePacket(t *testing.T, plen int, eth bool, gsoMaxSize uint32, hash u
|
||||
t.Fatalf("vnetHdr.csumOffset = %v, want %v", vnetHdr.csumOffset, csumOffset)
|
||||
}
|
||||
gsoType := uint8(0)
|
||||
if int(gso.MSS) < plen {
|
||||
if plen > gsoMSS {
|
||||
gsoType = _VIRTIO_NET_HDR_GSO_TCPV6
|
||||
}
|
||||
if vnetHdr.gsoType != gsoType {
|
||||
@@ -333,7 +332,7 @@ func TestPreserveSrcAddress(t *testing.T) {
|
||||
ReserveHeaderBytes: header.EthernetMinimumSize,
|
||||
Data: buffer.VectorisedView{},
|
||||
})
|
||||
if err := c.ep.WritePacket(r, nil /* gso */, proto, pkt); err != nil {
|
||||
if err := c.ep.WritePacket(r, proto, pkt); err != nil {
|
||||
t.Fatalf("WritePacket failed: %v", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ func (*endpoint) Wait() {}
|
||||
|
||||
// WritePacket implements stack.LinkEndpoint.WritePacket. It delivers outbound
|
||||
// packets to the network-layer dispatcher.
|
||||
func (e *endpoint) WritePacket(_ stack.RouteInfo, _ *stack.GSO, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) tcpip.Error {
|
||||
func (e *endpoint) WritePacket(_ stack.RouteInfo, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) tcpip.Error {
|
||||
// Construct data as the unparsed portion for the loopback packet.
|
||||
data := buffer.NewVectorisedView(pkt.Size(), pkt.Views())
|
||||
|
||||
@@ -92,7 +92,7 @@ func (e *endpoint) WritePacket(_ stack.RouteInfo, _ *stack.GSO, protocol tcpip.N
|
||||
}
|
||||
|
||||
// WritePackets implements stack.LinkEndpoint.WritePackets.
|
||||
func (e *endpoint) WritePackets(stack.RouteInfo, *stack.GSO, stack.PacketBufferList, tcpip.NetworkProtocolNumber) (int, tcpip.Error) {
|
||||
func (e *endpoint) WritePackets(stack.RouteInfo, stack.PacketBufferList, tcpip.NetworkProtocolNumber) (int, tcpip.Error) {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
|
||||
@@ -87,20 +87,20 @@ func (m *InjectableEndpoint) InjectInbound(protocol tcpip.NetworkProtocolNumber,
|
||||
// WritePackets writes outbound packets to the appropriate
|
||||
// LinkInjectableEndpoint based on the RemoteAddress. HandleLocal only works if
|
||||
// r.RemoteAddress has a route registered in this endpoint.
|
||||
func (m *InjectableEndpoint) WritePackets(r stack.RouteInfo, gso *stack.GSO, pkts stack.PacketBufferList, protocol tcpip.NetworkProtocolNumber) (int, tcpip.Error) {
|
||||
func (m *InjectableEndpoint) WritePackets(r stack.RouteInfo, pkts stack.PacketBufferList, protocol tcpip.NetworkProtocolNumber) (int, tcpip.Error) {
|
||||
endpoint, ok := m.routes[r.RemoteAddress]
|
||||
if !ok {
|
||||
return 0, &tcpip.ErrNoRoute{}
|
||||
}
|
||||
return endpoint.WritePackets(r, gso, pkts, protocol)
|
||||
return endpoint.WritePackets(r, pkts, protocol)
|
||||
}
|
||||
|
||||
// WritePacket writes outbound packets to the appropriate LinkInjectableEndpoint
|
||||
// based on the RemoteAddress. HandleLocal only works if r.RemoteAddress has a
|
||||
// route registered in this endpoint.
|
||||
func (m *InjectableEndpoint) WritePacket(r stack.RouteInfo, gso *stack.GSO, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) tcpip.Error {
|
||||
func (m *InjectableEndpoint) WritePacket(r stack.RouteInfo, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) tcpip.Error {
|
||||
if endpoint, ok := m.routes[r.RemoteAddress]; ok {
|
||||
return endpoint.WritePacket(r, gso, protocol, pkt)
|
||||
return endpoint.WritePacket(r, protocol, pkt)
|
||||
}
|
||||
return &tcpip.ErrNoRoute{}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ func TestInjectableEndpointDispatch(t *testing.T) {
|
||||
var packetRoute stack.RouteInfo
|
||||
packetRoute.RemoteAddress = dstIP
|
||||
|
||||
endpoint.WritePacket(packetRoute, nil /* gso */, ipv4.ProtocolNumber, pkt)
|
||||
endpoint.WritePacket(packetRoute, ipv4.ProtocolNumber, pkt)
|
||||
|
||||
buf := make([]byte, 6500)
|
||||
bytesRead, err := sock.Read(buf)
|
||||
@@ -76,7 +76,7 @@ func TestInjectableEndpointDispatchHdrOnly(t *testing.T) {
|
||||
pkt.TransportHeader().Push(1)[0] = 0xFA
|
||||
var packetRoute stack.RouteInfo
|
||||
packetRoute.RemoteAddress = dstIP
|
||||
endpoint.WritePacket(packetRoute, nil /* gso */, ipv4.ProtocolNumber, pkt)
|
||||
endpoint.WritePacket(packetRoute, ipv4.ProtocolNumber, pkt)
|
||||
buf := make([]byte, 6500)
|
||||
bytesRead, err := sock.Read(buf)
|
||||
if err != nil {
|
||||
|
||||
@@ -113,13 +113,13 @@ func (e *Endpoint) LinkAddress() tcpip.LinkAddress {
|
||||
}
|
||||
|
||||
// WritePacket implements stack.LinkEndpoint.
|
||||
func (e *Endpoint) WritePacket(r stack.RouteInfo, gso *stack.GSO, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) tcpip.Error {
|
||||
return e.child.WritePacket(r, gso, protocol, pkt)
|
||||
func (e *Endpoint) WritePacket(r stack.RouteInfo, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) tcpip.Error {
|
||||
return e.child.WritePacket(r, protocol, pkt)
|
||||
}
|
||||
|
||||
// WritePackets implements stack.LinkEndpoint.
|
||||
func (e *Endpoint) WritePackets(r stack.RouteInfo, gso *stack.GSO, pkts stack.PacketBufferList, protocol tcpip.NetworkProtocolNumber) (int, tcpip.Error) {
|
||||
return e.child.WritePackets(r, gso, pkts, protocol)
|
||||
func (e *Endpoint) WritePackets(r stack.RouteInfo, pkts stack.PacketBufferList, protocol tcpip.NetworkProtocolNumber) (int, tcpip.Error) {
|
||||
return e.child.WritePackets(r, pkts, protocol)
|
||||
}
|
||||
|
||||
// Wait implements stack.LinkEndpoint.
|
||||
|
||||
@@ -35,16 +35,16 @@ func New(lower stack.LinkEndpoint) stack.LinkEndpoint {
|
||||
}
|
||||
|
||||
// WritePacket implements stack.LinkEndpoint.WritePacket.
|
||||
func (e *endpoint) WritePacket(r stack.RouteInfo, gso *stack.GSO, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) tcpip.Error {
|
||||
func (e *endpoint) WritePacket(r stack.RouteInfo, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) tcpip.Error {
|
||||
e.Endpoint.DeliverOutboundPacket(r.RemoteLinkAddress, r.LocalLinkAddress, protocol, pkt)
|
||||
return e.Endpoint.WritePacket(r, gso, protocol, pkt)
|
||||
return e.Endpoint.WritePacket(r, protocol, pkt)
|
||||
}
|
||||
|
||||
// WritePackets implements stack.LinkEndpoint.WritePackets.
|
||||
func (e *endpoint) WritePackets(r stack.RouteInfo, gso *stack.GSO, pkts stack.PacketBufferList, proto tcpip.NetworkProtocolNumber) (int, tcpip.Error) {
|
||||
func (e *endpoint) WritePackets(r stack.RouteInfo, pkts stack.PacketBufferList, proto tcpip.NetworkProtocolNumber) (int, tcpip.Error) {
|
||||
for pkt := pkts.Front(); pkt != nil; pkt = pkt.Next() {
|
||||
e.Endpoint.DeliverOutboundPacket(r.RemoteLinkAddress, r.LocalLinkAddress, pkt.NetworkProtocolNumber, pkt)
|
||||
}
|
||||
|
||||
return e.Endpoint.WritePackets(r, gso, pkts, proto)
|
||||
return e.Endpoint.WritePackets(r, pkts, proto)
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ func (e *Endpoint) deliverPackets(r stack.RouteInfo, proto tcpip.NetworkProtocol
|
||||
}
|
||||
|
||||
// WritePacket implements stack.LinkEndpoint.
|
||||
func (e *Endpoint) WritePacket(r stack.RouteInfo, _ *stack.GSO, proto tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) tcpip.Error {
|
||||
func (e *Endpoint) WritePacket(r stack.RouteInfo, proto tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) tcpip.Error {
|
||||
var pkts stack.PacketBufferList
|
||||
pkts.PushBack(pkt)
|
||||
e.deliverPackets(r, proto, pkts)
|
||||
@@ -74,7 +74,7 @@ func (e *Endpoint) WritePacket(r stack.RouteInfo, _ *stack.GSO, proto tcpip.Netw
|
||||
}
|
||||
|
||||
// WritePackets implements stack.LinkEndpoint.
|
||||
func (e *Endpoint) WritePackets(r stack.RouteInfo, _ *stack.GSO, pkts stack.PacketBufferList, proto tcpip.NetworkProtocolNumber) (int, tcpip.Error) {
|
||||
func (e *Endpoint) WritePackets(r stack.RouteInfo, pkts stack.PacketBufferList, proto tcpip.NetworkProtocolNumber) (int, tcpip.Error) {
|
||||
n := pkts.Len()
|
||||
e.deliverPackets(r, proto, pkts)
|
||||
return n, nil
|
||||
|
||||
@@ -91,7 +91,7 @@ func (q *queueDispatcher) dispatchLoop() {
|
||||
}
|
||||
// We pass a protocol of zero here because each packet carries its
|
||||
// NetworkProtocol.
|
||||
q.lower.WritePackets(stack.RouteInfo{}, nil /* gso */, batch, 0 /* protocol */)
|
||||
q.lower.WritePackets(stack.RouteInfo{}, batch, 0 /* protocol */)
|
||||
for pkt := batch.Front(); pkt != nil; pkt = pkt.Next() {
|
||||
batch.Remove(pkt)
|
||||
}
|
||||
@@ -150,12 +150,12 @@ func (e *endpoint) GSOMaxSize() uint32 {
|
||||
}
|
||||
|
||||
// WritePacket implements stack.LinkEndpoint.WritePacket.
|
||||
func (e *endpoint) WritePacket(r stack.RouteInfo, gso *stack.GSO, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) tcpip.Error {
|
||||
// WritePacket caller's do not set the following fields in PacketBuffer
|
||||
// so we populate them here.
|
||||
pkt.EgressRoute = r
|
||||
pkt.GSOOptions = gso
|
||||
pkt.NetworkProtocolNumber = protocol
|
||||
//
|
||||
// The packet must have the following fields populated:
|
||||
// - pkt.EgressRoute
|
||||
// - pkt.GSOOptions
|
||||
// - pkt.NetworkProtocolNumber
|
||||
func (e *endpoint) WritePacket(r stack.RouteInfo, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) tcpip.Error {
|
||||
d := e.dispatchers[int(pkt.Hash)%len(e.dispatchers)]
|
||||
if !d.q.enqueue(pkt) {
|
||||
return &tcpip.ErrNoBufferSpace{}
|
||||
@@ -166,12 +166,12 @@ func (e *endpoint) WritePacket(r stack.RouteInfo, gso *stack.GSO, protocol tcpip
|
||||
|
||||
// WritePackets implements stack.LinkEndpoint.WritePackets.
|
||||
//
|
||||
// Being a batch API, each packet in pkts should have the following
|
||||
// fields populated:
|
||||
// Each packet in the packet buffer list must have the following fields
|
||||
// populated:
|
||||
// - pkt.EgressRoute
|
||||
// - pkt.GSOOptions
|
||||
// - pkt.NetworkProtocolNumber
|
||||
func (e *endpoint) WritePackets(r stack.RouteInfo, gso *stack.GSO, pkts stack.PacketBufferList, protocol tcpip.NetworkProtocolNumber) (int, tcpip.Error) {
|
||||
func (e *endpoint) WritePackets(r stack.RouteInfo, pkts stack.PacketBufferList, protocol tcpip.NetworkProtocolNumber) (int, tcpip.Error) {
|
||||
enqueued := 0
|
||||
for pkt := pkts.Front(); pkt != nil; {
|
||||
d := e.dispatchers[int(pkt.Hash)%len(e.dispatchers)]
|
||||
|
||||
@@ -203,7 +203,7 @@ func (e *endpoint) AddHeader(local, remote tcpip.LinkAddress, protocol tcpip.Net
|
||||
|
||||
// WritePacket writes outbound packets to the file descriptor. If it is not
|
||||
// currently writable, the packet is dropped.
|
||||
func (e *endpoint) WritePacket(r stack.RouteInfo, _ *stack.GSO, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) tcpip.Error {
|
||||
func (e *endpoint) WritePacket(r stack.RouteInfo, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) tcpip.Error {
|
||||
e.AddHeader(r.LocalLinkAddress, r.RemoteLinkAddress, protocol, pkt)
|
||||
|
||||
views := pkt.Views()
|
||||
@@ -220,7 +220,7 @@ func (e *endpoint) WritePacket(r stack.RouteInfo, _ *stack.GSO, protocol tcpip.N
|
||||
}
|
||||
|
||||
// WritePackets implements stack.LinkEndpoint.WritePackets.
|
||||
func (*endpoint) WritePackets(stack.RouteInfo, *stack.GSO, stack.PacketBufferList, tcpip.NetworkProtocolNumber) (int, tcpip.Error) {
|
||||
func (*endpoint) WritePackets(stack.RouteInfo, stack.PacketBufferList, tcpip.NetworkProtocolNumber) (int, tcpip.Error) {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
|
||||
@@ -281,7 +281,7 @@ func TestSimpleSend(t *testing.T) {
|
||||
copy(pkt.NetworkHeader().Push(hdrLen), hdrBuf)
|
||||
|
||||
proto := tcpip.NetworkProtocolNumber(rand.Intn(0x10000))
|
||||
if err := c.ep.WritePacket(r, nil /* gso */, proto, pkt); err != nil {
|
||||
if err := c.ep.WritePacket(r, proto, pkt); err != nil {
|
||||
t.Fatalf("WritePacket failed: %v", err)
|
||||
}
|
||||
|
||||
@@ -351,7 +351,7 @@ func TestPreserveSrcAddressInSend(t *testing.T) {
|
||||
})
|
||||
|
||||
proto := tcpip.NetworkProtocolNumber(rand.Intn(0x10000))
|
||||
if err := c.ep.WritePacket(r, nil /* gso */, proto, pkt); err != nil {
|
||||
if err := c.ep.WritePacket(r, proto, pkt); err != nil {
|
||||
t.Fatalf("WritePacket failed: %v", err)
|
||||
}
|
||||
|
||||
@@ -407,7 +407,7 @@ func TestFillTxQueue(t *testing.T) {
|
||||
Data: buf.ToVectorisedView(),
|
||||
})
|
||||
|
||||
if err := c.ep.WritePacket(r, nil /* gso */, header.IPv4ProtocolNumber, pkt); err != nil {
|
||||
if err := c.ep.WritePacket(r, header.IPv4ProtocolNumber, pkt); err != nil {
|
||||
t.Fatalf("WritePacket failed unexpectedly: %v", err)
|
||||
}
|
||||
|
||||
@@ -425,7 +425,7 @@ func TestFillTxQueue(t *testing.T) {
|
||||
ReserveHeaderBytes: int(c.ep.MaxHeaderLength()),
|
||||
Data: buf.ToVectorisedView(),
|
||||
})
|
||||
err := c.ep.WritePacket(r, nil /* gso */, header.IPv4ProtocolNumber, pkt)
|
||||
err := c.ep.WritePacket(r, header.IPv4ProtocolNumber, pkt)
|
||||
if _, ok := err.(*tcpip.ErrWouldBlock); !ok {
|
||||
t.Fatalf("got WritePacket(...) = %v, want %s", err, &tcpip.ErrWouldBlock{})
|
||||
}
|
||||
@@ -453,7 +453,7 @@ func TestFillTxQueueAfterBadCompletion(t *testing.T) {
|
||||
ReserveHeaderBytes: int(c.ep.MaxHeaderLength()),
|
||||
Data: buf.ToVectorisedView(),
|
||||
})
|
||||
if err := c.ep.WritePacket(r, nil /* gso */, header.IPv4ProtocolNumber, pkt); err != nil {
|
||||
if err := c.ep.WritePacket(r, header.IPv4ProtocolNumber, pkt); err != nil {
|
||||
t.Fatalf("WritePacket failed unexpectedly: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -476,7 +476,7 @@ func TestFillTxQueueAfterBadCompletion(t *testing.T) {
|
||||
ReserveHeaderBytes: int(c.ep.MaxHeaderLength()),
|
||||
Data: buf.ToVectorisedView(),
|
||||
})
|
||||
if err := c.ep.WritePacket(r, nil /* gso */, header.IPv4ProtocolNumber, pkt); err != nil {
|
||||
if err := c.ep.WritePacket(r, header.IPv4ProtocolNumber, pkt); err != nil {
|
||||
t.Fatalf("WritePacket failed unexpectedly: %v", err)
|
||||
}
|
||||
|
||||
@@ -494,7 +494,7 @@ func TestFillTxQueueAfterBadCompletion(t *testing.T) {
|
||||
ReserveHeaderBytes: int(c.ep.MaxHeaderLength()),
|
||||
Data: buf.ToVectorisedView(),
|
||||
})
|
||||
err := c.ep.WritePacket(r, nil /* gso */, header.IPv4ProtocolNumber, pkt)
|
||||
err := c.ep.WritePacket(r, header.IPv4ProtocolNumber, pkt)
|
||||
if _, ok := err.(*tcpip.ErrWouldBlock); !ok {
|
||||
t.Fatalf("got WritePacket(...) = %v, want %s", err, &tcpip.ErrWouldBlock{})
|
||||
}
|
||||
@@ -520,7 +520,7 @@ func TestFillTxMemory(t *testing.T) {
|
||||
ReserveHeaderBytes: int(c.ep.MaxHeaderLength()),
|
||||
Data: buf.ToVectorisedView(),
|
||||
})
|
||||
if err := c.ep.WritePacket(r, nil /* gso */, header.IPv4ProtocolNumber, pkt); err != nil {
|
||||
if err := c.ep.WritePacket(r, header.IPv4ProtocolNumber, pkt); err != nil {
|
||||
t.Fatalf("WritePacket failed unexpectedly: %v", err)
|
||||
}
|
||||
|
||||
@@ -539,7 +539,7 @@ func TestFillTxMemory(t *testing.T) {
|
||||
ReserveHeaderBytes: int(c.ep.MaxHeaderLength()),
|
||||
Data: buf.ToVectorisedView(),
|
||||
})
|
||||
err := c.ep.WritePacket(r, nil /* gso */, header.IPv4ProtocolNumber, pkt)
|
||||
err := c.ep.WritePacket(r, header.IPv4ProtocolNumber, pkt)
|
||||
if _, ok := err.(*tcpip.ErrWouldBlock); !ok {
|
||||
t.Fatalf("got WritePacket(...) = %v, want %s", err, &tcpip.ErrWouldBlock{})
|
||||
}
|
||||
@@ -566,7 +566,7 @@ func TestFillTxMemoryWithMultiBuffer(t *testing.T) {
|
||||
ReserveHeaderBytes: int(c.ep.MaxHeaderLength()),
|
||||
Data: buf.ToVectorisedView(),
|
||||
})
|
||||
if err := c.ep.WritePacket(r, nil /* gso */, header.IPv4ProtocolNumber, pkt); err != nil {
|
||||
if err := c.ep.WritePacket(r, header.IPv4ProtocolNumber, pkt); err != nil {
|
||||
t.Fatalf("WritePacket failed unexpectedly: %v", err)
|
||||
}
|
||||
|
||||
@@ -581,7 +581,7 @@ func TestFillTxMemoryWithMultiBuffer(t *testing.T) {
|
||||
ReserveHeaderBytes: int(c.ep.MaxHeaderLength()),
|
||||
Data: buffer.NewView(bufferSize).ToVectorisedView(),
|
||||
})
|
||||
err := c.ep.WritePacket(r, nil /* gso */, header.IPv4ProtocolNumber, pkt)
|
||||
err := c.ep.WritePacket(r, header.IPv4ProtocolNumber, pkt)
|
||||
if _, ok := err.(*tcpip.ErrWouldBlock); !ok {
|
||||
t.Fatalf("got WritePacket(...) = %v, want %s", err, &tcpip.ErrWouldBlock{})
|
||||
}
|
||||
@@ -593,7 +593,7 @@ func TestFillTxMemoryWithMultiBuffer(t *testing.T) {
|
||||
ReserveHeaderBytes: int(c.ep.MaxHeaderLength()),
|
||||
Data: buf.ToVectorisedView(),
|
||||
})
|
||||
if err := c.ep.WritePacket(r, nil /* gso */, header.IPv4ProtocolNumber, pkt); err != nil {
|
||||
if err := c.ep.WritePacket(r, header.IPv4ProtocolNumber, pkt); err != nil {
|
||||
t.Fatalf("WritePacket failed unexpectedly: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ func NewWithWriter(lower stack.LinkEndpoint, writer io.Writer, snapLen uint32) (
|
||||
// called by the link-layer endpoint being wrapped when a packet arrives, and
|
||||
// logs the packet before forwarding to the actual dispatcher.
|
||||
func (e *endpoint) DeliverNetworkPacket(remote, local tcpip.LinkAddress, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) {
|
||||
e.dumpPacket(directionRecv, nil, protocol, pkt)
|
||||
e.dumpPacket(directionRecv, protocol, pkt)
|
||||
e.Endpoint.DeliverNetworkPacket(remote, local, protocol, pkt)
|
||||
}
|
||||
|
||||
@@ -148,10 +148,10 @@ func (e *endpoint) DeliverOutboundPacket(remote, local tcpip.LinkAddress, protoc
|
||||
e.Endpoint.DeliverOutboundPacket(remote, local, protocol, pkt)
|
||||
}
|
||||
|
||||
func (e *endpoint) dumpPacket(dir direction, gso *stack.GSO, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) {
|
||||
func (e *endpoint) dumpPacket(dir direction, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) {
|
||||
writer := e.writer
|
||||
if writer == nil && atomic.LoadUint32(&LogPackets) == 1 {
|
||||
logPacket(e.logPrefix, dir, protocol, pkt, gso)
|
||||
logPacket(e.logPrefix, dir, protocol, pkt)
|
||||
}
|
||||
if writer != nil && atomic.LoadUint32(&LogPacketsToPCAP) == 1 {
|
||||
totalLength := pkt.Size()
|
||||
@@ -187,22 +187,22 @@ func (e *endpoint) dumpPacket(dir direction, gso *stack.GSO, protocol tcpip.Netw
|
||||
// WritePacket implements the stack.LinkEndpoint interface. It is called by
|
||||
// higher-level protocols to write packets; it just logs the packet and
|
||||
// forwards the request to the lower endpoint.
|
||||
func (e *endpoint) WritePacket(r stack.RouteInfo, gso *stack.GSO, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) tcpip.Error {
|
||||
e.dumpPacket(directionSend, gso, protocol, pkt)
|
||||
return e.Endpoint.WritePacket(r, gso, protocol, pkt)
|
||||
func (e *endpoint) WritePacket(r stack.RouteInfo, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) tcpip.Error {
|
||||
e.dumpPacket(directionSend, protocol, pkt)
|
||||
return e.Endpoint.WritePacket(r, protocol, pkt)
|
||||
}
|
||||
|
||||
// WritePackets implements the stack.LinkEndpoint interface. It is called by
|
||||
// higher-level protocols to write packets; it just logs the packet and
|
||||
// forwards the request to the lower endpoint.
|
||||
func (e *endpoint) WritePackets(r stack.RouteInfo, gso *stack.GSO, pkts stack.PacketBufferList, protocol tcpip.NetworkProtocolNumber) (int, tcpip.Error) {
|
||||
func (e *endpoint) WritePackets(r stack.RouteInfo, pkts stack.PacketBufferList, protocol tcpip.NetworkProtocolNumber) (int, tcpip.Error) {
|
||||
for pkt := pkts.Front(); pkt != nil; pkt = pkt.Next() {
|
||||
e.dumpPacket(directionSend, gso, protocol, pkt)
|
||||
e.dumpPacket(directionSend, protocol, pkt)
|
||||
}
|
||||
return e.Endpoint.WritePackets(r, gso, pkts, protocol)
|
||||
return e.Endpoint.WritePackets(r, pkts, protocol)
|
||||
}
|
||||
|
||||
func logPacket(prefix string, dir direction, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer, gso *stack.GSO) {
|
||||
func logPacket(prefix string, dir direction, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) {
|
||||
// Figure out the network layer info.
|
||||
var transProto uint8
|
||||
src := tcpip.Address("unknown")
|
||||
@@ -411,8 +411,8 @@ func logPacket(prefix string, dir direction, protocol tcpip.NetworkProtocolNumbe
|
||||
return
|
||||
}
|
||||
|
||||
if gso != nil {
|
||||
details += fmt.Sprintf(" gso: %+v", gso)
|
||||
if pkt.GSOOptions.Type != stack.GSONone {
|
||||
details += fmt.Sprintf(" gso: %#v", pkt.GSOOptions)
|
||||
}
|
||||
|
||||
log.Infof("%s%s %s %s:%d -> %s:%d len:%d id:%04x %s", prefix, directionPrefix, transName, src, srcPort, dst, dstPort, size, id, details)
|
||||
|
||||
@@ -108,12 +108,12 @@ func (e *Endpoint) LinkAddress() tcpip.LinkAddress {
|
||||
// WritePacket implements stack.LinkEndpoint.WritePacket. It is called by
|
||||
// higher-level protocols to write packets. It only forwards packets to the
|
||||
// lower endpoint if Wait or WaitWrite haven't been called.
|
||||
func (e *Endpoint) WritePacket(r stack.RouteInfo, gso *stack.GSO, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) tcpip.Error {
|
||||
func (e *Endpoint) WritePacket(r stack.RouteInfo, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) tcpip.Error {
|
||||
if !e.writeGate.Enter() {
|
||||
return nil
|
||||
}
|
||||
|
||||
err := e.lower.WritePacket(r, gso, protocol, pkt)
|
||||
err := e.lower.WritePacket(r, protocol, pkt)
|
||||
e.writeGate.Leave()
|
||||
return err
|
||||
}
|
||||
@@ -121,12 +121,12 @@ func (e *Endpoint) WritePacket(r stack.RouteInfo, gso *stack.GSO, protocol tcpip
|
||||
// WritePackets implements stack.LinkEndpoint.WritePackets. It is called by
|
||||
// higher-level protocols to write packets. It only forwards packets to the
|
||||
// lower endpoint if Wait or WaitWrite haven't been called.
|
||||
func (e *Endpoint) WritePackets(r stack.RouteInfo, gso *stack.GSO, pkts stack.PacketBufferList, protocol tcpip.NetworkProtocolNumber) (int, tcpip.Error) {
|
||||
func (e *Endpoint) WritePackets(r stack.RouteInfo, pkts stack.PacketBufferList, protocol tcpip.NetworkProtocolNumber) (int, tcpip.Error) {
|
||||
if !e.writeGate.Enter() {
|
||||
return pkts.Len(), nil
|
||||
}
|
||||
|
||||
n, err := e.lower.WritePackets(r, gso, pkts, protocol)
|
||||
n, err := e.lower.WritePackets(r, pkts, protocol)
|
||||
e.writeGate.Leave()
|
||||
return n, err
|
||||
}
|
||||
|
||||
@@ -69,13 +69,13 @@ func (e *countedEndpoint) LinkAddress() tcpip.LinkAddress {
|
||||
return e.linkAddr
|
||||
}
|
||||
|
||||
func (e *countedEndpoint) WritePacket(stack.RouteInfo, *stack.GSO, tcpip.NetworkProtocolNumber, *stack.PacketBuffer) tcpip.Error {
|
||||
func (e *countedEndpoint) WritePacket(stack.RouteInfo, tcpip.NetworkProtocolNumber, *stack.PacketBuffer) tcpip.Error {
|
||||
e.writeCount++
|
||||
return nil
|
||||
}
|
||||
|
||||
// WritePackets implements stack.LinkEndpoint.WritePackets.
|
||||
func (e *countedEndpoint) WritePackets(_ stack.RouteInfo, _ *stack.GSO, pkts stack.PacketBufferList, _ tcpip.NetworkProtocolNumber) (int, tcpip.Error) {
|
||||
func (e *countedEndpoint) WritePackets(_ stack.RouteInfo, pkts stack.PacketBufferList, _ tcpip.NetworkProtocolNumber) (int, tcpip.Error) {
|
||||
e.writeCount += pkts.Len()
|
||||
return pkts.Len(), nil
|
||||
}
|
||||
@@ -98,21 +98,21 @@ func TestWaitWrite(t *testing.T) {
|
||||
wep := New(ep)
|
||||
|
||||
// Write and check that it goes through.
|
||||
wep.WritePacket(stack.RouteInfo{}, nil /* gso */, 0, stack.NewPacketBuffer(stack.PacketBufferOptions{}))
|
||||
wep.WritePacket(stack.RouteInfo{}, 0, stack.NewPacketBuffer(stack.PacketBufferOptions{}))
|
||||
if want := 1; ep.writeCount != want {
|
||||
t.Fatalf("Unexpected writeCount: got=%v, want=%v", ep.writeCount, want)
|
||||
}
|
||||
|
||||
// Wait on dispatches, then try to write. It must go through.
|
||||
wep.WaitDispatch()
|
||||
wep.WritePacket(stack.RouteInfo{}, nil /* gso */, 0, stack.NewPacketBuffer(stack.PacketBufferOptions{}))
|
||||
wep.WritePacket(stack.RouteInfo{}, 0, stack.NewPacketBuffer(stack.PacketBufferOptions{}))
|
||||
if want := 2; ep.writeCount != want {
|
||||
t.Fatalf("Unexpected writeCount: got=%v, want=%v", ep.writeCount, want)
|
||||
}
|
||||
|
||||
// Wait on writes, then try to write. It must not go through.
|
||||
wep.WaitWrite()
|
||||
wep.WritePacket(stack.RouteInfo{}, nil /* gso */, 0, stack.NewPacketBuffer(stack.PacketBufferOptions{}))
|
||||
wep.WritePacket(stack.RouteInfo{}, 0, stack.NewPacketBuffer(stack.PacketBufferOptions{}))
|
||||
if want := 2; ep.writeCount != want {
|
||||
t.Fatalf("Unexpected writeCount: got=%v, want=%v", ep.writeCount, want)
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ func (e *endpoint) MaxHeaderLength() uint16 {
|
||||
|
||||
func (*endpoint) Close() {}
|
||||
|
||||
func (*endpoint) WritePacket(*stack.Route, *stack.GSO, stack.NetworkHeaderParams, *stack.PacketBuffer) tcpip.Error {
|
||||
func (*endpoint) WritePacket(*stack.Route, stack.NetworkHeaderParams, *stack.PacketBuffer) tcpip.Error {
|
||||
return &tcpip.ErrNotSupported{}
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ func (*endpoint) NetworkProtocolNumber() tcpip.NetworkProtocolNumber {
|
||||
}
|
||||
|
||||
// WritePackets implements stack.NetworkEndpoint.WritePackets.
|
||||
func (*endpoint) WritePackets(*stack.Route, *stack.GSO, stack.PacketBufferList, stack.NetworkHeaderParams) (int, tcpip.Error) {
|
||||
func (*endpoint) WritePackets(*stack.Route, stack.PacketBufferList, stack.NetworkHeaderParams) (int, tcpip.Error) {
|
||||
return 0, &tcpip.ErrNotSupported{}
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ func (e *endpoint) HandlePacket(pkt *stack.PacketBuffer) {
|
||||
//
|
||||
// Send the packet to the (new) target hardware address on the same
|
||||
// hardware on which the request was received.
|
||||
if err := e.nic.WritePacketToRemote(tcpip.LinkAddress(origSender), nil /* gso */, ProtocolNumber, respPkt); err != nil {
|
||||
if err := e.nic.WritePacketToRemote(tcpip.LinkAddress(origSender), ProtocolNumber, respPkt); err != nil {
|
||||
stats.outgoingRepliesDropped.Increment()
|
||||
} else {
|
||||
stats.outgoingRepliesSent.Increment()
|
||||
@@ -355,7 +355,7 @@ func (e *endpoint) sendARPRequest(localAddr, targetAddr tcpip.Address, remoteLin
|
||||
}
|
||||
|
||||
stats := e.stats.arp
|
||||
if err := e.nic.WritePacketToRemote(remoteLinkAddr, nil /* gso */, ProtocolNumber, pkt); err != nil {
|
||||
if err := e.nic.WritePacketToRemote(remoteLinkAddr, ProtocolNumber, pkt); err != nil {
|
||||
stats.outgoingRequestsDropped.Increment()
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -451,12 +451,12 @@ type testLinkEndpoint struct {
|
||||
writeErr tcpip.Error
|
||||
}
|
||||
|
||||
func (t *testLinkEndpoint) WritePacket(r stack.RouteInfo, gso *stack.GSO, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) tcpip.Error {
|
||||
func (t *testLinkEndpoint) WritePacket(r stack.RouteInfo, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) tcpip.Error {
|
||||
if t.writeErr != nil {
|
||||
return t.writeErr
|
||||
}
|
||||
|
||||
return t.LinkEndpoint.WritePacket(r, gso, protocol, pkt)
|
||||
return t.LinkEndpoint.WritePacket(r, protocol, pkt)
|
||||
}
|
||||
|
||||
func TestLinkAddressRequest(t *testing.T) {
|
||||
|
||||
@@ -64,7 +64,7 @@ func (*MockLinkEndpoint) MaxHeaderLength() uint16 { return 0 }
|
||||
func (*MockLinkEndpoint) LinkAddress() tcpip.LinkAddress { return "" }
|
||||
|
||||
// WritePacket implements LinkEndpoint.WritePacket.
|
||||
func (ep *MockLinkEndpoint) WritePacket(_ stack.RouteInfo, _ *stack.GSO, _ tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) tcpip.Error {
|
||||
func (ep *MockLinkEndpoint) WritePacket(_ stack.RouteInfo, _ tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) tcpip.Error {
|
||||
if ep.allowPackets == 0 {
|
||||
return ep.err
|
||||
}
|
||||
@@ -74,11 +74,11 @@ func (ep *MockLinkEndpoint) WritePacket(_ stack.RouteInfo, _ *stack.GSO, _ tcpip
|
||||
}
|
||||
|
||||
// WritePackets implements LinkEndpoint.WritePackets.
|
||||
func (ep *MockLinkEndpoint) WritePackets(r stack.RouteInfo, gso *stack.GSO, pkts stack.PacketBufferList, protocol tcpip.NetworkProtocolNumber) (int, tcpip.Error) {
|
||||
func (ep *MockLinkEndpoint) WritePackets(r stack.RouteInfo, pkts stack.PacketBufferList, protocol tcpip.NetworkProtocolNumber) (int, tcpip.Error) {
|
||||
var n int
|
||||
|
||||
for pkt := pkts.Front(); pkt != nil; pkt = pkt.Next() {
|
||||
if err := ep.WritePacket(r, gso, protocol, pkt); err != nil {
|
||||
if err := ep.WritePacket(r, protocol, pkt); err != nil {
|
||||
return n, err
|
||||
}
|
||||
n++
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user