aboutsummaryrefslogtreecommitdiffstats
path: root/src/charon/plugins/kernel_pfkey/kernel_pfkey_ipsec.c
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2009-08-31 17:59:00 +0200
committerMartin Willi <martin@strongswan.org>2009-08-31 18:00:28 +0200
commit6180a55852afaf7fee4086a45dccbff9d7f7dfa8 (patch)
tree61968edccb4b5b5e39a045b16067299f1e5cda02 /src/charon/plugins/kernel_pfkey/kernel_pfkey_ipsec.c
parentde5784452b31af3c7342269127a12d352edc0b4e (diff)
downloadstrongswan-6180a55852afaf7fee4086a45dccbff9d7f7dfa8.tar.bz2
strongswan-6180a55852afaf7fee4086a45dccbff9d7f7dfa8.tar.xz
use time_monotonic() instead of time() for statistics and time difference calculations
Diffstat (limited to 'src/charon/plugins/kernel_pfkey/kernel_pfkey_ipsec.c')
-rw-r--r--src/charon/plugins/kernel_pfkey/kernel_pfkey_ipsec.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/charon/plugins/kernel_pfkey/kernel_pfkey_ipsec.c b/src/charon/plugins/kernel_pfkey/kernel_pfkey_ipsec.c
index 1f83e8f39..7674654c9 100644
--- a/src/charon/plugins/kernel_pfkey/kernel_pfkey_ipsec.c
+++ b/src/charon/plugins/kernel_pfkey/kernel_pfkey_ipsec.c
@@ -1911,9 +1911,16 @@ static status_t query_policy(private_kernel_pfkey_ipsec_t *this,
free(out);
return FAILED;
}
-
- *use_time = response.lft_current->sadb_lifetime_usetime;
-
+ /* we need the monotonic time, but the kernel returns system time. */
+ if (response.lft_current->sadb_lifetime_usetime)
+ {
+ *use_time = time_monotonic(NULL) -
+ (time(NULL) - response.lft_current->sadb_lifetime_usetime);
+ }
+ else
+ {
+ *use_time = 0;
+ }
free(out);
return SUCCESS;