Page MenuHomeFreeBSD

bsnmpd: Return the correct uptime.
ClosedPublic

Authored by imp on May 5 2021, 12:24 AM.
Tags
None
Referenced Files
Unknown Object (File)
Nov 25 2024, 9:57 AM
Unknown Object (File)
Nov 23 2024, 4:10 AM
Unknown Object (File)
Oct 2 2024, 3:25 PM
Unknown Object (File)
Oct 1 2024, 12:20 PM
Unknown Object (File)
Oct 1 2024, 7:08 AM
Unknown Object (File)
Sep 28 2024, 12:39 AM
Unknown Object (File)
Sep 25 2024, 8:25 AM
Unknown Object (File)
Sep 25 2024, 8:25 AM
Subscribers
None

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
Lint Not Applicable
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.