summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/network/ipv4
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/tcpip/network/ipv4')
-rw-r--r--pkg/tcpip/network/ipv4/stats.go2
-rw-r--r--pkg/tcpip/network/ipv4/stats_test.go38
2 files changed, 19 insertions, 21 deletions
diff --git a/pkg/tcpip/network/ipv4/stats.go b/pkg/tcpip/network/ipv4/stats.go
index 7620728f9..bee72c649 100644
--- a/pkg/tcpip/network/ipv4/stats.go
+++ b/pkg/tcpip/network/ipv4/stats.go
@@ -35,7 +35,7 @@ type Stats struct {
}
// IsNetworkEndpointStats implements stack.NetworkEndpointStats.
-func (s *Stats) IsNetworkEndpointStats() {}
+func (*Stats) IsNetworkEndpointStats() {}
// IPStats implements stack.IPNetworkEndointStats
func (s *Stats) IPStats() *tcpip.IPStats {
diff --git a/pkg/tcpip/network/ipv4/stats_test.go b/pkg/tcpip/network/ipv4/stats_test.go
index 84641bcf4..b28e7dcde 100644
--- a/pkg/tcpip/network/ipv4/stats_test.go
+++ b/pkg/tcpip/network/ipv4/stats_test.go
@@ -34,7 +34,7 @@ func (t *testInterface) ID() tcpip.NICID {
return t.nicID
}
-func getKnownNICIDs(proto *protocol) []tcpip.NICID {
+func knownNICIDs(proto *protocol) []tcpip.NICID {
var nicIDs []tcpip.NICID
for k := range proto.mu.eps {
@@ -51,30 +51,28 @@ func TestClearEndpointFromProtocolOnClose(t *testing.T) {
proto := s.NetworkProtocolInstance(ProtocolNumber).(*protocol)
nic := testInterface{nicID: 1}
ep := proto.NewEndpoint(&nic, nil, nil, nil).(*endpoint)
- {
- proto.mu.Lock()
- foundEP, hasEP := proto.mu.eps[nic.ID()]
- nicIDs := getKnownNICIDs(proto)
- proto.mu.Unlock()
+ var nicIDs []tcpip.NICID
+
+ proto.mu.Lock()
+ foundEP, hasEndpointBeforeClose := proto.mu.eps[nic.ID()]
+ nicIDs = knownNICIDs(proto)
+ proto.mu.Unlock()
- if !hasEP {
- t.Fatalf("expected to find the nic id %d in the protocol's endpoint map (%v)", nic.ID(), nicIDs)
- }
- if foundEP != ep {
- t.Fatalf("expected protocol to map endpoint %p to nic id %d, but endpoint %p was found instead", ep, nic.ID(), foundEP)
- }
+ if !hasEndpointBeforeClose {
+ t.Fatalf("expected to find the nic id %d in the protocol's endpoint map (%v)", nic.ID(), nicIDs)
+ }
+ if foundEP != ep {
+ t.Fatalf("found an incorrect endpoint mapped to nic id %d", nic.ID())
}
ep.Close()
- {
- proto.mu.Lock()
- _, hasEP := proto.mu.eps[nic.ID()]
- nicIDs := getKnownNICIDs(proto)
- proto.mu.Unlock()
- if hasEP {
- t.Fatalf("unexpectedly found an endpoint mapped to the nic id %d in the protocol's known nic ids (%v)", nic.ID(), nicIDs)
- }
+ proto.mu.Lock()
+ _, hasEP := proto.mu.eps[nic.ID()]
+ nicIDs = knownNICIDs(proto)
+ proto.mu.Unlock()
+ if hasEP {
+ t.Fatalf("unexpectedly found an endpoint mapped to the nic id %d in the protocol's known nic ids (%v)", nic.ID(), nicIDs)
}
}