From patchwork Wed Feb 17 16:34:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gaetan Rivet X-Patchwork-Id: 1441282 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=u256.net header.i=@u256.net header.a=rsa-sha256 header.s=fm1 header.b=v+ax+a4f; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=VCQFUnWG; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DgkB40lptz9sSC for ; Thu, 18 Feb 2021 03:41:16 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 9B2CD86CAB; Wed, 17 Feb 2021 16:41:14 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 938u8bOEMTzx; Wed, 17 Feb 2021 16:41:13 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id BC32A86AB1; Wed, 17 Feb 2021 16:41:13 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A77C2C1DA9; Wed, 17 Feb 2021 16:41:13 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3A377C013A for ; Wed, 17 Feb 2021 16:41:12 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 268F287248 for ; Wed, 17 Feb 2021 16:41:12 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id g3h8DwI8+USK for ; Wed, 17 Feb 2021 16:41:10 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from new4-smtp.messagingengine.com (new4-smtp.messagingengine.com [66.111.4.230]) by hemlock.osuosl.org (Postfix) with ESMTPS id 0781287220 for ; Wed, 17 Feb 2021 16:41:10 +0000 (UTC) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.nyi.internal (Postfix) with ESMTP id 8D833580340; Wed, 17 Feb 2021 11:34:49 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 17 Feb 2021 11:34:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=u256.net; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=UvGnotpRSDssd n8yhb637C+8D/+WOfMrJ65XtWdjgUg=; b=v+ax+a4fdEQK4jDzf0bKjtT2IJR4p bNeTnD/7bE8Tcr3kSCUm9rkgMSaq/oZ3BzUkPFYqvUNvUpp7vt2XEaQN9POXuGoz D9hK1WPIDXIHygcMOzyyaapJOaKU1OPZ055uMDWIR70kOy+0nF1127RbEZ4OWxhm fsMduRHtCn7rPp4SG1XgooJIPtwYgP3TVKMoo7SY7GZW3mJP6+jAmuFioX/CzbSC v2dAH89Tmrl/mQRAqPU1awcP6zcuC8vXG7CP6bwcR7JWvUGlIxczvQDcsVl1TobQ yJ6njkyhscDEfMcxTVdzN64huIQtYk2CRH/pd5DuiE8AYhunGu6Xs4fkw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=UvGnotpRSDssdn8yhb637C+8D/+WOfMrJ65XtWdjgUg=; b=VCQFUnWG 7VFcllsY6+RJhDADativjYzjvCyNZWcf9U67LopMg0ZOh6hO39ygJsoYvVIQ2l4n qTTje9MWY2wYNjaBgVFdHBKVfVIw+i/NzdYT/twbHvlfxXGPva+CkAzyiFvrSQHM iBvv5lgNIO7K7yyXbWtTvRk3viN2+0f4+NnRg5K11695x+z/wrSzsNyQ1S7VI8Pm Uzkfe1Swwi3FP4OQp62PggORV2n2p9vub/7mBFiw/7+XPjpqP37ym6NVpV1xKg2d nK9cCQUTGZndJj+zWbhvxfJi7EowqTpJ6+vpV+8014rZPVOOBAJqzPlX3tcfRCsa 9Ab0azCNP2xpPw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrjedvgdeihecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepifgrvghtrghn ucftihhvvghtuceoghhrihhvvgesuhdvheeirdhnvghtqeenucggtffrrghtthgvrhhnpe ehgfevffekteehteefieefvdehleefjeefheevudetjefhkeeutdekieeuvdetheenucfk phepkeeirddvheegrddvgeefrddugeeinecuvehluhhsthgvrhfuihiivgepudenucfrrg hrrghmpehmrghilhhfrhhomhepghhrihhvvgesuhdvheeirdhnvght X-ME-Proxy: Received: from inocybe.home (lfbn-poi-1-930-146.w86-254.abo.wanadoo.fr [86.254.243.146]) by mail.messagingengine.com (Postfix) with ESMTPA id AC009240065; Wed, 17 Feb 2021 11:34:48 -0500 (EST) From: Gaetan Rivet To: dev@openvswitch.org Date: Wed, 17 Feb 2021 17:34:37 +0100 Message-Id: X-Mailer: git-send-email 2.30.0 In-Reply-To: References: MIME-Version: 1.0 Cc: Eli Britstein , ameerm@nvidia.com, majd@nvidia.com Subject: [ovs-dev] [PATCH v1 3/9] conntrack: Init hash basis first at creation X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" 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 Reviewed-by: Eli Britstein Acked-by: William Tu --- lib/conntrack.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/conntrack.c b/lib/conntrack.c index c218200dc..8062dcd6b 100644 --- a/lib/conntrack.c +++ b/lib/conntrack.c @@ -291,6 +291,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); @@ -308,7 +313,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);