kernel-interface: Raise mapping event with a proto/SPI/dst tuple
[strongswan.git] / src / libcharon / processing / jobs / delete_child_sa_job.c
index ac1dfd6..0d85883 100644 (file)
@@ -31,11 +31,6 @@ struct private_delete_child_sa_job_t {
        delete_child_sa_job_t public;
 
        /**
-        * reqid of the CHILD_SA
-        */
-       u_int32_t reqid;
-
-       /**
         * protocol of the CHILD_SA (ESP/AH)
         */
        protocol_id_t protocol;
@@ -46,6 +41,11 @@ struct private_delete_child_sa_job_t {
        u_int32_t spi;
 
        /**
+        * SA destination address
+        */
+       host_t *dst;
+
+       /**
         * Delete for an expired CHILD_SA
         */
        bool expired;
@@ -54,20 +54,21 @@ struct private_delete_child_sa_job_t {
 METHOD(job_t, destroy, void,
        private_delete_child_sa_job_t *this)
 {
+       this->dst->destroy(this->dst);
        free(this);
 }
 
-METHOD(job_t, execute, void,
+METHOD(job_t, execute, job_requeue_t,
        private_delete_child_sa_job_t *this)
 {
        ike_sa_t *ike_sa;
 
-       ike_sa = charon->ike_sa_manager->checkout_by_id(charon->ike_sa_manager,
-                                                                                                       this->reqid, TRUE);
+       ike_sa = charon->child_sa_manager->checkout(charon->child_sa_manager,
+                                                                       this->protocol, this->spi, this->dst, NULL);
        if (ike_sa == NULL)
        {
-               DBG1(DBG_JOB, "CHILD_SA with reqid %d not found for delete",
-                        this->reqid);
+               DBG1(DBG_JOB, "CHILD_SA %N/0x%08x/%H not found for delete",
+                        protocol_id_names, this->protocol, htonl(this->spi), this->dst);
        }
        else
        {
@@ -75,7 +76,7 @@ METHOD(job_t, execute, void,
 
                charon->ike_sa_manager->checkin(charon->ike_sa_manager, ike_sa);
        }
-       destroy(this);
+       return JOB_REQUEUE_NONE;
 }
 
 METHOD(job_t, get_priority, job_priority_t,
@@ -87,8 +88,8 @@ METHOD(job_t, get_priority, job_priority_t,
 /*
  * Described in header
  */
-delete_child_sa_job_t *delete_child_sa_job_create(u_int32_t reqid,
-                                                       protocol_id_t protocol, u_int32_t spi, bool expired)
+delete_child_sa_job_t *delete_child_sa_job_create(protocol_id_t protocol,
+                                                                       u_int32_t spi, host_t *dst, bool expired)
 {
        private_delete_child_sa_job_t *this;
 
@@ -100,12 +101,11 @@ delete_child_sa_job_t *delete_child_sa_job_create(u_int32_t reqid,
                                .destroy = _destroy,
                        },
                },
-               .reqid = reqid,
                .protocol = protocol,
                .spi = spi,
+               .dst = dst->clone(dst),
                .expired = expired,
        );
 
        return &this->public;
 }
-