Page MenuHomeFreeBSD

bsnmpd: Return the correct uptime.
ClosedPublic

Authored by imp on May 5 2021, 12:24 AM.

Details

Summary

Do not assume that the kernel boot time is invariant. It is not. FreeBSD
uses the formula:
wall_time = boot_time + uptime
where uptime is monotinically increasing and boot_time is adjusted to
get the proper time of day. FreeBSD offers a way to retrieve the uptime
directly, so use that instead of trying to compute it by subtracting
boot_time from wall_time.

Sponsored by: Netflix

Test Plan

To test, one can step the time after starting bsnmpd. Since boot time changes but the new value isn't re-fetched, the uptime will step when it shouldn't.
With the fixed code, this doesn't happen.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

imp requested review of this revision.May 5 2021, 12:24 AM
imp created this revision.
imp edited the test plan for this revision. (Show Details)
imp retitled this revision from bsndmp: Return the correct uptime. to bsnmpd: Return the correct uptime..May 5 2021, 4:02 AM

This is certainly an improvement over the original.

However tabs have been replaced by spaces (0x20). Is this intentional?

This revision is now accepted and ready to land.May 5 2021, 4:40 AM
In D30114#676001, @cy wrote:

This is certainly an improvement over the original.

However tabs have been replaced by spaces (0x20). Is this intentional?

Nope... not sure how that happened.

This revision now requires review to proceed.May 5 2021, 5:47 AM
This revision is now accepted and ready to land.May 5 2021, 2:55 PM
This revision was automatically updated to reflect the committed changes.