diff options
author | Ghanan Gowripalan <ghanan@google.com> | 2021-05-03 16:44:02 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-05-03 16:45:48 -0700 |
commit | 279f9fcee763a52d210f8269bc4c871b7eee112f (patch) | |
tree | af2d397dce721ead0d80efd8a768e84e3f8e38ff /pkg/tcpip/stack | |
parent | f0b3298db07df63fa74559d5689008f9de9980a9 (diff) |
Implement standard clock safely
Previously, tcpip.StdClock depended on linking with the unexposed method
time.now to implement tcpip.Clock using the time package. This change
updates the standard clock to not require manually linking to this
unexported method and use publicly documented functions from the time
package.
PiperOrigin-RevId: 371805101
Diffstat (limited to 'pkg/tcpip/stack')
-rw-r--r-- | pkg/tcpip/stack/neighbor_cache_test.go | 2 | ||||
-rw-r--r-- | pkg/tcpip/stack/stack.go | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/pkg/tcpip/stack/neighbor_cache_test.go b/pkg/tcpip/stack/neighbor_cache_test.go index 48bb75e2f..9821a18d3 100644 --- a/pkg/tcpip/stack/neighbor_cache_test.go +++ b/pkg/tcpip/stack/neighbor_cache_test.go @@ -1556,7 +1556,7 @@ func TestNeighborCacheRetryResolution(t *testing.T) { func BenchmarkCacheClear(b *testing.B) { b.StopTimer() config := DefaultNUDConfigurations() - clock := &tcpip.StdClock{} + clock := tcpip.NewStdClock() linkRes := newTestNeighborResolver(nil, config, clock) linkRes.delay = 0 diff --git a/pkg/tcpip/stack/stack.go b/pkg/tcpip/stack/stack.go index 843118b13..436392f23 100644 --- a/pkg/tcpip/stack/stack.go +++ b/pkg/tcpip/stack/stack.go @@ -322,7 +322,7 @@ func (*TransportEndpointInfo) IsEndpointInfo() {} func New(opts Options) *Stack { clock := opts.Clock if clock == nil { - clock = &tcpip.StdClock{} + clock = tcpip.NewStdClock() } if opts.UniqueID == nil { |