Page MenuHomeFreeBSD

ping6: Annotate truncating of time values saved in a packet
AbandonedPublic

Authored by asomers on Aug 12 2019, 7:30 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Apr 9, 1:01 AM
Unknown Object (File)
Mon, Apr 8, 12:57 PM
Unknown Object (File)
Mon, Apr 8, 12:57 PM
Unknown Object (File)
Mar 16 2024, 11:34 AM
Unknown Object (File)
Jan 13 2024, 10:13 AM
Unknown Object (File)
Dec 23 2023, 3:11 PM
Unknown Object (File)
Dec 21 2023, 10:10 PM
Unknown Object (File)
Dec 20 2023, 2:33 AM
Subscribers
None

Details

Reviewers
jansucan
Summary

Annotate truncating of time values saved in a packet

Submitted by: Ján Sučan <sucanjan@gmail.com>
Sponsored by: Google, inc. (Google Summer of Code 2019)

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 25793
Build 24365: arc lint + arc unit

Event Timeline

sbin/ping6/ping6.c
1384

Yeah they're truncated. That much is clear from the cast. But why?

sbin/ping6/ping6.c
1384

Please, tell me what's the correct comment. Or should remove it?

A useful comment would tell the reader why it's ok to truncate the time in this case. Usually, that would be very bad. But in this case, we're only concerned about the difference between two close timespecs. Dropping the MSB from both samples won't affect their difference[1]. So a useful comment would say something like "Truncate seconds down to 32 bits in order to fit the timestamp within 8 bytes of the packet. We're only concerned with durations, not absolute times".

[1] Actually, it could affect the difference once every 68 years or so. But your other commit, which replaces gettimeofday with clock_gettime, will mostly fix that. CLOCK_MONOTONIC is implemented by measuring seconds since boot. So then ping6 will only have a problem after 68 years of _uptime_.

In fact, maybe you should combine this revision with the clock_gettime change. The combination is more correct than this change alone.

The revision has been combined.

asomers abandoned this revision.
asomers edited reviewers, added: jansucan; removed: asomers.

Closing in favor of D21226