From 961763b84d4d9001216096ab0aa6a1234ecc0988 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Tue, 3 Sep 2024 16:09:54 +0200 Subject: [PATCH] quick-mode: Allow "aborting" task if it's currently active Basically the same as the previous commit. --- src/libcharon/sa/ikev1/tasks/quick_mode.c | 21 ++++++++++++++++++++- src/libcharon/sa/ikev1/tasks/quick_mode.h | 8 +++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/libcharon/sa/ikev1/tasks/quick_mode.c b/src/libcharon/sa/ikev1/tasks/quick_mode.c index 13163dd0f1..3589241cce 100644 --- a/src/libcharon/sa/ikev1/tasks/quick_mode.c +++ b/src/libcharon/sa/ikev1/tasks/quick_mode.c @@ -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, diff --git a/src/libcharon/sa/ikev1/tasks/quick_mode.h b/src/libcharon/sa/ikev1/tasks/quick_mode.h index 23efd34110..85e986dc61 100644 --- a/src/libcharon/sa/ikev1/tasks/quick_mode.h +++ b/src/libcharon/sa/ikev1/tasks/quick_mode.h @@ -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); }; /**