diff options
author | gVisor bot <gvisor-bot@google.com> | 2021-09-27 20:39:27 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-09-27 20:39:27 +0000 |
commit | 21a4133cd489b551c6bbf59c2a50d89dde1ba709 (patch) | |
tree | 3ddff58b813860dab87efce5cfd2aa1c82cd3d0d /pkg/tcpip/stack | |
parent | de86fb500484540562ad094c136a9cf39c684103 (diff) | |
parent | 1fe0a6691ff5cb2e6b8955dc24819651cfe0c3af (diff) |
Merge release-20210921.0-34-g1fe0a6691 (automated)
Diffstat (limited to 'pkg/tcpip/stack')
-rw-r--r-- | pkg/tcpip/stack/packet_buffer.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/pkg/tcpip/stack/packet_buffer.go b/pkg/tcpip/stack/packet_buffer.go index bf248ef20..456b0cf80 100644 --- a/pkg/tcpip/stack/packet_buffer.go +++ b/pkg/tcpip/stack/packet_buffer.go @@ -425,13 +425,14 @@ func (d PacketData) PullUp(size int) (tcpipbuffer.View, bool) { return d.pk.buf.PullUp(d.pk.dataOffset(), size) } -// DeleteFront removes count from the beginning of d. It panics if count > -// d.Size(). All backing storage references after the front of the d are -// invalidated. -func (d PacketData) DeleteFront(count int) { - if !d.pk.buf.Remove(d.pk.dataOffset(), count) { - panic("count > d.Size()") +// Consume is the same as PullUp except that is additionally consumes the +// returned bytes. Subsequent PullUp or Consume will not return these bytes. +func (d PacketData) Consume(size int) (tcpipbuffer.View, bool) { + v, ok := d.PullUp(size) + if ok { + d.pk.consumed += size } + return v, ok } // CapLength reduces d to at most length bytes. |