mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
netstack: remove PacketBufferPtr
PacketBufferPtr is leftover from a dead experiment. Just use *PacketBuffer. PiperOrigin-RevId: 611531815
This commit is contained in:
committed by
gVisor bot
parent
1af2f96634
commit
5b4fbd06d8
@@ -120,7 +120,7 @@ func (*OwnerMatcher) revision() uint8 {
|
||||
}
|
||||
|
||||
// Match implements Matcher.Match.
|
||||
func (om *OwnerMatcher) Match(hook stack.Hook, pkt stack.PacketBufferPtr, _, _ string) (bool, bool) {
|
||||
func (om *OwnerMatcher) Match(hook stack.Hook, pkt *stack.PacketBuffer, _, _ string) (bool, bool) {
|
||||
// Support only for OUTPUT chain.
|
||||
if hook != stack.Output {
|
||||
return false, true
|
||||
|
||||
@@ -115,7 +115,7 @@ func (*OwnerMatcherV1) revision() uint8 {
|
||||
}
|
||||
|
||||
// Match implements Matcher.Match.
|
||||
func (om *OwnerMatcherV1) Match(hook stack.Hook, pkt stack.PacketBufferPtr, _, _ string) (bool, bool) {
|
||||
func (om *OwnerMatcherV1) Match(hook stack.Hook, pkt *stack.PacketBuffer, _, _ string) (bool, bool) {
|
||||
// Support only for OUTPUT chain.
|
||||
if hook != stack.Output {
|
||||
return false, true
|
||||
|
||||
@@ -498,7 +498,7 @@ func (jt *JumpTarget) id() targetID {
|
||||
}
|
||||
|
||||
// Action implements stack.Target.Action.
|
||||
func (jt *JumpTarget) Action(stack.PacketBufferPtr, stack.Hook, *stack.Route, stack.AddressableEndpoint) (stack.RuleVerdict, int) {
|
||||
func (jt *JumpTarget) Action(*stack.PacketBuffer, stack.Hook, *stack.Route, stack.AddressableEndpoint) (stack.RuleVerdict, int) {
|
||||
return stack.RuleJump, jt.RuleNum
|
||||
}
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ func (*TCPMatcher) revision() uint8 {
|
||||
}
|
||||
|
||||
// Match implements Matcher.Match.
|
||||
func (tm *TCPMatcher) Match(hook stack.Hook, pkt stack.PacketBufferPtr, _, _ string) (bool, bool) {
|
||||
func (tm *TCPMatcher) Match(hook stack.Hook, pkt *stack.PacketBuffer, _, _ string) (bool, bool) {
|
||||
switch pkt.NetworkProtocolNumber {
|
||||
case header.IPv4ProtocolNumber:
|
||||
netHeader := header.IPv4(pkt.NetworkHeader().Slice())
|
||||
|
||||
@@ -99,7 +99,7 @@ func (*UDPMatcher) revision() uint8 {
|
||||
}
|
||||
|
||||
// Match implements Matcher.Match.
|
||||
func (um *UDPMatcher) Match(hook stack.Hook, pkt stack.PacketBufferPtr, _, _ string) (bool, bool) {
|
||||
func (um *UDPMatcher) Match(hook stack.Hook, pkt *stack.PacketBuffer, _, _ string) (bool, bool) {
|
||||
switch pkt.NetworkProtocolNumber {
|
||||
case header.IPv4ProtocolNumber:
|
||||
netHeader := header.IPv4(pkt.NetworkHeader().Slice())
|
||||
|
||||
@@ -27,7 +27,7 @@ import (
|
||||
// pkt.Data.
|
||||
//
|
||||
// Returns true if the header was successfully parsed.
|
||||
func ARP(pkt stack.PacketBufferPtr) bool {
|
||||
func ARP(pkt *stack.PacketBuffer) bool {
|
||||
_, ok := pkt.NetworkHeader().Consume(header.ARPSize)
|
||||
if ok {
|
||||
pkt.NetworkProtocolNumber = header.ARPProtocolNumber
|
||||
@@ -39,7 +39,7 @@ func ARP(pkt stack.PacketBufferPtr) bool {
|
||||
// header with the IPv4 header.
|
||||
//
|
||||
// Returns true if the header was successfully parsed.
|
||||
func IPv4(pkt stack.PacketBufferPtr) bool {
|
||||
func IPv4(pkt *stack.PacketBuffer) bool {
|
||||
hdr, ok := pkt.Data().PullUp(header.IPv4MinimumSize)
|
||||
if !ok {
|
||||
return false
|
||||
@@ -71,7 +71,7 @@ func IPv4(pkt stack.PacketBufferPtr) bool {
|
||||
|
||||
// IPv6 parses an IPv6 packet found in pkt.Data and populates pkt's network
|
||||
// header with the IPv6 header.
|
||||
func IPv6(pkt stack.PacketBufferPtr) (proto tcpip.TransportProtocolNumber, fragID uint32, fragOffset uint16, fragMore bool, ok bool) {
|
||||
func IPv6(pkt *stack.PacketBuffer) (proto tcpip.TransportProtocolNumber, fragID uint32, fragOffset uint16, fragMore bool, ok bool) {
|
||||
hdr, ok := pkt.Data().PullUp(header.IPv6MinimumSize)
|
||||
if !ok {
|
||||
return 0, 0, 0, false, false
|
||||
@@ -157,7 +157,7 @@ traverseExtensions:
|
||||
// header with the UDP header.
|
||||
//
|
||||
// Returns true if the header was successfully parsed.
|
||||
func UDP(pkt stack.PacketBufferPtr) bool {
|
||||
func UDP(pkt *stack.PacketBuffer) bool {
|
||||
_, ok := pkt.TransportHeader().Consume(header.UDPMinimumSize)
|
||||
pkt.TransportProtocolNumber = header.UDPProtocolNumber
|
||||
return ok
|
||||
@@ -167,7 +167,7 @@ func UDP(pkt stack.PacketBufferPtr) bool {
|
||||
// header with the TCP header.
|
||||
//
|
||||
// Returns true if the header was successfully parsed.
|
||||
func TCP(pkt stack.PacketBufferPtr) bool {
|
||||
func TCP(pkt *stack.PacketBuffer) bool {
|
||||
// TCP header is variable length, peek at it first.
|
||||
hdrLen := header.TCPMinimumSize
|
||||
hdr, ok := pkt.Data().PullUp(hdrLen)
|
||||
@@ -191,7 +191,7 @@ func TCP(pkt stack.PacketBufferPtr) bool {
|
||||
// if present.
|
||||
//
|
||||
// Returns true if an ICMPv4 header was successfully parsed.
|
||||
func ICMPv4(pkt stack.PacketBufferPtr) bool {
|
||||
func ICMPv4(pkt *stack.PacketBuffer) bool {
|
||||
if _, ok := pkt.TransportHeader().Consume(header.ICMPv4MinimumSize); ok {
|
||||
pkt.TransportProtocolNumber = header.ICMPv4ProtocolNumber
|
||||
return true
|
||||
@@ -203,7 +203,7 @@ func ICMPv4(pkt stack.PacketBufferPtr) bool {
|
||||
// if present.
|
||||
//
|
||||
// Returns true if an ICMPv6 header was successfully parsed.
|
||||
func ICMPv6(pkt stack.PacketBufferPtr) bool {
|
||||
func ICMPv6(pkt *stack.PacketBuffer) bool {
|
||||
hdr, ok := pkt.Data().PullUp(header.ICMPv6MinimumSize)
|
||||
if !ok {
|
||||
return false
|
||||
|
||||
@@ -43,7 +43,7 @@ type NotificationHandle struct {
|
||||
|
||||
type queue struct {
|
||||
// c is the outbound packet channel.
|
||||
c chan stack.PacketBufferPtr
|
||||
c chan *stack.PacketBuffer
|
||||
mu sync.RWMutex
|
||||
// +checklocks:mu
|
||||
notify []*NotificationHandle
|
||||
@@ -58,7 +58,7 @@ func (q *queue) Close() {
|
||||
q.closed = true
|
||||
}
|
||||
|
||||
func (q *queue) Read() stack.PacketBufferPtr {
|
||||
func (q *queue) Read() *stack.PacketBuffer {
|
||||
select {
|
||||
case p := <-q.c:
|
||||
return p
|
||||
@@ -67,7 +67,7 @@ func (q *queue) Read() stack.PacketBufferPtr {
|
||||
}
|
||||
}
|
||||
|
||||
func (q *queue) ReadContext(ctx context.Context) stack.PacketBufferPtr {
|
||||
func (q *queue) ReadContext(ctx context.Context) *stack.PacketBuffer {
|
||||
select {
|
||||
case pkt := <-q.c:
|
||||
return pkt
|
||||
@@ -76,7 +76,7 @@ func (q *queue) ReadContext(ctx context.Context) stack.PacketBufferPtr {
|
||||
}
|
||||
}
|
||||
|
||||
func (q *queue) Write(pkt stack.PacketBufferPtr) tcpip.Error {
|
||||
func (q *queue) Write(pkt *stack.PacketBuffer) tcpip.Error {
|
||||
// q holds the PacketBuffer.
|
||||
q.mu.RLock()
|
||||
if q.closed {
|
||||
@@ -152,7 +152,7 @@ type Endpoint struct {
|
||||
func New(size int, mtu uint32, linkAddr tcpip.LinkAddress) *Endpoint {
|
||||
return &Endpoint{
|
||||
q: &queue{
|
||||
c: make(chan stack.PacketBufferPtr, size),
|
||||
c: make(chan *stack.PacketBuffer, size),
|
||||
},
|
||||
mtu: mtu,
|
||||
linkAddr: linkAddr,
|
||||
@@ -167,13 +167,13 @@ func (e *Endpoint) Close() {
|
||||
}
|
||||
|
||||
// Read does non-blocking read one packet from the outbound packet queue.
|
||||
func (e *Endpoint) Read() stack.PacketBufferPtr {
|
||||
func (e *Endpoint) Read() *stack.PacketBuffer {
|
||||
return e.q.Read()
|
||||
}
|
||||
|
||||
// ReadContext does blocking read for one packet from the outbound packet queue.
|
||||
// It can be cancelled by ctx, and in this case, it returns nil.
|
||||
func (e *Endpoint) ReadContext(ctx context.Context) stack.PacketBufferPtr {
|
||||
func (e *Endpoint) ReadContext(ctx context.Context) *stack.PacketBuffer {
|
||||
return e.q.ReadContext(ctx)
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ func (e *Endpoint) NumQueued() int {
|
||||
|
||||
// InjectInbound injects an inbound packet. If the endpoint is not attached, the
|
||||
// packet is not delivered.
|
||||
func (e *Endpoint) InjectInbound(protocol tcpip.NetworkProtocolNumber, pkt stack.PacketBufferPtr) {
|
||||
func (e *Endpoint) InjectInbound(protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) {
|
||||
e.mu.RLock()
|
||||
d := e.dispatcher
|
||||
e.mu.RUnlock()
|
||||
@@ -287,7 +287,7 @@ func (*Endpoint) ARPHardwareType() header.ARPHardwareType {
|
||||
}
|
||||
|
||||
// AddHeader implements stack.LinkEndpoint.AddHeader.
|
||||
func (*Endpoint) AddHeader(stack.PacketBufferPtr) {}
|
||||
func (*Endpoint) AddHeader(*stack.PacketBuffer) {}
|
||||
|
||||
// ParseHeader implements stack.LinkEndpoint.ParseHeader.
|
||||
func (*Endpoint) ParseHeader(stack.PacketBufferPtr) bool { return true }
|
||||
func (*Endpoint) ParseHeader(*stack.PacketBuffer) bool { return true }
|
||||
|
||||
@@ -59,7 +59,7 @@ func (e *Endpoint) MTU() uint32 {
|
||||
}
|
||||
|
||||
// DeliverNetworkPacket implements stack.NetworkDispatcher.
|
||||
func (e *Endpoint) DeliverNetworkPacket(_ tcpip.NetworkProtocolNumber, pkt stack.PacketBufferPtr) {
|
||||
func (e *Endpoint) DeliverNetworkPacket(_ tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) {
|
||||
if !e.ParseHeader(pkt) {
|
||||
return
|
||||
}
|
||||
@@ -103,7 +103,7 @@ func (e *Endpoint) ARPHardwareType() header.ARPHardwareType {
|
||||
}
|
||||
|
||||
// AddHeader implements stack.LinkEndpoint.
|
||||
func (*Endpoint) AddHeader(pkt stack.PacketBufferPtr) {
|
||||
func (*Endpoint) AddHeader(pkt *stack.PacketBuffer) {
|
||||
eth := header.Ethernet(pkt.LinkHeader().Push(header.EthernetMinimumSize))
|
||||
fields := header.EthernetFields{
|
||||
SrcAddr: pkt.EgressRoute.LocalLinkAddress,
|
||||
@@ -114,7 +114,7 @@ func (*Endpoint) AddHeader(pkt stack.PacketBufferPtr) {
|
||||
}
|
||||
|
||||
// ParseHeader implements stack.LinkEndpoint.
|
||||
func (*Endpoint) ParseHeader(pkt stack.PacketBufferPtr) bool {
|
||||
func (*Endpoint) ParseHeader(pkt *stack.PacketBuffer) bool {
|
||||
_, ok := pkt.LinkHeader().Consume(header.EthernetMinimumSize)
|
||||
return ok
|
||||
}
|
||||
|
||||
@@ -33,18 +33,18 @@ var _ stack.NetworkDispatcher = (*testNetworkDispatcher)(nil)
|
||||
|
||||
type deliveredPacket struct {
|
||||
protocol tcpip.NetworkProtocolNumber
|
||||
packet stack.PacketBufferPtr
|
||||
packet *stack.PacketBuffer
|
||||
}
|
||||
|
||||
type testNetworkDispatcher struct {
|
||||
networkPackets []deliveredPacket
|
||||
}
|
||||
|
||||
func (t *testNetworkDispatcher) DeliverNetworkPacket(proto tcpip.NetworkProtocolNumber, pb stack.PacketBufferPtr) {
|
||||
func (t *testNetworkDispatcher) DeliverNetworkPacket(proto tcpip.NetworkProtocolNumber, pb *stack.PacketBuffer) {
|
||||
t.networkPackets = append(t.networkPackets, deliveredPacket{protocol: proto, packet: pb})
|
||||
}
|
||||
|
||||
func (*testNetworkDispatcher) DeliverLinkPacket(tcpip.NetworkProtocolNumber, stack.PacketBufferPtr) {
|
||||
func (*testNetworkDispatcher) DeliverLinkPacket(tcpip.NetworkProtocolNumber, *stack.PacketBuffer) {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
|
||||
@@ -516,7 +516,7 @@ const (
|
||||
)
|
||||
|
||||
// AddHeader implements stack.LinkEndpoint.AddHeader.
|
||||
func (e *endpoint) AddHeader(pkt stack.PacketBufferPtr) {
|
||||
func (e *endpoint) AddHeader(pkt *stack.PacketBuffer) {
|
||||
if e.hdrSize > 0 {
|
||||
// Add ethernet header if needed.
|
||||
eth := header.Ethernet(pkt.LinkHeader().Push(header.EthernetMinimumSize))
|
||||
@@ -528,14 +528,14 @@ func (e *endpoint) AddHeader(pkt stack.PacketBufferPtr) {
|
||||
}
|
||||
}
|
||||
|
||||
func (e *endpoint) parseHeader(pkt stack.PacketBufferPtr) bool {
|
||||
func (e *endpoint) parseHeader(pkt *stack.PacketBuffer) bool {
|
||||
_, ok := pkt.LinkHeader().Consume(e.hdrSize)
|
||||
return ok
|
||||
|
||||
}
|
||||
|
||||
// ParseHeader implements stack.LinkEndpoint.ParseHeader.
|
||||
func (e *endpoint) ParseHeader(pkt stack.PacketBufferPtr) bool {
|
||||
func (e *endpoint) ParseHeader(pkt *stack.PacketBuffer) bool {
|
||||
if e.hdrSize > 0 {
|
||||
return e.parseHeader(pkt)
|
||||
}
|
||||
@@ -544,7 +544,7 @@ func (e *endpoint) ParseHeader(pkt stack.PacketBufferPtr) bool {
|
||||
|
||||
// writePacket writes outbound packets to the file descriptor. If it is not
|
||||
// currently writable, the packet is dropped.
|
||||
func (e *endpoint) writePacket(pkt stack.PacketBufferPtr) tcpip.Error {
|
||||
func (e *endpoint) writePacket(pkt *stack.PacketBuffer) tcpip.Error {
|
||||
fdInfo := e.fds[pkt.Hash%uint32(len(e.fds))]
|
||||
fd := fdInfo.fd
|
||||
var vnetHdrBuf []byte
|
||||
@@ -594,7 +594,7 @@ func (e *endpoint) writePacket(pkt stack.PacketBufferPtr) tcpip.Error {
|
||||
return rawfile.NonBlockingWriteIovec(fd, iovecs)
|
||||
}
|
||||
|
||||
func (e *endpoint) sendBatch(batchFDInfo fdInfo, pkts []stack.PacketBufferPtr) (int, tcpip.Error) {
|
||||
func (e *endpoint) sendBatch(batchFDInfo fdInfo, pkts []*stack.PacketBuffer) (int, tcpip.Error) {
|
||||
// Degrade to writePacket if underlying fd is not a socket.
|
||||
if !batchFDInfo.isSocket {
|
||||
var written int
|
||||
@@ -711,7 +711,7 @@ func (e *endpoint) sendBatch(batchFDInfo fdInfo, pkts []stack.PacketBufferPtr) (
|
||||
// - pkt.NetworkProtocolNumber
|
||||
func (e *endpoint) WritePackets(pkts stack.PacketBufferList) (int, tcpip.Error) {
|
||||
// Preallocate to avoid repeated reallocation as we append to batch.
|
||||
batch := make([]stack.PacketBufferPtr, 0, BatchSize)
|
||||
batch := make([]*stack.PacketBuffer, 0, BatchSize)
|
||||
batchFDInfo := fdInfo{fd: -1, isSocket: false}
|
||||
sentPackets := 0
|
||||
for _, pkt := range pkts.AsSlice() {
|
||||
@@ -801,7 +801,7 @@ func (e *InjectableEndpoint) Attach(dispatcher stack.NetworkDispatcher) {
|
||||
|
||||
// InjectInbound injects an inbound packet. If the endpoint is not attached, the
|
||||
// packet is not delivered.
|
||||
func (e *InjectableEndpoint) InjectInbound(protocol tcpip.NetworkProtocolNumber, pkt stack.PacketBufferPtr) {
|
||||
func (e *InjectableEndpoint) InjectInbound(protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) {
|
||||
e.mu.RLock()
|
||||
d := e.dispatcher
|
||||
e.mu.RUnlock()
|
||||
|
||||
@@ -47,7 +47,7 @@ const (
|
||||
|
||||
type packetInfo struct {
|
||||
Proto tcpip.NetworkProtocolNumber
|
||||
Contents stack.PacketBufferPtr
|
||||
Contents *stack.PacketBuffer
|
||||
}
|
||||
|
||||
type packetContents struct {
|
||||
@@ -61,7 +61,7 @@ func checkPacketInfoEqual(t *testing.T, got, want packetInfo) {
|
||||
t.Helper()
|
||||
if diff := cmp.Diff(
|
||||
want, got,
|
||||
cmp.Transformer("ExtractPacketBuffer", func(pk stack.PacketBufferPtr) *packetContents {
|
||||
cmp.Transformer("ExtractPacketBuffer", func(pk *stack.PacketBuffer) *packetContents {
|
||||
if pk.IsNil() {
|
||||
return nil
|
||||
}
|
||||
@@ -132,12 +132,12 @@ func (c *context) cleanup() {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *context) DeliverNetworkPacket(protocol tcpip.NetworkProtocolNumber, pkt stack.PacketBufferPtr) {
|
||||
func (c *context) DeliverNetworkPacket(protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) {
|
||||
pkt.IncRef()
|
||||
c.ch <- packetInfo{protocol, pkt}
|
||||
}
|
||||
|
||||
func (c *context) DeliverLinkPacket(tcpip.NetworkProtocolNumber, stack.PacketBufferPtr) {
|
||||
func (c *context) DeliverLinkPacket(tcpip.NetworkProtocolNumber, *stack.PacketBuffer) {
|
||||
c.t.Fatal("DeliverLinkPacket not implemented")
|
||||
}
|
||||
|
||||
@@ -567,15 +567,15 @@ func TestIovecBufferSkipVnetHdr(t *testing.T) {
|
||||
|
||||
// fakeNetworkDispatcher delivers packets to pkts.
|
||||
type fakeNetworkDispatcher struct {
|
||||
pkts []stack.PacketBufferPtr
|
||||
pkts []*stack.PacketBuffer
|
||||
}
|
||||
|
||||
func (d *fakeNetworkDispatcher) DeliverNetworkPacket(_ tcpip.NetworkProtocolNumber, pkt stack.PacketBufferPtr) {
|
||||
func (d *fakeNetworkDispatcher) DeliverNetworkPacket(_ tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) {
|
||||
pkt.IncRef()
|
||||
d.pkts = append(d.pkts, pkt)
|
||||
}
|
||||
|
||||
func (*fakeNetworkDispatcher) DeliverLinkPacket(tcpip.NetworkProtocolNumber, stack.PacketBufferPtr) {
|
||||
func (*fakeNetworkDispatcher) DeliverLinkPacket(tcpip.NetworkProtocolNumber, *stack.PacketBuffer) {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ func (*endpoint) ARPHardwareType() header.ARPHardwareType {
|
||||
}
|
||||
|
||||
// AddHeader implements stack.LinkEndpoint.
|
||||
func (*endpoint) AddHeader(stack.PacketBufferPtr) {}
|
||||
func (*endpoint) AddHeader(*stack.PacketBuffer) {}
|
||||
|
||||
// ParseHeader implements stack.LinkEndpoint.
|
||||
func (*endpoint) ParseHeader(stack.PacketBufferPtr) bool { return true }
|
||||
func (*endpoint) ParseHeader(*stack.PacketBuffer) bool { return true }
|
||||
|
||||
@@ -90,7 +90,7 @@ func (m *InjectableEndpoint) IsAttached() bool {
|
||||
}
|
||||
|
||||
// InjectInbound implements stack.InjectableLinkEndpoint.
|
||||
func (m *InjectableEndpoint) InjectInbound(protocol tcpip.NetworkProtocolNumber, pkt stack.PacketBufferPtr) {
|
||||
func (m *InjectableEndpoint) InjectInbound(protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) {
|
||||
m.mu.RLock()
|
||||
d := m.dispatcher
|
||||
m.mu.RUnlock()
|
||||
@@ -145,10 +145,10 @@ func (*InjectableEndpoint) ARPHardwareType() header.ARPHardwareType {
|
||||
}
|
||||
|
||||
// AddHeader implements stack.LinkEndpoint.AddHeader.
|
||||
func (*InjectableEndpoint) AddHeader(stack.PacketBufferPtr) {}
|
||||
func (*InjectableEndpoint) AddHeader(*stack.PacketBuffer) {}
|
||||
|
||||
// ParseHeader implements stack.LinkEndpoint.ParseHeader.
|
||||
func (*InjectableEndpoint) ParseHeader(stack.PacketBufferPtr) bool { return true }
|
||||
func (*InjectableEndpoint) ParseHeader(*stack.PacketBuffer) bool { return true }
|
||||
|
||||
// NewInjectableEndpoint creates a new multi-endpoint injectable endpoint.
|
||||
func NewInjectableEndpoint(routes map[tcpip.Address]stack.InjectableLinkEndpoint) *InjectableEndpoint {
|
||||
|
||||
@@ -51,7 +51,7 @@ func (e *Endpoint) Init(child stack.LinkEndpoint, embedder stack.NetworkDispatch
|
||||
}
|
||||
|
||||
// DeliverNetworkPacket implements stack.NetworkDispatcher.
|
||||
func (e *Endpoint) DeliverNetworkPacket(protocol tcpip.NetworkProtocolNumber, pkt stack.PacketBufferPtr) {
|
||||
func (e *Endpoint) DeliverNetworkPacket(protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) {
|
||||
e.mu.RLock()
|
||||
d := e.dispatcher
|
||||
e.mu.RUnlock()
|
||||
@@ -61,7 +61,7 @@ func (e *Endpoint) DeliverNetworkPacket(protocol tcpip.NetworkProtocolNumber, pk
|
||||
}
|
||||
|
||||
// DeliverLinkPacket implements stack.NetworkDispatcher.
|
||||
func (e *Endpoint) DeliverLinkPacket(protocol tcpip.NetworkProtocolNumber, pkt stack.PacketBufferPtr) {
|
||||
func (e *Endpoint) DeliverLinkPacket(protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) {
|
||||
e.mu.RLock()
|
||||
d := e.dispatcher
|
||||
e.mu.RUnlock()
|
||||
@@ -144,11 +144,11 @@ func (e *Endpoint) ARPHardwareType() header.ARPHardwareType {
|
||||
}
|
||||
|
||||
// AddHeader implements stack.LinkEndpoint.AddHeader.
|
||||
func (e *Endpoint) AddHeader(pkt stack.PacketBufferPtr) {
|
||||
func (e *Endpoint) AddHeader(pkt *stack.PacketBuffer) {
|
||||
e.child.AddHeader(pkt)
|
||||
}
|
||||
|
||||
// ParseHeader implements stack.LinkEndpoint.ParseHeader.
|
||||
func (e *Endpoint) ParseHeader(pkt stack.PacketBufferPtr) bool {
|
||||
func (e *Endpoint) ParseHeader(pkt *stack.PacketBuffer) bool {
|
||||
return e.child.ParseHeader(pkt)
|
||||
}
|
||||
|
||||
@@ -53,11 +53,11 @@ type counterDispatcher struct {
|
||||
|
||||
var _ stack.NetworkDispatcher = (*counterDispatcher)(nil)
|
||||
|
||||
func (d *counterDispatcher) DeliverNetworkPacket(tcpip.NetworkProtocolNumber, stack.PacketBufferPtr) {
|
||||
func (d *counterDispatcher) DeliverNetworkPacket(tcpip.NetworkProtocolNumber, *stack.PacketBuffer) {
|
||||
d.count++
|
||||
}
|
||||
|
||||
func (*counterDispatcher) DeliverLinkPacket(tcpip.NetworkProtocolNumber, stack.PacketBufferPtr) {
|
||||
func (*counterDispatcher) DeliverLinkPacket(tcpip.NetworkProtocolNumber, *stack.PacketBuffer) {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func New(lower stack.LinkEndpoint) stack.LinkEndpoint {
|
||||
}
|
||||
|
||||
// DeliverNetworkPacket implements stack.NetworkDispatcher.
|
||||
func (e *endpoint) DeliverNetworkPacket(protocol tcpip.NetworkProtocolNumber, pkt stack.PacketBufferPtr) {
|
||||
func (e *endpoint) DeliverNetworkPacket(protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) {
|
||||
e.Endpoint.DeliverLinkPacket(protocol, pkt)
|
||||
|
||||
e.Endpoint.DeliverNetworkPacket(protocol, pkt)
|
||||
|
||||
@@ -52,18 +52,18 @@ func (e *nullEndpoint) Attach(d stack.NetworkDispatcher) { e.disp = d }
|
||||
func (e *nullEndpoint) IsAttached() bool { return e.disp != nil }
|
||||
func (*nullEndpoint) Wait() {}
|
||||
func (*nullEndpoint) ARPHardwareType() header.ARPHardwareType { return header.ARPHardwareNone }
|
||||
func (*nullEndpoint) AddHeader(stack.PacketBufferPtr) {}
|
||||
func (*nullEndpoint) ParseHeader(stack.PacketBufferPtr) bool { return true }
|
||||
func (*nullEndpoint) AddHeader(*stack.PacketBuffer) {}
|
||||
func (*nullEndpoint) ParseHeader(*stack.PacketBuffer) bool { return true }
|
||||
|
||||
var _ stack.NetworkDispatcher = (*testNetworkDispatcher)(nil)
|
||||
|
||||
type linkPacketInfo struct {
|
||||
pkt stack.PacketBufferPtr
|
||||
pkt *stack.PacketBuffer
|
||||
protocol tcpip.NetworkProtocolNumber
|
||||
}
|
||||
|
||||
type networkPacketInfo struct {
|
||||
pkt stack.PacketBufferPtr
|
||||
pkt *stack.PacketBuffer
|
||||
protocol tcpip.NetworkProtocolNumber
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ func (t *testNetworkDispatcher) reset() {
|
||||
*t = testNetworkDispatcher{}
|
||||
}
|
||||
|
||||
func (t *testNetworkDispatcher) DeliverNetworkPacket(protocol tcpip.NetworkProtocolNumber, pkt stack.PacketBufferPtr) {
|
||||
func (t *testNetworkDispatcher) DeliverNetworkPacket(protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) {
|
||||
networkPacket := networkPacketInfo{
|
||||
pkt: pkt.IncRef(),
|
||||
protocol: protocol,
|
||||
@@ -99,7 +99,7 @@ func (t *testNetworkDispatcher) DeliverNetworkPacket(protocol tcpip.NetworkProto
|
||||
t.networkPacket = networkPacket
|
||||
}
|
||||
|
||||
func (t *testNetworkDispatcher) DeliverLinkPacket(protocol tcpip.NetworkProtocolNumber, pkt stack.PacketBufferPtr) {
|
||||
func (t *testNetworkDispatcher) DeliverLinkPacket(protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) {
|
||||
linkPacket := linkPacketInfo{
|
||||
pkt: pkt.IncRef(),
|
||||
protocol: protocol,
|
||||
|
||||
@@ -122,7 +122,7 @@ func (*Endpoint) ARPHardwareType() header.ARPHardwareType {
|
||||
}
|
||||
|
||||
// AddHeader implements stack.LinkEndpoint.
|
||||
func (*Endpoint) AddHeader(stack.PacketBufferPtr) {}
|
||||
func (*Endpoint) AddHeader(*stack.PacketBuffer) {}
|
||||
|
||||
// ParseHeader implements stack.LinkEndpoint.
|
||||
func (*Endpoint) ParseHeader(stack.PacketBufferPtr) bool { return true }
|
||||
func (*Endpoint) ParseHeader(*stack.PacketBuffer) bool { return true }
|
||||
|
||||
@@ -127,7 +127,7 @@ func (qd *queueDispatcher) dispatchLoop() {
|
||||
// - pkt.EgressRoute
|
||||
// - pkt.GSOOptions
|
||||
// - pkt.NetworkProtocolNumber
|
||||
func (d *discipline) WritePacket(pkt stack.PacketBufferPtr) tcpip.Error {
|
||||
func (d *discipline) WritePacket(pkt *stack.PacketBuffer) tcpip.Error {
|
||||
if d.closed.Load() == qDiscClosed {
|
||||
return &tcpip.ErrClosedForSend{}
|
||||
}
|
||||
|
||||
@@ -23,14 +23,14 @@ import "gvisor.dev/gvisor/pkg/tcpip/stack"
|
||||
//
|
||||
// +stateify savable
|
||||
type packetBufferCircularList struct {
|
||||
pbs []stack.PacketBufferPtr
|
||||
pbs []*stack.PacketBuffer
|
||||
head int
|
||||
size int
|
||||
}
|
||||
|
||||
// init initializes the list with the given size.
|
||||
func (pl *packetBufferCircularList) init(size int) {
|
||||
pl.pbs = make([]stack.PacketBufferPtr, size)
|
||||
pl.pbs = make([]*stack.PacketBuffer, size)
|
||||
}
|
||||
|
||||
// length returns the number of elements in the list.
|
||||
@@ -60,7 +60,7 @@ func (pl *packetBufferCircularList) isEmpty() bool {
|
||||
// Failing to do so may clobber existing entries.
|
||||
//
|
||||
//go:nosplit
|
||||
func (pl *packetBufferCircularList) pushBack(pb stack.PacketBufferPtr) {
|
||||
func (pl *packetBufferCircularList) pushBack(pb *stack.PacketBuffer) {
|
||||
next := (pl.head + pl.size) % len(pl.pbs)
|
||||
pl.pbs[next] = pb
|
||||
pl.size++
|
||||
@@ -69,7 +69,7 @@ func (pl *packetBufferCircularList) pushBack(pb stack.PacketBufferPtr) {
|
||||
// removeFront returns the first element of the list or nil.
|
||||
//
|
||||
//go:nosplit
|
||||
func (pl *packetBufferCircularList) removeFront() stack.PacketBufferPtr {
|
||||
func (pl *packetBufferCircularList) removeFront() *stack.PacketBuffer {
|
||||
if pl.isEmpty() {
|
||||
return nil
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user