suspend/resume time-gap and expiration timers in network stack
Hiroki Sato
hrs at FreeBSD.org
Sat Aug 17 08:32:55 UTC 2013
Hi,
I recently committed s/time_second/time_uptime/ replacement in
sys/netinet6 which was done in sys/netinet some years ago. It works
well and should be more robust against time_second deviation (by NTP,
for example). However, IPv6 default routers and prefixes do not
expire as before if the machine is suspended and then resumed after a
long time, say, 3 days.
I think the impact is limited because suspend/resume causes to reset
all of the physical network interfaces in some way, but in some cases
the decayed entries can persist. So I would like your comments about
the following idea to solve this:
1. Record RTC value upon suspend.
2. Calculate the time-gap by using the recorded value and the current
one upon resume.
3. Store the calculated time-gap in time_uptime_gap variable and use
(time_uptime + time_uptime_gap) for expiration timers.
If there is no suspend/resume event, nothing happens. If any, the
time-gap is added to the expiration time. The time_uptime_gap
variable is always positive, so (time_uptime + time_uptime_gap) never
goes backwards.
A experimental patch is attached. Changes include the following:
====
- Add clock_suspend_stamp() and clock_resume_fixup() functions to
calculate suspend/resume time-gap. clock_suspend_stamp() record
an RTC value just before disabling timer, and clock_resume_fixup()
store the time-gap into time_uptime_gap variable. Ideally,
time_uptime + time_uptime_gap becomes equal to the elapsed time
since boottime.
- Add time-gap calculation in ACPI suspend/resume.
- Add kern.clock_suspend_stamp and kern.clock_resume_fixup sysctls to
allow time-gap calculation from userland. These are write-only, and
setting them to non-zero calls the functions. Typically,
kern.clock_suspend_stamp should be set to 1 just before suspend,
and kern.clock_resume_fixup should be set to 1 just after resume.
kern.clock_resume_fixup is idempotent.
- Add TIME_UPTIME_CALED macro. This is defined as (time_uptime +
time_uptime_gap).
- Use TIME_UPTIME_CALED for expiration timers in sys/netinet6.
====
It is not so smart and I do not think it is commit-ready, but it
helps you to understand what I want to do. While this implementation
cares about only ACPI suspend/resume and timers in sys/netinet6, this
can be applied to VM suspend/resume and sys/net and sys/netinet
expiration timers like one for ARP table.
-- Hiroki
-------------- next part --------------
A non-text attachment was scrubbed...
Name: uptime_gap.20130817-1.diff
Type: text/x-patch
Size: 22063 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20130817/10774d58/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20130817/10774d58/attachment.sig>
More information about the freebsd-arch
mailing list