kernel-interface: Raise mapping event with a proto/SPI/dst tuple
[strongswan.git] / src / libcharon / processing / jobs / inactivity_job.c
index 9ab69b4..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,16 +69,17 @@ 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, diff;
+                               time_t in, out, install, diff;
 
                                child_sa->get_usestats(child_sa, TRUE, &in, NULL, NULL);
                                child_sa->get_usestats(child_sa, FALSE, &out, NULL, NULL);
+                               install = child_sa->get_installtime(child_sa);
 
-                               diff = time_monotonic(NULL) - max(in, out);
+                               diff = time_monotonic(NULL) - max(max(in, out), install);
 
                                if (diff >= this->timeout)
                                {
@@ -135,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;
@@ -148,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,
        );