]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
quick-mode: Allow "aborting" task if it's currently active
authorTobias Brunner <tobias@strongswan.org>
Tue, 3 Sep 2024 14:09:54 +0000 (16:09 +0200)
committerTobias Brunner <tobias@strongswan.org>
Wed, 18 Sep 2024 09:53:17 +0000 (11:53 +0200)
Basically the same as the previous commit.

src/libcharon/sa/ikev1/tasks/quick_mode.c
src/libcharon/sa/ikev1/tasks/quick_mode.h

index 13163dd0f1772d973b46dee7daf92b05d0588220..3589241cce520dc922627d7e743b62c702651f5b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012-2019 Tobias Brunner
+ * Copyright (C) 2012-2024 Tobias Brunner
  * Copyright (C) 2011 Martin Willi
  *
  * Copyright (C) secunet Security Networks AG
@@ -164,6 +164,11 @@ struct private_quick_mode_t {
         */
        bool delete;
 
+       /**
+        * Whether the task was aborted
+        */
+       bool aborted;
+
        /**
         * Negotiated mode, tunnel or transport
         */
@@ -955,6 +960,13 @@ METHOD(task_t, build_i, status_t,
                }
                case QM_NEGOTIATED:
                {
+                       if (this->aborted)
+                       {
+                               this->ike_sa->queue_task(this->ike_sa,
+                               (task_t*)quick_delete_create(this->ike_sa,
+                                                               this->proposal->get_protocol(this->proposal),
+                                                               this->spi_i, TRUE, FALSE));
+                       }
                        return SUCCESS;
                }
                default:
@@ -1476,6 +1488,12 @@ METHOD(quick_mode_t, rekey, void,
        this->rekey = spi;
 }
 
+METHOD(quick_mode_t, abort_, void,
+       private_quick_mode_t *this)
+{
+       this->aborted = TRUE;
+}
+
 METHOD(task_t, migrate, void,
        private_quick_mode_t *this, ike_sa_t *ike_sa)
 {
@@ -1545,6 +1563,7 @@ quick_mode_t *quick_mode_create(ike_sa_t *ike_sa, child_cfg_t *config,
                        .use_marks = _use_marks,
                        .use_if_ids = _use_if_ids,
                        .rekey = _rekey,
+                       .abort = _abort_,
                },
                .ike_sa = ike_sa,
                .initiator = config != NULL,
index 23efd341101872d20dea27716f831a36aa28df05..85e986dc6122c19f8c303aecfc733ce59efe063b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015-2019 Tobias Brunner
+ * Copyright (C) 2015-2024 Tobias Brunner
  * Copyright (C) 2011 Martin Willi
  *
  * Copyright (C) secunet Security Networks AG
@@ -87,6 +87,12 @@ struct quick_mode_t {
         * @param spi                   spi of SA to rekey
         */
        void (*rekey)(quick_mode_t *this, uint32_t spi);
+
+       /**
+        * Mark this active task as being aborted, i.e. cause a deletion of the
+        * created CHILD_SA immediately after its successful creation.
+        */
+       void (*abort)(quick_mode_t *this);
 };
 
 /**