fixing IKE_SA rekeying if charon.ikesa_table_size > 1
authorTobias Brunner <tobias@strongswan.org>
Fri, 17 Apr 2009 16:58:11 +0000 (16:58 -0000)
committerTobias Brunner <tobias@strongswan.org>
Fri, 17 Apr 2009 16:58:11 +0000 (16:58 -0000)
src/charon/sa/ike_sa_manager.c
src/charon/sa/ike_sa_manager.h

index f9588c2..f6abb0c 100644 (file)
@@ -901,25 +901,35 @@ static ike_sa_t* checkout(private_ike_sa_manager_t *this, ike_sa_id_t *ike_sa_id
  */
 static ike_sa_t *checkout_new(private_ike_sa_manager_t* this, bool initiator)
 {
+       ike_sa_id_t *ike_sa_id;
+       ike_sa_t *ike_sa;
        entry_t *entry;
        u_int segment;
        
-       entry = entry_create();
        if (initiator)
        {
-               entry->ike_sa_id = ike_sa_id_create(get_next_spi(this), 0, TRUE);
+               ike_sa_id = ike_sa_id_create(get_next_spi(this), 0, TRUE);
        }
        else
        {
-               entry->ike_sa_id = ike_sa_id_create(0, get_next_spi(this), FALSE);
+               ike_sa_id = ike_sa_id_create(0, get_next_spi(this), FALSE);
+       }
+       ike_sa = ike_sa_create(ike_sa_id);
+       
+       DBG2(DBG_MGR, "created IKE_SA");
+       
+       if (!initiator)
+       {
+               ike_sa_id->destroy(ike_sa_id);
+               return ike_sa;
        }
-       entry->ike_sa = ike_sa_create(entry->ike_sa_id);
        
-       segment = put_entry(this, entry); 
+       entry = entry_create();
+       entry->ike_sa_id = ike_sa_id;
+       entry->ike_sa = ike_sa;
+       segment = put_entry(this, entry);
        entry->checked_out = TRUE;
        unlock_single_segment(this, segment);
-       
-       DBG2(DBG_MGR, "created IKE_SA");
        return entry->ike_sa;
 }
 
index d487a0a..84a3be8 100644 (file)
@@ -53,6 +53,9 @@ struct ike_sa_manager_t {
        
        /**
         * Create and check out a new IKE_SA.
+        * 
+        * @note If initiator equals FALSE, the returned IKE_SA is not registered
+        * in the manager.
         *
         * @param initiator                     TRUE for initiator, FALSE otherwise
         * @returns                             created and checked out IKE_SA