ikev2: Don't cache response to MID sync request
authorTobias Brunner <tobias@strongswan.org>
Mon, 19 Sep 2016 09:16:06 +0000 (11:16 +0200)
committerTobias Brunner <tobias@strongswan.org>
Wed, 8 Feb 2017 14:03:25 +0000 (15:03 +0100)
src/libcharon/sa/ikev2/task_manager_v2.c

index ede908c..debfe23 100644 (file)
@@ -818,7 +818,7 @@ static status_t build_response(private_task_manager_t *this, message_t *request)
        task_t *task;
        message_t *message;
        host_t *me, *other;
-       bool delete = FALSE, hook = FALSE;
+       bool delete = FALSE, hook = FALSE, mid_sync = FALSE;
        ike_sa_id_t *id = NULL;
        uint64_t responder_spi = 0;
        bool result;
@@ -837,6 +837,10 @@ static status_t build_response(private_task_manager_t *this, message_t *request)
        enumerator = array_create_enumerator(this->passive_tasks);
        while (enumerator->enumerate(enumerator, (void*)&task))
        {
+               if (task->get_type(task) == TASK_IKE_MID_SYNC)
+               {
+                       mid_sync = TRUE;
+               }
                switch (task->build(task, message))
                {
                        case SUCCESS:
@@ -909,6 +913,12 @@ static status_t build_response(private_task_manager_t *this, message_t *request)
                }
                return DESTROY_ME;
        }
+       else if (mid_sync)
+       {
+               /* we don't want to resend messages to sync MIDs if requests with the
+                * previous MID arrive */
+               clear_packets(this->responding.packets);
+       }
 
        array_compress(this->passive_tasks);