summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/buffer/view.go
diff options
context:
space:
mode:
authorTing-Yu Wang <anivia@google.com>2021-01-29 17:35:27 -0800
committergVisor bot <gvisor-bot@google.com>2021-01-29 17:37:29 -0800
commit825c185dc56251bd330124ef773c6653e3887579 (patch)
treec059718acc0418795dc444184e08cbea19f7fc80 /pkg/tcpip/buffer/view.go
parent45fe9fe9c6fa92954a5017b98835eac5fd8d3987 (diff)
Make fragmentation return a reassembled PacketBuffer
This allows later decoupling of the backing network buffer implementation. PiperOrigin-RevId: 354643297
Diffstat (limited to 'pkg/tcpip/buffer/view.go')
-rw-r--r--pkg/tcpip/buffer/view.go10
1 files changed, 10 insertions, 0 deletions
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