[RFC/RFT] use monotonic clock for relative time where available

Submitted by Johannes Berg on Nov. 13, 2013, 7:03 p.m.


Message ID 1384369434.14578.29.camel@jlt4.sipsolutions.net
State Superseded
Headers show

Commit Message

Johannes Berg Nov. 13, 2013, 7:03 p.m.
On Wed, 2013-11-13 at 17:50 +0100, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
> Relative time shouldn't be calculated based on gettimeofday
> because that clock can jump (e.g. when the time is adjusted
> by the system administrator.)
> On systems where that is available, use CLOCK_BOOTTIME (on
> fairly recent Linux systems, this clock takes into account
> the time spend suspended) or CLOCK_MONOTONIC (on Linux and
> some POSIX systems, this clock is just freely running with
> no adjustments.)
> Unfortunately this patch is invasive since a lot of places
> need to be adjusted to use os_get_reltime() rather than
> os_get_time() that is used now. However, not all instances
> should use the other clock, e.g. absolute time needed in
> any certificate checking and similar needs to be wall time.
> TODO: carefully check all replacements to see if any should
>       actually be using os_get_time() instead!

FWIW, with this patch, tests are passing (still running) when I add this
patch to my vm runner script:

With this clock modification and an unmodified wpa_s, it totally fails.


Patch hide | download patch | download mbox

--- a/tests/hwsim/vm/inside.sh
+++ b/tests/hwsim/vm/inside.sh
@@ -56,6 +56,13 @@  ip link set lo up
 mkdir /tmp/logs
 mount -t 9p -o trans=virtio,rw logshare /tmp/logs
+    while sleep 1 ; do
+        date --set "@$(($(date +%s) + 19))"
+        date >/dev/ttyS0
+    done
+) &
 # check if we're rebooting due to a kernel panic ...
 if grep -q 'Kernel panic' /tmp/logs/console ; then
        echo "KERNEL CRASHED!" >/dev/ttyS0