ike-sa-manager: Rename checkout_new() to create_new()
authorTobias Brunner <tobias@strongswan.org>
Fri, 15 Jan 2021 15:08:20 +0000 (16:08 +0100)
committerTobias Brunner <tobias@strongswan.org>
Fri, 12 Feb 2021 14:49:08 +0000 (15:49 +0100)
We don't actually check that SA out (i.e. it's not registered with the
manager).  That was originally different but had to be changed with
86993d6b9037 to avoid that SAs created for rekeying don't block other
threads on the manager.

src/libcharon/sa/ike_sa.c
src/libcharon/sa/ike_sa_manager.c
src/libcharon/sa/ike_sa_manager.h
src/libcharon/sa/ikev1/task_manager_v1.c
src/libcharon/sa/ikev2/task_manager_v2.c
src/libcharon/sa/ikev2/tasks/ike_rekey.c
src/libcharon/sa/trap_manager.c
src/libcharon/tests/utils/exchange_test_helper.c

index 24fb4cd..99c1116 100644 (file)
@@ -2186,8 +2186,8 @@ METHOD(ike_sa_t, reestablish, status_t,
                return FAILED;
        }
 
                return FAILED;
        }
 
-       new = charon->ike_sa_manager->checkout_new(charon->ike_sa_manager,
-                                                                                          this->version, TRUE);
+       new = charon->ike_sa_manager->create_new(charon->ike_sa_manager,
+                                                                                        this->version, TRUE);
        if (!new)
        {
                return FAILED;
        if (!new)
        {
                return FAILED;
@@ -2270,8 +2270,8 @@ static bool redirect_established(private_ike_sa_t *this, identification_t *to)
        host_t *other;
        time_t redirect;
 
        host_t *other;
        time_t redirect;
 
-       new = charon->ike_sa_manager->checkout_new(charon->ike_sa_manager,
-                                                                                          this->version, TRUE);
+       new = charon->ike_sa_manager->create_new(charon->ike_sa_manager,
+                                                                                        this->version, TRUE);
        if (!new)
        {
                return FALSE;
        if (!new)
        {
                return FALSE;
index 2a72794..b7df1d8 100644 (file)
@@ -1241,7 +1241,7 @@ METHOD(ike_sa_manager_t, checkout, ike_sa_t*,
        return ike_sa;
 }
 
        return ike_sa;
 }
 
-METHOD(ike_sa_manager_t, checkout_new, ike_sa_t*,
+METHOD(ike_sa_manager_t, create_new, ike_sa_t*,
        private_ike_sa_manager_t* this, ike_version_t version, bool initiator)
 {
        ike_sa_id_t *ike_sa_id;
        private_ike_sa_manager_t* this, ike_version_t version, bool initiator)
 {
        ike_sa_id_t *ike_sa_id;
@@ -1489,7 +1489,7 @@ METHOD(ike_sa_manager_t, checkout_by_config, ike_sa_t*,
 
        if (!this->reuse_ikesa && peer_cfg->get_ike_version(peer_cfg) != IKEV1)
        {       /* IKE_SA reuse disabled by config (not possible for IKEv1) */
 
        if (!this->reuse_ikesa && peer_cfg->get_ike_version(peer_cfg) != IKEV1)
        {       /* IKE_SA reuse disabled by config (not possible for IKEv1) */
-               ike_sa = checkout_new(this, peer_cfg->get_ike_version(peer_cfg), TRUE);
+               ike_sa = create_new(this, peer_cfg->get_ike_version(peer_cfg), TRUE);
                ike_sa->set_peer_cfg(ike_sa, peer_cfg);
 
                segment = create_and_put_entry(this, ike_sa, &entry);
                ike_sa->set_peer_cfg(ike_sa, peer_cfg);
 
                segment = create_and_put_entry(this, ike_sa, &entry);
@@ -1564,7 +1564,7 @@ METHOD(ike_sa_manager_t, checkout_by_config, ike_sa_t*,
 
        if (!ike_sa)
        {
 
        if (!ike_sa)
        {
-               ike_sa = checkout_new(this, peer_cfg->get_ike_version(peer_cfg), TRUE);
+               ike_sa = create_new(this, peer_cfg->get_ike_version(peer_cfg), TRUE);
                ike_sa->set_peer_cfg(ike_sa, peer_cfg);
 
                segment = create_and_put_entry(this, ike_sa, &entry);
                ike_sa->set_peer_cfg(ike_sa, peer_cfg);
 
                segment = create_and_put_entry(this, ike_sa, &entry);
@@ -2467,8 +2467,8 @@ ike_sa_manager_t *ike_sa_manager_create()
 
        INIT(this,
                .public = {
 
        INIT(this,
                .public = {
+                       .create_new = _create_new,
                        .checkout = _checkout,
                        .checkout = _checkout,
-                       .checkout_new = _checkout_new,
                        .checkout_by_message = _checkout_by_message,
                        .checkout_by_config = _checkout_by_config,
                        .checkout_by_id = _checkout_by_id,
                        .checkout_by_message = _checkout_by_message,
                        .checkout_by_config = _checkout_by_config,
                        .checkout_by_id = _checkout_by_id,
index 58cde4d..5695c94 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2008-2017 Tobias Brunner
+ * Copyright (C) 2008-2021 Tobias Brunner
  * Copyright (C) 2005-2008 Martin Willi
  * Copyright (C) 2005 Jan Hutter
  * HSR Hochschule fuer Technik Rapperswil
  * Copyright (C) 2005-2008 Martin Willi
  * Copyright (C) 2005 Jan Hutter
  * HSR Hochschule fuer Technik Rapperswil
@@ -50,6 +50,16 @@ typedef uint64_t (*spi_cb_t)(void *data);
 struct ike_sa_manager_t {
 
        /**
 struct ike_sa_manager_t {
 
        /**
+        * Create a new IKE_SA.
+        *
+        * @param version                       IKE version of this SA
+        * @param initiator                     TRUE for initiator, FALSE otherwise
+        * @returns                             created IKE_SA (not registered/checked out)
+        */
+       ike_sa_t *(*create_new)(ike_sa_manager_t* this, ike_version_t version,
+                                                       bool initiator);
+
+       /**
         * Checkout an existing IKE_SA.
         *
         * @param ike_sa_id                     the SA identifier, will be updated
         * Checkout an existing IKE_SA.
         *
         * @param ike_sa_id                     the SA identifier, will be updated
@@ -60,16 +70,6 @@ struct ike_sa_manager_t {
        ike_sa_t* (*checkout) (ike_sa_manager_t* this, ike_sa_id_t *sa_id);
 
        /**
        ike_sa_t* (*checkout) (ike_sa_manager_t* this, ike_sa_id_t *sa_id);
 
        /**
-        * Create and check out a new IKE_SA.
-        *
-        * @param version                       IKE version of this SA
-        * @param initiator                     TRUE for initiator, FALSE otherwise
-        * @returns                             created and checked out IKE_SA
-        */
-       ike_sa_t* (*checkout_new) (ike_sa_manager_t* this, ike_version_t version,
-                                                          bool initiator);
-
-       /**
         * Checkout an IKE_SA by a message.
         *
         * In some situations, it is necessary that the manager knows the
         * Checkout an IKE_SA by a message.
         *
         * In some situations, it is necessary that the manager knows the
index f49a8eb..d3089a6 100644 (file)
@@ -1636,7 +1636,7 @@ METHOD(task_manager_t, queue_ike_reauth, void,
        ike_sa_t *new;
        host_t *host;
 
        ike_sa_t *new;
        host_t *host;
 
-       new = charon->ike_sa_manager->checkout_new(charon->ike_sa_manager,
+       new = charon->ike_sa_manager->create_new(charon->ike_sa_manager,
                                                                this->ike_sa->get_version(this->ike_sa), TRUE);
        if (!new)
        {       /* shouldn't happen */
                                                                this->ike_sa->get_version(this->ike_sa), TRUE);
        if (!new)
        {       /* shouldn't happen */
index 9a3c1ca..f45d074 100644 (file)
@@ -1905,7 +1905,7 @@ static void trigger_mbb_reauth(private_task_manager_t *this)
        queued_task_t *queued;
        bool children = FALSE;
 
        queued_task_t *queued;
        bool children = FALSE;
 
-       new = charon->ike_sa_manager->checkout_new(charon->ike_sa_manager,
+       new = charon->ike_sa_manager->create_new(charon->ike_sa_manager,
                                                                this->ike_sa->get_version(this->ike_sa), TRUE);
        if (!new)
        {       /* shouldn't happen */
                                                                this->ike_sa->get_version(this->ike_sa), TRUE);
        if (!new)
        {       /* shouldn't happen */
index 57f9a79..83af67b 100644 (file)
@@ -167,7 +167,7 @@ METHOD(task_t, build_i, status_t,
        if (this->new_sa == NULL)
        {
                version = this->ike_sa->get_version(this->ike_sa);
        if (this->new_sa == NULL)
        {
                version = this->ike_sa->get_version(this->ike_sa);
-               this->new_sa = charon->ike_sa_manager->checkout_new(
+               this->new_sa = charon->ike_sa_manager->create_new(
                                                                                charon->ike_sa_manager, version, TRUE);
                if (!this->new_sa)
                {       /* shouldn't happen */
                                                                                charon->ike_sa_manager, version, TRUE);
                if (!this->new_sa)
                {       /* shouldn't happen */
@@ -236,7 +236,7 @@ METHOD(task_t, process_r, status_t,
                return NEED_MORE;
        }
 
                return NEED_MORE;
        }
 
-       this->new_sa = charon->ike_sa_manager->checkout_new(charon->ike_sa_manager,
+       this->new_sa = charon->ike_sa_manager->create_new(charon->ike_sa_manager,
                                                        this->ike_sa->get_version(this->ike_sa), FALSE);
        if (!this->new_sa)
        {       /* shouldn't happen */
                                                        this->ike_sa->get_version(this->ike_sa), FALSE);
        if (!this->new_sa)
        {       /* shouldn't happen */
index 49ad136..f9f78ac 100644 (file)
@@ -509,7 +509,7 @@ METHOD(trap_manager_t, acquire, void,
 
        if (wildcard)
        {       /* the peer config would match IKE_SAs with other peers */
 
        if (wildcard)
        {       /* the peer config would match IKE_SAs with other peers */
-               ike_sa = charon->ike_sa_manager->checkout_new(charon->ike_sa_manager,
+               ike_sa = charon->ike_sa_manager->create_new(charon->ike_sa_manager,
                                                                                        peer->get_ike_version(peer), TRUE);
                if (ike_sa)
                {
                                                                                        peer->get_ike_version(peer), TRUE);
                if (ike_sa)
                {
index 97fa6fe..be55a13 100644 (file)
@@ -237,11 +237,11 @@ METHOD(exchange_test_helper_t, create_sa, child_cfg_t*,
        peer_cfg_t *peer_cfg;
        child_cfg_t *child_cfg;
 
        peer_cfg_t *peer_cfg;
        child_cfg_t *child_cfg;
 
-       *init = charon->ike_sa_manager->checkout_new(charon->ike_sa_manager,
-                                                                                                IKEV2, TRUE);
+       *init = charon->ike_sa_manager->create_new(charon->ike_sa_manager,
+                                                                                          IKEV2, TRUE);
 
 
-       *resp = charon->ike_sa_manager->checkout_new(charon->ike_sa_manager,
-                                                                                                IKEV2, FALSE);
+       *resp = charon->ike_sa_manager->create_new(charon->ike_sa_manager,
+                                                                                          IKEV2, FALSE);
 
        peer_cfg = create_peer_cfg(FALSE, conf);
        child_cfg = create_child_cfg(FALSE, conf);
 
        peer_cfg = create_peer_cfg(FALSE, conf);
        child_cfg = create_child_cfg(FALSE, conf);