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

Johannes Berg johannes
Wed Nov 13 08:50:09 PST 2013

From: Johannes Berg <johannes.berg at 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!

Reported-by: Holger Schurig <holgerschurig at gmail.com>
Signed-hostap: Johannes Berg <johannes.berg at intel.com>
patch too big for list, see

More information about the Hostap mailing list