Added a quick_delete task flag to enforce delete, even if CHILD_SA not found
authorMartin Willi <martin@revosec.ch>
Thu, 15 Dec 2011 17:03:14 +0000 (18:03 +0100)
committerMartin Willi <martin@revosec.ch>
Tue, 20 Mar 2012 16:31:24 +0000 (17:31 +0100)
src/libcharon/sa/ike_sa.c
src/libcharon/sa/tasks/informational.c
src/libcharon/sa/tasks/quick_delete.c
src/libcharon/sa/tasks/quick_delete.h

index 223901c..cb560cd 100644 (file)
@@ -1354,7 +1354,7 @@ METHOD(ike_sa_t, delete_child_sa, status_t,
 
        if (this->version == IKEV1)
        {
-               task = (task_t*)quick_delete_create(&this->public, protocol, spi);
+               task = (task_t*)quick_delete_create(&this->public, protocol, spi, FALSE);
        }
        else
        {
index f0ddad0..60e1cfc 100644 (file)
@@ -105,7 +105,7 @@ METHOD(task_t, process_r, status_t,
                                        else
                                        {
                                                this->del = (task_t*)quick_delete_create(this->ike_sa,
-                                                                                                                                PROTO_NONE, 0);
+                                                                                                               PROTO_NONE, 0, FALSE);
                                        }
                                }
                                break;
index 61fa2ef..a5f27c5 100644 (file)
@@ -49,6 +49,11 @@ struct private_quick_delete_t {
         * Inbound SPI of CHILD_SA to delete
         */
        u_int32_t spi;
+
+       /**
+        * Send delete even if SA does not exist
+        */
+       bool force;
 };
 
 /**
@@ -96,7 +101,7 @@ static bool delete_child(private_quick_delete_t *this,
 METHOD(task_t, build_i, status_t,
        private_quick_delete_t *this, message_t *message)
 {
-       if (delete_child(this, this->protocol, this->spi))
+       if (delete_child(this, this->protocol, this->spi) || this->force)
        {
                delete_payload_t *delete_payload;
 
@@ -185,7 +190,7 @@ METHOD(task_t, destroy, void,
  * Described in header.
  */
 quick_delete_t *quick_delete_create(ike_sa_t *ike_sa, protocol_id_t protocol,
-                                                                       u_int32_t spi)
+                                                                       u_int32_t spi, bool force)
 {
        private_quick_delete_t *this;
 
@@ -200,6 +205,7 @@ quick_delete_t *quick_delete_create(ike_sa_t *ike_sa, protocol_id_t protocol,
                .ike_sa = ike_sa,
                .protocol = protocol,
                .spi = spi,
+               .force = force,
        );
 
        if (protocol != PROTO_NONE)
index a0dbd0b..80aae82 100644 (file)
@@ -45,9 +45,10 @@ struct quick_delete_t {
  * @param ike_sa               IKE_SA this task works for
  * @param protocol             protocol of CHILD_SA to delete, PROTO_NONE as responder
  * @param spi                  inbound SPI of CHILD_SA to delete
+ * @param force                        send delete even if SA does not exist
  * @return                             quick_delete task to handle by the task_manager
  */
 quick_delete_t *quick_delete_create(ike_sa_t *ike_sa, protocol_id_t protocol,
-                                                                       u_int32_t spi);
+                                                                       u_int32_t spi, bool force);
 
 #endif /** QUICK_DELETE_H_ @}*/