kernel-pfkey: Prefer policies with reqid over those without
authorTobias Brunner <tobias@strongswan.org>
Mon, 4 Apr 2016 13:06:44 +0000 (15:06 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Sat, 9 Apr 2016 14:51:01 +0000 (16:51 +0200)
src/libcharon/plugins/kernel_pfkey/kernel_pfkey_ipsec.c

index 0e2e7df..7eb6c58 100644 (file)
@@ -2598,7 +2598,13 @@ METHOD(kernel_ipsec_t, add_policy, status_t,
        enumerator = policy->used_by->create_enumerator(policy->used_by);
        while (enumerator->enumerate(enumerator, (void**)&current_sa))
        {
-               if (current_sa->priority >= assigned_sa->priority)
+               if (current_sa->priority > assigned_sa->priority)
+               {
+                       break;
+               }
+               /* prefer SAs with a reqid over those without */
+               if (current_sa->priority == assigned_sa->priority &&
+                       (!current_sa->sa->cfg.reqid || assigned_sa->sa->cfg.reqid))
                {
                        break;
                }