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 A220B43CAD for ; Thu, 14 Mar 2024 01:10:55 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9554942E40; Thu, 14 Mar 2024 01:10:55 +0100 (CET) Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by mails.dpdk.org (Postfix) with ESMTP id 358284021E for ; Thu, 14 Mar 2024 01:10:53 +0100 (CET) Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-33e8b957a89so254270f8f.0 for ; Wed, 13 Mar 2024 17:10:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710375053; x=1710979853; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5h+wI+qYzzAFdWIpGMF4wEf/AtR71riV254yg/wyrvY=; b=NGPckcvH1IWOBiB5yu5E2hI80/wUZn/jCj+imAAe/IzxMn7AeY239BI5PPEIBip6+N NYffsdNDBNywgOFWUjnZlCWn/dcDNbW+DNqL1AgS55gCmr8WMvITbTGo6r07GGb8N4N2 GxYSF3WWTsBHBWgnZfrSjZ9/bmyetnXuRAjhmGt3ofN0DqLDQD0LYEveB8QhwauACzUn Nzv5x5+znprqyFUrwTKk+PbfS7csaDeEBunOW/fdnJcvUQFvc39BCl6M7BLtCQ9Aft2T MPkeSkCaXovS2mWpoDddWDQRdJto0lvYxxmNiYg8PFNYaK9o3pINrl7zA7A1WbgIcE7u XJrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710375053; x=1710979853; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5h+wI+qYzzAFdWIpGMF4wEf/AtR71riV254yg/wyrvY=; b=KyydDhAWjiBjhJCd2z6nsSDVNv0QbAN3DQ7lZG0sJbU6T/+E2m77zWwdD6A1Mukrlf cmvMZRply9ahSAruOnLT++w6Kfa37mRmu10iCBOzlNOYklW2HJJpd+ZsO8rjXEzQ2yt7 lhjxSxdMmZG416VvbMASp8ltPzxGVOTsdfQEDUW7ac5EpqEaaaAWeF4h/3QQoMB1OTN1 tMcVf09uPHC6MThjNHuLNuYU++WtfrE+sE1kbvGjeUf44FFUEswdfTuDuxtKeXfxZ2HP 1KKrM3wkI3q0hIpF3NcBXxfuUyKuQhfT8LRgFj4uXF2932s359hVqbH9pxXYXZnX22Th PVNA== X-Gm-Message-State: AOJu0YwZcVCw6YyjYW31w6k8hR/Rm7yfxnkIkvUek+bTk3oO6fltLQaY cUGHADo0rxeuh9aM2YjQlqHiHb7iLanBtDh9aZptbHherF9WqJGK4MqNbv4d X-Google-Smtp-Source: AGHT+IHstMt3D+rg+GHcJ/RlDtyAe/8E6i3NhOYTSXuTHSjrH/vN6qvddikU5OcKiWy8By4ZXq22SQ== X-Received: by 2002:a05:6000:1754:b0:33d:6be8:bb61 with SMTP id m20-20020a056000175400b0033d6be8bb61mr77334wrf.35.1710375052857; Wed, 13 Mar 2024 17:10:52 -0700 (PDT) Received: from localhost ([137.220.120.171]) by smtp.gmail.com with ESMTPSA id t13-20020a5d42cd000000b0033d640c8942sm295550wrr.10.2024.03.13.17.10.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 17:10:52 -0700 (PDT) From: luca.boccassi@gmail.com To: Stephen Hemminger Cc: dpdk stable Subject: patch 'net/tap: fix traffic control handle calculation' has been queued to stable release 22.11.5 Date: Thu, 14 Mar 2024 00:09:14 +0000 Message-Id: <20240314000957.2810803-18-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240314000957.2810803-1-luca.boccassi@gmail.com> References: <20240307013159.1735343-102-luca.boccassi@gmail.com> <20240314000957.2810803-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 22.11.5 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/16/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/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/48309178df5e964dba1fdfff31f7498339b34112 Thanks. Luca Boccassi --- >From 48309178df5e964dba1fdfff31f7498339b34112 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 431ce37e12..741ef09fc6 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -1297,9 +1298,7 @@ tap_flow_validate(struct rte_eth_dev *dev, * In those rules, the handle (uint32_t) is the part that would identify * 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 * The flow that needs its handle set. @@ -1309,16 +1308,18 @@ 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) handle = 1; -- 2.39.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-03-14 00:09:21.592235130 +0000 +++ 0018-net-tap-fix-traffic-control-handle-calculation.patch 2024-03-14 00:09:20.589614745 +0000 @@ -1 +1 @@ -From 4e924ff6f789c6a67424263bf384f3e4b4fba373 Mon Sep 17 00:00:00 2001 +From 48309178df5e964dba1fdfff31f7498339b34112 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 431ce37e12..741ef09fc6 100644