diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-05-29 20:03:58 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-05-29 20:03:58 +0000 |
commit | 721df40b22b6b9af6365d0b1bbab259d2cd95d9d (patch) | |
tree | f58b9db9014941af4b9452e1dfcfec8ef3119f56 /pkg/tcpip/stack/nic.go | |
parent | a69f9d244d7042ac23a430987b2ebdadc3b8cc55 (diff) | |
parent | 341be65421edff16fd9eeb593301ce1d66148772 (diff) |
Merge release-20200522.0-37-g341be654 (automated)
Diffstat (limited to 'pkg/tcpip/stack/nic.go')
-rw-r--r-- | pkg/tcpip/stack/nic.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/pkg/tcpip/stack/nic.go b/pkg/tcpip/stack/nic.go index 9213cbb9a..05646e5e2 100644 --- a/pkg/tcpip/stack/nic.go +++ b/pkg/tcpip/stack/nic.go @@ -1304,13 +1304,16 @@ func (n *NIC) forwardPacket(r *Route, protocol tcpip.NetworkProtocolNumber, pkt pkt.Header = buffer.NewPrependable(linkHeaderLen) } + // WritePacket takes ownership of pkt, calculate numBytes first. + numBytes := pkt.Header.UsedLength() + pkt.Data.Size() + if err := n.linkEP.WritePacket(r, nil /* gso */, protocol, pkt); err != nil { r.Stats().IP.OutgoingPacketErrors.Increment() return } n.stats.Tx.Packets.Increment() - n.stats.Tx.Bytes.IncrementBy(uint64(pkt.Header.UsedLength() + pkt.Data.Size())) + n.stats.Tx.Bytes.IncrementBy(uint64(numBytes)) } // DeliverTransportPacket delivers the packets to the appropriate transport |