Use ref_get() to make sure CHILD_SA reqids are unique
authorMartin Willi <martin@revosec.ch>
Wed, 8 May 2013 13:18:50 +0000 (15:18 +0200)
committerMartin Willi <martin@revosec.ch>
Tue, 11 Jun 2013 13:54:27 +0000 (15:54 +0200)
src/libcharon/sa/child_sa.c

index 34435a1..a14b039 100644 (file)
@@ -1083,7 +1083,7 @@ METHOD(child_sa_t, destroy, void,
 child_sa_t * child_sa_create(host_t *me, host_t* other,
                                                         child_cfg_t *config, u_int32_t rekey, bool encap)
 {
-       static u_int32_t reqid = 0;
+       static refcount_t reqid = 0;
        private_child_sa_t *this;
 
        INIT(this,
@@ -1142,7 +1142,14 @@ child_sa_t * child_sa_create(host_t *me, host_t* other,
        if (!this->reqid)
        {
                /* reuse old reqid if we are rekeying an existing CHILD_SA */
-               this->reqid = rekey ? rekey : ++reqid;
+               if (rekey)
+               {
+                       this->reqid = rekey;
+               }
+               else
+               {
+                       this->reqid = ref_get(&reqid);
+               }
        }
 
        if (this->mark_in.value == MARK_REQID)