]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
kernel-interface: Remove unnecessary parameters for release_reqid()
authorTobias Brunner <tobias@strongswan.org>
Mon, 2 Oct 2023 12:08:56 +0000 (14:08 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 13 Nov 2023 11:02:11 +0000 (12:02 +0100)
These are not included in the initial lookup anymore. Also simplified
the implementation as we always add the same entry to the two hash
tables.

src/libcharon/kernel/kernel_interface.c
src/libcharon/kernel/kernel_interface.h
src/libcharon/sa/child_sa.c

index d4a7286efdac4928e8aedfda7a099cf376a2f3f2..844af7060cf4e58b43ca2ede6dfc085a07994fe4 100644 (file)
@@ -434,45 +434,24 @@ METHOD(kernel_interface_t, alloc_reqid, status_t,
 }
 
 METHOD(kernel_interface_t, release_reqid, status_t,
-       private_kernel_interface_t *this, uint32_t reqid,
-       mark_t mark_in, mark_t mark_out, uint32_t if_id_in, uint32_t if_id_out,
-       sec_label_t *label)
+       private_kernel_interface_t *this, uint32_t reqid)
 {
        reqid_entry_t *entry, tmpl = {
                .reqid = reqid,
-               .mark_in = mark_in,
-               .mark_out = mark_out,
-               .if_id_in = if_id_in,
-               .if_id_out = if_id_out,
-               .label = label,
        };
 
        this->mutex->lock(this->mutex);
-       entry = this->reqids->remove(this->reqids, &tmpl);
-       if (entry)
+       entry = this->reqids->get(this->reqids, &tmpl);
+       if (entry && --entry->refs == 0)
        {
-               if (--entry->refs == 0)
-               {
-                       array_insert_create_value(&this->released_reqids, sizeof(uint32_t),
-                                                                         ARRAY_TAIL, &entry->reqid);
-                       entry = this->reqids_by_ts->remove(this->reqids_by_ts, entry);
-                       if (entry)
-                       {
-                               reqid_entry_destroy(entry);
-                       }
-               }
-               else
-               {
-                       this->reqids->put(this->reqids, entry, entry);
-               }
+               array_insert_create_value(&this->released_reqids, sizeof(uint32_t),
+                                                                 ARRAY_TAIL, &entry->reqid);
+               this->reqids->remove(this->reqids, entry);
+               this->reqids_by_ts->remove(this->reqids_by_ts, entry);
+               reqid_entry_destroy(entry);
        }
        this->mutex->unlock(this->mutex);
-
-       if (entry)
-       {
-               return SUCCESS;
-       }
-       return NOT_FOUND;
+       return entry ? SUCCESS : NOT_FOUND;
 }
 
 METHOD(kernel_interface_t, add_sa, status_t,
index 2bc9d86572a89300b8d2c27464bd410d1a747a8e..9f8e9b7144c8bb098e1fe86cb5225a874fc27cdd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2016 Tobias Brunner
+ * Copyright (C) 2006-2023 Tobias Brunner
  * Copyright (C) 2006 Daniel Roethlisberger
  * Copyright (C) 2005-2006 Martin Willi
  * Copyright (C) 2005 Jan Hutter
@@ -162,17 +162,9 @@ struct kernel_interface_t {
         * Release a previously allocated reqid.
         *
         * @param reqid         reqid to release
-        * @param mark_in       inbound mark on SA
-        * @param mark_out      outbound mark on SA
-        * @param if_id_in      inbound interface ID on SA
-        * @param if_id_out     outbound interface ID on SA
-        * @param label         security label (usually the one on the policy, not SA)
         * @return                      SUCCESS if reqid released
         */
-       status_t (*release_reqid)(kernel_interface_t *this, uint32_t reqid,
-                                                         mark_t mark_in, mark_t mark_out,
-                                                         uint32_t if_id_in, uint32_t if_id_out,
-                                                         sec_label_t *label);
+       status_t (*release_reqid)(kernel_interface_t *this, uint32_t reqid);
 
        /**
         * Add an SA to the SAD.
index d76d7aebcbec7984348617b93d3214f1064de39a..e23accf0efd6e71ecfef94406e7bb6dd72bfd84a 100644 (file)
@@ -1810,9 +1810,7 @@ METHOD(child_sa_t, update, status_t,
                {
                        if (new_reqid &&
                                charon->kernel->release_reqid(charon->kernel,
-                                               new_reqid, this->mark_in, this->mark_out,
-                                               this->if_id_in, this->if_id_out,
-                                               label_for(this, LABEL_USE_REQID)) != SUCCESS)
+                                                                                         new_reqid) != SUCCESS)
                        {
                                DBG1(DBG_CHD, "releasing reqid %u failed", new_reqid);
                        }
@@ -1827,9 +1825,7 @@ METHOD(child_sa_t, update, status_t,
                if (new_reqid)
                {
                        if (charon->kernel->release_reqid(charon->kernel,
-                                               this->reqid, this->mark_in, this->mark_out,
-                                               this->if_id_in, this->if_id_out,
-                                               label_for(this, LABEL_USE_REQID)) != SUCCESS)
+                                                                                         this->reqid) != SUCCESS)
                        {
                                DBG1(DBG_CHD, "releasing reqid %u failed", this->reqid);
                        }
@@ -1950,9 +1946,7 @@ METHOD(child_sa_t, destroy, void,
        if (this->reqid_allocated)
        {
                if (charon->kernel->release_reqid(charon->kernel,
-                                               this->reqid, this->mark_in, this->mark_out,
-                                               this->if_id_in, this->if_id_out,
-                                               label_for(this, LABEL_USE_REQID)) != SUCCESS)
+                                                                                 this->reqid) != SUCCESS)
                {
                        DBG1(DBG_CHD, "releasing reqid %u failed", this->reqid);
                }