use time_monotonic() instead of gettimeofday() for time difference calculations
This commit is contained in:
@@ -36,8 +36,6 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/time.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <gmp.h>
|
#include <gmp.h>
|
||||||
|
|
||||||
#include "eap_aka.h"
|
#include "eap_aka.h"
|
||||||
@@ -272,7 +270,8 @@ static chunk_t peer_sqn = chunk_from_buf(peer_sqn_buf);
|
|||||||
static void update_sqn(u_int8_t *sqn, time_t offset)
|
static void update_sqn(u_int8_t *sqn, time_t offset)
|
||||||
{
|
{
|
||||||
timeval_t time;
|
timeval_t time;
|
||||||
gettimeofday(&time, NULL);
|
|
||||||
|
time_monotonic(&time);
|
||||||
/* set sqb_sqn to an integer containing seconds followed by most
|
/* set sqb_sqn to an integer containing seconds followed by most
|
||||||
* significant useconds */
|
* significant useconds */
|
||||||
time.tv_sec = htonl(time.tv_sec + offset);
|
time.tv_sec = htonl(time.tv_sec + offset);
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/time.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <linux/ipsec.h>
|
#include <linux/ipsec.h>
|
||||||
#include <linux/netlink.h>
|
#include <linux/netlink.h>
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <linux/netlink.h>
|
#include <linux/netlink.h>
|
||||||
#include <linux/rtnetlink.h>
|
#include <linux/rtnetlink.h>
|
||||||
#include <sys/time.h>
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@@ -145,7 +144,7 @@ struct private_kernel_netlink_net_t {
|
|||||||
/**
|
/**
|
||||||
* time of the last roam_job
|
* time of the last roam_job
|
||||||
*/
|
*/
|
||||||
struct timeval last_roam;
|
timeval_t last_roam;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* routing table to install routes
|
* routing table to install routes
|
||||||
@@ -208,22 +207,20 @@ static int get_vip_refcount(private_kernel_netlink_net_t *this, host_t* ip)
|
|||||||
*/
|
*/
|
||||||
static void fire_roam_job(private_kernel_netlink_net_t *this, bool address)
|
static void fire_roam_job(private_kernel_netlink_net_t *this, bool address)
|
||||||
{
|
{
|
||||||
struct timeval now;
|
timeval_t now;
|
||||||
|
|
||||||
if (gettimeofday(&now, NULL) == 0)
|
time_monotonic(&now);
|
||||||
|
if (timercmp(&now, &this->last_roam, >))
|
||||||
{
|
{
|
||||||
if (timercmp(&now, &this->last_roam, >))
|
now.tv_usec += ROAM_DELAY * 1000;
|
||||||
|
while (now.tv_usec > 1000000)
|
||||||
{
|
{
|
||||||
now.tv_usec += ROAM_DELAY * 1000;
|
now.tv_sec++;
|
||||||
while (now.tv_usec > 1000000)
|
now.tv_usec -= 1000000;
|
||||||
{
|
|
||||||
now.tv_sec++;
|
|
||||||
now.tv_usec -= 1000000;
|
|
||||||
}
|
|
||||||
this->last_roam = now;
|
|
||||||
charon->scheduler->schedule_job_ms(charon->scheduler,
|
|
||||||
(job_t*)roam_job_create(address), ROAM_DELAY);
|
|
||||||
}
|
}
|
||||||
|
this->last_roam = now;
|
||||||
|
charon->scheduler->schedule_job_ms(charon->scheduler,
|
||||||
|
(job_t*)roam_job_create(address), ROAM_DELAY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ struct private_kernel_pfroute_net_t
|
|||||||
/**
|
/**
|
||||||
* time of last roam job
|
* time of last roam job
|
||||||
*/
|
*/
|
||||||
struct timeval last_roam;
|
timeval_t last_roam;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -156,22 +156,20 @@ struct private_kernel_pfroute_net_t
|
|||||||
*/
|
*/
|
||||||
static void fire_roam_job(private_kernel_pfroute_net_t *this, bool address)
|
static void fire_roam_job(private_kernel_pfroute_net_t *this, bool address)
|
||||||
{
|
{
|
||||||
struct timeval now;
|
timeval_t now;
|
||||||
|
|
||||||
if (gettimeofday(&now, NULL) == 0)
|
time_monotonic(&now);
|
||||||
|
if (timercmp(&now, &this->last_roam, >))
|
||||||
{
|
{
|
||||||
if (timercmp(&now, &this->last_roam, >))
|
now.tv_usec += ROAM_DELAY * 1000;
|
||||||
|
while (now.tv_usec > 1000000)
|
||||||
{
|
{
|
||||||
now.tv_usec += ROAM_DELAY * 1000;
|
now.tv_sec++;
|
||||||
while (now.tv_usec > 1000000)
|
now.tv_usec -= 1000000;
|
||||||
{
|
|
||||||
now.tv_sec++;
|
|
||||||
now.tv_usec -= 1000000;
|
|
||||||
}
|
|
||||||
this->last_roam = now;
|
|
||||||
charon->scheduler->schedule_job_ms(charon->scheduler,
|
|
||||||
(job_t*)roam_job_create(address), ROAM_DELAY);
|
|
||||||
}
|
}
|
||||||
|
this->last_roam = now;
|
||||||
|
charon->scheduler->schedule_job_ms(charon->scheduler,
|
||||||
|
(job_t*)roam_job_create(address), ROAM_DELAY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
* for more details.
|
* for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,6 @@
|
|||||||
|
|
||||||
typedef struct scheduler_t scheduler_t;
|
typedef struct scheduler_t scheduler_t;
|
||||||
|
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
#include <library.h>
|
#include <library.h>
|
||||||
#include <processing/jobs/job.h>
|
#include <processing/jobs/job.h>
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
* for more details.
|
* for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <sys/time.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|||||||
@@ -25,7 +25,6 @@
|
|||||||
#include <resolv.h>
|
#include <resolv.h>
|
||||||
#include <arpa/nameser.h> /* missing from <resolv.h> on old systems */
|
#include <arpa/nameser.h> /* missing from <resolv.h> on old systems */
|
||||||
#include <sys/queue.h>
|
#include <sys/queue.h>
|
||||||
#include <sys/time.h> /* for gettimeofday */
|
|
||||||
|
|
||||||
#include <freeswan.h>
|
#include <freeswan.h>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user