]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
load-tester: Fix race condition issuing same identity
authorChristophe Gouault <christophe.gouault@6wind.com>
Tue, 8 Apr 2014 15:11:13 +0000 (17:11 +0200)
committerTobias Brunner <tobias@strongswan.org>
Thu, 24 Apr 2014 15:54:15 +0000 (17:54 +0200)
Due to an unprotected incrementation, two load-tester initiators occasionally
use the same identifier under high load. The responder typically drops one of
the connections.

Use an atomic incrementation to avoid this race condition.

Signed-off-by: Christophe Gouault <christophe.gouault@6wind.com>
src/libcharon/plugins/load_tester/load_tester_config.c

index e133190b47c7fa2b25fc3c32fa1f0aabc871f346..bc7c0ffbc259473eecb3cf425ba503557f99457c 100644 (file)
@@ -150,7 +150,7 @@ struct private_load_tester_config_t {
        /**
         * incremental numbering of generated configs
         */
-       u_int num;
+       refcount_t num;
 
        /**
         * Dynamic source port, if used
@@ -802,7 +802,7 @@ METHOD(backend_t, get_peer_cfg_by_name, peer_cfg_t*,
 {
        if (streq(name, "load-test"))
        {
-               return generate_config(this, this->num++);
+               return generate_config(this, (u_int)ref_get(&this->num));
        }
        return NULL;
 }