From ba6de21539131bbf8116137704259e4d11d2894b Mon Sep 17 00:00:00 2001 From: Ting-Yu Wang Date: Wed, 12 May 2021 14:09:52 -0700 Subject: Fix not calling decRef on merged segments This code path is for outgoing packets, and we don't currently do memory accounting on this path. So it wasn't breaking anything. This change did not add a test for ref-counting issue fixed, but will switch to the leak-checking ref-counter later when all ref-counting issues are fixed. PiperOrigin-RevId: 373447913 --- pkg/tcpip/transport/tcp/segment.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'pkg/tcpip/transport/tcp/segment.go') diff --git a/pkg/tcpip/transport/tcp/segment.go b/pkg/tcpip/transport/tcp/segment.go index c28641be3..7e5ba6ef7 100644 --- a/pkg/tcpip/transport/tcp/segment.go +++ b/pkg/tcpip/transport/tcp/segment.go @@ -140,6 +140,15 @@ func (s *segment) clone() *segment { return t } +// merge merges data in oth and clears oth. +func (s *segment) merge(oth *segment) { + s.data.Append(oth.data) + s.dataMemSize = s.data.Size() + + oth.data = buffer.VectorisedView{} + oth.dataMemSize = oth.data.Size() +} + // flagIsSet checks if at least one flag in flags is set in s.flags. func (s *segment) flagIsSet(flags header.TCPFlags) bool { return s.flags&flags != 0 -- cgit v1.2.3