ike: Apply retransmission_limit before applying the jitter
authorTobias Brunner <tobias@strongswan.org>
Fri, 26 May 2017 16:16:40 +0000 (18:16 +0200)
committerTobias Brunner <tobias@strongswan.org>
Fri, 26 May 2017 16:16:40 +0000 (18:16 +0200)
src/libcharon/sa/ikev1/task_manager_v1.c
src/libcharon/sa/ikev2/task_manager_v2.c

index 89077b0..48ec3e7 100644 (file)
@@ -366,15 +366,15 @@ static status_t retransmit_packet(private_task_manager_t *this, uint32_t seqnr,
        }
        t = (uint32_t)(this->retransmit_timeout * 1000.0 *
                                        pow(this->retransmit_base, retransmitted));
+       if (this->retransmit_limit)
+       {
+               t = min(t, this->retransmit_limit);
+       }
        if (this->retransmit_jitter)
        {
                max_jitter = (t / 100.0) * this->retransmit_jitter;
                t -= max_jitter * (random() / (RAND_MAX + 1.0));
        }
-       if (this->retransmit_limit)
-       {
-               t = min(t, this->retransmit_limit);
-       }
        if (retransmitted)
        {
                DBG1(DBG_IKE, "sending retransmit %u of %s message ID %u, seq %u",
index d215596..c2ddbc5 100644 (file)
@@ -362,15 +362,15 @@ METHOD(task_manager_t, retransmit, status_t,
                                timeout = (uint32_t)(this->retransmit_timeout * 1000.0 *
                                        pow(this->retransmit_base, this->initiating.retransmitted));
 
+                               if (this->retransmit_limit)
+                               {
+                                       timeout = min(timeout, this->retransmit_limit);
+                               }
                                if (this->retransmit_jitter)
                                {
                                        max_jitter = (timeout / 100.0) * this->retransmit_jitter;
                                        timeout -= max_jitter * (random() / (RAND_MAX + 1.0));
                                }
-                               if (this->retransmit_limit)
-                               {
-                                       timeout = min(timeout, this->retransmit_limit);
-                               }
                        }
                        else
                        {