summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/stack/route.go
diff options
context:
space:
mode:
authorBert Muthalaly <stijlist@google.com>2019-03-19 08:29:37 -0700
committerShentubot <shentubot@google.com>2019-03-19 08:30:43 -0700
commit928809fa7d3b682c7e2e06c9f9b1f3fb5d75a0d6 (patch)
tree33e1e1c21be68ffaeeb83cfb86f29af512515058 /pkg/tcpip/stack/route.go
parent8a499ae65f361fb01c2e4be03122f69910a8ba4a (diff)
Add layer 2 stats (tx, rx) X (packets, bytes) to netstack
PiperOrigin-RevId: 239194420 Change-Id: Ie193e8ac2b7a6db21195ac85824a335930483971
Diffstat (limited to 'pkg/tcpip/stack/route.go')
-rw-r--r--pkg/tcpip/stack/route.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/pkg/tcpip/stack/route.go b/pkg/tcpip/stack/route.go
index 86fb728b2..3f2264d16 100644
--- a/pkg/tcpip/stack/route.go
+++ b/pkg/tcpip/stack/route.go
@@ -146,8 +146,11 @@ func (r *Route) IsResolutionRequired() bool {
// WritePacket writes the packet through the given route.
func (r *Route) WritePacket(hdr buffer.Prependable, payload buffer.VectorisedView, protocol tcpip.TransportProtocolNumber, ttl uint8) *tcpip.Error {
err := r.ref.ep.WritePacket(r, hdr, payload, protocol, ttl, r.loop)
- if err == tcpip.ErrNoRoute {
+ if err != nil {
r.Stats().IP.OutgoingPacketErrors.Increment()
+ } else {
+ r.ref.nic.stats.Tx.Packets.Increment()
+ r.ref.nic.stats.Tx.Bytes.IncrementBy(uint64(hdr.UsedLength() + payload.Size()))
}
return err
}