diff options
author | gVisor bot <gvisor-bot@google.com> | 2021-05-25 20:05:47 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-05-25 20:05:47 +0000 |
commit | 93b3be2eb2457c3c12436503e6da384e40a68944 (patch) | |
tree | 1672784315b329b6f64e525456af7653f56eaff0 /pkg/tcpip/header | |
parent | 6f34ae308865ce8877797e9b2501a85195c42d7d (diff) | |
parent | 4f2439fb0ed4a6efda2637417c7137d27e4c4d26 (diff) |
Merge release-20210518.0-38-g4f2439fb0 (automated)
Diffstat (limited to 'pkg/tcpip/header')
-rw-r--r-- | pkg/tcpip/header/ipv4.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/pkg/tcpip/header/ipv4.go b/pkg/tcpip/header/ipv4.go index 2be21ec75..6a8db84d6 100644 --- a/pkg/tcpip/header/ipv4.go +++ b/pkg/tcpip/header/ipv4.go @@ -17,6 +17,7 @@ package header import ( "encoding/binary" "fmt" + "time" "gvisor.dev/gvisor/pkg/tcpip" ) @@ -813,9 +814,12 @@ const ( // ipv4TimestampTime provides the current time as specified in RFC 791. func ipv4TimestampTime(clock tcpip.Clock) uint32 { - const millisecondsPerDay = 24 * 3600 * 1000 - const nanoPerMilli = 1000000 - return uint32((clock.NowNanoseconds() / nanoPerMilli) % millisecondsPerDay) + // Per RFC 791 page 21: + // The Timestamp is a right-justified, 32-bit timestamp in + // milliseconds since midnight UT. + now := clock.Now().UTC() + midnight := now.Truncate(24 * time.Hour) + return uint32(now.Sub(midnight).Milliseconds()) } // IP Timestamp option fields. |