inactivity-job: Schedule job by CHILD_SA unique ID instead of reqid
authorMartin Willi <martin@revosec.ch>
Mon, 27 Oct 2014 14:19:09 +0000 (15:19 +0100)
committerMartin Willi <martin@revosec.ch>
Fri, 20 Feb 2015 12:34:51 +0000 (13:34 +0100)
src/libcharon/processing/jobs/inactivity_job.c
src/libcharon/processing/jobs/inactivity_job.h
src/libcharon/sa/ikev1/tasks/quick_mode.c
src/libcharon/sa/ikev2/tasks/child_create.c

index 1977339..f0f90ee 100644 (file)
@@ -30,9 +30,9 @@ struct private_inactivity_job_t {
        inactivity_job_t public;
 
        /**
-        * Reqid of CHILD_SA to check
+        * Unique CHILD_SA identifier to check
         */
-       u_int32_t reqid;
+       u_int32_t id;
 
        /**
         * Inactivity timeout
@@ -57,8 +57,8 @@ METHOD(job_t, execute, job_requeue_t,
        ike_sa_t *ike_sa;
        u_int32_t reschedule = 0;
 
-       ike_sa = charon->ike_sa_manager->checkout_by_id(charon->ike_sa_manager,
-                                                                                                       this->reqid, TRUE);
+       ike_sa = charon->child_sa_manager->checkout_by_id(charon->child_sa_manager,
+                                                                                                         this->id, NULL);
        if (ike_sa)
        {
                enumerator_t *enumerator;
@@ -69,9 +69,9 @@ METHOD(job_t, execute, job_requeue_t,
                status_t status = SUCCESS;
 
                enumerator = ike_sa->create_child_sa_enumerator(ike_sa);
-               while (enumerator->enumerate(enumerator, (void**)&child_sa))
+               while (enumerator->enumerate(enumerator, &child_sa))
                {
-                       if (child_sa->get_reqid(child_sa) == this->reqid)
+                       if (child_sa->get_unique_id(child_sa) == this->id)
                        {
                                time_t in, out, install, diff;
 
@@ -136,7 +136,7 @@ METHOD(job_t, get_priority, job_priority_t,
 /**
  * See header
  */
-inactivity_job_t *inactivity_job_create(u_int32_t reqid, u_int32_t timeout,
+inactivity_job_t *inactivity_job_create(u_int32_t unique_id, u_int32_t timeout,
                                                                                bool close_ike)
 {
        private_inactivity_job_t *this;
@@ -149,7 +149,7 @@ inactivity_job_t *inactivity_job_create(u_int32_t reqid, u_int32_t timeout,
                                .destroy = _destroy,
                        },
                },
-               .reqid = reqid,
+               .id = unique_id,
                .timeout = timeout,
                .close_ike = close_ike,
        );
index 890f770..ff19fe5 100644 (file)
@@ -42,12 +42,12 @@ struct inactivity_job_t {
 /**
  * Create a inactivity_job instance.
  *
- * @param reqid                reqid of CHILD_SA to check for inactivity
+ * @param unique_id    unique CHILD_SA identifier to check for inactivity
  * @param timeout      inactivity timeout in s
  * @param close_ike    close IKE_SA if the last remaining CHILD_SA is inactive?
  * @return                     inactivity checking job
  */
-inactivity_job_t *inactivity_job_create(u_int32_t reqid, u_int32_t timeout,
+inactivity_job_t *inactivity_job_create(u_int32_t unique_id, u_int32_t timeout,
                                                                                bool close_ike);
 
 #endif /** INACTIVITY_JOB_H_ @}*/
index 5fe04c0..8ca3ac7 100644 (file)
@@ -206,8 +206,8 @@ static void schedule_inactivity_timeout(private_quick_mode_t *this)
                close_ike = lib->settings->get_bool(lib->settings,
                                                                        "%s.inactivity_close_ike", FALSE, lib->ns);
                lib->scheduler->schedule_job(lib->scheduler, (job_t*)
-                               inactivity_job_create(this->child_sa->get_reqid(this->child_sa),
-                                                                         timeout, close_ike), timeout);
+                       inactivity_job_create(this->child_sa->get_unique_id(this->child_sa),
+                                                                 timeout, close_ike), timeout);
        }
 }
 
@@ -406,10 +406,7 @@ static bool install(private_quick_mode_t *this)
        {
                charon->bus->child_updown(charon->bus, this->child_sa, TRUE);
        }
-       if (!this->rekey)
-       {
-               schedule_inactivity_timeout(this);
-       }
+       schedule_inactivity_timeout(this);
        this->child_sa = NULL;
        return TRUE;
 }
index 5ec0537..abee0da 100644 (file)
@@ -296,7 +296,7 @@ static bool allocate_spi(private_child_create_t *this)
  */
 static void schedule_inactivity_timeout(private_child_create_t *this)
 {
-       u_int32_t timeout;
+       u_int32_t timeout, id;
        bool close_ike;
 
        timeout = this->config->get_inactivity(this->config);
@@ -304,9 +304,9 @@ static void schedule_inactivity_timeout(private_child_create_t *this)
        {
                close_ike = lib->settings->get_bool(lib->settings,
                                                                        "%s.inactivity_close_ike", FALSE, lib->ns);
+               id = this->child_sa->get_unique_id(this->child_sa);
                lib->scheduler->schedule_job(lib->scheduler, (job_t*)
-                               inactivity_job_create(this->child_sa->get_reqid(this->child_sa),
-                                                                         timeout, close_ike), timeout);
+                                               inactivity_job_create(id, timeout, close_ike), timeout);
        }
 }
 
@@ -693,10 +693,7 @@ static status_t select_and_install(private_child_create_t *this,
        this->ike_sa->add_child_sa(this->ike_sa, this->child_sa);
        this->established = TRUE;
 
-       if (!this->rekey)
-       {       /* a rekeyed SA uses the same reqid, no need for a new job */
-               schedule_inactivity_timeout(this);
-       }
+       schedule_inactivity_timeout(this);
 
        my_ts = linked_list_create_from_enumerator(
                                this->child_sa->create_ts_enumerator(this->child_sa, TRUE));