Page MenuHomeFreeBSD

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

Authored by asomers on Mon, Aug 12, 7:30 AM.

Details

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 OK
Unit
No Unit Test Coverage
Build Status
Buildable 25793
Build 24365: arc lint + arc unit

Event Timeline

asomers added inline comments.Mon, Aug 12, 7:21 PM
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 edited reviewers, added: sucanjan_gmail.com; removed: asomers.Tue, Aug 13, 4:26 PM
asomers commandeered this revision.
asomers abandoned this revision.

Closing in favor of D21226