summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/link/pipe
diff options
context:
space:
mode:
authorLucas Manning <lucasmanning@google.com>2021-11-08 13:26:02 -0800
committergVisor bot <gvisor-bot@google.com>2021-11-08 13:28:38 -0800
commit84b38f4c6e065d3f9314a8abbb3f5857ed4fa44e (patch)
tree53eb76fa6d0612696f93ec6919185ea5a37ff3f9 /pkg/tcpip/link/pipe
parent49d23beb283d0306c9ccf5300e73517153ddd3c2 (diff)
Add reference counting to packet buffers.
PiperOrigin-RevId: 408426639
Diffstat (limited to 'pkg/tcpip/link/pipe')
-rw-r--r--pkg/tcpip/link/pipe/pipe.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/pkg/tcpip/link/pipe/pipe.go b/pkg/tcpip/link/pipe/pipe.go
index c67ca98ea..c2a888054 100644
--- a/pkg/tcpip/link/pipe/pipe.go
+++ b/pkg/tcpip/link/pipe/pipe.go
@@ -59,9 +59,11 @@ func (e *Endpoint) deliverPackets(r stack.RouteInfo, proto tcpip.NetworkProtocol
// avoid a deadlock when a packet triggers a response which leads the stack to
// try and take a lock it already holds.
for pkt := pkts.Front(); pkt != nil; pkt = pkt.Next() {
- e.linked.dispatcher.DeliverNetworkPacket(r.LocalLinkAddress /* remote */, r.RemoteLinkAddress /* local */, proto, stack.NewPacketBuffer(stack.PacketBufferOptions{
+ newPkt := stack.NewPacketBuffer(stack.PacketBufferOptions{
Data: buffer.NewVectorisedView(pkt.Size(), pkt.Views()),
- }))
+ })
+ e.linked.dispatcher.DeliverNetworkPacket(r.LocalLinkAddress /* remote */, r.RemoteLinkAddress /* local */, proto, newPkt)
+ newPkt.DecRef()
}
}