diff options
author | Ian Gudger <igudger@google.com> | 2018-09-13 19:11:12 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-09-13 19:12:15 -0700 |
commit | 29a7271f5da9fdb7b4a9a6c9ea61421ce6844a73 (patch) | |
tree | 6b6fe019f6459d36f50cdf47e406ccb0ae034f83 /pkg/sentry/kernel/kernel.go | |
parent | bde2a91433cfbac426577a691bf13817115b53be (diff) |
Plumb monotonic time to netstack
Netstack needs to be portable, so this seems to be preferable to using raw
system calls.
PiperOrigin-RevId: 212917409
Change-Id: I7b2073e7db4b4bf75300717ca23aea4c15be944c
Diffstat (limited to 'pkg/sentry/kernel/kernel.go')
-rw-r--r-- | pkg/sentry/kernel/kernel.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/pkg/sentry/kernel/kernel.go b/pkg/sentry/kernel/kernel.go index bc41c3963..316612b37 100644 --- a/pkg/sentry/kernel/kernel.go +++ b/pkg/sentry/kernel/kernel.go @@ -943,6 +943,8 @@ func (k *Kernel) SetExitError(err error) { } } +var _ tcpip.Clock = (*Kernel)(nil) + // NowNanoseconds implements tcpip.Clock.NowNanoseconds. func (k *Kernel) NowNanoseconds() int64 { now, err := k.timekeeper.GetTime(sentrytime.Realtime) @@ -952,6 +954,15 @@ func (k *Kernel) NowNanoseconds() int64 { return now } +// NowMonotonic implements tcpip.Clock.NowMonotonic. +func (k *Kernel) NowMonotonic() int64 { + now, err := k.timekeeper.GetTime(sentrytime.Monotonic) + if err != nil { + panic("Kernel.NowMonotonic: " + err.Error()) + } + return now +} + // SupervisorContext returns a Context with maximum privileges in k. It should // only be used by goroutines outside the control of the emulated kernel // defined by e. |