patch 'app/testpmd: fix hexadecimal parser with odd length' has been queued to stable release 20.11.4
Xueming Li
xuemingl at nvidia.com
Sun Nov 28 15:54:15 CET 2021
Hi,
FYI, your patch has been queued to stable release 20.11.4
Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 11/30/21. 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/a6f7eb3e2079ba5141b8b06f1da2946a0577eecf
Thanks.
Xueming Li <xuemingl at nvidia.com>
---
>From a6f7eb3e2079ba5141b8b06f1da2946a0577eecf Mon Sep 17 00:00:00 2001
From: Gregory Etelson <getelson at nvidia.com>
Date: Wed, 24 Nov 2021 14:33:54 +0200
Subject: [PATCH] app/testpmd: fix hexadecimal parser with odd length
Cc: Xueming Li <xuemingl at nvidia.com>
[ upstream commit ea1da434c0a876b1913b9f0758abd1b6e70a19fd ]
Current hex string parser assumes input has even characters number.
The parser fails input string with odd length.
The patch parses hex strings with even and odd length.
Parse result of an input with odd length will match result of
even length input, that has `0` as MSB, following by the original
sequence.
For example:
"0x1" results in *dst={0x01, 0x00}, *size=1
"0xabc" results in *dst={0x0a, 0xbc, 0x00}, *size=2
Fixes: 169a9fed1f4c ("app/testpmd: fix hex string parser support for flow API")
Signed-off-by: Gregory Etelson <getelson at nvidia.com>
Reviewed-by: Viacheslav Ovsiienko <viacheslavo at nvidia.com>
---
app/test-pmd/cmdline_flow.c | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index bbf62be5ae..6ff6391146 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -6411,9 +6411,8 @@ error:
static int
parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
{
- char *c = NULL;
- uint32_t i, len;
- char tmp[3];
+ uint32_t left = *size;
+ const uint8_t *head = dst;
/* Check input parameters */
if ((src == NULL) ||
@@ -6423,19 +6422,23 @@ parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
return -1;
/* Convert chars to bytes */
- for (i = 0, len = 0; i < *size; i += 2) {
- snprintf(tmp, 3, "%s", src + i);
- dst[len++] = strtoul(tmp, &c, 16);
- if (*c != 0) {
- len--;
- dst[len] = 0;
- *size = len;
+ while (left) {
+ char tmp[3], *end = tmp;
+ uint32_t read_lim = left & 1 ? 1 : 2;
+
+ snprintf(tmp, read_lim + 1, "%s", src);
+ *dst = strtoul(tmp, &end, 16);
+ if (*end) {
+ *dst = 0;
+ *size = (uint32_t)(dst - head);
return -1;
}
+ left -= read_lim;
+ src += read_lim;
+ dst++;
}
- dst[len] = 0;
- *size = len;
-
+ *dst = 0;
+ *size = (uint32_t)(dst - head);
return 0;
}
--
2.34.0
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2021-11-28 22:41:06.816987317 +0800
+++ 0071-app-testpmd-fix-hexadecimal-parser-with-odd-length.patch 2021-11-28 22:41:03.430205655 +0800
@@ -1 +1 @@
-From ea1da434c0a876b1913b9f0758abd1b6e70a19fd Mon Sep 17 00:00:00 2001
+From a6f7eb3e2079ba5141b8b06f1da2946a0577eecf Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit ea1da434c0a876b1913b9f0758abd1b6e70a19fd ]
@@ -18 +20,0 @@
-Cc: stable at dpdk.org
@@ -27 +29 @@
-index 1b00ae507b..bbe3dc0115 100644
+index bbf62be5ae..6ff6391146 100644
@@ -30 +32 @@
-@@ -7702,9 +7702,8 @@ error:
+@@ -6411,9 +6411,8 @@ error:
@@ -42 +44 @@
-@@ -7714,19 +7713,23 @@ parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
+@@ -6423,19 +6422,23 @@ parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
More information about the stable
mailing list