summaryrefslogtreecommitdiff
path: root/lib/conntrack.c
diff options
context:
space:
mode:
authorGaetan Rivet <grive@u256.net>2021-06-16 01:22:46 +0200
committerIlya Maximets <i.maximets@ovn.org>2021-07-09 22:23:59 +0200
commitb889d5dcc81ff7103e49429a9beb3f8b0ddf62d5 (patch)
tree980f56b188ce5adf785afe7b67929e12ead4ba90 /lib/conntrack.c
parentb0d289bb5af9627b6d1751b4c58eda239b8f1c2d (diff)
downloadopenvswitch-b889d5dcc81ff7103e49429a9beb3f8b0ddf62d5.tar.gz
conntrack: Init hash basis first at creation.
The 'hash_basis' field is used sometimes during sub-systems init routine. It will be 0 by default before randomization. Sub-systems would then init some nodes with incorrect hash values. The timeout policies module is affected, making the default policy being referenced using an incorrect hash value. Fixes: 2078901a4c14 ("userspace: Add conntrack timeout policy support.") Signed-off-by: Gaetan Rivet <grive@u256.net> Reviewed-by: Eli Britstein <elibr@nvidia.com> Acked-by: William Tu <u9012063@gmail.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to 'lib/conntrack.c')
-rw-r--r--lib/conntrack.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/conntrack.c b/lib/conntrack.c
index 508116a29..551c2061a 100644
--- a/lib/conntrack.c
+++ b/lib/conntrack.c
@@ -293,6 +293,11 @@ conntrack_init(void)
static struct ovsthread_once setup_l4_once = OVSTHREAD_ONCE_INITIALIZER;
struct conntrack *ct = xzalloc(sizeof *ct);
+ /* This value can be used during init (e.g. timeout_policy_init()),
+ * set it first to ensure it is available.
+ */
+ ct->hash_basis = random_uint32();
+
ovs_rwlock_init(&ct->resources_lock);
ovs_rwlock_wrlock(&ct->resources_lock);
hmap_init(&ct->alg_expectations);
@@ -310,7 +315,6 @@ conntrack_init(void)
timeout_policy_init(ct);
ovs_mutex_unlock(&ct->ct_lock);
- ct->hash_basis = random_uint32();
atomic_count_init(&ct->n_conn, 0);
atomic_init(&ct->n_conn_limit, DEFAULT_N_CONN_LIMIT);
atomic_init(&ct->tcp_seq_chk, true);