patch 'trace: fix init with long file prefix' has been queued to stable release 20.11.6

Xueming Li xuemingl at nvidia.com
Wed Jul 20 10:20:32 CEST 2022


Hi,

FYI, your patch has been queued to stable release 20.11.6

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 07/22/22. 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/steevenlee/dpdk

This queued commit can be viewed at:
https://github.com/steevenlee/dpdk/commit/a6388c75952c77411d8bdea305433283428ada55

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From a6388c75952c77411d8bdea305433283428ada55 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen at huawei.com>
Date: Fri, 17 Jun 2022 10:29:11 +0800
Subject: [PATCH] trace: fix init with long file prefix
Cc: Xueming Li <xuemingl at nvidia.com>

[ upstream commit d59a940667989461e2916207e7fbb8148504c44f ]

Bug scenario:
1. start testpmd:
  $ dpdk-testpmd -l 4-6 -a 0000:7d:00.0 --trace=.* \
    --file-prefix=trace_autotest -- -i
2. then observed:
  EAL: eal_trace_init():93 failed to initialize trace [File exists]
  EAL: FATAL: Cannot init trace
  EAL: Cannot init trace
  EAL: Error - exiting with code: 1

The root cause it that the offset set wrong with long file-prefix and
then lead the strftime return failed.

At the same time, trace_session_name_generate() uses errno as the return
value, but the errno was not set if strftime returned zero.
A previously set errno (EEXIST or ENOENT from call to mkdir for creating
the runtime configuration directory) was returned in this case.
This is fragile and may lead to incorrect logic if errno was set
to 0 previously.
This also resulted in inaccurate prompting.
Set errno to ENOSPC if strftime return zero.

Fixes: 321dd5f8fa62 ("trace: add internal init and fini interface")

Signed-off-by: Chengwen Feng <fengchengwen at huawei.com>
Reviewed-by: David Marchand <david.marchand at redhat.com>
Acked-by: Jerin Jacob <jerinj at marvell.com>
---
 lib/librte_eal/common/eal_common_trace_utils.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_trace_utils.c b/lib/librte_eal/common/eal_common_trace_utils.c
index 64f58fb66a..2b55dbec65 100644
--- a/lib/librte_eal/common/eal_common_trace_utils.c
+++ b/lib/librte_eal/common/eal_common_trace_utils.c
@@ -104,13 +104,15 @@ trace_session_name_generate(char *trace_dir)
 	rc = rte_strscpy(trace_dir, eal_get_hugefile_prefix(),
 			TRACE_PREFIX_LEN);
 	if (rc == -E2BIG)
-		rc = TRACE_PREFIX_LEN;
+		rc = TRACE_PREFIX_LEN - 1;
 	trace_dir[rc++] = '-';
 
 	rc = strftime(trace_dir + rc, TRACE_DIR_STR_LEN - rc,
 			"%Y-%m-%d-%p-%I-%M-%S", tm_result);
-	if (rc == 0)
+	if (rc == 0) {
+		errno = ENOSPC;
 		goto fail;
+	}
 
 	return rc;
 fail:
-- 
2.35.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2022-07-20 15:00:58.963368636 +0800
+++ 0003-trace-fix-init-with-long-file-prefix.patch	2022-07-20 15:00:58.641000610 +0800
@@ -1 +1 @@
-From d59a940667989461e2916207e7fbb8148504c44f Mon Sep 17 00:00:00 2001
+From a6388c75952c77411d8bdea305433283428ada55 Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit d59a940667989461e2916207e7fbb8148504c44f ]
@@ -29 +31,0 @@
-Cc: stable at dpdk.org
@@ -35 +37 @@
- lib/eal/common/eal_common_trace_utils.c | 6 ++++--
+ lib/librte_eal/common/eal_common_trace_utils.c | 6 ++++--
@@ -38 +40 @@
-diff --git a/lib/eal/common/eal_common_trace_utils.c b/lib/eal/common/eal_common_trace_utils.c
+diff --git a/lib/librte_eal/common/eal_common_trace_utils.c b/lib/librte_eal/common/eal_common_trace_utils.c
@@ -40,2 +42,2 @@
---- a/lib/eal/common/eal_common_trace_utils.c
-+++ b/lib/eal/common/eal_common_trace_utils.c
+--- a/lib/librte_eal/common/eal_common_trace_utils.c
++++ b/lib/librte_eal/common/eal_common_trace_utils.c


More information about the stable mailing list