From 0e8b16f9a1dae0a9817e2efc5a0e4a2af894bb92 Mon Sep 17 00:00:00 2001 From: xjasonlyu Date: Sun, 27 Mar 2022 20:52:02 +0800 Subject: [PATCH] Fix: decrease packet reference (#106) ref: https://github.com/google/gvisor/commit/f375784d83852b1e3ff20cc9de0648b3c0cf8525 --- core/device/iobased/endpoint.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/device/iobased/endpoint.go b/core/device/iobased/endpoint.go index cc2d4ee..04e3627 100644 --- a/core/device/iobased/endpoint.go +++ b/core/device/iobased/endpoint.go @@ -103,7 +103,7 @@ func (e *Endpoint) dispatchLoop(cancel context.CancelFunc) { case header.IPv6Version: e.InjectInbound(header.IPv6ProtocolNumber, pkt) } - pkt.DecRef() /* release */ + pkt.DecRef() } } @@ -121,6 +121,8 @@ func (e *Endpoint) outboundLoop(ctx context.Context) { // writePacket writes outbound packets to the io.Writer. func (e *Endpoint) writePacket(pkt *stack.PacketBuffer) tcpip.Error { + defer pkt.DecRef() + size := pkt.Size() views := pkt.Views() if e.offset != 0 {