Moved migrate job creation to kernel event handler.
authorTobias Brunner <tobias@strongswan.org>
Tue, 6 Jul 2010 10:46:40 +0000 (12:46 +0200)
committerTobias Brunner <tobias@strongswan.org>
Thu, 2 Sep 2010 17:01:24 +0000 (19:01 +0200)
src/libcharon/kernel/kernel_handler.c
src/libcharon/plugins/kernel_netlink/kernel_netlink_ipsec.c
src/libcharon/plugins/kernel_pfkey/kernel_pfkey_ipsec.c

index b4fe1ef..4fae6cd 100644 (file)
@@ -18,8 +18,9 @@
 #include <hydra.h>
 #include <daemon.h>
 #include <processing/jobs/acquire_job.h>
-#include <processing/jobs/rekey_child_sa_job.h>
 #include <processing/jobs/delete_child_sa_job.h>
+#include <processing/jobs/migrate_job.h>
+#include <processing/jobs/rekey_child_sa_job.h>
 #include <processing/jobs/update_sa_job.h>
 
 typedef struct private_kernel_handler_t private_kernel_handler_t;
@@ -87,6 +88,21 @@ METHOD(kernel_listener_t, mapping, bool,
        return TRUE;
 }
 
+METHOD(kernel_listener_t, migrate, bool,
+          private_kernel_handler_t *this, u_int32_t reqid,
+          traffic_selector_t *src_ts, traffic_selector_t *dst_ts,
+          policy_dir_t direction, host_t *local, host_t *remote)
+{
+       job_t *job;
+       DBG1(DBG_KNL, "creating migrate job for policy %R === %R %N with "
+                                 "reqid {%u}", src_ts, dst_ts, policy_dir_names, direction,
+                                 reqid, local);
+       job = (job_t*)migrate_job_create(reqid, src_ts, dst_ts, direction, local,
+                                                                        remote);
+       hydra->processor->queue_job(hydra->processor, job);
+       return TRUE;
+}
+
 METHOD(kernel_handler_t, destroy, void,
           private_kernel_handler_t *this)
 {
@@ -105,6 +121,7 @@ kernel_handler_t *kernel_handler_create()
                                .acquire = _acquire,
                                .expire = _expire,
                                .mapping = _mapping,
+                               .migrate = _migrate,
                        },
                        .destroy = _destroy,
                },
index 8d4d2c9..6d971bd 100644 (file)
@@ -41,7 +41,6 @@
 #include <threading/mutex.h>
 #include <utils/hashtable.h>
 #include <processing/jobs/callback_job.h>
-#include <processing/jobs/migrate_job.h>
 
 /** required for Linux 2.6.26 kernel and later */
 #ifndef XFRM_STATE_AF_UNSPEC
@@ -632,7 +631,6 @@ static void process_migrate(private_kernel_netlink_ipsec_t *this, struct nlmsghd
        size_t rtasize;
        u_int32_t reqid = 0;
        policy_dir_t dir;
-       job_t *job;
 
        policy_id = (struct xfrm_userpolicy_id*)NLMSG_DATA(hdr);
        rta     = XFRM_RTA(hdr, struct xfrm_userpolicy_id);
@@ -683,11 +681,8 @@ static void process_migrate(private_kernel_netlink_ipsec_t *this, struct nlmsghd
 
        if (src_ts && dst_ts && local && remote)
        {
-               DBG1(DBG_KNL, "creating migrate job for policy %R === %R %N with reqid {%u}",
-                                          src_ts, dst_ts, policy_dir_names, dir, reqid, local);
-               job = (job_t*)migrate_job_create(reqid, src_ts, dst_ts, dir,
-                                                                                local, remote);
-               hydra->processor->queue_job(hydra->processor, job);
+               charon->kernel_interface->migrate(charon->kernel_interface, reqid,
+                                                                                 src_ts, dst_ts, dir, local, remote);
        }
        else
        {
index 28cc980..91e46cb 100644 (file)
@@ -60,7 +60,6 @@
 #include <threading/thread.h>
 #include <threading/mutex.h>
 #include <processing/jobs/callback_job.h>
-#include <processing/jobs/migrate_job.h>
 
 /** non linux specific */
 #ifndef IPPROTO_COMP
@@ -982,7 +981,6 @@ static void process_migrate(private_kernel_pfkey_ipsec_t *this, struct sadb_msg*
        policy_dir_t dir;
        u_int32_t reqid = 0;
        host_t *local = NULL, *remote = NULL;
-       job_t *job;
 
        DBG2(DBG_KNL, "received an SADB_X_MIGRATE");
 
@@ -1014,11 +1012,8 @@ static void process_migrate(private_kernel_pfkey_ipsec_t *this, struct sadb_msg*
 
        if (src_ts && dst_ts && local && remote)
        {
-               DBG1(DBG_KNL, "creating migrate job for policy %R === %R %N with reqid {%u}",
-                                          src_ts, dst_ts, policy_dir_names, dir, reqid, local);
-               job = (job_t*)migrate_job_create(reqid, src_ts, dst_ts, dir,
-                                                                                local, remote);
-               hydra->processor->queue_job(hydra->processor, job);
+               charon->kernel_interface->migrate(charon->kernel_interface, reqid,
+                                                                                 src_ts, dst_ts, dir, local, remote);
        }
        else
        {