From 825c185dc56251bd330124ef773c6653e3887579 Mon Sep 17 00:00:00 2001 From: Ting-Yu Wang Date: Fri, 29 Jan 2021 17:35:27 -0800 Subject: Make fragmentation return a reassembled PacketBuffer This allows later decoupling of the backing network buffer implementation. PiperOrigin-RevId: 354643297 --- pkg/tcpip/buffer/view.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'pkg/tcpip/buffer/view.go') diff --git a/pkg/tcpip/buffer/view.go b/pkg/tcpip/buffer/view.go index 91cc62cc8..b05e81526 100644 --- a/pkg/tcpip/buffer/view.go +++ b/pkg/tcpip/buffer/view.go @@ -239,6 +239,16 @@ func (vv *VectorisedView) Size() int { return vv.size } +// MemSize returns the estimation size of the vv in memory, including backing +// buffer data. +func (vv *VectorisedView) MemSize() int { + var size int + for _, v := range vv.views { + size += cap(v) + } + return size + cap(vv.views)*viewStructSize + vectorisedViewStructSize +} + // ToView returns a single view containing the content of the vectorised view. // // If the vectorised view contains a single view, that view will be returned -- cgit v1.2.3