From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id F10C943B67 for ; Fri, 8 Mar 2024 15:31:02 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E668342FCB; Fri, 8 Mar 2024 15:31:02 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 5EACD40E2D for ; Fri, 8 Mar 2024 15:31:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709908262; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3IdlHiQ9DrbiL0gN3baIv+1nkgR2h9g94aIz0e8zj7A=; b=O2i2rbdBlN4xIhhx7bTOOcgZA6PWQ4ya2fvmWXh3nmnWPOjAshC7kjIVsZudNWUEcUao9Z B7jDrWEkM/BXLe5TIbTUnQebnltO3FwtNNozgmMHXgeTNPVQEZEo8A3oQd6dbO5NLWxaf3 fm4vMIztJknN11SAK0hTmCf6nltHE4A= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-68-F-kOfFktM8alBX01F0_yiA-1; Fri, 08 Mar 2024 09:31:00 -0500 X-MC-Unique: F-kOfFktM8alBX01F0_yiA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 299788007AF; Fri, 8 Mar 2024 14:31:00 +0000 (UTC) Received: from rh.redhat.com (unknown [10.39.194.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id B1ACB36FF; Fri, 8 Mar 2024 14:30:58 +0000 (UTC) From: Kevin Traynor To: Stephen Hemminger Cc: dpdk stable Subject: patch 'net/tap: fix traffic control handle calculation' has been queued to stable release 21.11.7 Date: Fri, 8 Mar 2024 14:27:58 +0000 Message-ID: <20240308142824.528417-10-ktraynor@redhat.com> In-Reply-To: <20240308142824.528417-1-ktraynor@redhat.com> References: <20240308142824.528417-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 21.11.7 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 03/13/24. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/6131c863c88a03df31f543c9356dd004466a9039 Thanks. Kevin --- >From 6131c863c88a03df31f543c9356dd004466a9039 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Thu, 29 Feb 2024 09:31:08 -0800 Subject: [PATCH] net/tap: fix traffic control handle calculation [ upstream commit 4e924ff6f789c6a67424263bf384f3e4b4fba373 ] The code to take a flow pointer and make a TC handle was incorrect and would always generate the same handle. This is because it was hashing the address of the union on the stack (which is invariant) rather than the contents of the union. The following testpmd case would cause an error: testpmd> flow create 0 ingress pattern eth src is 06:05:04:03:02:01 \ / end actions queue index 2 / end Flow rule #0 created testpmd> flow create 0 ingress pattern eth src is 06:05:04:03:02:02 \ / end actions queue index 3 / end tap_nl_dump_ext_ack(): Filter already exists tap_flow_create(): Kernel refused TC filter rule creation (17): File exists port_flow_complain(): Caught PMD error type 2 (flow rule (handle)): overlapping rules or Kernel too old for flower support: File exists This fix does it in a more robust manner using size independent code. It also initializes the hash seed so the same hash won't show up every time and risk potential leakage of address to other places. Bugzilla ID: 1382 Fixes: de96fe68ae95 ("net/tap: add basic flow API patterns and actions") Fixes: a625ab89df11 ("net/tap: fix build with GCC 11") Signed-off-by: Stephen Hemminger --- drivers/net/tap/tap_flow.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index e086cabf74..b4879d3f93 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -12,4 +12,5 @@ #include #include +#include #include #include @@ -1298,7 +1299,5 @@ tap_flow_validate(struct rte_eth_dev *dev, * specifically each rule. * - * On 32-bit architectures, the handle can simply be the flow's pointer address. - * On 64-bit architectures, we rely on jhash(flow) to find a (sufficiently) - * unique handle. + * Use jhash of the flow pointer to make a unique handle. * * @param[in, out] flow @@ -1310,14 +1309,16 @@ tap_flow_set_handle(struct rte_flow *flow) union { struct rte_flow *flow; - const void *key; - } tmp; - uint32_t handle = 0; + uint32_t words[sizeof(flow) / sizeof(uint32_t)]; + } tmp = { + .flow = flow, + }; + uint32_t handle; + static uint64_t hash_seed; - tmp.flow = flow; + if (hash_seed == 0) + hash_seed = rte_rand(); + + handle = rte_jhash_32b(tmp.words, sizeof(flow) / sizeof(uint32_t), hash_seed); - if (sizeof(flow) > 4) - handle = rte_jhash(tmp.key, sizeof(flow), 1); - else - handle = (uintptr_t)flow; /* must be at least 1 to avoid letting the kernel choose one for us */ if (!handle) -- 2.43.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-03-08 13:47:49.353497000 +0000 +++ 0010-net-tap-fix-traffic-control-handle-calculation.patch 2024-03-08 13:47:48.996686597 +0000 @@ -1 +1 @@ -From 4e924ff6f789c6a67424263bf384f3e4b4fba373 Mon Sep 17 00:00:00 2001 +From 6131c863c88a03df31f543c9356dd004466a9039 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 4e924ff6f789c6a67424263bf384f3e4b4fba373 ] + @@ -30 +31,0 @@ -Cc: stable@dpdk.org @@ -38 +39 @@ -index 5b0fee9064..fa50fe45d7 100644 +index e086cabf74..b4879d3f93 100644