aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcharon/plugins/kernel_netlink/kernel_netlink_net.c
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2010-07-06 16:03:09 +0200
committerTobias Brunner <tobias@strongswan.org>2010-09-02 19:01:25 +0200
commitba26508d0598d440638710736031864320253d94 (patch)
tree01459ecd827e571b90a4436475cec5bd46b56508 /src/libcharon/plugins/kernel_netlink/kernel_netlink_net.c
parent61e8e73206829e1d37c8e64585dd283ab4a29cef (diff)
downloadstrongswan-ba26508d0598d440638710736031864320253d94.tar.bz2
strongswan-ba26508d0598d440638710736031864320253d94.tar.xz
Moved roam job creation to kernel event handler.
Diffstat (limited to 'src/libcharon/plugins/kernel_netlink/kernel_netlink_net.c')
-rw-r--r--src/libcharon/plugins/kernel_netlink/kernel_netlink_net.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/src/libcharon/plugins/kernel_netlink/kernel_netlink_net.c b/src/libcharon/plugins/kernel_netlink/kernel_netlink_net.c
index fa4a50134..e55329e84 100644
--- a/src/libcharon/plugins/kernel_netlink/kernel_netlink_net.c
+++ b/src/libcharon/plugins/kernel_netlink/kernel_netlink_net.c
@@ -54,9 +54,8 @@
#include <threading/mutex.h>
#include <utils/linked_list.h>
#include <processing/jobs/callback_job.h>
-#include <processing/jobs/roam_job.h>
-/** delay before firing roam jobs (ms) */
+/** delay before firing roam events (ms) */
#define ROAM_DELAY 100
typedef struct addr_entry_t addr_entry_t;
@@ -159,7 +158,7 @@ struct private_kernel_netlink_net_t {
int socket_events;
/**
- * time of the last roam_job
+ * time of the last roam event
*/
timeval_t last_roam;
@@ -224,12 +223,22 @@ static int get_vip_refcount(private_kernel_netlink_net_t *this, host_t* ip)
}
/**
- * start a roaming job. We delay it for a second and fire only one job
- * for multiple events. Otherwise we would create too many jobs.
+ * callback function that raises the delayed roam event
*/
-static void fire_roam_job(private_kernel_netlink_net_t *this, bool address)
+static job_requeue_t roam_event(uintptr_t address)
+{
+ charon->kernel_interface->roam(charon->kernel_interface, address != 0);
+ return JOB_REQUEUE_NONE;
+}
+
+/**
+ * fire a roaming event. we delay it for a bit and fire only one event
+ * for multiple calls. otherwise we would create too many events.
+ */
+static void fire_roam_event(private_kernel_netlink_net_t *this, bool address)
{
timeval_t now;
+ job_t *job;
time_monotonic(&now);
if (timercmp(&now, &this->last_roam, >))
@@ -241,8 +250,11 @@ static void fire_roam_job(private_kernel_netlink_net_t *this, bool address)
now.tv_usec -= 1000000;
}
this->last_roam = now;
- hydra->scheduler->schedule_job_ms(hydra->scheduler,
- (job_t*)roam_job_create(address), ROAM_DELAY);
+
+ job = (job_t*)callback_job_create((callback_job_cb_t)roam_event,
+ (void*)(uintptr_t)(address ? 1 : 0),
+ NULL, NULL);
+ hydra->scheduler->schedule_job_ms(hydra->scheduler, job, ROAM_DELAY);
}
}
@@ -342,7 +354,7 @@ static void process_link(private_kernel_netlink_net_t *this,
/* send an update to all IKE_SAs */
if (update && event)
{
- fire_roam_job(this, TRUE);
+ fire_roam_event(this, TRUE);
}
}
@@ -459,7 +471,7 @@ static void process_addr(private_kernel_netlink_net_t *this,
/* send an update to all IKE_SAs */
if (update && event && changed)
{
- fire_roam_job(this, TRUE);
+ fire_roam_event(this, TRUE);
}
}
@@ -495,7 +507,7 @@ static void process_route(private_kernel_netlink_net_t *this, struct nlmsghdr *h
this->mutex->lock(this->mutex);
if (!get_vip_refcount(this, host))
{ /* ignore routes added for virtual IPs */
- fire_roam_job(this, FALSE);
+ fire_roam_event(this, FALSE);
}
this->mutex->unlock(this->mutex);
host->destroy(host);