summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/transport
diff options
context:
space:
mode:
authorIan Gudger <igudger@google.com>2018-08-23 08:54:09 -0700
committerShentubot <shentubot@google.com>2018-08-23 08:55:23 -0700
commitabe7764928bb18fe417c53c8ea8aa9fb970114b7 (patch)
tree4ea44a38b3193ac29a4151daff471d8744f9071e /pkg/tcpip/transport
parenta78df1d874f376c0924d5a8f91e9e2b5458cca0f (diff)
Encapsulate netstack metrics
PiperOrigin-RevId: 209943212 Change-Id: I96dcbc7c2ab2426e510b94a564436505256c5c79
Diffstat (limited to 'pkg/tcpip/transport')
-rw-r--r--pkg/tcpip/transport/tcp/connect.go5
-rw-r--r--pkg/tcpip/transport/tcp/endpoint.go4
-rw-r--r--pkg/tcpip/transport/tcp/tcp_timestamp_test.go9
3 files changed, 9 insertions, 9 deletions
diff --git a/pkg/tcpip/transport/tcp/connect.go b/pkg/tcpip/transport/tcp/connect.go
index b90d3fe48..58d7942f3 100644
--- a/pkg/tcpip/transport/tcp/connect.go
+++ b/pkg/tcpip/transport/tcp/connect.go
@@ -16,7 +16,6 @@ package tcp
import (
"sync"
- "sync/atomic"
"time"
"gvisor.googlesource.com/gvisor/pkg/rand"
@@ -292,7 +291,7 @@ func (h *handshake) synRcvdState(s *segment) *tcpip.Error {
// not carry a timestamp option then the segment must be dropped
// as per https://tools.ietf.org/html/rfc7323#section-3.2.
if h.ep.sendTSOk && !s.parsedOptions.TS {
- atomic.AddUint64(&h.ep.stack.MutableStats().DroppedPackets, 1)
+ h.ep.stack.Stats().DroppedPackets.Increment()
return nil
}
@@ -793,7 +792,7 @@ func (e *endpoint) handleSegments() *tcpip.Error {
// must be dropped as per
// https://tools.ietf.org/html/rfc7323#section-3.2.
if e.sendTSOk && !s.parsedOptions.TS {
- atomic.AddUint64(&e.stack.MutableStats().DroppedPackets, 1)
+ e.stack.Stats().DroppedPackets.Increment()
s.decRef()
continue
}
diff --git a/pkg/tcpip/transport/tcp/endpoint.go b/pkg/tcpip/transport/tcp/endpoint.go
index 3fcbf6502..bdcba39c6 100644
--- a/pkg/tcpip/transport/tcp/endpoint.go
+++ b/pkg/tcpip/transport/tcp/endpoint.go
@@ -1225,7 +1225,7 @@ func (e *endpoint) GetRemoteAddress() (tcpip.FullAddress, *tcpip.Error) {
func (e *endpoint) HandlePacket(r *stack.Route, id stack.TransportEndpointID, vv *buffer.VectorisedView) {
s := newSegment(r, id, vv)
if !s.parse() {
- atomic.AddUint64(&e.stack.MutableStats().MalformedRcvdPackets, 1)
+ e.stack.Stats().MalformedRcvdPackets.Increment()
s.decRef()
return
}
@@ -1235,7 +1235,7 @@ func (e *endpoint) HandlePacket(r *stack.Route, id stack.TransportEndpointID, vv
e.newSegmentWaker.Assert()
} else {
// The queue is full, so we drop the segment.
- atomic.AddUint64(&e.stack.MutableStats().DroppedPackets, 1)
+ e.stack.Stats().DroppedPackets.Increment()
s.decRef()
}
}
diff --git a/pkg/tcpip/transport/tcp/tcp_timestamp_test.go b/pkg/tcpip/transport/tcp/tcp_timestamp_test.go
index 4f6f1da18..a529d9e72 100644
--- a/pkg/tcpip/transport/tcp/tcp_timestamp_test.go
+++ b/pkg/tcpip/transport/tcp/tcp_timestamp_test.go
@@ -268,7 +268,8 @@ func TestSegmentDropWhenTimestampMissing(t *testing.T) {
defer c.WQ.EventUnregister(&we)
stk := c.Stack()
- droppedPackets := stk.Stats().DroppedPackets
+ droppedPacketsStat := stk.Stats().DroppedPackets
+ droppedPackets := droppedPacketsStat.Value()
data := []byte{1, 2, 3}
// Save the sequence number as we will reset it later down
// in the test.
@@ -283,11 +284,11 @@ func TestSegmentDropWhenTimestampMissing(t *testing.T) {
}
// Assert that DroppedPackets was incremented by 1.
- if got, want := stk.Stats().DroppedPackets, droppedPackets+1; got != want {
+ if got, want := droppedPacketsStat.Value(), droppedPackets+1; got != want {
t.Fatalf("incorrect number of dropped packets, got: %v, want: %v", got, want)
}
- droppedPackets = stk.Stats().DroppedPackets
+ droppedPackets = droppedPacketsStat.Value()
// Reset the sequence number so that the other endpoint accepts
// this segment and does not treat it like an out of order delivery.
rep.NextSeqNum = savedSeqNum
@@ -301,7 +302,7 @@ func TestSegmentDropWhenTimestampMissing(t *testing.T) {
}
// Assert that DroppedPackets was not incremented by 1.
- if got, want := stk.Stats().DroppedPackets, droppedPackets; got != want {
+ if got, want := droppedPacketsStat.Value(), droppedPackets; got != want {
t.Fatalf("incorrect number of dropped packets, got: %v, want: %v", got, want)
}